2022年9月21日 星期三

V20301 –[複製] – 複製多筆資料 – CheckboxModel – 覆蓋原本 parent.[複製處理]

 目的: V20301 –[複製] – 複製多筆資料 – CheckboxModel – 覆蓋原本 parent.[複製]鈕.處理

處理說明:  1>覆蓋原本 parent.[複製]鈕.處理 un('click', Handlerfn);
                   2>一筆一筆複製,呼叫後端函式 CopyFMNO (par_FMNO) ,於後端新增資料
                   3>重新顯示資料,btn_show.fireHandler()


1>*.js
//覆蓋原本 parent 的 [複製]鈕處理
Ext.getCmp('btn_copy').un("click", Ext.getCmp('btn_copy').events.click.listeners[0].fn);

//新的  [複製]鈕處理,
    var buttonModel = Ext.create('G_buttonModel');   //取得 目前的畫面狀態(1,2,3 : 新增/編輯/瀏覽)
    Ext.getCmp("btn_copy").on('click', function (me, e, eOpts) {        
       var cur_recs = Ext.getCmp('grid_Single').getSelectionModel().getSelection();
        var cur_rec;
        console.log("before copy_rec");
        var copy_rec;  //?? 如何產生另一 copy_rec 不和 cur_rec 相同
        var np = {};
        if (cur_recs.length == 0) {
            buttonModel.modelType = 0;
            mywarnalert('請先勾選要複製的資料!!');
        }
        else {
            var gridstore = Ext.getCmp('grid_Single').store;
            me.delMessage = "確定複製勾選的資料嗎?";
            Ext.Msg.confirm('提醒', me.delMessage, callBackFunc);
            function callBackFunc(id) {
                if (id == 'yes') {
                    console.log("cur_recs.length:", cur_recs.length);                    
                    for (let i = 0; i <= cur_recs.length - 1; i++) {
                        console.log("i:", i);                        
                        cur_rec = cur_recs[i];                        
                        copy_rec = cur_rec;
                        console.log("0 cur_rec: ", cur_rec);
                        var Tmp_NEXT_FMNO = get_NEXT_FMNO();
                        var Tmp_cur_DT = DatetoStr(now, "Y/m/d");
                        var Tmp_MDDT = DatetoStr(copy_rec.data["MDDT"], "Y/m/d");
                        console.log("Tmp_NEXT_FMNO:", Tmp_NEXT_FMNO);
                        copy_rec.data["FMNO"]=Tmp_NEXT_FMNO;                        
                        copy_rec.data["BTDT"] = Tmp_cur_DT;        
                        copy_rec.data["MDDT"] = Tmp_cur_DT;        
                        copy_rec.data["STATFM"] = "A";        
                        copy_rec.data["DTSOR"] = "A";        
                        copy_rec.data["OSM"] = "";                    
                        console.log("1 cur_rec: ", cur_rec);
                        console.log("copy_rec: ", copy_rec);
                        //新增資料庫資料
                        Copy_FMNO(copy_rec);
                    } //  end of for (let i=0,)
                    //複製完成後,重新顯示資料  
                    Ext.getCmp('btn_Show').fireHandler();
                    buttonModel.modelType = 0;
                }  // end    if (id == 'yes')             
            }  // end of callbackfunc
        }  //end of else {}       
    }
    );

function Copy_FMNO(par_copy_rec)
{
    var np = {};
    np = par_copy_rec.data;
    Ext.Ajax.request({
        method: "POST",
        url: '../../api/V20301API/Copy_FMNO',
        params: np,
        async: false,
        success: function (response, opts) {
            var Tmp_Obj = Ext.decode(response.responseText);
            if (Tmp_Obj["success"]) {
                Tmp_Rtn_Msg = Tmp_Obj['Rtn_Msg'].toString();       
                //"複製成功 !! <br>" 
                mywarnalert(Tmp_Rtn_Msg);
                //gridstore.add(copy_rec);
            }
            else {
                Tmp_Rtn_Msg = Tmp_Obj['Rtn_Msg'].toString();       
                //"複製失敗 !!"
                mywarnalert(Tmp_Rtn_Msg);
            }
        }, // end of  success 
        failure: function (response, opts) {
            isOk = false;
        }
    });  // end of Ext.Ajax                   
}  // end of  function string  Copy_FMNO(Tmp_FMNO)



    //取得   FMNO 的下一編號
    function get_NEXT_FMNO() {
        var isOk = true;
        var Tmp_NEXT_FMNO = "";        
        var np = {};
        Ext.Ajax.request({
            method: "POST",
            url: '../../api/V20301API/get_NEXT_FMNO',
            params: np,
            async: false,
            success: function (response, opts) {
                var Tmp_Obj = Ext.decode(response.responseText);
                //console.log("Tmp_Obj[success]=", Tmp_Obj["success"]);
                if (Tmp_Obj["success"]) {
                    Tmp_NEXT_FMNO = Tmp_Obj['NEXT_FMNO'].toString();
                    if (Tmp_NEXT_FMNO.length == 0)
                        Tmp_NEXT_FMNO = '001';
                    console.log("Tmp_NEXT_FMNO=", Tmp_NEXT_FMNO);
                    return Tmp_NEXT_FMNO;
                    //mywarnalert(Tmp_Str);
                    //console.log(" 1 success return false");                    
                }
                else {
                    mywarnalert("取得下一系統件單號(FMNO)失敗 !!");
                }
            }, // end of  success 
            failure: function (response, opts) {
                isOk = false;
            }
        });  // end of Ext.Ajax               
        return Tmp_NEXT_FMNO;
    }  // end of  function string  get_NEXT_FMNO(Tmp_FMNO)


V20301 – [刪除]鈕, - checkboxModel -刪除勾選的多筆資料 - 覆蓋原本event的處理 - 移除目前 store 資料

 目的:  [刪除]鈕,  -刪除勾選的多筆資料 - checkboxModel 

處理說明:  1>將 grid_Single 換成 checkboxModel class

                   2> 重寫 btn_del.onclick 處理 , 即  beforedel() 傳回 false, 不處理 parent.del 函式

                   3> 依勾選的資料, 一筆一筆從資料庫刪除 , 資料庫刪除後, 再刪除畫面的資料


