let inputrow = 0;
let inputrow0 = 0;


$(document).ready(function () {

    getdata0(1, 0, 0, '');
    getdata1(1, 0, 0, '');


});
function showdata() {
    getdata0(1, 0, 0, '');
    getdata1(1, 0, 0, '');
}

function newrows(ctl) {

    $('#tbldt tr').find('span').each(function () {


        if ($(this).attr('id').indexOf('txt_linegroup') != -1) {

            var ctlname = $(this).attr('id');
            var arrctl = ctlname.split('_');

            let irow = parseFloat(arrctl[3].toString());
            irow = irow + 1;
            addrow("Y");
            return false;



        }
    });

}
function addrow(news) {



    $('#tbldt tr').find('span').each(function () {


        if ($(this).attr('id').indexOf('txt_linegroup') != -1) {

            var ctlname = $(this).attr('id');
            var arrctl = ctlname.split('_');

            inputrow = parseFloat(arrctl[3].toString());



        }
    });

    var aClone = $('#tbldt tbody>tr:last').clone(true)
    var regex = new RegExp("_" + inputrow.toString(), "g");
    var newrow = aClone.html().replace(regex, "_" + (inputrow + 1).toString());
    inputrow++;
    $("#tbldt > tbody:last").append("<tr id='rowd_" + inputrow.toString() + "'>" + newrow + "</tr>");


    


    $('#tbldt tbody>tr span').each(function () {

        $(this).addClass("fonttextcontent");
        $(this).css({ 'border-style': 'none' });
        $(this).prop('readonly', true);


    });


    controlpage();





}

function newrows0(ctl) {

    $('#tbldt1 tr').find('span').each(function () {


        if ($(this).attr('id').indexOf('txt_linegroup') != -1) {

            var ctlname = $(this).attr('id');
            var arrctl = ctlname.split('_');

            let irow = parseFloat(arrctl[3].toString());
            irow = irow + 1;
            addrow0("Y");
            return false;



        }
    });

}
function addrow0(news) {



    $('#tbldt1 tr').find('span').each(function () {


        if ($(this).attr('id').indexOf('txt_linegroup') != -1) {

            var ctlname = $(this).attr('id');
            var arrctl = ctlname.split('_');

            inputrow0 = parseFloat(arrctl[3].toString());



        }
    });

    var aClone = $('#tbldt1 tbody>tr:last').clone(true)
    var regex = new RegExp("_" + inputrow0.toString(), "g");
    var newrow = aClone.html().replace(regex, "_" + (inputrow0 + 1).toString());
    inputrow0++;
    $("#tbldt1 > tbody:last").append("<tr id='rowd_" + inputrow0.toString() + "'>" + newrow + "</tr>");


  


    $('#tbldt1 tbody>tr span').each(function () {

        $(this).addClass("fonttextcontent");
        $(this).css({ 'border-style': 'none' });
        $(this).prop('readonly', true);


    });


    controlpage();





}








let pubirow0 = 0;
let pubfilter0 = "";
let pubiseqno0 = 1;
let pubcurrentpage_checkitem0 = 1;
let publastpage0 = 1;

