目的: V20107 - Template.存檔後,額外處理資料
處理說明: 1>Template.存檔後,額外處理資料 , 寫在V20107.btn_save.click ()
--> 即 Template 執行完存檔後,再執行 V20107.存檔
1>*.js
//按[存檔], 若
Ext.getCmp('btn_save').on('click', function () {
//若 checkFormValue 有問題,則 is_Keepgoing=false , 不往下執行
Ext.getCmp('btn_save').on('click', function () {
//若 checkFormValue 有問題,則 is_Keepgoing=false , 不往下執行
if (is_keepgoing==false)
return ;
return ;
if (!check_AMM_WKSTPD_isnull()) {
console.log("if !check_AMM_WKSTPD_isnull() , return ");
console.log("if !check_AMM_WKSTPD_isnull() , return ");
return ; // AMM_WKSTPD 已有資料,不新增 4筆資料
}
//若 AMM_WKSTPD 為空值,則詢問是否為系統件維修,
//若是,則 INSERT_AMM_WKSTPD4 ,寫入 4筆資料
console.log("3 詢問是否為系統件維修嗎?");
var Tmp_Msg = "本交修件是否為系統件維修嗎 ?";
Ext.Msg.confirm('確認', Tmp_Msg, callBackFunc);
function callBackFunc(id) {
console.log("1 callBackFunc : 本交修件是否為系統件維修嗎 ?");
if (id == 'no')
return;
//insert 四筆資料 AMM_WKSTPD
var np = {};
np["MITM"] = Ext.getCmp("MITM").getValue();
np["PN"] = Ext.getCmp("PN").getValue();
np["DEPID"] = Ext.getCmp("DEPID").getValue();
np["WC"] = Ext.getCmp("WC").getValue();
var isOk = true;
Ext.Ajax.request({
method: "POST",
url: '../../api/V20107API/DO_Ins_AMM_WKSTPD4',
params: np,
async: false,
success: function (response, opts) {
console.log("0 response.responseText=", response.responseText);
var Tmp_Obj = Ext.decode(response.responseText);
console.log("1 Tmp_Obj=", Tmp_Obj);
if (Tmp_Obj["success"] == true) {
var Tmp_Rtn_Msg = "自動新增4筆工作步序說明資料(AMM_WKSTPD)<br>"
+ "- 進廠檢測,拆檢,組裝,完工測試<br>";
+ Tmp_Obj["Rtn_Msg"];
mysuccessalert(Tmp_Rtn_Msg);
is_Ok=true;
}
else {
var Tmp_Rtn_Msg = "自動新增4筆工作步序說明資料(AMM_WKSTPD)失敗<br>"
+ "- 進廠檢測,拆檢,組裝,完工測試<br>"
+ "請檢核!! <br>"
+ Tmp_Obj["Rtn_Msg"];
mywarnalert(Tmp_Rtn_Msg);
is_Ok=false;
}
}, //end of success
failure: function (response, opts) {
var Tmp_Obj = Ext.decode(response.responseText);
var Tmp_Rtn_Msg = "新增4筆工作步序說明資料(AMM_WKSTPD)失敗<br>"
+ "請檢核<br>"
+ Tmp_Obj["Rtn_Msg"];
mywarnalert(Tmp_Rtn_Msg);
is_Ok=false;
}
}) //end of Ext.Ajax.Request
console.log("3 詢問是否為系統件維修嗎?");
var Tmp_Msg = "本交修件是否為系統件維修嗎 ?";
Ext.Msg.confirm('確認', Tmp_Msg, callBackFunc);
function callBackFunc(id) {
console.log("1 callBackFunc : 本交修件是否為系統件維修嗎 ?");
if (id == 'no')
return;
//insert 四筆資料 AMM_WKSTPD
var np = {};
np["MITM"] = Ext.getCmp("MITM").getValue();
np["PN"] = Ext.getCmp("PN").getValue();
np["DEPID"] = Ext.getCmp("DEPID").getValue();
np["WC"] = Ext.getCmp("WC").getValue();
var isOk = true;
Ext.Ajax.request({
method: "POST",
url: '../../api/V20107API/DO_Ins_AMM_WKSTPD4',
params: np,
async: false,
success: function (response, opts) {
console.log("0 response.responseText=", response.responseText);
var Tmp_Obj = Ext.decode(response.responseText);
console.log("1 Tmp_Obj=", Tmp_Obj);
if (Tmp_Obj["success"] == true) {
var Tmp_Rtn_Msg = "自動新增4筆工作步序說明資料(AMM_WKSTPD)<br>"
+ "- 進廠檢測,拆檢,組裝,完工測試<br>";
+ Tmp_Obj["Rtn_Msg"];
mysuccessalert(Tmp_Rtn_Msg);
is_Ok=true;
}
else {
var Tmp_Rtn_Msg = "自動新增4筆工作步序說明資料(AMM_WKSTPD)失敗<br>"
+ "- 進廠檢測,拆檢,組裝,完工測試<br>"
+ "請檢核!! <br>"
+ Tmp_Obj["Rtn_Msg"];
mywarnalert(Tmp_Rtn_Msg);
is_Ok=false;
}
}, //end of success
failure: function (response, opts) {
var Tmp_Obj = Ext.decode(response.responseText);
var Tmp_Rtn_Msg = "新增4筆工作步序說明資料(AMM_WKSTPD)失敗<br>"
+ "請檢核<br>"
+ Tmp_Obj["Rtn_Msg"];
mywarnalert(Tmp_Rtn_Msg);
is_Ok=false;
}
}) //end of Ext.Ajax.Request
return is_OK;
}; // end of callBackFunc(id)
}) //Ext.getCmp('btn_save').on('click', function () {
//檢核 AMM_WKSTPD 是否為空值, 若是,則傳回 true, 否則傳回 false
function check_AMM_WKSTPD_isnull() {
var np = {};
var Tmp_MITM = Ext.getCmp("MITM").getValue();
np["MITM"] = Tmp_MITM;
var is_Ok = true;
Ext.Ajax.request({
url: '../../api/V20107API/check_AMM_WKSTPD_isnull',
method: 'POST',
async: false,
params: np,
success: function (response, opts) {
console.log('0 check_AMM_WKSTPD_isnull sucess!!');
//console.log('0 opts:', opts);
//console.log('0 response:', response);
console.log("success response.responseText:", response.responseText);
var obj = Ext.decode(response.responseText);
//console.log("obj:", obj);
if (obj["success"]) {
console.log(' 1 check_AMM_WKSTPD_isnull true !!');
is_Ok = true;
}
else {
console.log(' 2 check_AMM_WKSTPD_isnull obj[sucess] false !!');
is_Ok = false;
}
},
failure: function (response, opts) {
console.log(' 3 check_isnotDull failure !!');
var obj = Ext.decode(response.responseText);
console.log("obj:", obj);
Tmp_Str = "檢核[工作步序說明(check_AMM_WKSTPD_isnull)]失敗!! <br>"
+ obj["Rtn_Msg"];
mywarnalert(Tmp_Str);
is_Ok = false;
} // end of failure
}); // end of Ext.Ajax
return is_Ok;
}
}; // end of callBackFunc(id)
}) //Ext.getCmp('btn_save').on('click', function () {
//檢核 AMM_WKSTPD 是否為空值, 若是,則傳回 true, 否則傳回 false
function check_AMM_WKSTPD_isnull() {
var np = {};
var Tmp_MITM = Ext.getCmp("MITM").getValue();
np["MITM"] = Tmp_MITM;
var is_Ok = true;
Ext.Ajax.request({
url: '../../api/V20107API/check_AMM_WKSTPD_isnull',
method: 'POST',
async: false,
params: np,
success: function (response, opts) {
console.log('0 check_AMM_WKSTPD_isnull sucess!!');
//console.log('0 opts:', opts);
//console.log('0 response:', response);
console.log("success response.responseText:", response.responseText);
var obj = Ext.decode(response.responseText);
//console.log("obj:", obj);
if (obj["success"]) {
console.log(' 1 check_AMM_WKSTPD_isnull true !!');
is_Ok = true;
}
else {
console.log(' 2 check_AMM_WKSTPD_isnull obj[sucess] false !!');
is_Ok = false;
}
},
failure: function (response, opts) {
console.log(' 3 check_isnotDull failure !!');
var obj = Ext.decode(response.responseText);
console.log("obj:", obj);
Tmp_Str = "檢核[工作步序說明(check_AMM_WKSTPD_isnull)]失敗!! <br>"
+ obj["Rtn_Msg"];
mywarnalert(Tmp_Str);
is_Ok = false;
} // end of failure
}); // end of Ext.Ajax
return is_Ok;
}
//btn_save.beforeInsert --> 實際寫入資料庫的處理
Ext.getCmp('btn_save').beforeInsert = function () {
console.log(" 5 beforeInsert Ext.getCmp(btn_save).beforeInsert - MD_DB.doSave(Insert )");
var isCheck = MD_DB.doSave('Insert');
return isCheck;
};
2>*.cs
//檢核 [AMM_WKSTPD] 是否為有資料,若無資料,則傳回 true, 否則傳回 false
[HttpPost]
public HttpResponseMessage check_AMM_WKSTPD_isnull()
{
HttpContext c = HttpContext.Current;
NameValueCollection nvc = c.Request.Form;
string Tmp_MITM = nvc["MITM"];
var response = this.Request.CreateResponse();
string Tmp_Sql, Tmp_Str;
int Tmp_cnt;
Tmp_Sql = " SELECT count(*) "
+ " FROM AMM_WKSTPD "
+ " WHERE MITM=" + myfunc.AA(Tmp_MITM);
Tmp_Str = myfunc.SqlValue(Tmp_Sql);
if (!myfunc.checkisnull(Tmp_Str))
{
Tmp_cnt = int.Parse(Tmp_Str);
if (Tmp_cnt == 0) //AMM_WKSTPD 無資料 of MITM
Tmp_Str = "{success: true }";
else
Tmp_Str = "{success: false }";
}
response.Content = new StringContent(Tmp_Str); // 回應內容
return response; //若[WC+PN]不重覆 , 傳回 true, 否則傳回 false
}
[HttpPost]
public void Insert()
{
var c = System.Web.HttpContext.Current;
NameValueCollection nvc = c.Request.Form;
//excuteInsert(nvc, DBTable);
NameValueCollection nvc1 = new NameValueCollection();
foreach (string k in nvc.Keys)
{
nvc1[k] = nvc[k];
}
// ITM=MAX_ITM 改在前端 setFormValue, 設定, 不在後端設定, 因為 store 不 reload();
//int Tmp_MAXITM = GET_MAX_ITM();
//nvc1["MITM"] =
nvc1["ENER"] = LoginUserModel.LoginUserId;
nvc1["ENDT"] = DateTime.Now.ToString("yyyy/MM/dd"); ;
excuteInsert(nvc1, DBTable);
}
[HttpPost]
public void Update()
{
var c = System.Web.HttpContext.Current;
NameValueCollection nvc = c.Request.Form;
string[] arrCondition = getPK();
excuteUpdate(nvc, DBTable, arrCondition);
}
沒有留言:
張貼留言