1>*.js
 1>>置換成 CheckboxModel  class
    //加入 checkbox Model 
    Ext.getCmp('grid_Single').destroy(); //20220905
    var grid_Single = Ext.create('grid_Single', {
        id: 'grid_Single',
        resizable: true,
        selModel: Ext.create('Ext.selection.CheckboxModel', {
            selectionMode: 'SIMPLE',
            listeners: {
                /*selectionchange: function (cb, selected, eOpts) {
                    //view.selModel.getSelection()
                },*/
                RowMouseDown: function (view, record, item, index, e) {
                    var me = this;
                    if (index !== -1) {

                        if (!me.allowRightMouseSelection(e)) {
                            return;
                        }

                        if (e.shiftKey && me.lastFocused) {
                            me.selectRange(me.lastFocused, record, e.ctrlKey);
                            me.processSelection(view, record, item, index, e);
                        }

                        if (!me.isSelected(record)) {
                            me.mousedownAction = true;
                            me.processSelection(view, record, item, index, e);
                        } else {
                            me.mousedownAction = false;
                        }
                    }

                }
            }
        })
    });
    Ext.getCmp('tab2').add(grid_Single); //將grid加入到tab裡面
    Ext.getCmp('tab2').updateLayout();

 2>>重寫 btn_del.onclick 處理 , 即  beforedel() 傳回 false, 不處理 parent.del 函式

//20220922  覆蓋原本的 [刪除]鈕 處理,  自行處理
    //不執行 paretn.delete , beforeDel 傳回 false
    Ext.getCmp('btn_del').beforeDel = function () {
        return false;
    }

    var buttonModel = Ext.create('G_buttonModel');   //取得 目前的畫面狀態(1,2,3 : 新增/編輯/瀏覽)

    Ext.getCmp("btn_del").on('click', function (me,e,eOpts) {    
      //已置換 grid_store , 不需 .getView().
     //var cur_recs = Ext.getCmp('grid_Single').getView().getSelectionModel().getSelection(); 
        var cur_recs = Ext.getCmp('grid_Single').getSelectionModel().getSelection();
        var cur_rec;
        if (cur_recs.length == 0)
        {
            buttonModel.modelType = 0;
            mywarnalert('請先勾選要刪除的資料!!');
        }
        else {
            me.delMessage = "確定刪除勾選的資料嗎?";
            Ext.Msg.confirm('提醒', me.delMessage, callBackFunc);
            function callBackFunc(id) {
                if (id == 'yes') {
                    console.log("cur_recs.length:", cur_recs.length);
                    var gridstore = Ext.getCmp('grid_Single').store;                        
                    for (let i = 0; i <= cur_recs.length - 1; i++) {
                        console.log("i:", i);
           Ext.getCmp('grid_Single').getSelectionModel().select(cur_recs[i]); //grid select指向所選的資料
                        if (Ext.getCmp('btn_del').afterDel() == false) {
                            return;
                        }                                                
                    } //  end of for (let i=0,)
                    //資料庫均刪除完成後, 才由 gridstore 移除資料
                    for (let i = 0; i <= cur_recs.length - 1; i++) {
                        gridstore.remove(cur_recs[i]); //畫面上隱藏刪除列                     
                    } //  end of for (let i=0,)
                    Ext.getCmp('grid_Single').getView().refresh();
                    buttonModel.modelType = 0;
                }  // end    if (id == 'yes')             
            }  // end of callbackfunc
        }  //else { of if length>0            
    } ) // end of click function 

V20301 – [刪除]鈕, 覆蓋原本 parent.[刪除]鈕的處理,

 目的: 覆蓋原本 parent class  event 的處理, Ex: [刪除]鈕, 覆蓋原本 parent.[刪除]鈕的處理

處理說明: 
     1>方法1:
          1>>btn_del 的 parent 函式中, 有一 beforeDel() 函式傳回 true 時, 才會往下執行
                所以將  beforeDel() 函式 傳回 false , 則不會往下執行, 即不執行 parent.btn_del 處理
    
     2>方法2:           
           1>>利用 元件.un("event名稱", event handler) , 解除 parent 的 event handler
           2>>重新 元件.on("event名稱", function (){})  ;
        


1>*.js

1>>方法1: 利用 parent.beforeDel 函式 , 傳回 false , 不會執行原本 parent.del處理

    Ext.getCmp('btn_del').beforeDel = function () {
        return false;
    }

    Ext.getCmp("btn_del").on('click', function () {
        mysuccessalert("btn_del click");
    });
    

2>>方法2:  利用 元件.un("event名稱", event handler) , 解除 parent 的 event handler  

    Ext.getCmp('btn_del').un("click", Ext.getCmp('btn_del').events.click.listeners[0].fn);
    console.log("2 after un Ext.getCmp('btn_del') : ", Ext.getCmp('btn_del'));    
    console.log("1 Ext.getCmp('btn_del') : ", Ext.getCmp('btn_del'));
 console.log("1 before   Ext.getCmp('btn_del').events.click.listeners[0].fn : ", Ext.getCmp('btn_del').events.click.listeners[0].fn);
    Ext.getCmp("btn_del").on('click', function () {
        mysuccessalert("btn_del click");
    });




2022年9月20日 星期二

V20301 - [挎貝]鈕, 複製目前的資料, 並設定PK欄位值 - PK取得最大值+1

 目的:  [挎貝]鈕, 複製目前的資料, 並設定PK欄位值

處理說明:  1>將 Template 的[挎貝]鈕, 設為 [顯示], 文字改為 [複製]

                   2> PK 取得最大值+1 







1>*.js

      Ext.getCmp('btn_copy').setVisible(true);
      Ext.getCmp('btn_copy').setText("複製");

      //按[複製]鈕時, 會先執行 parent class 的處理,再呼叫目前 class 的處理 
      //所以  on('click' , 時, 編輯畫面 FMNO欄位已存在
     Ext.getCmp("btn_copy").on('click', function () {
        var Tmp_NEXT_FMNO = get_NEXT_FMNO();
        console.log("Tmp_NEXT_FMNO:", Tmp_NEXT_FMNO);
        Ext.getCmp("FMNO").setValue(Tmp_NEXT_FMNO);
    }
    );

    //取得   FMNO 的下一編號
    function get_NEXT_FMNO() {
        var isOk = true;
        var Tmp_NEXT_FMNO = "";        
        var np = {};
        Ext.Ajax.request({
            method: "POST",
            url: '../../api/V20301API/get_NEXT_FMNO',
            params: np,
            async: false,
            success: function (response, opts) {
                var Tmp_Obj = Ext.decode(response.responseText);
                //console.log("Tmp_Obj[success]=", Tmp_Obj["success"]);
                if (Tmp_Obj["success"]) {
                    Tmp_NEXT_FMNO = Tmp_Obj['NEXT_FMNO'].toString();
                    if (Tmp_NEXT_FMNO.length == 0)
                        Tmp_NEXT_FMNO = '001';
                    console.log("Tmp_NEXT_FMNO=", Tmp_NEXT_FMNO);
                    return Tmp_NEXT_FMNO;
                    //mywarnalert(Tmp_Str);
                    //console.log(" 1 success return false");                    
                }
                else {
                    mywarnalert("取得下一系統件單號(FMNO)失敗 !!");
                }
            }, // end of  success 
            failure: function (response, opts) {
                isOk = false;
            }
        });  // end of Ext.Ajax               
        return Tmp_NEXT_FMNO;
    }  // end of  function string  get_NEXT_FMNO(Tmp_FMNO)


