protected void btn_PatternSelect_Click(object sender, EventArgs e) { #region try { ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); Hashtable htTemp = new Hashtable(); htTemp.Clear(); htTemp.Add("ChanNo", SLP_StoreChain1.Text.Trim()); htTemp.Add("Store", SLP_Store1.Text.Trim()); htTemp.Add("StartDate", SLP_SLPDate2.Text.Trim()); htTemp.Add("EndDate", SLP_SLPDate3.Text.Trim()); if (CheckPATTERNSPECCanAdd(htTemp)) { dtMultiSaveClassAndItem = dtClassAndItemSelected; if (dtMultiSaveClassAndItem.Rows.Count > 0) { #region if (!dtMultiSaveClassAndItem.Columns.Contains("chan_no")) dtMultiSaveClassAndItem.Columns.Add("chan_no"); if (!dtMultiSaveClassAndItem.Columns.Contains("store")) dtMultiSaveClassAndItem.Columns.Add("store"); if (!dtMultiSaveClassAndItem.Columns.Contains("SPEC_TYPE")) dtMultiSaveClassAndItem.Columns.Add("SPEC_TYPE"); if (!dtMultiSaveClassAndItem.Columns.Contains("SPEC_TYPE_NAME")) dtMultiSaveClassAndItem.Columns.Add("SPEC_TYPE_NAME"); if (!dtMultiSaveClassAndItem.Columns.Contains("S_START_DATE")) dtMultiSaveClassAndItem.Columns.Add("S_START_DATE"); if (!dtMultiSaveClassAndItem.Columns.Contains("S_END_DATE")) dtMultiSaveClassAndItem.Columns.Add("S_END_DATE"); if (!dtMultiSaveClassAndItem.Columns.Contains("spec_qty")) dtMultiSaveClassAndItem.Columns.Add("spec_qty"); if (!dtMultiSaveClassAndItem.Columns.Contains("reason")) dtMultiSaveClassAndItem.Columns.Add("reason"); if (!dtMultiSaveClassAndItem.Columns.Contains("explain")) dtMultiSaveClassAndItem.Columns.Add("explain"); #endregion strErrMsgAfterChecked = "";//清空暫存錯誤訊息 //Add Data to Temp DataTable for (Int32 i = dtMultiSaveClassAndItem.Rows.Count - 1; i >= 0; i--) { htTemp.Clear(); htTemp.Add("ChanNo", SLP_StoreChain1.Text.Trim()); htTemp.Add("Store", SLP_Store1.Text.Trim()); htTemp.Add("ROOT_NO", dtMultiSaveClassAndItem.Rows[i]["ROOT_NO"].ToString().Trim()); htTemp.Add("PMA", dtMultiSaveClassAndItem.Rows[i]["PMA"].ToString().Trim()); if (dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim() == "") { htTemp.Add("PATTERN_NO", null); } else { htTemp.Add("PATTERN_NO", dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim()); } if (CheckPATTERNSPECExist(htTemp)) { dtMultiSaveClassAndItem.Rows[i]["CHAN_NO"] = SLP_StoreChain1.Text; dtMultiSaveClassAndItem.Rows[i]["STORE"] = SLP_Store1.Text; dtMultiSaveClassAndItem.Rows[i]["SPEC_TYPE"] = getSpecTypeChecked(); dtMultiSaveClassAndItem.Rows[i]["SPEC_TYPE_NAME"] = getSpecTypeNameChecked(); dtMultiSaveClassAndItem.Rows[i]["S_START_DATE"] = SLP_SLPDate2.Text; dtMultiSaveClassAndItem.Rows[i]["S_END_DATE"] = SLP_SLPDate3.Text; dtMultiSaveClassAndItem.Rows[i]["SPEC_QTY"] = SLP_Number1.Text; dtMultiSaveClassAndItem.Rows[i]["REASON"] = SLP_CodeFile1.Text; dtMultiSaveClassAndItem.Rows[i]["EXPLAIN"] = SLP_CodeFile1.DropDownListControl.SelectedItem.Text; } else { dtMultiSaveClassAndItem.Rows.RemoveAt(i); } } if (strErrMsgAfterChecked != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", strErrMsgAfterChecked), true); } GridView1.DataSource = dtMultiSaveClassAndItem; GridView1.DataBind(); } } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; UpdatePanel1.Update(); } #endregion }
/// <summary> /// 檢查此PK是否已存在於DB,已存在為FALSE,不存在則為TRUE。 /// </summary> /// <param name="htTemp"></param> /// <returns></returns> private bool CheckPATTERNSPECExist(Hashtable htTemp) { #region bool bResult = false; try { ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); bResult = BCO.CheckPATTERNSPECExist(htTemp); if (!bResult) { strErrMsgAfterChecked += string.Format("該門市已設定 ( 群分類_大分類_PATTERN={0}_{1}_{2} ) 的控制檔;\\n", htTemp["ROOT_NO"], htTemp["PMA"], htTemp["PATTERN_NO"]); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; UpdatePanel1.Update(); } return bResult; #endregion }
protected void btn_Save_Click(object sender, EventArgs e) { #region Int32 iResult = 0; try { if (dtMultiSaveClassAndItem.Rows.Count > 0) { Hashtable htTemp = new Hashtable(); Hashtable htParams = new Hashtable(); htTemp.Clear(); htTemp.Add("ChanNo", SLP_StoreChain1.Text.Trim()); htTemp.Add("Store", SLP_Store1.Text.Trim()); htTemp.Add("StartDate", SLP_SLPDate2.Text.Trim()); htTemp.Add("EndDate", SLP_SLPDate3.Text.Trim()); if (CheckSpecTypeAndValue() && CheckDetailDataIsNotNull() && CheckPATTERNSPECCanAdd(htTemp) ) { #region DataTable dtForUpdate = dtDetailData;//.GetChanges(DataRowState.Added); ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); string strCode = ""; strErrMsgAfterChecked = "";//清空暫存錯誤訊息 for (Int32 i = 0; i <= dtMultiSaveClassAndItem.Rows.Count - 1; i++) { #region Master htTemp.Clear(); htTemp.Add("ChanNo", SLP_StoreChain1.Text.Trim()); htTemp.Add("Store", SLP_Store1.Text.Trim()); htTemp.Add("ROOT_NO", dtMultiSaveClassAndItem.Rows[i]["ROOT_NO"].ToString().Trim()); htTemp.Add("PMA", dtMultiSaveClassAndItem.Rows[i]["PMA"].ToString().Trim()); if (dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim() == "") { htTemp.Add("PATTERN_NO", null); } else { htTemp.Add("PATTERN_NO", dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim()); } if (CheckPATTERNSPECExist(htTemp)) { strCode = string.Format("{0}_{1}_{2}_{3}_{4}", SLP_StoreChain1.Text.Trim(), SLP_Store1.Text.Trim(), dtMultiSaveClassAndItem.Rows[i]["ROOT_NO"].ToString().Trim(), dtMultiSaveClassAndItem.Rows[i]["PMA"].ToString().Trim(), dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim()); htParams.Clear(); htParams.Add("CODE", strCode); htParams.Add("UserID", Session["UID"].ToString()); htParams.Add("ChanNO", SLP_StoreChain1.Text.Trim()); htParams.Add("STORE", SLP_Store1.Text.Trim()); htParams.Add("ROOT_NO", dtMultiSaveClassAndItem.Rows[i]["ROOT_NO"].ToString().Trim()); htParams.Add("PMA", dtMultiSaveClassAndItem.Rows[i]["PMA"].ToString().Trim()); htParams.Add("PATTERN_NO", dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim()); htParams.Add("SPEC_TYPE", getSpecTypeChecked()); htParams.Add("SPEC_QTY", SLP_Number1.Text.Trim()); htParams.Add("S_START_DATE", SLP_SLPDate2.Text.Trim()); htParams.Add("S_END_DATE", SLP_SLPDate3.Text.Trim()); htParams.Add("REASON", strReason.Trim()); iResult = BCO.CreateMasterAndDetail(htParams, dtForUpdate, null); } #endregion } if (strErrMsgAfterChecked != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", strErrMsgAfterChecked), true); } if (iResult == 0) { throw new Exception("新增0筆資料!"); } else { if (dtForUpdate != null) dtForUpdate.AcceptChanges(); dtDetailData = dtForUpdate; dtForDetailDeleted.Clear(); ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "ClientScript", string.Format("alert('新增完成');location.replace('ALO081.aspx?Code=ALO08&ChanNo={0}&Store={1}');", SLP_StoreChain1.Text, SLP_Store1.Text), true); } #endregion } } else { ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "ClientScript", "alert('請先加入商品');", true); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void btn_CopyDetail_Click(object sender, EventArgs e) { #region ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); Hashtable htParams = new Hashtable(); htParams.Clear(); htParams.Add("ChanNo", SLP_StoreChain1.Text.Trim()); htParams.Add("STORE", SLP_Store1.Text.Trim()); DataTable dtDetl = BCO.QueryLastPATTERNSPECDetail(htParams); if (dtDetl != null && dtDetl.Rows.Count > 0) { dtDetailData = dtDetl; gv_Detail.DataSource = dtDetl; gv_Detail.DataBind(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", "alert('此門市無前筆有效明細設定資訊,請手動新增');", true); } #endregion }
private bool CheckPATTERNSPECCanAdd(Hashtable htTemp) { #region bool bResult = false; try { ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); string strErrMsg = ""; bResult = BCO.CheckPATTERNSPECCanAdd(htTemp, ref strErrMsg); if (!bResult && strErrMsg != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", strErrMsg), true); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; UpdatePanel1.Update(); } return bResult; #endregion }
protected void btn_Exec_Click(object sender, EventArgs e) { fmStatus = FormStatus.fmProcess; try { if (CheckInputValuesNotNull() && CheckItemClassValid()) { ALOModel.MaintainPatternSpec BCO = new PIC.VDS2G.BSM.ALO.MaintainPatternSpec(ConnectionDB); bool bResult=false; if (SLP_Pattern1.Text.Trim() == "" && SLP_Pattern2.Text.Trim() == "") { bResult = BCO.CopyToNewPMA(GetInputValues(), null); } else if (SLP_Pattern1.Text.Trim() != "" && SLP_Pattern2.Text.Trim() != "") { bResult = BCO.CopyToNewPattern(GetInputValues(), null); } if (bResult) { ErrorMsgLabel.Text = ""; ResultMsgLabel.Text = "複製成功"; } else { ErrorMsgLabel.Text = ""; ResultMsgLabel.Text = "複製失敗"; } } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { fmStatus = FormStatus.fmBrowse; } }
protected void btn_Exec_Click(object sender, EventArgs e) { fmStatus = FormStatus.fmProcess; try { if (CheckInputValuesNotNull()) { ALOModel.MaintainPatternSpec BCO = new PIC.VDS2G.BSM.ALO.MaintainPatternSpec(ConnectionDB); bool bResult = BCO.CopyToNewStore(GetInputValues(), null); if (bResult) { ResultMsgLabel.Text = "複製成功"; } else { ResultMsgLabel.Text = "複製失敗"; } } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { fmStatus = FormStatus.fmBrowse; } }
/// <summary> /// 檢查此PK是否已存在於DB,已存在為FALSE,不存在則為TRUE。 /// </summary> /// <param name="htTemp"></param> /// <returns></returns> private bool CheckPATTERNSPECExist(Hashtable htTemp) { #region bool bResult = false; try { ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); string strErrMsg = ""; bResult = BCO.CheckPATTERNSPECExist(htTemp); if (!bResult) { strErrMsg = string.Format("該門市已設定 ( 群分類_大分類_PATTERN={0}_{1}_{2} ) 的控制檔;", htTemp["ROOT_NO"], htTemp["PMA"], htTemp["PATTERN_NO"]); ErrorMsgLabel.Text = strErrMsg; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", strErrMsg), true); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } return bResult; #endregion }
private void QueryData() { #region LabelQueryRecordCount.Text = ""; string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); DataTable Dt = BCO.QueryPatternSpecByFind(GetInputValues()); Session[SessionIDName] = Dt; SmartGridView1.DataSource = Dt; SmartGridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text); if (!(CurrentPageMode == PageCurrentMode.Query || CurrentPageMode == PageCurrentMode.Readonly)) { string strCode = string.Format("{0}_{1}_{2}_{3}_{4}", SLP_StoreChain2.Text.Trim(), SLP_Store2.Text.Trim(), SLP_RootNo2.Text.Trim(), SLP_PMA3.Text.Trim(), SLP_Pattern3.Text.Trim()); SmartGridView1.PageIndex = GetPageIndexByParam(strCode); } else { SmartGridView1.PageIndex = 0; } SmartGridView1.DataBind(); LabelQueryRecordCount.Text = string.Format(" {0} Rows ", Dt.Rows.Count.ToString()); if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { if (btn_Export.Visible == true) { btn_Export.Enabled = false; } //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true); ResultMsgLabel.Text = "查無資料"; CurrentPageMode = PageCurrentMode.Query; } else { if (btn_Export.Visible == true) { btn_Export.Enabled = true; } LastPageMode = PageCurrentMode.Query; CurrentPageMode = PageCurrentMode.Readonly; } btn_EditComment.Enabled = true; #endregion }
protected void SmartGridView1_RowEditing(object sender, GridViewEditEventArgs e) { #region Label lbl_ID = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_ID"); Label lbl_item = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_item"); Label lbl_spec_qty = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_spec_qty"); Label lbl_reason = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_reason"); Label lbl_s_start_date = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_s_start_date"); Label lbl_s_end_date = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_s_end_date"); Label lbl_spec_type = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_spec_type"); Label lbl_chan_no = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_chan_no"); Label lbl_store = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_store"); Label lbl_Root_no = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_Root_no"); Label lbl_pma = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_pma"); Label lbl_Pattern_no = (Label)SmartGridView1.Rows[e.NewEditIndex].FindControl("lbl_Pattern_no"); #region ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); Hashtable ht = new Hashtable(); ht.Add("PID", lbl_ID.Text); DataTable dtDetl = BCO.QueryDetlByPID(ht); if (dtDetl != null && dtDetl.Rows.Count > 0) { dtDetailData = dtDetl; gv_Detail.DataSource = dtDetl; Panel_Detail.Visible = true; btn_AddDetail.Visible = true; btn_CopyDetail.Visible = true; dtForDetailDeleted.Clear(); } else { dtDetailData = null; Panel_Detail.Visible = false; } gv_Detail.DataBind(); SLP_StoreChain2.Text = lbl_chan_no.Text; SLP_Store2.Text = lbl_store.Text; SLP_RootNo2.Text = lbl_Root_no.Text; SLP_PMA3.Text = lbl_pma.Text; SLP_Pattern3.Text = lbl_Pattern_no.Text; SLP_SLPDate2.Text = lbl_s_start_date.Text; SLP_SLPDate3.Text = lbl_s_end_date.Text; SLP_Number1.Text = lbl_spec_qty.Text; DropDownList ddl = (DropDownList)SLP_CodeFile1.FindControl("D1"); ddl.SelectedValue = lbl_reason.Text; SetRadioButtonClear(); switch (lbl_spec_type.Text) { case "1": rBtn_SpecType1.Checked = true; btn_Setting.Enabled = true; hiddenCurrentSpecType.Value = "1"; SLP_Number1.ReadOnly = true; break; case "2": rBtn_SpecType2.Checked = true; btn_Setting.Enabled = false; hiddenCurrentSpecType.Value = "2"; SLP_Number1.ReadOnly = false; break; case "3": rBtn_SpecType3.Checked = true; btn_Setting.Enabled = false; hiddenCurrentSpecType.Value = "3"; SLP_Number1.ReadOnly = true; break; case "4": rBtn_SpecType4.Checked = true; btn_Setting.Enabled = false; hiddenCurrentSpecType.Value = "4"; SLP_Number1.ReadOnly = false; break; case "5": rBtn_SpecType5.Checked = true; btn_Setting.Enabled = false; hiddenCurrentSpecType.Value = "5"; SLP_Number1.ReadOnly = false; break; case "6": rBtn_SpecType6.Checked = true; btn_Setting.Enabled = false; hiddenCurrentSpecType.Value = "6"; SLP_Number1.ReadOnly = false; break; } #endregion SetTmpDataForMaster(lbl_ID.Text.Trim()); LastPageMode = PageCurrentMode.Readonly; CurrentPageMode = PageCurrentMode.Edit; #endregion }
protected void SmartGridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { #region try { bool bResult = false; #region 取得畫面元件的值 DateTime processtime = DateTime.Now; #endregion #region 取得刪除前舊值 Label lbl_ID = (Label)SmartGridView1.Rows[e.RowIndex].FindControl("lbl_ID"); SetTmpDataForMaster(lbl_ID.Text.Trim());//將CurrentRow的值塞入暫存master DataTable dtTemp = dtForMaster; if (dtTemp == null || dtTemp.Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } #endregion #region 加入更新條件 //master htParams.Clear(); //舊值 htParams.Add("ID", dtTemp.Rows[0]["ID"]); htParams.Add("CODE", dtTemp.Rows[0]["CODE"]); htParams.Add("CREATEDATE", dtTemp.Rows[0]["CREATEDATE"]); htParams.Add("CREATEUID", dtTemp.Rows[0]["CREATEUID"]); htParams.Add("UPDATEDATE", dtTemp.Rows[0]["UPDATEDATE"]); htParams.Add("UPDATEUID", dtTemp.Rows[0]["UPDATEUID"]); htParams.Add("ENABLE", dtTemp.Rows[0]["ENABLE"]); htParams.Add("ChanN0", dtTemp.Rows[0]["CHAN_NO"]); htParams.Add("STORE", dtTemp.Rows[0]["STORE"]); htParams.Add("SPEC_TYPE", dtTemp.Rows[0]["SPEC_TYPE"]); htParams.Add("SPEC_QTY", dtTemp.Rows[0]["SPEC_QTY"]); htParams.Add("S_START_DATE", dtTemp.Rows[0]["S_START_DATE"]); htParams.Add("S_END_DATE", dtTemp.Rows[0]["S_END_DATE"]); htParams.Add("REASON", dtTemp.Rows[0]["REASON"]); htParams.Add("ROOT_NO", dtTemp.Rows[0]["ROOT_NO"]); htParams.Add("PMA", dtTemp.Rows[0]["PMA"]); htParams.Add("PATTERN_NO", dtTemp.Rows[0]["PATTERN_NO"]); //需要更新值 htParams.Add("NEW_UPDATEDATE", processtime); htParams.Add("NEW_UPDATEUID", Session["UID"].ToString()); //detail htParams2.Clear(); htParams2.Add("PIDForLog", dtTemp.Rows[0]["ID"]); htParams2.Add("UIDForLog", dtTemp.Rows[0]["CREATEUID"]); #endregion ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); bResult = BCO.DeleteMasterAndDetail(htParams, htParams2, null); //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('刪除完成');", true); ResultMsgLabel.Text = "刪除完成"; QueryData(); CurrentPageMode = PageCurrentMode.Readonly; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void btn_Save_Click(object sender, EventArgs e) { #region if (CurrentPageMode == PageCurrentMode.Edit) { #region bool bResult = false; try { if (CheckSpecTypeAndValue() && CheckDetailDataIsNotNull()) { #region 取得畫面元件的值 DateTime processtime = DateTime.Now; #endregion #region 取得更新前舊值 if (dtForMaster == null || dtForMaster.Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } #endregion DataTable dtForUpdate = dtDetailData.GetChanges(); DataTable dtMaster = dtForMaster; string strUID = Session["UID"].ToString(); #region Master htParams.Clear(); for (Int32 i = 0; i <= dtMaster.Rows.Count - 1; i++) { if (dtMaster.Rows[i].RowState != DataRowState.Deleted) { htParams.Add("ID", dtMaster.Rows[i]["ID"]); htParams.Add("CODE", dtMaster.Rows[i]["CODE"]); htParams.Add("CREATEDATE", dtMaster.Rows[i]["CREATEDATE"]); htParams.Add("CREATEUID", dtMaster.Rows[i]["CREATEUID"]); htParams.Add("UPDATEDATE", dtMaster.Rows[i]["UPDATEDATE"]); htParams.Add("UPDATEUID", dtMaster.Rows[i]["UPDATEUID"]); htParams.Add("ENABLE", dtMaster.Rows[i]["ENABLE"]); htParams.Add("ChanN0", dtMaster.Rows[i]["CHAN_NO"]); htParams.Add("STORE", dtMaster.Rows[i]["STORE"]); htParams.Add("SPEC_TYPE", dtMaster.Rows[i]["SPEC_TYPE"]); htParams.Add("SPEC_QTY", dtMaster.Rows[i]["SPEC_QTY"]); htParams.Add("S_START_DATE", dtMaster.Rows[i]["S_START_DATE"]); htParams.Add("S_END_DATE", dtMaster.Rows[i]["S_END_DATE"]); htParams.Add("REASON", dtMaster.Rows[i]["REASON"]); htParams.Add("ROOT_NO", dtMaster.Rows[i]["ROOT_NO"]); htParams.Add("PMA", dtMaster.Rows[i]["PMA"]); htParams.Add("PATTERN_NO", dtMaster.Rows[i]["PATTERN_NO"]); //新的資料 htParams.Add("NEW_UPDATEDATE", processtime); htParams.Add("NEW_UPDATEUID", strUID); htParams.Add("NEW_SPEC_TYPE", getSpecTypeChecked()); htParams.Add("NEW_SPEC_QTY", SLP_Number1.Text.Trim()); htParams.Add("NEW_S_START_DATE", SLP_SLPDate2.Text.Trim()); htParams.Add("NEW_S_END_DATE", SLP_SLPDate3.Text.Trim()); htParams.Add("NEW_REASON", strReason.Trim()); break; } } htParams.Add("PIDForLog", dtMaster.Rows[0]["ID"]); htParams.Add("UIDForLog", dtMaster.Rows[0]["CREATEUID"]); #endregion ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); bResult = BCO.UpdateMasterAndDetail(htParams, dtForUpdate, strUID, dtForDetailDeleted, null); if (!bResult) { throw new Exception("更新0筆資料!"); } else { dtDetailData.AcceptChanges(); dtForDetailDeleted.Clear(); //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('更改完成');", true); ResultMsgLabel.Text = "更改完成"; QueryData(); CurrentPageMode = PageCurrentMode.Readonly; } } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion } else if (CurrentPageMode == PageCurrentMode.Insert) { #region Int32 iResult = 0; try { htTemp.Clear(); htTemp.Add("ChanNo",SLP_StoreChain2.Text.Trim()); htTemp.Add("Store", SLP_Store2.Text.Trim()); htTemp.Add("StartDate", SLP_SLPDate2.Text.Trim()); htTemp.Add("EndDate", SLP_SLPDate3.Text.Trim()); if (CheckSpecTypeAndValue() && CheckItemClassValid() && CheckDetailDataIsNotNull() && CheckPATTERNSPECCanAdd(htTemp)) { #region htTemp.Clear(); htTemp.Add("ChanNo", SLP_StoreChain2.Text.Trim()); htTemp.Add("Store", SLP_Store2.Text.Trim()); htTemp.Add("ROOT_NO", SLP_RootNo2.Text.Trim()); htTemp.Add("PMA", SLP_PMA3.Text.Trim()); if (SLP_Pattern3.Text.Trim() == "") { htTemp.Add("PATTERN_NO", null); } else { htTemp.Add("PATTERN_NO", SLP_Pattern3.Text.Trim()); } if (CheckPATTERNSPECExist(htTemp)) { DataTable dtForUpdate = dtDetailData;//.GetChanges(DataRowState.Added); #region Master string strCode = string.Format("{0}_{1}_{2}_{3}_{4}", SLP_StoreChain2.Text.Trim(), SLP_Store2.Text.Trim(), SLP_RootNo2.Text.Trim(), SLP_PMA3.Text.Trim(), SLP_Pattern3.Text.Trim()); htParams.Clear(); htParams.Add("CODE", strCode); htParams.Add("UserID", Session["UID"].ToString()); htParams.Add("ChanNO", SLP_StoreChain2.Text.Trim()); htParams.Add("STORE", SLP_Store2.Text.Trim()); htParams.Add("ROOT_NO", SLP_RootNo2.Text.Trim()); htParams.Add("PMA", SLP_PMA3.Text.Trim()); htParams.Add("PATTERN_NO", SLP_Pattern3.Text.Trim()); htParams.Add("SPEC_TYPE", getSpecTypeChecked()); htParams.Add("SPEC_QTY", SLP_Number1.Text.Trim()); htParams.Add("S_START_DATE", SLP_SLPDate2.Text.Trim()); htParams.Add("S_END_DATE", SLP_SLPDate3.Text.Trim()); htParams.Add("REASON", strReason.Trim()); #endregion ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB); iResult = BCO.CreateMasterAndDetail(htParams, dtForUpdate, null); if (iResult == 0) { throw new Exception("新增0筆資料!"); } else { if (dtForUpdate != null) dtForUpdate.AcceptChanges(); dtDetailData = dtForUpdate; dtForDetailDeleted.Clear(); //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('新增完成');", true); ResultMsgLabel.Text = "新增完成"; QueryData(); CurrentPageMode = PageCurrentMode.Readonly; } } #endregion } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion } #endregion }