2025年12月30日 星期二

V20305O - 撥發單位查詢 -挑選欄位 SQL - SP_NSN@TLS_245 的處理 - @ 的不同資料庫 - 挑選欄位處理 - DBLINK

 目的: V20305O - 撥發單位查詢 -挑選件號  SQL -  SP_NSN@TLS_245

處理說明:1>設定 DBLINK = TLSEU
                     若為測試區,則會自動加 '5'             
                 2>當成一般 Table 處理  SP_NSN
                 3>其他 挑選欄位時,DBLINK會自動還原 成預設值(AMMEU5)
                 4>SQL 修改如下, - 設定 DBLINK 
                      string Tmp_Sql = "  SELECT  DISTINCT  PN   "
                                                + " FROM     SP_NSN  "
                                                + " WHERE   1=1 "
                                                + " ORDER  BY   PN  ";
                      string n = funId + "_sub_PN";
                      DBLINK = "TLSEU";
                      DataSet ds = setupPickDs(n, Tmp_Sql, new string[] { "SP_NSN" }); 
                 5>V20305F1
                       Tmp_Sql = "  SELECT  DISTINCT C_UNIT,   "
                          + "   (SELECT C_DES  FROM C_UNIT  WHERE  C_UNIT=A.C_UNIT) as C_DES "
                                       + " FROM     SP_NSN  A  "
                                       + " WHERE   PN = " + myfunc.AA(par_PN)
                                       + " AND        CAGE =" + myfunc.AA(par_CAGE)
                                       + " ORDER  BY   C_UNIT  ";
            string n = funId + "_sub_C_UNIT";
            DBLINK = "TLSEU";
            DataSet ds = setupPickDs(n, Tmp_Sql, new string[] { "SP_NSN" },false,true);



1>*.cs

    [HttpPost]
        public dynamic get_sub_PNPick(string PN = "", int isComplete = 0)
        {
            //列出所有申請單(PN)
string Tmp_Sql = "  SELECT  DISTINCT  PN   "
                        + " FROM     SP_NSN@TLS_245  "
                        + " WHERE   1=1 "
                        + " ORDER  BY   PN  ";
            DataSet ds = setupPickDs(n, Tmp_Sql, new string[] { "SP_NSN@TLS_245" });
            //--> 會出現錯誤訊息 , 修改如下藍字,即可 - DBLINK='TLSEU'
 
            string Tmp_Sql = "  SELECT  DISTINCT  PN   "
                         + " FROM     SP_NSN  "
                         + " WHERE   1=1 "
                         + " ORDER  BY   PN  ";
            string n = funId + "_sub_PN";
            DBLINK = "TLSEU";
            DataSet ds = setupPickDs(n, Tmp_Sql, new string[] { "SP_NSN" });
            if (PN != null && !PN.Equals(""))
            {
                if (isComplete == 1)矩形圖說文字: 若直接寫 SP_NSN@TLS_245
à 
會出現錯誤                {
                    ds = getPickDsbyCondi(n, "PN='" + PN + "'");
                }
                else
                {
                    ds = getPickDsbyCondi(n, "PN  LIKE '%" + PN + "%'");
                }
            }
            return ds;
        }  // end of  get_V20305P_PNPick

3>V20305F1*.cs
  [HttpPost]
        public dynamic get_sub1_C_UNITPick(string C_UNIT = "", string par_PN = "", string par_CAGE = "", 
                                                   string par_CBIL = "", int isComplete = 0)
        {
            //列出所有申請單(C_UNIT)
            string Tmp_Sql="";
            if (par_CBIL=="2")
            {
                Tmp_Sql = "  SELECT  DISTINCT UNIT_IS  as C_UNIT,   "
                         + "   (SELECT C_DES  FROM C_UNIT WHERE  C_UNIT=A.UNIT_IS) as C_DES "
                                       + " FROM     SP_NSN  A"
                                       + " WHERE   PN = " + myfunc.AA(par_PN)
                                       + " AND        CAGE =" + myfunc.AA(par_CAGE)
                                       + " ORDER  BY   C_UNIT  ";
            }
            else
            {
                Tmp_Sql = "  SELECT  DISTINCT C_UNIT,   "
                          + "   (SELECT C_DES  FROM C_UNIT  WHERE  C_UNIT=A.C_UNIT) as C_DES "
                                       + " FROM     SP_NSN  A  "
                                       + " WHERE   PN = " + myfunc.AA(par_PN)
                                       + " AND        CAGE =" + myfunc.AA(par_CAGE)
                                       + " ORDER  BY   C_UNIT  ";
            }
            string n = funId + "_sub_C_UNIT";
            // table C_UNIT 和 SP_NSN 均在 @TLSEU
            DBLINK = "TLSEU";
            DataSet ds = setupPickDs(n, Tmp_Sql, new string[] { "SP_NSN" },false,true);
            if (C_UNIT != null && !C_UNIT.Equals(""))
            {
                if (isComplete == 1)
                {
                    ds = getPickDsbyCondi(n, "C_UNIT='" + C_UNIT + "'");
                }
                else
                {
                    ds = getPickDsbyCondi(n, "C_UNIT  LIKE '%" + C_UNIT + "%'");
                }
            }
            return ds;
        }  // end of  get_V20305F1_C_UNITPick

沒有留言:

張貼留言