2022年9月14日 星期三

V20104 - 資料庫批次更新 - Transaction 處理 - V20301 - 批次新增 -transaction 處理

 目的: V20104 - 資料庫批次更新時,Transaction 處理 , 若批次處理有問題,則整批 Rollback

  處理說明: 1>產生 OracleTransaction
                         OracleTransaction trn = conn.BeginTransaction();
                         try
                        {
                            for (i=0;i<length;i++)
                                  cmd.ExecuteNonQuery(); //Loop 多筆更新
                            trn.Commit();
                        }
                        catch (Exception ex)
                       {
                           trn.Rollback();
                        }


1>*.cs

            try
            {
                List<string> SQLStringList_U = new List<string>();
                List<string> SQLStringList_A = new List<string>();

                    updSql = "update AMM_DEVICE set SNM = '" + Tmp_SNM + "', NOTE = '" + Tmp_NOTE + "'" + sWhr;
                SQLStringList_U.Add(updSql);
                     :
                    excuteSQLTran(SQLStringList_U);
                    excuteSQLTran(SQLStringList_A);
                }





2>BaseAPIController.cs excuteSQLTran 函式

public int excuteSQLTran(List<string> SQLStringList)
        {
            setActionName();
            int rows = 0;
OracleConnection conn = new OracleConnection(DBService.ConnectionString(DBLINK));
conn.Open();
conn.ClientInfo = User.Identity.Name;
conn.ModuleName = BaseSYS + "_" + BaseMODID;
conn.ActionName = ActionName;
OracleTransaction trn = conn.BeginTransaction();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.Transaction = trn;
try
{
excMsg = "";
for (int n = 0; n < SQLStringList.Count; n++)
{
string strsql = SQLStringList[n].ToString();
cmd.CommandText = strsql;
rows += cmd.ExecuteNonQuery();
}
trn.Commit();
}
catch (Exception ex)
{
trn.Rollback();
rows = -1;
//Console.WriteLine("error : " + ex.Message);
excMsg = ex.Message;
throw ex;
}
finally
{
cmd.Cancel();
conn.Close();
}
return rows;
}


3>*.cs  V20301 - 批次新增 - transaction 處理

