xtype: "button", id: "btn_APNO", name: "btn_APNO", text: "...",
var win = EditPickx('申請單號', '../api/V120202DAPI/get_APNOPick', ['APNO'],
['sub_APNO'], J_pickstore_sub_APNO, J_pickcolumns_sub_APNO,
xtype: "button", text: "加入資料", width: 120, border: 2, margin: { left: 10, },
console.log("insider handler of sub_btn_Add");
var Tmp_APNO = Ext.getCmp("sub_APNO").getValue();
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();