πŸ“–
BPackCore CodingConventions
  • 곡톡
  • Desktop Application
    • UI λ””μžμΈ 및 싀행ꡬ쑰
    • 디렉토리 ꡬ쑰
    • λͺ…λͺ…κ·œμΉ™ 및 κ΅¬ν˜„
      • Model
      • IPocket
      • Pocket
      • Zipper
      • Carrying
        • Args (FormArgs)
        • MainForm
        • SubForm
        • EditForm
        • StrapControl
        • FileUp/Download
      • Tips
    • λ‹€κ΅­μ–΄μ²˜λ¦¬
  • Web Application - Mobile
    • UI λ””μžμΈ
    • 디렉토리 ꡬ쑰
    • λͺ…λͺ…κ·œμΉ™ 및 κ΅¬ν˜„
      • Model
      • Controller
      • View
      • Tips
    • λ‹€κ΅­μ–΄μ²˜λ¦¬
  • Database
    • λͺ…λͺ…κ·œμΉ™
      • μš©μ–΄μ‚¬μ „
    • SP κ΅¬ν˜„
      • Template
      • μΌλ ¨λ²ˆν˜Έλ°œν–‰
    • ERD μž‘μ„±κ·œμΉ™ 및 μƒ˜ν”Œ
  • μ†ŒμŠ€ν˜•μƒκ΄€λ¦¬(Git/Gitlab)
  • WebAPI
Powered by GitBook
On this page
  • View 생성
  • Scan barcode
  • Barcode Format
  • Add BarcodeNo Sample
  • Ajax Sample (jQuery)
  • Get
  • Post
  1. Web Application - Mobile
  2. λͺ…λͺ…κ·œμΉ™ 및 κ΅¬ν˜„

View

View 생성

- Views폴더 – ν”„λ‘œκ·Έλž¨μ½”λ“œν΄λ”λ‚΄ 생성 : Controllers.ν”„λ‘œκ·Έλž¨μ½”λ“œ.XxxController.cs ex) Controllers.MM.PurInBoundController.cs

@{
    ViewData["Title"] = "κ΅¬λ§€μž…κ³ ";
}

<h3 id="purInboundTitle">κ΅¬λ§€μž…κ³ </h3>
<input id="inputBarcode" class="form-control" type="text" placeholder="Scan test" onkeydown="scanTest(event)"
       value='{ "barcodeType":"Inbound","barcodeNo":"PIH20191105-00000101" }' />

<div id="purInboundHeaderTitle" class="card-header">κ΅¬λ§€μž…κ³ μ •λ³΄</div>
<div>
    <div class="row">
        <div id="inboundNo" class="col-4 align-self-center" >λ‚©ν’ˆμ¦λ²ˆν˜Έ</div>
        <div class="col-8"><input id="doNo" class="form-control" type="text" /></div>
    </div>
    <div class="row">
        <div id="bp" class="col-4 align-self-center">거래처</div>
        <div class="col-8"><input id="bpNo" class="form-control" type="text" /></div>
    </div>
</div>

<hr />
<p id="huListTitle" class="card-header">μ‹λ³„ν‘œ λͺ©λ‘</p>
<div>
    <table class="table">
        <tbody id="huList">
        </tbody>
    </table>
</div>

<div>
    <button id="bpInButton" class="btn btn-info" onclick="bpPurInBound()">μž…κ³ μ²˜λ¦¬</button>
</div>