function getnext_item() {


    var elmnt = document.getElementById("gtbl");
    var y = elmnt.scrollTop;
    var x = elmnt.scrollHeight;
    var n = elmnt.clientHeight;
    //$("#MainContent_txt_linegroup").val(parseInt(y, 0).toString() + "," + (x - n).toString());
    if (parseInt(y, 0) == (x - n) - 1 || parseInt(y, 0) == (x - n)) {


        try {

            setTimeout(
              function () {
                  let len = $("#tbldt tbody").find('tr').length;
                  pubcurrentpage_checkitem0 = Math.ceil((len - 1) / 10);
                  pubcurrentpage_checkitem0 = pubcurrentpage_checkitem0 + 1;
                  if (publastpage0 == pubcurrentpage_checkitem0) {
                      pubcurrentpage_checkitem0 = pubcurrentpage_checkitem0 + 1;
                      publastpage0 = pubcurrentpage_checkitem0;
                  }

                  publastpage0 = pubcurrentpage_checkitem0;
                  getdata0(pubcurrentpage_checkitem0, pubirow0, parseInt(y, 0), pubfilter0);



              }, 500);



        } catch (err) { };



    }

}
let iseqno0 = 1;
let ipub0 = 0;
function getdata0(currentpage, irow, scposstock, filter) {



    let linegroup = $("#MainContent_txt_linegroup").val();
    let linename = $("#MainContent_txt_linename").val();
    let partnumber = $("#MainContent_txt_partnumber").val();

    let userid = $("#lbluserid").html();


    iseqno0 = irow + 1;
    pubfilter0 = filter;

    $.ajax({
        type: "POST",
        url: "RegisterEquipment.aspx/getdata_equipment",
        data: '{parahd:"' + filter + '",currentpage:"' + currentpage + '",linegroup:"' + linename + '",partnumber:"' + partnumber + '",userid:"'+userid+'"}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            var xmlDoc = $.parseXML(response.d);
            var xml = $(xmlDoc);
            var customers = xml.find("Table");
            if (customers.length == 0) {



            }

            $.each(customers, function () {
                var customer = $(this);

                addrow("Y");


                $("#MainContent_txt_linegroup_" + irow.toString()).html($(this).find("linegroupid").text());
                $("#MainContent_txt_linename_" + irow.toString()).html("<a href='#' onclick=\"javascript:resultdetail(" + irow.toString() + ");return false;\" style='text-decoration:none;font-size:14px'><span id='strMainContent_txt_linename_" + irow.toString() + "'>" + $(this).find("linename").text() + "</span></a>");
                $("#MainContent_txt_machinename_" + irow.toString()).html("<a href='#' onclick=\"javascript:resultdetail(" + irow.toString() + ");return false;\" style='text-decoration:none;font-size:12px;line-height:12px;'><span id='strMainContent_txt_machinename_" + irow.toString() + "' style='font-size:12px;line-height:12px;'>" + $(this).find("machinename").text() + "</span></a>");
                $("#MainContent_txt_machineno_" + irow.toString()).html("<a href='#' onclick=\"javascript:resultdetail(" + irow.toString() + ");return false;\" style='text-decoration:none;font-size:14px'><span id='strMainContent_txt_machineid_" + irow.toString() + "'>" + $(this).find("machineid").text() + "</span></a>");
                $("#MainContent_txt_partnumber_" + irow.toString()).html($(this).find("partnumber").text());
                $("#MainContent_txt_lamp_" + irow.toString()).html("<a href='#' onclick=\"javascript:resultdetail(" + irow.toString() + ");return false;\" style='text-decoration:none;font-size:14px'><span id='strMainContent_txt_lamp_" + irow.toString() + "'>" + $(this).find("lamp").text() + "</span></a>");
                $("#MainContent_txt_model_" + irow.toString()).html("<a href='#' onclick=\"javascript:resultdetail(" + irow.toString() + ");return false;\" style='text-decoration:none;font-size:14px'><span id='strMainContent_txt_model_" + irow.toString() + "'>" + $(this).find("model").text() + "</span></a>");



                irow++;
                iseqno0++;
            });

            pubirow0 = irow;
            if (currentpage > 1) {
                $("#tbdy0").animate({ scrollTop: (scposstock + 100) }, "fast");
            }



            setTimeout(function () {

                $('#tbldt tbody>tr span').each(function () {
                    var ctl = $(this).attr('id');
                    if (ctl.indexOf("_txt_linegroup_") != -1) {

                        if ($(this).html() == "") {

                            $(this).closest('tr').remove();
                        }

                    }


                });
            }, 500);


        },
        failure: function (response) {
            alert(response.d);
        },
        error: function (response) {
            alert(response.d);
        }
    });


}


