顯示具有 store 標籤的文章。 顯示所有文章
顯示具有 store 標籤的文章。 顯示所有文章

2023年7月25日 星期二

V40A : 過濾目前畫面的 store 的資料 - SAP單況='ROFF' - filter - filterby

 目的: V40A : 過濾目前畫面的 store 的資料 - SAP單況='ROFF'

處理說明: 1>利用 store.filter("FieldName", FieldValue);
                          過濾前先清空 filter        Store.clearFilter(true);

                     2>filterby(fn());
               store.filterBy(function (rec){
                             if (rec.get('host') && rec.get('policyDetails')) {
                                  // do something
                                  return true;
                             }
                             return false;
                        });




2023年6月20日 星期二

V120202E 清除 store 所有資料 - removeAll - clearData

 目的: V120202E 清除 store 所有資料

處理說明: 1>  var Tmp_gridstore = Ext.getCmp("sub_Grid").store;
                                          Tmp_gridstore.clearData();
                                     Tmp_gridstore.removeAll();


1>*.js
    Tmp_Str = Tmp_Str
                    + "申請單號(" + cur_rec.data["APNO"].toString() + ") <br> "
                    + "退庫歸儲完成!!<br>";
                Ext.Msg.alert('確認', Tmp_Str, ok2go);
                function ok2go(id) {          
                    console.log("id:", id);
                    if (id == 'ok') {
                        //mysuccessalert("退庫歸儲完成 !!");
                        //清空 [點料人員][退庫原因] & grid 資料
                        Ext.getCmp("sub_BKMG").setValue("");
                        Ext.getCmp("sub_APNO").setValue("");
                        Ext.getCmp("sub_CAUSE_REMARK").setValue("");
                        var Tmp_gridstore = Ext.getCmp("sub_Grid").store;
                        Tmp_gridstore.clearData();
                        Tmp_gridstore.removeAll();

                    }// end of if(id=='yes')
                } //end of callbackfunc


2023年6月18日 星期日

