Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem to line

Hi,
";" below is being highlighted, like
User generated imageto this line
var Purchaser = $(this).find('.Purchaser').val();

Open in new window

why?
Avatar of chaau
chaau
Flag of Australia image

I would not worry about it. Most likely the IDE get confused by something. In fact, I do not believe the intellisense validates JavaScript very well. You can try to restart the visual studio, sometimes it helps
This doesn't bring up any warnings in my IDE (VS2015)
if ($(".row [type=checkbox]:checked").length >= 1) {
    var PurchaserArr = [];
    $(".selectedRow"}.each(function() {
        if (@session["usergroup"] = "4") {
            var Purchaser = $(this).find('.Purchaser').val();
            var usergroup_id = $(this).find('.usergroup_id').val();

        }

Open in new window

Avatar of Peter Chan

ASKER

No, such part cannot be executed as expected. where is the problem?
By the way, how can I ensure that

.purchaser

has been declared under ".selectedRow"? I'm using VS 2013.
Please note that .Purchaser and .purchaser are not the same, i.e. jquery is case sensitive
Can you please put your html code as well as without rendered HTML, it is difficult to check/resolve?  

In general .find() function searches for descendant elements!

It might be the case where It could not find that element OR it may get multiple elements for the same!!
@model IEnumerable<ceres.Models.PurchaseOrderModel>

@functions {
    string genTabs(string tabName, int tabSum) {
        string strSuffix = "<span>(" + tabSum + ")</span>";
        string str = "<a onclick='tabOption(\"" + tabName + "\")'><div class='tab-item' data-id='" + tabName + "'>" + Language.p(tabName.ToUpper()) + " " + strSuffix + "</div></a>";
        return str;
    }
    
    string genQtyTable(PurchaseOrderModel data) {
        string str = @"<table cellpadding='0' cellspacing='0' border='0'>";
        int shipQty = data.ship_qty != null ? (int)data.ship_qty : 0;
        int otwQty = data.otw_qty != null ? (int)data.otw_qty : 0;
        
        int receiveQty = data.receive_qty != null ? (int)data.receive_qty : 0;
        int qcPassQty = data.qc_pass_qty != null ? (int)data.qc_pass_qty : 0;
        int qcRejectQty = data.qc_reject_qty != null ? (int)data.qc_reject_qty : 0;
        int confirmQcPassQty = data.confirm_qc_pass_qty != null ? (int)data.confirm_qc_pass_qty : 0;
        int confirmQcRejectQty = data.confirm_qc_reject_qty != null ? (int)data.confirm_qc_reject_qty : 0;
        //if (data.ship_qty > 0)
        str += @"<tr><td class='first-row'>" + Language.p("Receiving") + "</td><td width='25%'>" + otwQty + "</td></tr>";
        //if (data.receive_qty > 0)
        str += @"<tr><td>" + Language.p("Receive") + "</td><td width='25%'>" + receiveQty + "</td></tr>";
        //if (data.qc_pass_qty > 0)
        str += @"<tr><td>" + Language.p("QC_Pass") + "(" + Language.p("Confirm") + ")" + "</td><td width='25%'>" + qcPassQty + "(" + confirmQcPassQty + ")</td></tr>";
        //if (data.qc_reject_qty > 0)
        str += @"<tr><td>" + Language.p("QC_Reject") + "(" + Language.p("Confirm") + ")" + "</td><td width='25%'>" + qcRejectQty + "(" + confirmQcRejectQty + ")</td></tr>";
        
        
        str += @"</table>";
        return str;                                
    }
}
@{  
    var data = Model.ToList();
    Dictionary<string, int> tabCount = null;
    if (ViewData["tabCount"] != null)
    {
        tabCount = (Dictionary<string, int>)ViewData["tabCount"];
    }

    int channel_site_id = -1;
    if (ViewData["channel_site"] != null)
    {
        channel_site_id = (int)ViewData["channel_site"];
    }

    string tab = "";
    if (ViewData["tab"]!=null)
    {
        tab = (string)ViewData["tab"];
    }
    
    List<SelectListItem> nullList = new List<SelectListItem>();
    nullList.Insert(0, new SelectListItem { Text = "--" + Language.p("SELECT") + "--", Value = "" });
    var productStatusList = (List<SelectListItem>)ViewData["productStatusList"];
    var warehouseList = (List<SelectListItem>)ViewData["warehouseList"];
    var poStatusList = (List<SelectListItem>)ViewData["poStatusList"];
    var supplierList = (List<SelectListItem>)ViewData["supplierList"];
    var poPaymentList = (List<SelectListItem>)ViewData["poPaymentList"];
    var poPaymentStatusList = (List<SelectListItem>)ViewData["poPaymentStatusList"];
    var keywords = ViewData["keywords"] == null ? "" : (string)ViewData["keywords"];
    var status = ViewData["status"] == null ? "" : (string)ViewData["status"];

    string warehouse_id = "-1";

    if (ViewData["warehouse_id"] != null)
    {
        warehouse_id = ViewData["warehouse_id"].ToString();
    }
    
}
<script>
    var supplierAjax = {
        source: function (request, response) {
            $.ajax({
                url: '@ViewBag.baseURL' + "/Supplier/Names",
                dataType: "json",
                data: {
                    key: request.term
                },
                success: function (data) {
                    response(data);
                }
            });
        },
        select: function (event, ui) {

            $supplierId = $(this).parent().find(".supplier_id");
            $supplierId.val(ui.item.id);
            $(this).val(ui.item.label);
        },
        minLength: 2,
        change: function (event, ui) {
            $(this).trigger('change');
        }
    };
    $(document).ready(function () {

        $(".supplier_name").autocomplete(supplierAjax);

        @Html.Raw("$('#keywords').val('" + keywords + "');")
        @Html.Raw("$('#keyword_txt').val('"+(string)ViewData["keyword_txt"]+"');")
        @Html.Raw("$('#warehouse_id_list').val('" + warehouse_id + "');")
        @Html.Raw("$('#supplier_id_list').val('" + ViewData["supplier_id"] + "');")
        @Html.Raw("$('#supplier_id').val('" + ViewData["supplier_id"] + "');")
        @Html.Raw("$('#supplier_name').val('" + ViewData["supplier_name"] + "');")

        @Html.Raw("$('#status_list').val('" + status + "');")
        @Html.Raw("$('#timeFrom').val('" + (string)ViewData["timeFrom"] + "');")
        @Html.Raw("$('#timeTo').val('" + (string)ViewData["timeTo"] + "');")

        @Html.Raw("$('#page').val('" + (string)ViewData["search_page"] + "');")
        @Html.Raw("$('#limit').val('" + (string)ViewData["search_limit"] + "');")
        @Html.Raw("$('#tab').val('" + tab + "');")

        @Html.Raw("$('#sorting').val('" + (string)ViewData["sorting"] + "');")

        @Html.Raw("$('#payment_status_list').val('" + (string)ViewData["payment_status"] + "');")
        @Html.Raw("$('#payment_type_list').val('" + (string)ViewData["payment_type"] + "');")
        @Html.Raw("$('#purchaser_id_list').val('" + ViewData["purchaser_id"] + "');")

        @Html.Raw("$('#purchase_order').val('" + ViewData["purchase_order_id"] + "');")
        @Html.Raw("$('#invoice_number').val('" + ViewData["invoice_number"] + "');")
        @Html.Raw("$('.tab-control div[data-id=" + tab + "]').addClass('target');")
        $("#timeFrom").datetimepicker({ dateFormat: "yy-mm-dd" });
        $("#timeTo").datetimepicker({ dateFormat: "yy-mm-dd" });
        $(".estimate_date").datetimepicker({ dateFormat: "yy-mm-dd" });
        $(".adjust_eta").datetimepicker({ dateFormat: "yy-mm-dd" });
        updateAllSupplierList();

    });

    function uploadPOExcel() {
        $('#search_form').attr("action", "@Url.Action("POExcelUpload", "ExcelDataExtract")");
    }

    function $_GET(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.search);
        return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }
    function checkFormData(type) {
        var tab = "@tab";
        var errMsg = "";
        var status = "";
        $(".selectedRow").each(function () {
            var row = this;
            if ($(row).find(".list").is(":checked")) {
                status = $(row).find(".status").val();
                var sku = $(row).find(".sku").val();
                switch (type) {
                    case "confirm_ship":
                        var ship_qty = $(row).find(".ship_qty").val();
                        errMsg = ship_qty == "" ? errMsg + "Please enter correct Ship Qty: " + sku + "\n" : errMsg;

                        break;
                    case "add_confirm_to_invoice":
                        break;
                    case "add_to_invoice":

                    case "create_po_form":
                        var request_qty = $(row).find(".request_qty").val();
                        var supplier_id = $(row).find(".supplier_id").val();
                        var estimate_date = $(row).find(".estimate_date").val();
                        var price = $(row).find(".price").val();
                        var payment_type = $(row).find(".payment_type").val();
                        var to_warehouse_id = $(row).find(".to_warehouse_id").val();
                        var purchaseQty = 0;
                        if (request_qty != "") {
                            purchaseQty = parseInt(request_qty);

                        }

                        errMsg = purchaseQty == 0 ? errMsg + "Please enter correct Purchase Qty: " + sku + "\n" : errMsg;
                        errMsg = supplier_id == "" ? errMsg + "Please Select Supplier\n" : errMsg;
                        errMsg = estimate_date == "" ? errMsg + "Please enter correct Request Qty: " + sku + "\n" : errMsg;
                        errMsg = price == "" ? errMsg + "Please enter price: " + sku + "\n" : errMsg;
                        errMsg = payment_type == "" ? errMsg + "Please select payment type: " + sku + "\n" : errMsg;
                        errMsg = (to_warehouse_id == "" || to_warehouse_id == "-1") ? errMsg + "Please select to warehouse: " + sku + "\n" : errMsg;

                        break;
                    case "receive_qty":
                        var receive_qty = $(row).find(".receive_qty").val();
                        errMsg = receive_qty == "" ? errMsg + "Please enter correct Receive Qty: " + sku + "\n" : errMsg;
                        break;
                    case "confirm_adjust":
                        var adjust_qty = $(row).find(".request_qty").val();
                        var adjust_eta = $(row).find(".estimate_date").val();

                        errMsg = adjust_qty == "" ? errMsg + "Please enter correct Request Qty: " + sku + "\n" : errMsg;
                        errMsg = adjust_eta == "" ? errMsg + "Please enter ETA\n" : errMsg;

                        break;
                    case "confirm_qc":
                        var qc_pass_qty = $(row).find(".qc_pass_qty").val();
                        var qc_reject_qty = $(row).find(".qc_reject_qty").val();

                        errMsg = qc_pass_qty == "" ? errMsg + "Please enter correct QC Pass Qty: " + sku + "\n" : errMsg;
                        errMsg = qc_reject_qty == "" ? errMsg + "Please enter correct  QC Reject Qty: " + sku + "\n" : errMsg;

                        break;
                    case "create_qc_list":

                        break;
                    case "complete_qc":

                        break;

                }
            }
        });
        if (errMsg != "") {
            alert(errMsg);
            return false;
        }
        return true;
    }
    function buttonOption(type, needConfirm) {
        if (type == "csv_ok") {
            if ($('#search_form input[name=select_result_selected]:checked').val() == "search_result") {
                type = "print_all_" + type;
            }
            else {
                type = "print_" + type;
            }
        }

        if (type != "print_all_csv_ok") {
            if ($(".row [type=checkbox]:checked").length <= 0) {
                alert("Please select one or more than one record.");
                return;
            }
        }

        if ($(".row [type=checkbox]:checked").length >= 1) {
            var PurchaserArr = [];
            $(".selectedRow").each(function () {
                if (@Session["usergroup"] = "4") {
                    var Purchaser = $(this).find('.Purchaser').val();
                    var usergroup_id = $(this).find('.usergroup_id').val();
                    if (usergroup_id = "4") {
                        if (Purchaser != "") {
                            if (Purchaser != @Session["userid"] && $.inArray(Purchaser, PurchaserArr) == -1) {
                                PurchaserArr.push(Purchaser);
                            }
                        }
                    }

                }

            });
            if (PurchaserArr.length >= 1) {
                alert("Sourcing user should not select record of other sourcing user!");
            }

        }

        if (needConfirm) {
            var r = confirm("Confirm Submit?xxxb");
            if (!r) { return; }
        }

        switch (type) {
            case "add_to_invoice":
            case "add_confirm_to_invoice":
            case "add_confirm_to_invoice":
                var formPass = checkFormData(type);
                var supplierArr = [];
                var toWarehouseArr = [];
                $(".selectedRow").each(function () {
                    var supplierId = $(this).find('.supplier_id').val();
                    if (supplierId != "" && $.inArray(supplierId, supplierArr) == -1) {
                        supplierArr.push(supplierId);
                    }

                    var toWarehouseId = $(this).find('.to_warehouse_id').val();
                    if (toWarehouseId != "" && toWarehouseId != "-1" && $.inArray(toWarehouseId, toWarehouseArr) == -1) {
                        toWarehouseArr.push(toWarehouseId);
                    }

                });

                if (supplierArr.length > 1 || toWarehouseArr.length > 1) {

                    if (supplierArr.length > 1)
                        alert("More than 1 suppliers selected");

                    else if (toWarehouseArr.length > 1)
                        alert("More than 1 warehouse selected");
                }
                else {

                    if (formPass) {
                        $('#search_form').attr("action", "@Url.Action("POOption")");
                        $('#buttonOptionVal').val(type);

                        openPreviewDialog(type);
                    }
                }
                break;

            default:
                var formPass = checkFormData(type);
                if (formPass) {
                    $('#search_form').attr("action", "@Url.Action("POOption")");
                    $('#buttonOptionVal').val(type);
                    $('#search_form').submit();
                }
                break;
        }

        $('#buttonOptionVal').val("");
    }

    function openPreviewDialog(type) {
        var formId = "#search_form";

        $.ajax(
        {
            type: 'POST',
            data: $(formId).serialize(),
            dataType: 'html',
            url: $(formId).attr('action'),
            success: function (result) {
                $("#dialog .loading").hide();
                $("#dialog .content").html(result);
                switch (type) {
                    case "add_to_invoice":

                        break;
                    case "add_to_invoice_ok":

                        break;
                }

            },
            error: function (error) {
                $("#dialog .loading").hide();
                $("#dialog .content").html("<div>Timeout, Click <a onclick='openPreviewDialog('" + type + "')'>here</a> to reload</div>");
            }
        });
        initDialog(type, 800, 600);
    }

    function disableUncheckedData() {
        $(".row").each(function () {
            if (!$(this).find(".list").is(":checked")) {
                $(this).find("input, select").attr("disabled", "disabled");
            }
        });
    }
    function updateAllSupplierList() {
        $(".row").each(function () {
            updateSulppierList($(this));
        });
    }
    function updateSulppierList(target) {
        var productId = target.find(".product_id").val();
        $.post("@Url.Action("GetSuppliersByProductId")", { id: productId }, function (data) {
            target.find('.supplier_id')
                .find('option:not(:first)')
                .remove();
            $(data.result).each(function () {
                target.find('.supplier_id')
                    .append(new Option(this.name, this.supplier_id));

                var defaultSupplierId = target.find(".default_supplier_id").val();
                target.find(".supplier_id").val(defaultSupplierId);
            });
        });
    }
    function updateProductSpplierInfo(selectBox) {
        var supplierId = $(selectBox).val();
        target = $(selectBox).closest(".row");
        var productId = target.find(".product_id").val();
        $.post("@Url.Action("UpdateProductSpplierInfo")", { supplier_id: supplierId, product_id: productId }, function (data) {
            $(data.result).each(function () {
                var re = /-?\d+/;
                var m = re.exec(this.date);
                var d = new Date(parseInt(m[0]));
                target.find('.estimate_date').val($.datepicker.formatDate('yy-mm-dd', d));
                target.find('.estimate_date').val(target.find('.estimate_date').val() + " 00:00");

                if (this.cost!=null) {
                    target.find('.price').val(this.cost);
                }
                if (this.payment_type != null) {
                    target.find('.payment_type').val(this.payment_type);
                }

            });
        });
    }

    var fileTypes = {
        '.xls': 1
    };

    function preSubmitCheck(target) {
        $(target).find('.btn-upload').attr("disabled", true).button('disable');
    }

    function check_extension(filename, submitId) {
        var re = /\..+$/;
        var ext = filename.match(re);
        var submitEl = document.getElementById(submitId);
        if (fileTypes[ext]) {
            $(submitEl).button({
                disabled: false
            });
            return true;
        } else {
            $(submitEl).button({
                disabled: true
            });
            alert("Invalid filename, please select another file");
            return false;
        }
    }

</script>
<style>
    .show-qty table {
        width:100%;
        box-sizing: border-box;
    }
    .show-qty table > tbody > tr > td {
        padding:3%;
        word-wrap: break-word;
        /*border:0px;
        border-top:1px solid #aaa;*/
    }
    .show-qty table > tbody > tr > td.first-row {
        /*border-top:0px;*/
    }
</style>
<div class="claro">
@using (Html.BeginForm("POExcelUpload", "ExcelDataExtract", FormMethod.Post, new { enctype = "multipart/form-data", onsubmit = "preSubmitCheck(this);" }))
{
    /*<table>
        <tr>
            <td>
                <label>@Language.p("Import_PO")</label>
            </td>
            <td>
                <input type="file" name="uploadedfile" size="20" onchange="check_extension(this.value, 'po-upload');" />
            </td>
            <td>
                <input type="submit" class="btn-upload" id="po-upload" name="upload" value="Attach" disabled="disabled" onsubmit="uploadPOExcel()" />
            </td>
            <td></td>
        </tr>
    </table>*/
}

@using (Html.BeginForm("", null, FormMethod.Post, new { id = "search_form", name = "search_form", onsubmit = "" }))
{
    @Html.Partial("SearchOption")
    <div id="err-container">
        @if (ViewData["msg"] != null)
        {
            string msgStr = (string)ViewData["msg"];
            var msgArr = msgStr.Split(';');
            foreach (var msg in msgArr)
            {
                <div class="err-msg">@msg</div>
            }
        }
    </div>
    <div class="radiusTop header">
        <h1>@Language.p("Purchase_Order")</h1>
        <div class="tab-control">

            @foreach (var tabs in tabCount)
            {
                //<a href="@Url.Action("Index", "PurchaseOrderShipment")"><span style="font-size:12px">@Language.p("Purchase_Order_Shipment")</span></a>
                @Html.Raw(genTabs(tabs.Key, tabs.Value) + " ")
            }
            
            <input type="hidden" id="tab" name="tab" value="" />
        </div>
    </div>
    
    <div class="actionBar">
        <div align="left">
            
        </div>
        <div align="right">
            <label for="selected_item">@Language.p("Selected_Item"):</label>
            @Html.RadioButton("select_result_selected", "selected_item", true, new { id = "selected_item" })

            <label for="search_result">@Language.p("Search_Result"): </label>
            @Html.RadioButton("select_result_selected", "search_result", false, new { id = "search_result" })
            <input type="button" value="@Language.p("Download_CSV")" onclick="buttonOption('csv_ok', true)" />
            <hr />
            @switch (tab)
            {
                case "open":
                    <input type="button" value="@Language.p("Create_Invoice")" onclick="buttonOption('add_to_invoice',true)" />
                    <!--<input type="button" value="@Language.p("Place_Order")" onclick="buttonOption('create_po_form',true)" />-->
                    break;
                case "adjust":
                <input type="button" value="@Language.p("Download_Invoice")" onclick="buttonOption('download_invoice', true)" />
                    <input type="button" value="@Language.p("Confirm_Adjust")" onclick="buttonOption('confirm_adjust', true)" />
                    <input type="button" value="@Language.p("Ask_To_Pay")" onclick="buttonOption('ask_to_pay', true)" />
                    <!--<input type="button" value="@Language.p("Complete_PO")" onclick="buttonOption('complete_po', true)" />-->
                    break;
                case "ship":
                    <!--<input type="button" value="@Language.p("Create_Invoice")" onclick="buttonOption('add_confirm_to_invoice',true)" />-->
                    <input type="button" value="@Language.p("Confirm_Ship")" onclick="buttonOption('confirm_ship', true)" />
                    break;
                case "processing":
                    <!--<input type="button" value="@Language.p("Confirm_Receive")" onclick="buttonOption('receive_qty', true)" />-->
                    break;
                
                case "complete":
                <input type="button" value="@Language.p("Close_PO")" onclick="buttonOption('close_po',true)" />
                <input type="button" value="@Language.p("Ask_For_Refund")" onclick="buttonOption('ask_for_refund',true)" />
                <input type="button" value="@Language.p("Create_New_PO")" onclick="buttonOption('create_new_po',true)" />
                    break;
                case "cancel":
                    break;
                case "close":
                    break;
            }

            @if (tab != "qc" && tab != "receive" && tab != "complete" && tab != "close" && tab != "pay" && tab != "cancel")
            {
                <input type="button" value="@Language.p("Cancel_PO")" onclick="buttonOption('cancel_po',true)" />
            }
            
        </div>
    </div>
    
    <table class="table order_table">
        <tbody>
            @if (data.Count() == 0)
            {
                <tr class="noResult">
                    <td width="1%">@Html.Raw("<span>No records were found!</span>")</td>
                </tr>
            }
            else
            {
                /*<tr>
                    <th colspan="8"></th>
                    <th colspan="3" class="tableFirstRow">@Language.p("Arrival_Qty")</th>
                    <th colspan="2"></th>
                    <th colspan="5" class="tableFirstRow">@Language.p("Action")</th>
                </tr>*/
                <tr class="tableFirstRow">
                    <th><input onclick="selectAllRows(this)" type="checkbox"></th>
                    <th>@Language.p("PO_ID")</th>
                    <th>@Language.p("Invoice_Number")</th>
                    <th>@Language.p("Status")</th>
                    
                    <th>@Language.p("Purchaser")</th>
                    <th>@Language.p("Product_Name")</th>
                    <th>@Language.p("SKU")</th>
                    <th>@Language.p("Supplier")</th>
                    <th>@Language.p("To_Warehouse")</th>
                    <th>@Language.p("Purchase_Qty")</th>
                    <th>@Language.p("Create_Date")</th>
            @{
                switch(tab) {
                    
                    case "open":
                        <th>@Language.p("ETA")</th>
                        <th>@Language.p("Unit_Price")</th>
                        <th>@Language.p("Remarks")</th>
                        break;
                    
                    case "ship":
                        <!--<th>@Language.p("Received_Qty")</th>
                        <th>@Language.p("Shipped_Qty")</th>-->
                        <th width="15%">@Language.p("Quantity")</th>
                        <th>@Language.p("Ship_Qty")</th>
                        <th>@Language.p("ETA")</th>
                        <th>@Language.p("Remarks")</th>
                        break;
                        
                    case "cancel":
                        break;
                    default:
                        <!--<th>@Language.p("Ship_Qty")</th>
                        <th>@Language.p("Received_Qty")</th>
                        <th>@Language.p("QC_Passed")</th>
                        <th>@Language.p("QC_Rejected")</th>
                        <th>@Language.p("Confirm_QC_Passed")</th>
                        <th>@Language.p("Confirm_QC_Rejected")</th>-->
                        <th width="15%">@Language.p("Quantity")</th>
                        <th>@Language.p("Remarks")</th>
                        break;
                }
            }
                    <th>@Language.p("Action")</th>
                </tr>
                for (int i=0;i<data.Count; i++ )
                {
                    int requestQty = data[i].request_qty ?? 0;
                    int shipQty = data[i].ship_qty ?? 0;
                    int otwQty = data[i].otw_qty ?? 0;
                    int receiveQty = data[i].receive_qty ?? 0;
                    int nextShipQty = requestQty - otwQty - receiveQty;
                    
                        
                    int statusInt = Convert.ToInt32(data[i].status);
                    var poStatus = data[i].status_name;
                    var toWarehouseId = data[i].to_warehouse; 
                    
                    <tr class="row">
                        
                        <td><input class="list" name="data[@i].purchase_order_id" onclick="selectRow(this)" type="checkbox" value="@data[i].purchase_order_id"></td>
                        <td>
                            <a href="@Url.Action("ViewHistory", new { id = data[i].purchase_order_id })" onclick="openIFrameDialog(this, '@Language.p("View_History")', '800', '600'); return false;">
                                @Html.Raw(data[i].purchase_order_id)
                            </a>
                        </td>
                        <td>
                            @Html.DisplayFor(model => data[i].invoice_number)
                        </td>
                        <td>@Html.Raw(poStatus) @Html.HiddenFor(model => data[i].status, new { @Class="status" })</td>
                        
                        <td>@data[i].purchaser</td>
                        <td>
                            @Html.HiddenFor(model => data[i].product_name, new { @Name = "data[" + i + "].product_name" })
                            @data[i].product_name
                        </td>
                        <td>@data[i].sku @Html.HiddenFor(model => data[i].sku, new { @Class = "sku" }) @Html.HiddenFor(model => data[i].product_id, new { @Class="product_id" })</td>
                        
                        
                        <td>
                            @if (statusInt == 200)
                            {
                                @Html.DropDownList("supplierList", nullList, new { @Name = "data[" + i + "].supplier_id", @Class = "supplier_id", @onchange = "updateProductSpplierInfo(this);" })
                                @Html.Hidden("default_supplier_id", data[i].supplier_id, new { @Class="default_supplier_id" })
                            }
                            else if (data[i].supplier_id > 0)
                            {
                                var supplier =  supplierList.Find(x => x.Value == data[i].supplier_id.ToString()) != null ? supplierList.Find(x => x.Value == data[i].supplier_id.ToString()).Text : "";
                                @Html.Raw(supplier)
                                @Html.HiddenFor(model => data[i].supplier_id, new { @Name = "data[" + i + "].supplier_id" })
                            }
                        </td>

                        <td>
                            @{
                                if (tab == "open")
                                {
                                    @Html.DropDownListFor(model => data[i].to_warehouse_id, new SelectList(warehouseList, "Value", "Text", data[i].to_warehouse_id), new { @Name = "data[" + i + "].to_warehouse_id", @Class = "to_warehouse_id" });
                                }
                                else
                                {
                                    @Html.Raw(toWarehouseId);
                                }
                            }
                        </td>
                        <td>
                            @if (statusInt <= 200 || tab == "adjust") 
                            {
                                @Html.TextBoxFor(model => data[i].request_qty, new { @Name = "data[" + i + "].request_qty", @Class = "num request_qty" })
                            }
                            else
                            {
                                @Html.Raw(data[i].request_qty)
                            }
                        </td>
                        <td>
                            @Html.DisplayFor(model => data[i].local_create_date)
                            @{/*<table>
                                <tr>
                                    <td>
                                        @Language.p("Create_Date")
                                    </td>
                                    <td>
                                        @Html.DisplayFor(model => data[i].local_create_date)
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Language.p("Create_Date")
                                    </td>
                                    <td>
                                        @Html.DisplayFor(model => data[i].local_create_date)
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Language.p("Create_Date")
                                    </td>
                                    <td>
                                        @Html.DisplayFor(model => data[i].local_create_date)
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Language.p("Create_Date")
                                    </td>
                                    <td>
                                        @Html.DisplayFor(model => data[i].local_create_date)
                                    </td>
                                </tr>
                            </table>*/}
                        </td>
                        @switch (tab)
                        {
                            case "open":
                                <td>@Html.TextBox("data["+@i+"].estimate_date", "", new { @Name = "data[" + i + "].estimate_date", @Class = "estimate_date", @Value = @Html.Raw(String.Format("{0:yyyy-MM-dd HH:mm}", data[i].local_estimate_date)) })</td>
                                <td>@Html.TextBoxFor(model => data[i].price, new { @Name = "data[" + i + "].price", @Class = "price num" })</td>
                                <td>@Html.TextBoxFor(model => data[i].remarks, new { @Name = "data[" + i + "].remarks", @Class = "remarks num" })</td>
                                break;
                            
                            case "ship":
                                
                                <!--<td>@Html.Raw(receiveQty)</td>
                                <td>@Html.Raw(shipQty)</td>-->
                                <td class="show-qty">@Html.Raw(@genQtyTable(data[i]))</td>
                                <td>
                                    @Html.TextBoxFor(model => data[i].ship_qty, new { @Name = "data[" + i + "].ship_qty", @Class = "num ship_qty", @Value = nextShipQty })    
                                </td>
                                <td>@Html.TextBox("data[" + @i + "].estimate_date", "", new { @Name = "data[" + i + "].estimate_date", @Class = "estimate_date", @Value = Html.DisplayFor(model => data[i].local_estimate_date) })</td> //@Html.Raw(String.Format("{0:yyyy-MM-dd HH:mm}", data[i].estimate_date))

                                <td>@Html.TextBoxFor(model => data[i].remarks, new { @Name = "data[" + i + "].remarks", @Class = "remarks num" })</td>

                                break;

                            case "cancel":
                                break;
                            default:
                                <!--<td>@Html.DisplayFor(model => data[i].ship_qty)</td>
                                <td>@Html.DisplayFor(model => data[i].receive_qty)</td>
                                <td>@Html.DisplayFor(model => data[i].qc_pass_qty)</td>
                                <td>@Html.DisplayFor(model => data[i].qc_reject_qty)</td>
                                <td>@Html.DisplayFor(model => data[i].confirm_qc_pass_qty)</td>
                                <td>@Html.DisplayFor(model => data[i].confirm_qc_reject_qty)</td>-->
                                <td class="show-qty">@Html.Raw(@genQtyTable(data[i]))</td>
                                <td>@Html.DisplayFor(model => data[i].remarks)</td>
                                break;
                        }

                        <td>
                            @if (statusInt != 700 && statusInt != 800 && statusInt != 900 && statusInt != 411)
                            {
                                <a class="canel-action-link" href="#" data-href="@Url.Action("CancelPOItem", new { id = data[i].purchase_order_id, targetAction = "Index", tab = (string)ViewData["tab"] })">Cancel</a>
                            }
                        </td>
                    </tr>
                }
            }
        </tbody>
    </table>
    <div class="radiusBottom">
        <table class="pagination">
            <tr>
                <td width="20%"><span>@ViewData["total_orders"]</span> @Language.p("Records")</td>
                <td align="center">

                    <div class="paging-row">
                        @{
                            <label for="page">@Language.p("Page"): </label>
                            if (int.Parse(ViewData["current_page"].ToString()) != 1)
                            {
                                <input type="button" value="<< First" onclick="paging('1')" />
                            }
                            if (int.Parse(@ViewData["current_page"].ToString()) > 1)
                            {
                                <input type="button" value="<" onclick="paging('@(int.Parse(ViewData["current_page"].ToString())-1)')" />
                            }

                            @Html.TextBox("page", ViewData["current_page"], new { @Name = "args[page]" })

                            if (int.Parse(ViewData["current_page"].ToString()) < int.Parse(ViewData["total_page"].ToString()))
                            {
                                <input type="button" value=">" onclick="paging('@(int.Parse(ViewData["current_page"].ToString())+1)')" />
                            }
                            if (int.Parse(@ViewData["current_page"].ToString()) != int.Parse(@ViewData["total_page"].ToString()))
                            {
                                <input type="button" value="Last >>" onclick="paging('@ViewData["total_page"].ToString()')" />
                            }
                        }
                    </div>
                    <div class="paging-row">
                        <label for="limit">@Language.p("Limit"): </label>
                        <input type="button" value="10" onclick="limited('10')" />
                        <input type="button" value="25" onclick="limited('25')" />
                        <input type="button" value="50" onclick="limited('50')" />
                        <input type="button" value="100" onclick="limited('100')" />

                        <input type="hidden" id="limit" name="args[limit]" value="" />
                        <input type="hidden" id="sorting" name="args[sorting]" value="" />
                    </div>

                </td>
                <td width="20%" align="right">Page @ViewData["current_page"] of @ViewData["total_page"]</td>
            </tr>
        </table>
    </div>
    <input type="hidden" id="buttonOptionVal" name="buttonOptionVal" value="" />
}
</div>

Open in new window


The above are the codes. and I do not know where I should have declared "Purchaser".
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please see the E-E grading guidelines.
http://support.experts-exchange.com/customer/portal/articles/481419

You are expected to explain a marked-down grade.  What was wrong with this answer?  Why didn't you ask for clarification or additional input if the answer was deficient?