let pubirow1 = 0;
let pubfilter1 = "";
let pubiseqno1 = 1;
let pubcurrentpage_checkitem1 = 1;
let publastpage1 = 1;
function getnext_item1() {


    var elmnt = document.getElementById("gtbl1");
    var y = elmnt.scrollTop;
    var x = elmnt.scrollHeight;
    var n = elmnt.clientHeight;
    //$("#MainContent_txt_linegroup").val(parseInt(y, 0).toString() + "," + (x - n).toString());
    if (parseInt(y, 0) == (x - n) - 1 || parseInt(y, 0) == (x - n)) {


        try {

            setTimeout(
              function () {
                  let len = $("#tbldt1 tbody").find('tr').length;
                  pubcurrentpage_checkitem1 = Math.ceil((len - 1) / 10);
                  pubcurrentpage_checkitem1 = pubcurrentpage_checkitem1 + 1;
                  if (publastpage1 == pubcurrentpage_checkitem1) {
                      pubcurrentpage_checkitem1 = pubcurrentpage_checkitem1 + 1;
                      publastpage1 = pubcurrentpage_checkitem1;
                  }

                  publastpage1 = pubcurrentpage_checkitem1;
                  getdata1(pubcurrentpage_checkitem1, pubirow1, parseInt(y, 0), pubfilter1);



              }, 500);



        } catch (err) { };



    }

}
let iseqno1 = 1;
let ipub1 = 0;
function getdata1(currentpage, irow, scposstock, filter) {



    let linegroup = $("#MainContent_txt_linegroup").val();
    let linename = $("#MainContent_txt_linename").val();
    let partnumber = $("#MainContent_txt_partnumber").val();

    let userid = $("#lbluserid").html();


    iseqno1 = irow + 1;
    pubfilter1 = filter;

    $.ajax({
        type: "POST",
        url: "RegisterEquipment.aspx/getdata_equipment_jig",
        data: '{parahd:"' + filter + '",currentpage:"' + currentpage + '",linegroup:"' + linename + '",partnumber:"' + partnumber + '",userid:"'+userid+'"}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            var xmlDoc1 = $.parseXML(response.d);
            var xml1 = $(xmlDoc1);
            var customers1 = xml1.find("Table");
           
            if (customers1.length == 0) {

                if(currentpage==1)
                {


                    setTimeout(function () {
              
                        $('#tbldt1 tbody>tr span').each(function () {
                            var ctl = $(this).attr('id');
                            if (ctl.indexOf("_txt_lamp1_") != -1) {

                                if (ctl.indexOf("_0")==-1) {

                                    $(this).closest('tr').remove();
                                }
                                
                            }
                           

                             $(this).html("");
                             
                             

                            
                        
                         

                        });
                    }, 300);
                 
                }


            }

            $.each(customers1, function () {
                var customer1 = $(this);


                addrow0("Y");
           
         
                $("#MainContent_txt_linegroup1_" + irow.toString()).html($(this).find("linegroupid").text());
                $("#MainContent_txt_linename1_" + irow.toString()).html($(this).find("linename").text());
                $("#MainContent_txt_jigname_" + irow.toString()).html($(this).find("toolname").text());
                $("#MainContent_txt_serial_" + irow.toString()).html($(this).find("serial").text());
                $("#MainContent_txt_partnumber1_" + irow.toString()).html($(this).find("partnumber").text());
                $("#MainContent_txt_expdate_" + irow.toString()).html($(this).find("expdate").text());
                $("#MainContent_txt_lamp1_" + irow.toString()).html($(this).find("lamp").text());
                $("#MainContent_txt_model1_" + irow.toString()).html($(this).find("model").text());

                irow++;
                iseqno1++;
            });

            pubirow1 = irow;
            if (currentpage > 1) {
                $("#tbdy1").animate({ scrollTop: (scposstock + 100) }, "fast");
            }



            setTimeout(function () {

                $('#tbldt1 tbody>tr span').each(function () {
                    var ctl = $(this).attr('id');
                    if (ctl.indexOf("_txt_linegroup1_") != -1) {

                        if ($(this).html() == "" && ctl.indexOf("_0")==-1) {

                            $(this).closest('tr').remove();
                        }

                    }


                });
            }, 500);


        },
        failure: function (response) {
            alert(response.d);
        },
        error: function (response) {
            alert(response.d);
        }
    });


}