V120202D -getUrlStr - 傳回ds - foreach(DataRow dr -checkRtnOk - - 挑選[申請單號]後,自動加入 store - dt2JSON - Ext.decode

 目的: V120202D - 領料登記 - 挑選[申請單號]後,自動加入 store

處理說明: 1>開啟畫面, store : where 1=2
                  2>利用隱藏按鈕 [加入資料], 挑選完資料(onchange)後,執行[加入資料]鈕
                  3>[挑選資料]後,將所挑選資料轉成 dt2JSON String傳至前端, 
                  4>由 Ext.decode 解碼成 Object (Tmp_recs)
                  5>將 Tmp_rec=Tmp_recs[i], 將 Tmp_rec 加入 store       

1>*.js
,{
xtype: "button", id: "btn_APNO", name: "btn_APNO", text: "...",
handler: function () {
//不分頁 & 不 suspendevent - 以便觸發 change event
var win = EditPickx('申請單號', '../api/V120202DAPI/get_APNOPick', ['APNO'],
['sub_APNO'], J_pickstore_sub_APNO, J_pickcolumns_sub_APNO, false,false);
win.show();
}
},
{ //加入資料
xtype: "button", text: "加入資料", width: 120, border: 2, margin: { left: 10, },
hidden: true,
id: "sub_btn_Add",
handler: function () {
console.log("insider handler of sub_btn_Add");
var Tmp_APNO = Ext.getCmp("sub_APNO").getValue();
var Tmp_Str = "";
if (checkisnull(Tmp_APNO)) {
Tmp_Str = "請先輸入[申請單號] !!"
mywarnalert(Tmp_Str);
return;
}
var np = {};
np["sub_APNO"] = Tmp_APNO;
var Tmp_url = "../../api/V120202DAPI/get_sub_data1";

//取得挑選資料的 dt2JSON 字串 
//getUrlStr : 必需傳回字串( dt.JSON字串) , 非 ds
var rtn_Str = getUrlStr(Tmp_url, np, "加入資料");

console.log("rtn_Str:", rtn_Str);

if (checkRtnOK(rtn_Str)) {
var Tmp_recs = Ext.decode(rtn_Str);
var Tmp_rec;
for (i = 0; i < Tmp_recs.length; i++) {
Tmp_rec = Tmp_recs[0];
console.log("Tmp_rec:", Tmp_rec);
if (Ext.getCmp("sub_Grid").store.find("APNO", Tmp_rec["APNO"]) == -1) {
console.log("add store Tmp_rec:", Tmp_rec);
Ext.getCmp("sub_Grid").store.add(Tmp_rec);
Ext.getCmp("sub_APNO").setValue("");
}
} //end of for
console.log("store :", Ext.getCmp("sub_Grid").store);
} // end of if (checkRtnOK(rtn_Str)) {
} // end of handler
}, // end of 加入資料

//開啟畫面
var win1 = getMyWindow("領料登記", sub_V120202D_Flds, sub_V120202D_Btns, "D");
    win1.x = 100;
    win1.setWidth(500);
    win1.setHeight(400);
    var np = {};
    //np["sub_APNO"] = Ext.getCmp("sub_APNO").getValue();
    var Tmp_url = "../../api/V120202DAPI/get_sub_data";  //
    Ext.getCmp("sub_Grid").store.getProxy().url = Tmp_url;
    Ext.getCmp("sub_Grid").store.getProxy().extraParams = np; //分頁OK,篩選條件OK    
    Ext.getCmp("sub_Grid").store.load();
    win1.show();
    
2>*.cs
//[顯示資料]鈕 - store.資料 - where  1=2
        [HttpPost]
        //public HttpResponseMessage get_sub_Data()
        public dynamic get_sub_Data()
        {
            var c = HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;            

            OracleCommand cmd = new OracleCommand();
            var response = this.Request.CreateResponse();
            /*
             * { name: "APNO" },
{ name: "MATNR" },
{ name: "MAKTX" },
{
name: "QTY",
convert: function (value, record) { return Ext.util.Format.round(value, 2); }
},
{ name: "UNIT" },
             */
            string Tmp_Sql1 = "";  //for 日期起迄
            string Tmp_Sql = "  SELECT  RNK,APNO,APER,APDT,PN,MATNR,MAKTX,QTY,UNIT,MPKUPP,MPKUPDT,STAT "
                                        + "  FROM   ( SELECT  dense_rank()  over(order by  APNO) as RNK,"
                                                                      + "    APNO,APER,APDT,PN,MATNR,MAKTX,QTY,UNIT,MPKUPP,MPKUPDT,STAT  "
                                                        + "   FROM     AMM_COMQ "
                                                       + "   WHERE  1=2 ";            
            Tmp_Sql = Tmp_Sql + ")";

            cmd.CommandText = Tmp_Sql;
            string countSql = " SELECT COUNT(*) as total FROM (" + Tmp_Sql + ")";
            //不分頁
            DataSet ds = getDataTable(cmd, countSql, false);

            //- [單況(STAT) ]            
            Tmp_Sql = " select    KEY_CODE as  STAT, DESCPT "
                           + " from      KEYCODE  "
                           + "  where   TBL_NAME = 'AMM_COMQ'  "
                           + "  and        KEY_NAME = 'STAT'   ";
            getKeyCode("STAT", ref ds, Tmp_Sql);

            int Tmp_TOTAL = int.Parse(ds.Tables["T1C"].Rows[0]["TOTAL"].ToString());
            string Tmp_Str = "";
            string Tmp_RtnMsg = "";



            //自訂  CaluField 欄位  - [儲位(SP_)] 
            ds.Tables["T1"].Columns.Add("WH_", typeof(object));
            ds.Tables["T1"].Columns.Add("SP_", typeof(object));
            ds.Tables["T1"].Columns.Add("APER_", typeof(object));
            ds.Tables["T1"].Columns.Add("MPKUPP_", typeof(object));

            OracleConnection conn = new OracleConnection(DBService.ConnectionString(DBLINK));
            OracleCommand cmd1 = new OracleCommand();
            OracleDataReader reader;
            string Tmp_dt2JSON;
            try
            {
                conn.Open();
                conn.ClientInfo = User.Identity.Name;
                conn.ModuleName = BaseSYS + "_" + BaseMODID;
                conn.ActionName = ActionName;
                cmd1.Connection = conn;

                string Tmp_cur_APNO = "";
                string Tmp_WH_ = "";
                string Tmp_SP_ = "";
                string Tmp_APER_ = "";
                string Tmp_MPKUPP_ = "";

                foreach (DataRow dr in ds.Tables["T1"].Rows)
                {
                    Tmp_WH_ = "";
                    Tmp_SP_ = "";
                    Tmp_APER_ = "";
                    Tmp_MPKUPP_ = "";
                    Tmp_cur_APNO = dr["APNO"].ToString();
                    if (Tmp_cur_APNO.Length > 0)
                    {
                        Tmp_Sql = " SELECT  WH,SP  "
                                        + " FROM    AMM_COMPQTY    "
                                        + "  WHERE APNO=" + myfunc.AA(Tmp_cur_APNO)
                                        + "   AND      rownum=1 "
                                       + "   ORDER  BY APNO DESC ";
                        Tmp_Str = myfunc.SqlValue(Tmp_Sql);
                        if (Tmp_Str.Length > 0)
                        {
                            Tmp_WH_ = myfunc.StrExtract(Tmp_Str, 1, ";");
                            Tmp_SP_ = myfunc.StrExtract(Tmp_Str, 2, ";");
                        }
                        Tmp_Sql = " SELECT  EMPLYNM  "
                                        + " FROM    HR_EMPLYM    "
                                        + "  WHERE EMPLYID=" + myfunc.AA(dr["APER"].ToString());                                       
                        Tmp_Str = myfunc.SqlValue(Tmp_Sql);
                        if (Tmp_Str.Length > 0)
                        {
                            Tmp_APER_ = myfunc.StrExtract(Tmp_Str, 1, ";");                            
                        }
                        dr["APER_"] = Tmp_APER_;
                        Tmp_Sql = " SELECT  EMPLYNM  "
                                        + " FROM    HR_EMPLYM    "
                                        + "  WHERE EMPLYID=" + myfunc.AA(dr["MPKUPP"].ToString());
                        Tmp_Str = myfunc.SqlValue(Tmp_Sql);
                        if (Tmp_Str.Length > 0)
                        {
                            Tmp_MPKUPP_ = myfunc.StrExtract(Tmp_Str, 1, ";");
                        }
                        dr["MPKUPP_"] = Tmp_MPKUPP_;
                    }  // end of  foreach (DataRow row in ds.Tables["T1"].Rows)
                } //end of  foreach (dr
                   //如何將  ds 的 T1包成 JSON格式, 傳回前遄                                
                return ds;                
            } // end of try            
            finally
            {
                conn.Close();
            }


//[加入資料]鈕 - 將所挑選的申請單號, 加入子畫面.grid
        [HttpPost]
        //public HttpResponseMessage get_sub_Data1()
        public dynamic get_sub_Data1()
        {
            var c = HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;            
            string Tmp_APNO = nvc["sub_APNO"];

            OracleCommand cmd = new OracleCommand();
            var response = this.Request.CreateResponse();
            /*
             * { name: "APNO" },
{ name: "MATNR" },
{ name: "MAKTX" },
{
name: "QTY",
convert: function (value, record) { return Ext.util.Format.round(value, 2); }
},
{ name: "UNIT" },
             */
            string Tmp_Sql1 = "";  //for 日期起迄
            string Tmp_Sql = "  SELECT  RNK,APNO,APER,APDT,PN,MATNR,MAKTX,QTY,UNIT,MPKUPP,MPKUPDT,STAT "
                                        + "  FROM   ( SELECT  dense_rank()  over(order by  APNO) as RNK,"
                                                                      + "    APNO,APER,APDT,PN,MATNR,MAKTX,QTY,UNIT,MPKUPP,MPKUPDT,STAT  "
                                                        + "   FROM     AMM_COMQ "
                                                       + "   WHERE  1=1 ";
            //panel11
            //申請編號 
            if (!myfunc.checkisnull(Tmp_APNO))
            {
                Tmp_Sql = Tmp_Sql + " AND    APNO=  " + myfunc.AA(Tmp_APNO);
            };
            Tmp_Sql = Tmp_Sql + ")";

            cmd.CommandText = Tmp_Sql;
            string countSql = " SELECT COUNT(*) as total FROM (" + Tmp_Sql + ")";
            //不分頁
            DataSet ds = getDataTable(cmd, countSql, false);

            int Tmp_TOTAL = int.Parse(ds.Tables["T1C"].Rows[0]["TOTAL"].ToString());            
            string Tmp_Str = "";
            string Tmp_RtnMsg = "";

            //- [單況(STAT) ]            
            Tmp_Sql = " select    KEY_CODE as  STAT, DESCPT "
                           + " from      KEYCODE  "
                           + "  where   TBL_NAME = 'AMM_COMQ'  "
                           + "  and        KEY_NAME = 'STAT'   ";
            getKeyCode("STAT", ref ds, Tmp_Sql);


            //自訂  CaluField 欄位  - [儲位(SP_)] 
            ds.Tables["T1"].Columns.Add("WH_", typeof(object));
            ds.Tables["T1"].Columns.Add("SP_", typeof(object));

            string Tmp_WH_ = "";
            string Tmp_SP_ = "";
            OracleConnection conn = new OracleConnection(DBService.ConnectionString(DBLINK));
            OracleCommand cmd1 = new OracleCommand();
            OracleDataReader reader;
            string Tmp_dt2JSON;
            try
            {
                conn.Open();
                conn.ClientInfo = User.Identity.Name;
                conn.ModuleName = BaseSYS + "_" + BaseMODID;
                conn.ActionName = ActionName;
                cmd1.Connection = conn;

                var Tmp_cur_APNO = "";
                foreach (DataRow dr in ds.Tables["T1"].Rows)
                {
                    Tmp_cur_APNO = dr["APNO"].ToString();                    
                    if (Tmp_cur_APNO.Length > 0)
                    {
                        //自訂 SQL , 取得 CaluField 欄位值 
                        Tmp_Sql = " SELECT  WH,SP "
                                       + "  FROM   AMM_COMPQTY "
                                       + " WHERE  1=1 "
                                       + "  AND       APNO=" + myfunc.AA(Tmp_cur_APNO)
                                       +"  AND       rownum=1 "                                       
                                       + "   ORDER  BY SP  ";
                        Tmp_Str = myfunc.SqlValue(Tmp_Sql);
                        if (Tmp_Str.Length > 0)
                        {
                            Tmp_WH_ = myfunc.StrExtract(Tmp_Str, 1, ";");
                            Tmp_SP_ = myfunc.StrExtract(Tmp_Str, 2, ";");
                        }
                        dr["WH_"] = Tmp_WH_;
                        dr["SP_"] = Tmp_SP_;                                                
                    }  // end of   if (Tmp_NATIXX.Length > 0)
                }  // end of  foreach (DataRow row in ds.Tables["T1"].Rows)
                   //如何將  ds 的 T1包成 JSON格式, 傳回前遄                

                Tmp_dt2JSON = myfunc.dt2JSON(ds.Tables["T1"]);
                Tmp_RtnMsg = Tmp_dt2JSON;
                return Tmp_RtnMsg;
            } // end of try
            catch (Exception e)
            {
                var Tmp_ErrMsg = myfunc.Get1ORA(e.Message);
                Tmp_RtnMsg = "錯誤: 取得[條碼編號]的資料失敗 (get_sub_data1) !!  <br> "
                                         + Tmp_ErrMsg;
                return Tmp_RtnMsg;
            }
            finally
            {
                conn.Close();
            }
            //return ds;           

        }// end of get_sub_Data1();

2023年5月17日 星期三

V20302 - 1>前端取得 store 的欄位值 & store.總筆數 2>後端取得 datatable 的欄位值 , 取得 ds,dt 欄位值

 目的: 1>前端取得 store 的欄位值 *.js

               取得 store 總筆數(store.getTotalCount())

           2>後端取得 datatable 的欄位值 *.cs 

處理說明: 1>*.js
                         for (var i=0;i<ds1.getTotalCount(); i++){
                         var rec = ds1.getAt(i);
                         rec.data["NOTES_MAIL"].toString();
                         }
                  2>*.cs
                        for (var i = 0; i < dt1.Rows.Count; i++)





1>*.js
    var ds1 = Ext.getCmp("sub_Grid1").store;
    var rec;
    for (i = 0; i < ds1.getTotalCount(); i++) {
        rec = ds1.getAt(i);
        console.log("rec:", rec);
        Tmp_MEmail = Tmp_MEmail + rec.data["NOTES_MAIL"].toString() + ";";
    }

2>*.cs

2>*.cs
       for (var i = 0; i < dt1.Rows.Count; i++)
                {
                    Tmp_AMMNO = dt1.Rows[i]["AMMNO"].ToString();
                    Tmp_RPNOAF = dt1.Rows[i]["RPNOAF"].ToString();
                    Tmp_MRPNOAF = dt1.Rows[i]["MRPNOAF"].ToString();
                    Tmp_SAPNO_ = dt1.Rows[i]["SAPNO_"].ToString();