2026年10月2日 星期五

V60202Q-[現場領用]鈕-識別證2員工編號 -SMS_AIDC -MSSQL -SQLSERVER - 按[ENTER]鍵 - 員工帳號 - CARDNO - SqlConnection - 輸入字元

 目的: V60202Q-[現場領用]鈕-刷識別證2員工編號 -  MSSQL -SQLSERVER - SQL SERVER

處理說明: 1>刷識別證2員工編號
                      myfunc.get_CARDNO2EMPLYID(par_CARDNO);
                   2>由 SQLServer 的 SMS_AIDC 取得資料
                         string Tmp_Sql = "  SELECT  TOP 1 PSNNO  "
                                                   + "  FROM    SMS_AIDC.dbo.V_CARD "
                                                  + " WHERE   CARDNO=" + myfunc.AA(Tmp_CARDNO);
                         DataSet ds = Tmp_BaseController.getDataTable_MSSQL("SMS_AIDC", Tmp_Sql);

                   3>判斷輸入的字元,是否 [ENTER]鍵
                        Ext.getCmp("sub_COMPER").on("specialkey", function (field, e) {
                                 if (e.getKey() === e.ENTER) {
                                 }
                       });  
 


1>*.js

//按[ENTER]時,咷至下一欄位
    Ext.getCmp("sub_COMPER").on("specialkey", function (field, e) {
        if (e.getKey() === e.ENTER) {
            //field.next().focus();            
            //Ext.getCmp("sub_COMPER").setValue("ABC");
            Ext.getCmp("sub_COMPER").fireEvent("blur", Ext.getCmp("sub_COMPER"));
            Ext.getCmp("sub_BKMG").focus();
        }
    });

 Ext.getCmp("sub_COMPER").on('blur', function (me, eOpts) {
        //STEP1 將[識別證卡號] 轉成 [員工編號]
        var Tmp_CARDNO = me.getValue();
        if (Tmp_CARDNO.length > 8) {
            console.log("卡號:", Tmp_CARDNO);
            var Tmp_EMPLYID = "";  //所有資料 PK 字串, 以 , 分隔
            var Tmp_EMPLYNM = "";
            var Tmp_url = "../../api/V60202QAPI/get_EMPLYID_EMPLYNM";
            var np = {};
            np["CARDNO"] = Tmp_CARDNO;
            var Tmp_Str = getUrlStr(Tmp_url, np, "識別證編號2員工編號");
            Tmp_EMPLYID = StrExtract1(Tmp_Str, 1);
            Tmp_EMPLYNM = StrExtract1(Tmp_Str, 2);
            if (checkRtnOK(Tmp_EMPLYID)) {
                me.setValue(Tmp_EMPLYID);
                Ext.getCmp("sub_COMPER_").setValue(Tmp_EMPLYNM);
            }
        }
        else {  //直接輸入帳號 
            Tmp_EMPLYID = Tmp_CARDNO;
            Tmp_EMPLYNM = getEmp_NM(Tmp_EMPLYID);
            Ext.getCmp("sub_COMPER_").setValue(Tmp_EMPLYNM);
        }
    });


2>*.cs  - myfunc.get_CARDNO2EMPLYID
//由識別證號碼取得員工帳號
        [HttpPost]
        public string get_EMPLYID_EMPLYNM()
        {
            var c = HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;
            string Tmp_Str;
            string Tmp_CARDNO = nvc["CARDNO"];
            string Tmp_EMPLYID = myfunc.get_CARDNO2EMPLYID(Tmp_CARDNO);
            string Tmp_Sql = " SELECT  EMPLYNM "
                                      + " FROM    HR_EMPLYM "
                                      + " WHERE  EMPLYID=" + myfunc.AA(Tmp_EMPLYID);
            string Tmp_EMPLYNM = myfunc.SqlValue(Tmp_Sql);
            Tmp_Str = Tmp_EMPLYID + ";" + Tmp_EMPLYNM;
            return Tmp_Str;
        }  // end of get_EMPLYID


public static string get_CARDNO2EMPLYID(string par_CARDNO)
        {
            string Tmp_CARDNO = par_CARDNO;
            string Tmp_EMPLYID = "";
            BaseAPIController Tmp_BaseController = new BaseAPIController();
            try
            {
                string Tmp_Sql = "  SELECT  TOP 1 PSNNO  "
                                       + "  FROM    SMS_AIDC.dbo.V_CARD "
                                       + " WHERE   CARDNO=" + myfunc.AA(Tmp_CARDNO);
                DataSet ds = Tmp_BaseController.getDataTable_MSSQL("SMS_AIDC", Tmp_Sql);
                int Tmp_cnt = ds.Tables[0].Rows.Count;
                if (Tmp_cnt > 0)
                {
                    string Tmp_PSNNO = ds.Tables[0].Rows[0]["PSNNO"].ToString();                 
                    Tmp_EMPLYID = Tmp_PSNNO;                    
                }
                return Tmp_EMPLYID;
            }  // end of try 
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return Tmp_EMPLYID;
        }  // end of         public string get_CARDNO2EMPLYID(string par_CARDNO)

2026年10月1日 星期四

V60202Q – [領用人員] – 按[Enter]鍵時,跳至下一欄位 - key - 取得欄位新值(取得識別證的員工編號)

 目的: V60202Q – [領用人員] – 按[Enter]鍵時,跳至下一欄位

處理說明:   1> specialkey event :   有輸入字元時觸發 
                       Ext.getCmp("sub_COMPER").on("specialkey", function (field, e) {
                       if (e.getKey() === e.ENTER) {
                            //field.next().focus();
                            //本元件的欄位值,設成新值 
                            Ext.getCmp("sub_COMPER").setValue("ABC");
                            Ext.getCmp("sub_BKMG").focus();
                       }
                       });


1>*.js
    //按[ENTER]時,咷至下一欄位
    Ext.getCmp("sub_COMPER").on("specialkey", function (field, e) {
        if (e.getKey() === e.ENTER) {
            //field.next().focus();
            Ext.getCmp("sub_BKMG").focus();
        }
    });
 
    Ext.getCmp("sub_BKMG").on("specialkey", function (field, e) {
        if (e.getKey() === e.ENTER) {
            //field.next().focus();
            Ext.getCmp("sub_MATNR").focus();
        }
    });
 
    Ext.getCmp("sub_MATNR").on("specialkey", function (field, e) {
        if (e.getKey() === e.ENTER) {
            //field.next().focus();
            Ext.getCmp("sub_SAPNO").focus();
        }
    });