function resultdetail(ictlrow) {

    let linegroup = $("#MainContent_txt_linegroup_" + ictlrow.toString()).html();
    let linename = $("#strMainContent_txt_linename_" + ictlrow.toString()).html();
    let machinename = $("#strMainContent_txt_machinename_" + ictlrow.toString()).html();
    let machineid = $("#strMainContent_txt_machineid_" + ictlrow.toString()).html();
    let partnumber = $("#MainContent_txt_partnumber_" + ictlrow.toString()).html();
    let model = $("#strMainContent_txt_model_" + ictlrow.toString()).html();
    let lamp = $("#strMainContent_txt_lamp_" + ictlrow.toString()).html();



    let para = linegroup + "|" + linename + "|" + machineid + "|" + machinename + "|" + partnumber + "|" + lamp + "|" + model + "|";
    let Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t = ""; var n, r, i, s, o, u, a; var f = 0; e = Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64 } else if (isNaN(i)) { a = 64 } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) } return t }, decode: function (e) { var t = ""; var n, r, i; var s, o, u, a; var f = 0; e = e.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r) } if (a != 64) { t = t + String.fromCharCode(i) } } t = Base64._utf8_decode(t); return t }, _utf8_encode: function (e) { e = e.replace(/rn/g, "n"); var t = ""; for (var n = 0; n < e.length; n++) { var r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r) } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128) } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128) } } return t }, _utf8_decode: function (e) { var t = ""; var n = 0; var r = c1 = c2 = 0; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++ } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2 } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3 } } return t } }
    let str_para = Base64.encode(para);

    window.location.href = "RegisterEquipment_inspection_item?para=" + str_para;


}

function editmc(ctl) {
    let ctlid = $(ctl).attr('id');
    let arr = ctlid.split('_');
    let ictlrow = arr[2];

    let linegroup = $("#MainContent_txt_linegroup_" + ictlrow.toString()).html();
    let linename = $("#strMainContent_txt_linename_" + ictlrow.toString()).html();
    let machinename = $("#strMainContent_txt_machinename_" + ictlrow.toString()).html();
    let machineid = $("#strMainContent_txt_machineid_" + ictlrow.toString()).html();
    let partnumber = $("#MainContent_txt_partnumber_" + ictlrow.toString()).html();
    let model = $("#strMainContent_txt_model_" + ictlrow.toString()).html();
    let lamp = $("#strMainContent_txt_lamp_" + ictlrow.toString()).html();





    let para = linegroup + "|" + linename + "|" + machineid + "|" + machinename + "|" + partnumber + "|" + lamp + "|" + model + "|";

    let Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t = ""; var n, r, i, s, o, u, a; var f = 0; e = Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64 } else if (isNaN(i)) { a = 64 } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) } return t }, decode: function (e) { var t = ""; var n, r, i; var s, o, u, a; var f = 0; e = e.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r) } if (a != 64) { t = t + String.fromCharCode(i) } } t = Base64._utf8_decode(t); return t }, _utf8_encode: function (e) { e = e.replace(/rn/g, "n"); var t = ""; for (var n = 0; n < e.length; n++) { var r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r) } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128) } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128) } } return t }, _utf8_decode: function (e) { var t = ""; var n = 0; var r = c1 = c2 = 0; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++ } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2 } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3 } } return t } }
    let str_para = Base64.encode(para);

    window.location.href = "RegisterMachine?para=" + str_para;




}
function delmc(ctl) {
    let ctlid = $(ctl).attr('id');
    let arr = ctlid.split('_');
    let ictlrow = arr[2];

    let linegroup = $("#MainContent_txt_linegroup_" + ictlrow.toString()).html();
    let linename = $("#strMainContent_txt_linename_" + ictlrow.toString()).html();
    let machinename = $("#strMainContent_txt_machinename_" + ictlrow.toString()).html();
    let machineid = $("#strMainContent_txt_machineid_" + ictlrow.toString()).html();
    let partnumber = $("#MainContent_txt_partnumber_" + ictlrow.toString()).html();
    let model = $("#strMainContent_txt_model_" + ictlrow.toString()).html();
    let lamp = $("#strMainContent_txt_lamp_" + ictlrow.toString()).html();





    let para = linegroup + "|" + linename + "|" + machineid + "|" + machinename + "|" + partnumber + "|" + lamp + "|" + model + "|";

    let Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t = ""; var n, r, i, s, o, u, a; var f = 0; e = Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64 } else if (isNaN(i)) { a = 64 } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) } return t }, decode: function (e) { var t = ""; var n, r, i; var s, o, u, a; var f = 0; e = e.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r) } if (a != 64) { t = t + String.fromCharCode(i) } } t = Base64._utf8_decode(t); return t }, _utf8_encode: function (e) { e = e.replace(/rn/g, "n"); var t = ""; for (var n = 0; n < e.length; n++) { var r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r) } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128) } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128) } } return t }, _utf8_decode: function (e) { var t = ""; var n = 0; var r = c1 = c2 = 0; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++ } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2 } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3 } } return t } }
    let str_para = Base64.encode(para);

    window.location.href = "Register_equipment_delete?para=" + str_para;




}
function editjig(ctl) {

   
    let ctlid = $(ctl).attr('id');
    let arr = ctlid.split('_');
    let ictlrow = arr[2];

    let linegroup = $("#MainContent_txt_linegroup_" + ictlrow.toString()).html();
    let linename = $("#strMainContent_txt_linename_" + ictlrow.toString()).html();
    let machinename = $("#strMainContent_txt_machinename_" + ictlrow.toString()).html();
    let machineid = $("#strMainContent_txt_machineid_" + ictlrow.toString()).html();
    let partnumber = $("#MainContent_txt_partnumber_" + ictlrow.toString()).html();
    let model = $("#strMainContent_txt_model_" + ictlrow.toString()).html();
    let lamp = $("#strMainContent_txt_lamp_" + ictlrow.toString()).html();



    let toolname = $("#MainContent_txt_jigname_" + ictlrow.toString()).html();
    let serial = $("#MainContent_txt_serial_" + ictlrow.toString()).html();
    let expdate = $("#MainContent_txt_expdate_" + ictlrow.toString()).html();

    let para = linegroup + "|" + linename + "|" + partnumber + "|" + toolname + "|" + serial + "|" + expdate + "|" + lamp + "|" + model + "|";
    let Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t = ""; var n, r, i, s, o, u, a; var f = 0; e = Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64 } else if (isNaN(i)) { a = 64 } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) } return t }, decode: function (e) { var t = ""; var n, r, i; var s, o, u, a; var f = 0; e = e.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r) } if (a != 64) { t = t + String.fromCharCode(i) } } t = Base64._utf8_decode(t); return t }, _utf8_encode: function (e) { e = e.replace(/rn/g, "n"); var t = ""; for (var n = 0; n < e.length; n++) { var r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r) } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128) } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128) } } return t }, _utf8_decode: function (e) { var t = ""; var n = 0; var r = c1 = c2 = 0; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++ } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2 } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3 } } return t } }
    let str_para = Base64.encode(para);

    window.location.href = "Jig_inspection_item_edit?para=" + str_para;


}