@section Scripts{

    <script>
        var purInBoundParamsModel = {DoNo: "", PurInBoundHuParamsModels: [] };
        var isScanningHu = false;
        var langWordVari = [];

        $(document).ready(function () {
            applyLanguage();
        });
        //λ‹€κ΅­μ–΄ 적용
        function applyLanguage() {
            var langWordPurInbound = @Html.Raw(Json.Serialize(ViewBag.LangWordPurInbound));
            langWordPurInbound.map((a) => {
                $('#' + a.WORD_CODE).html(a.WORD_NAME);
                //console.log(a.WORD_CODE);
                if (a.WORD_CODE.indexOf("vari_") == 0) { //μ—†μœΌλ©΄ -1
                    //console.log(a);
                    langWordVari.push(a);
                }
            });
        }

        function scanTest(event) {
            if (event.keyCode == 13 && barcode != "") {
                try {
                    var barcodeString = $('#inputBarcode').val();
                    //console.log(barcodeString);
                    var barcode = JSON.parse(barcodeString);
                    //console.log(barcode);
                } catch (e) {
                    alert('비정상 λ°”μ½”λ“œ μž…λ‹ˆλ‹€.');
                    return;
                }

                if (barcode.barcodeType == "Inbound") {
                    console.log(barcode.barcodeType);
                    console.log(barcode.barcodeNo);
                    selectDeliOrderHuModelsByDoNo(barcode.barcodeNo); //λ‚©ν’ˆμ¦μΌλ•Œ
                } else if (barcode.barcodeType == "Hu") {
                    addHu(barcode.barcodeNo); //μ‹λ³„ν‘œ μΌλ•Œ
                } else {

                }
            }
        }

        function selectDeliOrderHuModelsByDoNo(doNo) {
            purInBoundParamsModel.DoNo = doNo;
            $('#doNo').val(doNo);
            $.ajax({
                url: '@Url.Content("~/PurInBound/SelectDeliOrderHuModelsByDoNo")',
                method: 'GET',
                data: { doNo: doNo },
                success: function (result) {
                    purInBoundParamsModel.PurInBoundHuParamsModels = result;
                    var variItem = langWordVari.find(a => a.WORD_CODE == "vari_item").WORD_NAME;
                    var variQty = langWordVari.find(a => a.WORD_CODE == "vari_qty").WORD_NAME;
                    var variUnit = langWordVari.find(a => a.WORD_CODE == "vari_unit").WORD_NAME;
                    var variHu = langWordVari.find(a => a.WORD_CODE == "vari_hu").WORD_NAME;
                    var variDt = langWordVari.find(a => { return a.WORD_CODE == "vari_workdt" }).WORD_NAME;
                    var htmlHuList;
                    for (i in result) {
                        htmlHuList += '<tr><td>';
                        htmlHuList += '<div>' + variItem + " : " + result[i].ITEM_CD;
                        htmlHuList += ' ' + variQty + " : " + result[i].DLO_QTY;
                        htmlHuList += ' ' + variUnit + " : " + result[i].UNIT + '</div>';
                        htmlHuList += '<div>' + variHu + " : " + result[i].DLO_BARCODE + '</div>';
                        htmlHuList += '<div>' + variDt + " : " + result[i].WORK_DT + '</div>';
                        htmlHuList += '</td></tr>';
                    }
                    $('#huList').append(htmlHuList);
                }
            });
        }

        function addHu(huBarcodeNo) {
            if (checkHu(huBarcodeNo)) {
                purInBoundParamsModel.PurInBoundHuParamsModels.push({ DLO_BARCODE: huBarcodeNo });
                var htmlHu;
                htmlHu = '<tr><td>' + huBarcodeNo + '</td></tr>';
                $('#huList').prepend(htmlHu);
            }
        }

        function checkHu(huBarcodeNo) {

            return true;
        }

        function bpPurInBound() {
            if (purInBoundParamsModel == null) {
                alert('');
                return;
            }
            if (confirm('μž…κ³ μ²˜λ¦¬ ν•©λ‹ˆλ‹€.')) {
                $.ajax({
                    url: '@Url.Content("~/PurInbound/bpPurInBound")',
                    method: 'POST',
                    data: JSON.stringify(purInBoundParamsModel),
                    contentType: "application/json",
                    success: function (result) {
                        alert('ok...');
                    },
                    error: function (xhr, status, error) {
                            alert("code:" + xhr.status + "\n" + "message:" + xhr.responseText + "\n" + "error:" + error);
                    }
                });
            }
        }

    </script>

}

Scan barcode

Barcode Format

//JSON
{ "barcodeType":"Inbound","barcodeNo":"PIH20191105-00000101" }

Add BarcodeNo Sample

function scanTest(event) {
    if (event.keyCode == 13 && barcode != "") {
        try {
            var barcodeString = $('#inputBarcode').val();
            console.log(barcodeString);
            var barcode = JSON.parse(barcodeString);
            console.log(barcode);
        } catch (e) {
            alert('비정상 λ°”μ½”λ“œ μž…λ‹ˆλ‹€.');
            return;
        }
        
        if (barcode.barcodeKind == "Inbound") {
            console.log(barcode.barcodeKind);
            console.log(barcode.barcodeNo);
            getHuListByDoNo(barcode); //λ‚©ν’ˆμ¦μΌλ•Œ
        } else if (barcode.barcodeKind == "Hu") {
            addHu(barcode); //μ‹λ³„ν‘œ μΌλ•Œ
        } else {

        }
    }
}

Ajax Sample (jQuery)

Get

function selectDeliOrderModelsByDoNo(doNo) {
    purInBoundInsertModel.DoNo = doNo;
    $('#doNo').val(doNo);
    $.ajax({
        url: '@Url.Content("~/PurInBound/SelectDeliOrderHuListByDoNo")',
        method: 'GET',
        data: { doNo: doNo },
        success: function (result) {
            purInBoundInsertModel.PurInBoundHuInsertModels = result;
            var htmlHuList;
            for (i in result) {
                htmlHuList += '<tr><td>';
                htmlHuList += '<div>ν’ˆλ²ˆ : ' + result[i].ITEM_CD;
                htmlHuList += ' μˆ˜λŸ‰ : ' + result[i].DLO_QTY;
                htmlHuList += ' λ‹¨μœ„ : ' + result[i].UNIT + '</div>';
                htmlHuList += '<div>μ‹λ³„ν‘œ : ' + result[i].DLO_BARCODE + '</div>';
                htmlHuList += '<div>μž‘μ—…μΌ : ' + result[i].WORK_DT + '</div>';
                htmlHuList += '</td></tr>';
            }
            $('#huList').append(htmlHuList);
        }
    });
}

Post

function InsertPurInBoundModel() {
    if (purInBoundInsertModel == null) {
        alert('');
        return;
    }
    if (confirm('μž…κ³ μ²˜λ¦¬ ν•©λ‹ˆλ‹€.')) {
        $.ajax({
            url: '@Url.Content("~/PurInbound/InsertPurInBoundModel")',
            method: 'POST',
            data: JSON.stringify(purInBoundInsertModel),
            contentType: "application/json",
            success: function (result) {
                alert('ok...');
            },
            error: function (xhr, status, error) {
                    alert("code:" + xhr.status + "\n" + "message:" + xhr.responseText + "\n" + "error:" + error);
            }
        });
    }
}
PreviousControllerNextTips

Last updated 5 years ago