//[匯入] 鈕 , 匯入 XLS 檔案
        [HttpPost]
        public HttpResponseMessage uploadFileToDB()
        {

            HttpContext c = HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;
            string FName = nvc["FName"];
            Workbook wk = null;

            HttpRequest Request = HttpContext.Current.Request;
            var response = this.Request.CreateResponse();
            string file_Name = FName;
            string FILEDT = DateTime.Now.ToString("yyyy/MM/dd");
            string Tmp_RtnMsg = "";
            string Tmp_RtnMsg1 = "";
            string Tmp_Sql = "", Tmp_Str = "";
            int Tmp_cnt = 0;
            
            List<string> SQLStringList_A = new List<string>();

            foreach (string cur_FName in Request.Files)
 {
                string fileType = Request.Files[cur_FName].ContentType;
                Stream file_Strm = Request.Files[cur_FName].InputStream;
                file_Name = Path.GetFileName(Request.Files[cur_FName].FileName);
                int fileSize = Request.Files[cur_FName].ContentLength;
                byte[] fileRcrd = new byte[fileSize];
                //更新資料庫欄位值                
                int Tmp_curpos = 0;
                try
                {

                    wk = new Workbook();
                    wk.LoadFromStream(file_Strm);
                    Worksheet sheet1 = wk.Worksheets[0];//獲取第一個工作表
                    /*
                    //共 33 欄
                    //string[] outFieldArray = { 資料來源,拆檢提領編號,維修提領編號,拆檢交修單號,維修約交修單號,
                                                                    WBS,數量,中文名稱(SAP勞務內容),英文簡稱,料號,
                                                                    件號,序號,機種,接收批次,預計拆檢完工日,
                                                                    客戶拆檢需求日,實際工廠接收日期,SAP OSM,EO,情況碼,
                                                                    工單類型,發工人員,管制人員,維修人員,拆檢結束日期,
                                                                    QDRNO,AMM工單備註,承修工場,專案,群組,
                                                                    是否序號管制,保固或構改管制碼,專案需求日};
                    //int RowsCount = sheet1.Rows.Count();
                    */
                    int RowsCount = sheet1.LastRow;
                    string Tmp_FMNO;
                    string  Tmp_DTSOR, Tmp_OGONOAF, Tmp_NGONOAF, Tmp_RPNOAF, Tmp_MRPNOAF;
                    string Tmp_WBSNO, Tmp_RQTYAF,  Tmp_C_NM, Tmp_ES_NM, Tmp_NSN;
                    string  Tmp_PN, Tmp_SEQOAF, Tmp_EIAC_CUS,Tmp_RBTHAF,Tmp_PRNRAF;
                    string  Tmp_CRNRAF, Tmp_FREDTAF, Tmp_OSM, Tmp_EONO, Tmp_CDCODE;
                    string Tmp_FRTP, Tmp_DLEMPLYID, Tmp_CREMPLYID, Tmp_MTEMPLYID, Tmp_NRCLAF;
                    string Tmp_QDRNO, Tmp_REMARK, Tmp_FACWC, Tmp_NEMPID, Tmp_LGROUP;
                    string Tmp_ISSN, Tmp_MCODE, Tmp_PJDT,Tmp_STATFM,Tmp_BTDT,Tmp_MDDT;

                    //STEP1 檢核  XLS 欄位名稱資料是否正確                                            
                    Tmp_DTSOR = sheet1.Range[myfunc.GetExcelPos(0, 0)].Value;
                    Tmp_OGONOAF = sheet1.Range[myfunc.GetExcelPos(1, 0)].Value;
                    Tmp_NGONOAF = sheet1.Range[myfunc.GetExcelPos(2, 0)].Value;
                    Tmp_RPNOAF = sheet1.Range[myfunc.GetExcelPos(3, 0)].Value;
                    Tmp_MRPNOAF = sheet1.Range[myfunc.GetExcelPos(4, 0)].Value;

                    Tmp_WBSNO = sheet1.Range[myfunc.GetExcelPos(5, 0)].Value;
                    Tmp_RQTYAF = sheet1.Range[myfunc.GetExcelPos(6, 0)].Value;
                    Tmp_C_NM = sheet1.Range[myfunc.GetExcelPos(7, 0)].Value;
                    Tmp_ES_NM = sheet1.Range[myfunc.GetExcelPos(8, 0)].Value;
                    Tmp_NSN = sheet1.Range[myfunc.GetExcelPos(9, 0)].Value;
                    
                    Tmp_PN = sheet1.Range[myfunc.GetExcelPos(10, 0)].Value;
                    Tmp_SEQOAF = sheet1.Range[myfunc.GetExcelPos(11, 0)].Value;
                    Tmp_EIAC_CUS = sheet1.Range[myfunc.GetExcelPos(12, 0)].Value;
                    Tmp_RBTHAF = sheet1.Range[myfunc.GetExcelPos(13, 0)].Value;
                    Tmp_PRNRAF = sheet1.Range[myfunc.GetExcelPos(14, 0)].Value;

                    Tmp_CRNRAF = sheet1.Range[myfunc.GetExcelPos(15, 0)].Value;
                    Tmp_FREDTAF = sheet1.Range[myfunc.GetExcelPos(16, 0)].Value;
                    Tmp_OSM = sheet1.Range[myfunc.GetExcelPos(17, 0)].Value;
                    Tmp_EONO = sheet1.Range[myfunc.GetExcelPos(18, 0)].Value;
                    Tmp_CDCODE = sheet1.Range[myfunc.GetExcelPos(19, 0)].Value;
                    
                    Tmp_FRTP = sheet1.Range[myfunc.GetExcelPos(20, 0)].Value;
                    Tmp_DLEMPLYID = sheet1.Range[myfunc.GetExcelPos(21, 0)].Value;
                    Tmp_CREMPLYID = sheet1.Range[myfunc.GetExcelPos(22, 0)].Value;
                    Tmp_MTEMPLYID = sheet1.Range[myfunc.GetExcelPos(23, 0)].Value;
                    Tmp_NRCLAF = sheet1.Range[myfunc.GetExcelPos(24, 0)].Value;

                    Tmp_QDRNO = sheet1.Range[myfunc.GetExcelPos(25, 0)].Value;
                    Tmp_REMARK = sheet1.Range[myfunc.GetExcelPos(26, 0)].Value;
                    Tmp_FACWC = sheet1.Range[myfunc.GetExcelPos(27, 0)].Value;
                    Tmp_NEMPID = sheet1.Range[myfunc.GetExcelPos(28, 0)].Value;
                    Tmp_LGROUP = sheet1.Range[myfunc.GetExcelPos(29, 0)].Value;

                    Tmp_ISSN = sheet1.Range[myfunc.GetExcelPos(30, 0)].Value;
                    Tmp_MCODE = sheet1.Range[myfunc.GetExcelPos(31, 0)].Value;
                    Tmp_PJDT = sheet1.Range[myfunc.GetExcelPos(32, 0)].Value;

                    /*
                     string  Tmp_DTSOR, Tmp_OGONOAF, Tmp_NGONOAF, Tmp_RPNOAF, Tmp_MRPNOAF;
                    string Tmp_WBSNO, Tmp_SEQOAF, Tmp_C_NM, Tmp_ES_NM, Tmp_NSN;
                    string  Tmp_PN, Tmp_SEQOAF, Tmp_EIAC_CUS,Tmp_RBTHAF,Tmp_PRNRAF;
                    string  Tmp_CRNRAF, Tmp_FREDTAF, Tmp_OSM, Tmp_EONO,, Tmp_CDCODE;
                    string Tmp_FRTP, Tmp_DLEMPLYID, Tmp_CREMPLYID, Tmp_MTEMPLYID, Tmp_NRCLAF;
                    string Tmp_QDRNO, Tmp_REMARK, Tmp_FACWC, Tmp_NEMPID, Tmp_LGROUP;
                    string Tmp_ISSN, Tmp_MCODE, Tmp_PJDT;
                     */
                    //xls 欄位名稱有問題
                    if ((Tmp_DTSOR != "資料來源") || (Tmp_OGONOAF != "拆檢提領編號") || (Tmp_NGONOAF != "維修提領編號") || (Tmp_RPNOAF != "拆檢交修單號") || (Tmp_MRPNOAF != "維修約交修單號") ||
                          (Tmp_WBSNO != "WBS") || (Tmp_RQTYAF != "數量") || (!Tmp_C_NM.Contains("中文名稱")) || (Tmp_ES_NM != "英文簡稱") || (Tmp_NSN != "料號") ||
                          (Tmp_PN != "件號") || (Tmp_SEQOAF != "序號")|| (Tmp_EIAC_CUS != "機種") || (Tmp_RBTHAF != "接收批次") || (Tmp_PRNRAF != "預計拆檢完工日") ||
                          (Tmp_CRNRAF != "客戶拆檢需求日") || (Tmp_FREDTAF != "實際工廠接收日期")|| (!Tmp_OSM.Contains("OSM")) || (Tmp_EONO != "EO") || (Tmp_CDCODE != "情況碼") ||
                          (Tmp_FRTP != "工單類型") || (Tmp_DLEMPLYID != "發工人員")|| (Tmp_CREMPLYID != "管制人員") || (Tmp_MTEMPLYID != "維修人員") || (Tmp_NRCLAF != "拆檢結束日期") ||
                          (Tmp_QDRNO != "QDRNO") || (Tmp_REMARK != "AMM工單備註")|| (Tmp_FACWC != "承修工場") || (Tmp_NEMPID != "專案") || (Tmp_LGROUP != "群組") ||
                          (Tmp_ISSN != "是否序號管制") || (Tmp_MCODE != "保固或構改管制碼")|| (Tmp_PJDT != "專案需求日")
                          )
                    {
                        Tmp_RtnMsg = "匯入檔案欄位名稱必需如下:<br>";
                        //(Tmp_DTSOR != "資料來源") || (Tmp_OGONOAF != "拆檢提領編號") || (Tmp_NGONOAF != "維修提領編號") || (Tmp_RPNOAF != "拆檢交修單號") || (Tmp_MRPNOAF != "維修約交修單號") ||
                        if (Tmp_DTSOR != "資料來源")
                            Tmp_RtnMsg = Tmp_RtnMsg+"第1欄欄位名稱:  [資料來源];";
                        if (Tmp_OGONOAF != "拆檢提領編號")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第2欄欄位名稱:  [拆檢提領編號];";
                        if (Tmp_NGONOAF != "維修提領編號")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第3欄欄位名稱:  [維修提領編號];";
                        if (Tmp_RPNOAF != "拆檢交修單號")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第4欄欄位名稱:  [拆檢交修單號];";
                        if (Tmp_MRPNOAF != "維修約交修單號")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第5欄欄位名稱:  [維修約交修單號];";
                        
                        //(Tmp_WBSNO != "WBS") || (Tmp_RQTYAF != "數量") || (!Tmp_C_NM.Contains("中文名稱")) || (Tmp_ES_NM != "英文簡稱") || (Tmp_PRNRAF != "保管人") || (Tmp_NSN != "料號") ||
                        if (Tmp_WBSNO != "WBS")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第6欄欄位名稱:  [WBS];";
                        if (Tmp_RQTYAF != "數量")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第7欄欄位名稱:  [數量];";
                        if (!Tmp_C_NM.Contains("中文名稱"))
                            Tmp_RtnMsg = Tmp_RtnMsg + "第8欄欄位名稱:  [中文名稱];";
                        if (Tmp_ES_NM != "英文簡稱")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第9欄欄位名稱:  [英文簡稱];";
                        if (Tmp_NSN != "料號")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第10欄欄位名稱:  [料號];";

                        //(Tmp_PN != "件號") || (Tmp_SEQOAF != "序號")|| (Tmp_EIAC_CUS != "機種") || (Tmp_RBTHAF != "接收批次") || (Tmp_PRNRAF != "預計拆檢完工日") ||
                        if (Tmp_PN != "件號")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第11欄欄位名稱:  [件號];";
                        if (Tmp_SEQOAF != "序號")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第12欄欄位名稱:  [序號];";
                        if (Tmp_EIAC_CUS != "機種")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第13欄欄位名稱:  [機種];";
                        if (Tmp_RBTHAF != "接收批次")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第14欄欄位名稱:  [接收批次];";
                        if (Tmp_PRNRAF != "預計拆檢完工日")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第15欄欄位名稱:  [預計拆檢完工日];";



                        //(Tmp_CRNRAF != "客戶拆檢需求日") || (Tmp_FREDTAF != "實際工廠接收日期") || (!Tmp_OSM.Contains("OSM")) || (Tmp_EONO != "EO") || (Tmp_CDCODE != "情況碼") ||
                        if (Tmp_CRNRAF != "客戶拆檢需求日")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第16欄欄位名稱:  [客戶拆檢需求日];";
                        if (Tmp_FREDTAF != "實際工廠接收日期")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第17欄欄位名稱:  [實際工廠接收日期];";
                        if (!Tmp_OSM.Contains("OSM"))
                            Tmp_RtnMsg = Tmp_RtnMsg + "第18欄欄位名稱:  [OSM];";
                        if (Tmp_EONO != "EO")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第19欄欄位名稱:  [EO];";
                        if (Tmp_CDCODE != "情況碼")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第20欄欄位名稱:  [情況碼];";

                        //(Tmp_FRTP != "工單類型") || (Tmp_DLEMPLYID != "發工人員") || (Tmp_CREMPLYID != "管制人員") || (Tmp_MTEMPLYID != "維修人員") || (Tmp_NRCLAF != "拆檢結束日期") ||
                        if (Tmp_FRTP != "工單類型")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第21欄欄位名稱:  [工單類型];";
                        if (Tmp_DLEMPLYID != "發工人員")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第22欄欄位名稱:  [發工人員];";
                        if (Tmp_CREMPLYID != "管制人員")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第23欄欄位名稱:  [管制人員];";
                        if (Tmp_MTEMPLYID != "維修人員")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第24欄欄位名稱:  [維修人員];";
                        if (Tmp_NRCLAF != "拆檢結束日期")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第25欄欄位名稱:  [拆檢結束日期];";

                        //(Tmp_QDRNO != "QDRNO") || (Tmp_REMARK != "AMM工單備註")|| (Tmp_FACWC != "承修工場") || (Tmp_NEMPID != "專案") || (Tmp_LGROUP != "群組") ||
                        if (Tmp_QDRNO != "QDRNO")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第26欄欄位名稱:  [QDRNO];";
                        if (Tmp_REMARK != "AMM工單備註")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第27欄欄位名稱:  [AMM工單備註];";
                        if (Tmp_FACWC != "承修工場")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第28欄欄位名稱:  [承修工場];";
                        if (Tmp_NEMPID != "專案")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第29欄欄位名稱:  [專案];";
                        if (Tmp_LGROUP != "群組")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第30欄欄位名稱:  [群組];";

                        // (Tmp_ISSN != "是否序號管制") || (Tmp_MCODE != "保固或構改管制碼")|| (Tmp_PJDT != "專案需求日")    
                        if (Tmp_ISSN != "是否序號管制")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第31欄欄位名稱:  [是否序號管制];";
                        if (Tmp_MCODE != "保固或構改管制碼")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第32欄欄位名稱:  [保固或構改管制碼];";
                        if (Tmp_PJDT != "專案需求日")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第33欄欄位名稱:  [專案需求日];";                        
                        //Tmp_RtnMsg = "匯入檔案欄位名稱必需如下:<br>"
                        //                         + "\"資料來源\",\"拆檢提領編號\",\"維修提領編號\",\"拆檢交修單號\",\"維修約交修單號\",<br>"
                        //                         + "\"WBS\",\"數量\",\"中文名稱(SAP勞務內容)\",\"英文簡稱\",\"料號\",<br>"
                        //                         + "\"件號\",\"序號\",\"機種\",\"接收批次\",\"預計拆檢完工日\",<br>"
                        //                         + "\"客戶拆檢需求日\",\"實際工廠接收日期\",\"SAP OSM\",\"EO\",\"情況碼\",<br>"
                        //                         + "\"工單類型\",\"發工人員\",\"管制人員\",\"維修人員\",\"拆檢結束日期\",<br>"
                        //                         + "\"QDRNO\",\"AMM工單備註\",\"承修工場\",\"專案\",\"群組\",<br>"
                        //                         + "\"是否序號管制\",\"保固或構改管制碼\",\"專案需求日\"<br>"
                        //                         + " 敬請檢核";
                        Tmp_Str = "{success: false,FName:" + myfunc.AA(FName) + ",Rtn_Msg:" + myfunc.AA(Tmp_RtnMsg) + "}";
                        response.Content = new StringContent(Tmp_Str);    // 回應內容
                        return response;
                    };


                    int Tmp_index;
                    //STEP2 檢核 xls 欄位值
                    Tmp_RtnMsg = "";
                    for (int i = 0; i < RowsCount; i++)
                    {
                        Tmp_RtnMsg1 = "";
                        Tmp_curpos = i + 1;
                        Tmp_DTSOR = sheet1.Range[myfunc.GetExcelPos(0, i + 1)].Value;
                        if (myfunc.checkisnull(Tmp_DTSOR))
                        {
                            break;
                            //Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[資料來源]欄位值不可空白;";
                        }
                        Tmp_OGONOAF = sheet1.Range[myfunc.GetExcelPos(1, i + 1)].Value;
                        Tmp_NGONOAF = sheet1.Range[myfunc.GetExcelPos(2, i + 1)].Value;
                        Tmp_RPNOAF = sheet1.Range[myfunc.GetExcelPos(3, i + 1)].Value;
                        Tmp_MRPNOAF = sheet1.Range[myfunc.GetExcelPos(4, i + 1)].Value;

                        Tmp_WBSNO = sheet1.Range[myfunc.GetExcelPos(5, i + 1)].Value;
                        Tmp_RQTYAF = sheet1.Range[myfunc.GetExcelPos(6, i + 1)].Value;
                        Tmp_C_NM = sheet1.Range[myfunc.GetExcelPos(7, i + 1)].Value;
                        Tmp_ES_NM = sheet1.Range[myfunc.GetExcelPos(8, i + 1)].Value;
                        Tmp_NSN = sheet1.Range[myfunc.GetExcelPos(9, i + 1)].Value;

                        Tmp_PN = sheet1.Range[myfunc.GetExcelPos(10, i + 1)].Value;
                        Tmp_SEQOAF = sheet1.Range[myfunc.GetExcelPos(11, i + 1)].Value;
                        Tmp_EIAC_CUS = sheet1.Range[myfunc.GetExcelPos(12, i + 1)].Value;
                        Tmp_RBTHAF = sheet1.Range[myfunc.GetExcelPos(13, i + 1)].Value;
                        Tmp_PRNRAF = sheet1.Range[myfunc.GetExcelPos(14, i + 1)].Value;

                        Tmp_CRNRAF = sheet1.Range[myfunc.GetExcelPos(15, i + 1)].Value;
                        Tmp_FREDTAF = sheet1.Range[myfunc.GetExcelPos(16, i + 1)].Value;
                        Tmp_OSM = sheet1.Range[myfunc.GetExcelPos(17, i + 1)].Value;
                        Tmp_EONO = sheet1.Range[myfunc.GetExcelPos(18, i + 1)].Value;
                        Tmp_CDCODE = sheet1.Range[myfunc.GetExcelPos(19, i + 1)].Value;

                        Tmp_FRTP = sheet1.Range[myfunc.GetExcelPos(20, i + 1)].Value;
                        Tmp_DLEMPLYID = sheet1.Range[myfunc.GetExcelPos(21, i + 1)].Value;
                        Tmp_CREMPLYID = sheet1.Range[myfunc.GetExcelPos(22, i + 1)].Value;
                        Tmp_MTEMPLYID = sheet1.Range[myfunc.GetExcelPos(23, i + 1)].Value;
                        Tmp_NRCLAF = sheet1.Range[myfunc.GetExcelPos(24, i + 1)].Value;

                        Tmp_QDRNO = sheet1.Range[myfunc.GetExcelPos(25, i + 1)].Value;
                        Tmp_REMARK = sheet1.Range[myfunc.GetExcelPos(26, i + 1)].Value;
                        Tmp_FACWC = sheet1.Range[myfunc.GetExcelPos(27, i + 1)].Value;
                        Tmp_NEMPID = sheet1.Range[myfunc.GetExcelPos(28, i + 1)].Value;
                        Tmp_LGROUP = sheet1.Range[myfunc.GetExcelPos(29, i + 1)].Value;

                        Tmp_ISSN = sheet1.Range[myfunc.GetExcelPos(30, i + 1)].Value;
                        Tmp_MCODE = sheet1.Range[myfunc.GetExcelPos(31, i + 1)].Value;
                        Tmp_PJDT = sheet1.Range[myfunc.GetExcelPos(32, i + 1)].Value;


                        //if (Tmp_curpos == 290)
                        //{
                        //    Tmp_Str = " 第 290筆資料";
                        //};                                                
                        //將日期轉成  yyyy/MM/dd 格式, 若非日期格式,則傳回 ""
                        Tmp_PRNRAF = myfunc.DatetoStr(Tmp_PRNRAF);
                        Tmp_CRNRAF = myfunc.DatetoStr(Tmp_CRNRAF);
                        Tmp_NRCLAF = myfunc.DatetoStr(Tmp_NRCLAF);
                        Tmp_FREDTAF = myfunc.DatetoStr(Tmp_FREDTAF);

                        //檢核 1: 欄位值不可空白 - 資料來源、WBS、數量、序號、機種、工單類型、是否序號管制
                        if (myfunc.checkisnull(Tmp_WBSNO))
                        {
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[WBS]不可空白;";
                        }
                        if (myfunc.checkisnull(Tmp_RQTYAF))
                        {
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[數量]不可空白;";
                        }
                        if (myfunc.checkisnull(Tmp_SEQOAF))
                        {
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[序號]不可空白;";
                        }
                        if (myfunc.checkisnull(Tmp_EIAC_CUS))
                        {
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[機種]不可空白;";
                        }
                        if (myfunc.checkisnull(Tmp_FRTP))
                        {
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[工單類型]不可空白;";
                        }
                        if (myfunc.checkisnull(Tmp_ISSN))
                        {
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[是否序號管制]不可空白;";
                        }
                        if (Tmp_PN.Substring(0,2)=="R=")
                            if (Tmp_FRTP!="DT03")
                            {
                                Tmp_RtnMsg1 = Tmp_RtnMsg1 + "件號以[R=]開頭,則工單類別必需為[DT03];";
                            }
                        if (  (!myfunc.checkisnull(Tmp_EONO)) && (!myfunc.checkisnull(Tmp_OSM))  )                            
                                Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[EO]及 [SAP OSM] 不可均有值;";
                        if ( (!myfunc.checkisnull(Tmp_CDCODE)) && (!myfunc.checkisnull(Tmp_OSM)) )
                                Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[情況碼]及 [SAP OSM] 不可均有值;";                        
                        if (!myfunc.checkisnum(Tmp_DLEMPLYID))
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[發工人員] 必需為員工編號,非姓名;";
                        if (!myfunc.checkisnum(Tmp_CREMPLYID))
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[管制人員] 必需為員工編號,非姓名;";
                        if (!myfunc.checkisnum(Tmp_MTEMPLYID))
                            Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[維修人員] 必需為員工編號,非姓名;";
                        if (Tmp_MCODE.Substring(0, 1) == "C")
                            if (myfunc.checkisnull(Tmp_PJDT))
                             {
                                Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[保固或構改管制碼]='C',則[專案需求日]不可空白;";
                            }
                        if (Tmp_RtnMsg1.Length > 0)
                            Tmp_RtnMsg = Tmp_RtnMsg
                                                      +"第" + Tmp_curpos.ToString() + "行欄位值錯誤, 請檢核:<br>"
                                                     + Tmp_RtnMsg1
                                                     +"<br>";

                    }  //end for 
                    if (Tmp_RtnMsg.Length>0)
                    {
                        Tmp_RtnMsg = "批次匯入失敗!!<br>"                                             
                                                 + Tmp_RtnMsg + "<br>";
                        //+ Tmp_Sql ;
                        //Tmp_Str = "{success: false,FName:" + myfunc.AA(FName) + ",Rtn_Msg:" + myfunc.AA(Tmp_RtnMsg) +",Tmp_Sql:"+ myfunc.AA(Tmp_Sql) +"}";
                        Tmp_Str = "{success: false,FName:" + myfunc.AA(FName) + ",Rtn_Msg:" + myfunc.AA(Tmp_RtnMsg) + "}";
                        response.Content = new StringContent(Tmp_Str);    // 回應內容                    
                        return response;
                    }
                    //STEP3 寫入資料庫
                    Tmp_RtnMsg = "";
                    var Tmp_pre_FMNO = "";
                    for (int i = 0; i < RowsCount; i++)
                    {
                        Tmp_curpos = i + 1;
                        Tmp_DTSOR = sheet1.Range[myfunc.GetExcelPos(0, i + 1)].Value;
                        if (myfunc.checkisnull(Tmp_DTSOR))
                        {
                            break;
                            //Tmp_RtnMsg = Tmp_RtnMsg + "[資料來源]欄位值不可空白";
                        }
                        Tmp_OGONOAF = sheet1.Range[myfunc.GetExcelPos(1, i + 1)].Value;
                        Tmp_NGONOAF = sheet1.Range[myfunc.GetExcelPos(2, i + 1)].Value;
                        Tmp_RPNOAF = sheet1.Range[myfunc.GetExcelPos(3, i + 1)].Value;
                        Tmp_MRPNOAF = sheet1.Range[myfunc.GetExcelPos(4, i + 1)].Value;

                        Tmp_WBSNO = sheet1.Range[myfunc.GetExcelPos(5, i + 1)].Value;
                        Tmp_RQTYAF = sheet1.Range[myfunc.GetExcelPos(6, i + 1)].Value;
                        Tmp_C_NM = sheet1.Range[myfunc.GetExcelPos(7, i + 1)].Value;
                        Tmp_ES_NM = sheet1.Range[myfunc.GetExcelPos(8, i + 1)].Value;
                        Tmp_NSN = sheet1.Range[myfunc.GetExcelPos(9, i + 1)].Value;

                        Tmp_PN = sheet1.Range[myfunc.GetExcelPos(10, i + 1)].Value;
                        Tmp_SEQOAF = sheet1.Range[myfunc.GetExcelPos(11, i + 1)].Value;
                        Tmp_EIAC_CUS = sheet1.Range[myfunc.GetExcelPos(12, i + 1)].Value;
                        Tmp_RBTHAF = sheet1.Range[myfunc.GetExcelPos(13, i + 1)].Value;
                        Tmp_PRNRAF = sheet1.Range[myfunc.GetExcelPos(14, i + 1)].Value;

                        Tmp_CRNRAF = sheet1.Range[myfunc.GetExcelPos(15, i + 1)].Value;
                        Tmp_FREDTAF = sheet1.Range[myfunc.GetExcelPos(16, i + 1)].Value;
                        Tmp_OSM = sheet1.Range[myfunc.GetExcelPos(17, i + 1)].Value;
                        Tmp_EONO = sheet1.Range[myfunc.GetExcelPos(18, i + 1)].Value;
                        Tmp_CDCODE = sheet1.Range[myfunc.GetExcelPos(19, i + 1)].Value;

                        Tmp_FRTP = sheet1.Range[myfunc.GetExcelPos(20, i + 1)].Value;
                        Tmp_DLEMPLYID = sheet1.Range[myfunc.GetExcelPos(21, i + 1)].Value;
                        Tmp_CREMPLYID = sheet1.Range[myfunc.GetExcelPos(22, i + 1)].Value;
                        Tmp_MTEMPLYID = sheet1.Range[myfunc.GetExcelPos(23, i + 1)].Value;
                        Tmp_NRCLAF = sheet1.Range[myfunc.GetExcelPos(24, i + 1)].Value;

                        Tmp_QDRNO = sheet1.Range[myfunc.GetExcelPos(25, i + 1)].Value;
                        Tmp_REMARK = sheet1.Range[myfunc.GetExcelPos(26, i + 1)].Value;
                        Tmp_FACWC = sheet1.Range[myfunc.GetExcelPos(27, i + 1)].Value;
                        Tmp_NEMPID = sheet1.Range[myfunc.GetExcelPos(28, i + 1)].Value;
                        Tmp_LGROUP = sheet1.Range[myfunc.GetExcelPos(29, i + 1)].Value;

                        Tmp_ISSN = sheet1.Range[myfunc.GetExcelPos(30, i + 1)].Value;
                        Tmp_MCODE = sheet1.Range[myfunc.GetExcelPos(31, i + 1)].Value;
                        Tmp_PJDT = sheet1.Range[myfunc.GetExcelPos(32, i + 1)].Value;


                        //if (Tmp_curpos == 290)
                        //{
                        //    Tmp_Str = " 第 290筆資料";
                        //};                                                
                        //將日期轉成  yyyy/MM/dd 格式, 若非日期格式,則傳回 ""
                        Tmp_PRNRAF = myfunc.DatetoStr(Tmp_PRNRAF);
                        Tmp_CRNRAF = myfunc.DatetoStr(Tmp_CRNRAF);
                        Tmp_NRCLAF = myfunc.DatetoStr(Tmp_NRCLAF);
                        Tmp_FREDTAF = myfunc.DatetoStr(Tmp_FREDTAF);
                        Tmp_PJDT = myfunc.DatetoStr(Tmp_PJDT);

                        Tmp_STATFM = "A";
                        Tmp_BTDT= DateTime.Now.ToString("yyyy/MM/dd");
                        Tmp_MDDT = DateTime.Now.ToString("yyyy/MM/dd");



                        Tmp_FMNO = get_NEXT_FMNO1(Tmp_pre_FMNO);
                        
                        Tmp_Sql = " INSERT  INTO  AMM_FM "
                                        + "  ( FMNO,"
                                        +     " DTSOR, OGONOAF, NGONOAF, RPNOAF, MRPNOAF,"
                                             + " WBSNO, RQTYAF, C_NM, ES_NM, NSN,  "
                                             + " PN, SEQOAF, EIAC_CUS,RBTHAF,PRNRAF, "
                                             + " CRNRAF, FREDTAF, OSM, EONO, CDCODE, "
                                             + " FRTP, DLEMPLYID, CREMPLYID, MTEMPLYID, NRCLAF, "
                                             + " QDRNO, REMARK, FACWC, NEMPID, LGROUP, "
                                             + " ISSN, MCODE, PJDT , STATFM, BTDT, "
                                             +"  MDDT"
                                        + ") "
                                        + "  VALUES "                                        
                                        + "(" + myfunc.AA(Tmp_FMNO) + ","
                                        + myfunc.AA(Tmp_DTSOR) + ","+ myfunc.AA(Tmp_OGONOAF) + "," + myfunc.AA(Tmp_NGONOAF) + "," + myfunc.AA(Tmp_RPNOAF) + "," + myfunc.AA(Tmp_MRPNOAF) + ",  "
                                        + myfunc.AA(Tmp_WBSNO) + "," + myfunc.AA(Tmp_RQTYAF) + "," + myfunc.AA(Tmp_C_NM) + "," + myfunc.AA(Tmp_ES_NM) + "," + myfunc.AA(Tmp_NSN) + ",  "
                                        + myfunc.AA(Tmp_PN) + "," + myfunc.AA(Tmp_SEQOAF) + "," + myfunc.AA(Tmp_EIAC_CUS) + "," + myfunc.AA(Tmp_RBTHAF) + "," + myfunc.AA(Tmp_PRNRAF) + ",  "
                                        + myfunc.AA(Tmp_CRNRAF) + "," + myfunc.AA(Tmp_FREDTAF) + "," + myfunc.AA(Tmp_OSM) + "," + myfunc.AA(Tmp_EONO) + "," + myfunc.AA(Tmp_CDCODE) + ",  "
                                        + myfunc.AA(Tmp_FRTP) + "," + myfunc.AA(Tmp_DLEMPLYID) + "," + myfunc.AA(Tmp_CREMPLYID) + "," + myfunc.AA(Tmp_MTEMPLYID) + "," + myfunc.AA(Tmp_NRCLAF) + ",  "
                                        + myfunc.AA(Tmp_QDRNO) + "," + myfunc.AA(Tmp_REMARK) + "," + myfunc.AA(Tmp_FACWC) + "," + myfunc.AA(Tmp_NEMPID) + "," + myfunc.AA(Tmp_LGROUP) + ",  "
                                        + myfunc.AA(Tmp_ISSN) + "," + myfunc.AA(Tmp_MCODE) + "," + myfunc.AA(Tmp_PJDT) +","+ myfunc.AA(Tmp_STATFM)+"," + myfunc.AA(Tmp_BTDT) +","
                                        + myfunc.AA(Tmp_MDDT)
                                        + ") ";
                        //myfunc.SqlExec(Tmp_Sql);
                        //因為批次執行,所以 Tmp_NEXT_FMNO 均相同, 多筆時,會重複
                        SQLStringList_A.Add(Tmp_Sql);
                        Tmp_pre_FMNO = Tmp_FMNO;
                    };
                    excuteSQLTran(SQLStringList_A);
                    Tmp_RtnMsg = "匯入成功!!";
                    Tmp_Str = "{success: true,FName:" + myfunc.AA(FName) + ",Rtn_Msg:" + myfunc.AA(Tmp_RtnMsg) + "}";
                    response.Content = new StringContent(Tmp_Str);    // 回應內容
                    return response;
                }// try
                catch (Exception e)
                {                                                                                          //失敗
                    Tmp_RtnMsg = "批次匯入失敗!!<br>"
                                             + "第" + Tmp_curpos.ToString() + "筆資料<br>"
                                             + e.Message + "<br>";
                    //+ Tmp_Sql ;
                    //Tmp_Str = "{success: false,FName:" + myfunc.AA(FName) + ",Rtn_Msg:" + myfunc.AA(Tmp_RtnMsg) +",Tmp_Sql:"+ myfunc.AA(Tmp_Sql) +"}";
                    Tmp_Str = "{success: false,FName:" + myfunc.AA(FName) + ",Rtn_Msg:" + myfunc.AA(Tmp_RtnMsg) + "}";
                    response.Content = new StringContent(Tmp_Str);    // 回應內容                    
                    return response;
                }
            }  //end of foreach (string cur_FName in Request.Files)
            return response;
        }  //  end of  uploadFileToDB()



        //若 par_pre_FMNO空白,則由資料庫取 MAX(FMNO), 
        //若有值,則直接+1
        public string get_NEXT_FMNO1(string par_pre_FMNO)
        {
            var response = this.Request.CreateResponse();
            string Tmp_Sql, Tmp_Str;
            string Tmp_DStr = "FM" + DateTime.Now.ToString("yyyyMMdd"); ;
            string Tmp_MAX_FMNO, Tmp_NEXT_FMNO;
            if (myfunc.checkisnull(par_pre_FMNO))
            {
                Tmp_Sql = "  SELECT   MAX(FMNO) "
                                + "  FROM      AMM_FM "
                                + "  WHERE   FMNO LIKE  " + myfunc.AA(Tmp_DStr + '%');
                Tmp_MAX_FMNO = myfunc.SqlValue(Tmp_Sql);
            }
            else
                Tmp_MAX_FMNO = par_pre_FMNO;
            if (myfunc.checkisnull(Tmp_MAX_FMNO))
            {
                Tmp_NEXT_FMNO = Tmp_DStr + "001";
            }
            else
            {
                //取流水號(末3碼)+1  
                int Tmp_NextSerno = int.Parse(Tmp_MAX_FMNO.Substring(Tmp_MAX_FMNO.Length - 3, 3));
                Tmp_NextSerno = Tmp_NextSerno + 1;
                Tmp_NEXT_FMNO = Tmp_DStr + Tmp_NextSerno.ToString("000");
            }            
            return Tmp_NEXT_FMNO;
            //return Tmp_NEXT_FMNO;
        }

2022年9月12日 星期一

V80C03 - 單檔 - 編輯頁 & 編輯按鈕 不顯示(設為 false)

目的: 編輯頁 & 編輯按鈕 設為 false

處理說明:  //將 [編輯]頁 & 編輯按鈕設為 false

    1>Ext.getCmp('TMSingleViewEdit').setTabVisible(0, false);

    2>Ext.getCmp('TMSingleViewEdit').setTemplateBtnVisible(false);



1> *.js
    //將 [編輯]頁 & 編輯按鈕設為 false
    Ext.getCmp('TMSingleViewEdit').setTabVisible(0, false);         
    Ext.getCmp('TMSingleViewEdit').setTemplateBtnVisible(false);