function gvdelrowid(ctl, msg) {

    let resindex = ctl.id.split("_");
    let irow = resindex[2].toString();
    let rowCount = $('#tbldt tr').length;
    rowCount = rowCount - 1;

    swal({
        title: 'Are you sure?',
        text: "Do you want delete this data!",
        type: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: 'Yes, delete it!'
    }).then(function (result) {
        if (result.value) {
            let linegroupid = $('#MainContent_txt_linegroup1_' + irow.toString()).html();
            let partnumber = $('#MainContent_txt_partnumber1_' + irow.toString()).html();
            let toolname = $('#MainContent_txt_jigname_' + irow.toString()).html();
            let serial = $('#MainContent_txt_serial_' + irow.toString()).html();



            $.ajax({
                type: "POST",
                url: "RegisterEquipment.aspx/deljig",
                data: "{linegroupid:'" + linegroupid + "',partnumber:'" + partnumber + "',toolname:'" + toolname + "',serial:'" + serial + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {


                },
                failure: function (response) {
                    alert(response.d);
                },
                error: function (response) {
                    alert(response.d);
                }
            });


            if (rowCount > 1) {
                $(ctl).closest('tr').remove();

            }
            else {
                if (irow != "0") {

                    $(ctl).closest('tr').remove();
                }
                else {
                    $('#tbldt tbody>tr span').each(function () {
                        $(this).val("");
                    });
                    $('#tbldt tbody>tr select').each(function () {
                        $(this).val("");
                    });

                }
            }



            swal({
                title: "Success",
                type: 'success',
                text: "Your file has been deleted.",
                timer: 1000,
                showConfirmButton: false,
                timerProgressBar: true
            })

   .then(() => {
       swal({ 
           title: 'Deleted!',
           type: 'info',
           timer: 1000,
           showConfirmButton: false
       })
   })
           

      
        } else {
            return false;
        }
    })








}


