private string ProcessConfirmFromBridge(string strStAcceptDate, string strDisNoForAry, string strCtrlPending, Int32 iProcessingAryIndex) { #region bool bResult = false, bResultCheck = false; string strCallbackResult = ""; string strResult = "", strErrMsg = "", strErrMsgCheck = ""; string strPrefixed = "POP_DisApproveError"; string strDisNo = "", strNextDisNo = ""; string strDIS_QTY = ""; string[] strAryDisAry = strDisNoForAry.Split(";".ToCharArray()); string[] strAryCtrlPending = strCtrlPending.Split(";".ToCharArray()); try { fmStatus = FormStatus.fmProcess; ALOModel.MaintainDisRecord BCO = new ALOModel.MaintainDisRecord(ConnectionDB); if (iProcessingAryIndex < strAryDisAry.Length) { strDisNo = strAryDisAry[iProcessingAryIndex]; ArrayList ParameterList = new ArrayList();//20091113 //--------------------------------------------------------------------- //2010/02/09 added:確認前檢核 ALOModel.MaintainDisCRMRecord BCO3 = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ParameterList.Clear(); ParameterList.Add(strStAcceptDate); ParameterList.Add(strDisNo); try { bResultCheck = BCO3.Pick_Control_Check(ParameterList, out strErrMsgCheck); } catch (Exception ex) { throw ex; } //--------------------------------------------------------------------- ParameterList.Clear(); ParameterList.Add(strStAcceptDate); ParameterList.Add(strDisNo); ParameterList.Add("VDS_ALO_DIS_STORE"); ParameterList.Add(strAryCtrlPending[5]); try { bResult = BCO.ProcessConfirm(ParameterList, out strResult, out strErrMsg, null); } catch (Exception ex) { throw ex; } if (!bResult) { Session[string.Format("{0}_DISNO_{1}", strPrefixed, strAryCtrlPending[0])] += string.Format("{0},", strDisNo); Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, strAryCtrlPending[0])] = "1"; Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strAryCtrlPending[0])] += string.Format("配本序號:{0},{1}{2}{3};\r\n", strDisNo, strErrMsgCheck, bResultCheck ? "" : ",", strErrMsg); } else { if (!bResultCheck) { Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strAryCtrlPending[0])] += string.Format("配本序號:{0},{1};\r\n", strDisNo, strErrMsgCheck); } } ALOModel.ProcessMultiDisRecords BCO2 = new ALOModel.ProcessMultiDisRecords(ConnectionDB); DataTable dtTemp = BCO2.QueryDisItemForALO20(GetQueryParams(strStAcceptDate, strDisNo, bResult)); if (dtTemp != null && dtTemp.Rows.Count > 0) strDIS_QTY = dtTemp.Rows[0]["DIS_QTY"].ToString().Trim(); iProcessingAryIndex = iProcessingAryIndex + 1; if (iProcessingAryIndex < strAryDisAry.Length) { strNextDisNo = strAryDisAry[iProcessingAryIndex]; } else { strNextDisNo = "X";//表示已執行到最後一筆 } //0:DIS_NO字串For陣列用- //1:下一筆陣列Index- //2:執行結果- //3:錯誤訊息- //4:要關閉執行狀態的DIS_NO- //5:要開啟執行狀態的DIS_NO- //6:是否有累積執行錯誤之DIS_NO- //7:ST_ACCEPT_DATE ClientID- //8:ResultMsgLabel ClientID- //9:ErrMsgLabel ClientID- //10:將再開啟之控制項字串陣列 //11:DIS_QTY string strCtrlIDToUnLock = string.Format("{0}", strAryCtrlPending[1]); strCallbackResult = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}-{9}-{10}-{11}", strDisNoForAry, iProcessingAryIndex, bResult ? "OK" : "NG", Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strAryCtrlPending[0])].ToString(),//strErrMsg, strDisNo, strNextDisNo, Session[string.Format("{0}_DISNO_{1}", strPrefixed, strAryCtrlPending[0])] == null ? "0" : "1", strAryCtrlPending[2], strAryCtrlPending[3], strAryCtrlPending[4], strCtrlIDToUnLock, strDIS_QTY ); } } catch (Exception ex) { throw ex; } return strCallbackResult; #endregion }
private void MakeDataTableDisItem() { #region try { ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); dtDisItem = BCO.GetDisCRMItemSchema(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
private void QueryData() { #region try { if (s_DIS_NO == "") return; //if (CurrentPageMode == PageCurrentMode.Insert || CurrentPageMode == PageCurrentMode.Edit) //{ #region CheckCurrentIndexAndSwitchNavigator(s_DIS_NO); ALOModel.MaintainDisMain BCO1 = new ALOModel.MaintainDisMain(ConnectionDB); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(s_DIS_NO == "" ? null : s_DIS_NO); dtDisMain = BCO1.QueryByDisNo(ParameterList); ALOModel.MaintainDisCRMRecord BCO2 = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ParameterList.Clear(); ParameterList.Add(s_DIS_NO == "" ? null : s_DIS_NO); dtDisItem = BCO2.QueryDisCRMItemByDisNo(ParameterList); dtDisItemOld = dtDisItem.Copy(); DataColumn[] PrimaryKeys21 = new DataColumn[3]; PrimaryKeys21[0] = dtDisItemOld.Columns["DIS_NO"]; PrimaryKeys21[1] = dtDisItemOld.Columns["ITEM"]; PrimaryKeys21[2] = dtDisItemOld.Columns["PERIOD"]; dtDisItemOld.PrimaryKey = PrimaryKeys21; DataColumn[] PrimaryKeys22 = new DataColumn[3]; PrimaryKeys22[0] = dtDisItem.Columns["DIS_NO"]; PrimaryKeys22[1] = dtDisItem.Columns["ITEM"]; PrimaryKeys22[2] = dtDisItem.Columns["PERIOD"]; dtDisItem.PrimaryKey = PrimaryKeys22; ALOModel.MaintainDisStore BCO3 = new ALOModel.MaintainDisStore(ConnectionDB); ParameterList.Clear(); ParameterList.Add(s_DIS_NO == "" ? null : s_DIS_NO); dtDisStoreAll = BCO3.QueryDisStoreByDisNo(ParameterList); dtDisStore = dtDisStoreAll.Copy(); dtDisStoreAllOld = dtDisStoreAll.Copy(); DataColumn[] PrimaryKeys31 = new DataColumn[1]; PrimaryKeys31[0] = dtDisStoreAllOld.Columns["CODE"]; dtDisStoreAllOld.PrimaryKey = PrimaryKeys31; DataColumn[] PrimaryKeys32 = new DataColumn[1]; PrimaryKeys32[0] = dtDisStoreAll.Columns["CODE"]; dtDisStoreAll.PrimaryKey = PrimaryKeys32; #region Binding Data txt_DisNo.Text = s_DIS_NO; if (dtDisMain != null && dtDisMain.Rows.Count > 0) { SLP_StoreChain1.Text = dtDisMain.Rows[0]["RCHAN_NO"].ToString(); SLP_SLPDate1_DisDate.Text = dtDisMain.Rows[0]["DIS_DATE"].ToString(); SLP_SLPDate2_StAcceptDate.Text = dtDisMain.Rows[0]["ST_ACCEPT_DATE"].ToString(); SLP_SLPDate3_TransStAcceptDate.Text = dtDisMain.Rows[0]["TRANS_ST_ACCEPT_DATE"].ToString(); SLP_SLPDate4_ApproveDate.Text = dtDisMain.Rows[0]["APPROVE_DATE"].ToString(); SLP_EnumBase1.Text = dtDisMain.Rows[0]["DATA_SOURCE"].ToString(); txt_POSourceNo.Text = dtDisMain.Rows[0]["PO_SOURCE_NO"].ToString(); } else { CurrentPageMode = PageCurrentMode.Query; throw new Exception("查無此筆資料或已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!"); } currentGvModeDisItem = CurrentGridviewMode.ReadOnly; gv_DisItem.DataSource = dtDisItem; gv_DisItem.DataBind(); if (dtDisItem != null && dtDisItem.Rows.Count > 0) { s_ITEM = dtDisItem.Rows[0]["ITEM"].ToString().Trim(); ; s_PERIOD = dtDisItem.Rows[0]["PERIOD"].ToString().Trim(); ; s_ITEM_NAME = dtDisItem.Rows[0]["ITEM_NAME"].ToString().Trim(); ; s_PMA = dtDisItem.Rows[0]["PMA"].ToString().Trim(); ; s_ROOT_NO = dtDisItem.Rows[0]["ROOT_NO"].ToString().Trim(); ; s_PATTERN = dtDisItem.Rows[0]["PATTERN_NO"].ToString().Trim(); ; } string strFilter = string.Format(" ITEM='{0}' and PERIOD='{1}' ", s_ITEM, s_PERIOD); DataView dv = dtDisStoreAll.DefaultView; dv.RowFilter = strFilter; dtDisStore = dv.ToTable().Copy(); currentGvModeDisStore = CurrentGridviewMode.ReadOnly; gv_DisStore.DataSource = dtDisStore; gv_DisStore.DataBind(); CountGvDisStoreInfo(); #endregion #endregion //} if (CurrentPageMode == PageCurrentMode.Readonly) { CheckConfirmOrRemove(); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void btn_DeleteItemWithoutStock_Click(object sender, System.EventArgs e) { #region try { string strITEM = "", strPERIOD = ""; Int32 i32Item = 0, i32Store = 0; if (dtDisItem != null && dtDisItem.Rows.Count > 0) { for (Int32 i = 0; i <= dtDisItem.Rows.Count - 1; i++) { if (dtDisItem.Rows[i]["ONHD_QTY"].ToString() == "" || dtDisItem.Rows[i]["ONHD_QTY"].ToString() == "0") { #region 刪除配本品項明細 strITEM = dtDisItem.Rows[i]["ITEM"].ToString().Trim(); strPERIOD = dtDisItem.Rows[i]["PERIOD"].ToString().Trim(); dtDisItem.Rows.RemoveAt(i); i32Item++; #endregion #region 刪除門市分配明細 if (dtDisStoreAll != null && dtDisStoreAll.Rows.Count > 0) { for (Int32 j = dtDisStoreAll.Rows.Count - 1; j >= 0; j--) { if (dtDisStoreAll.Rows[j].RowState != DataRowState.Deleted && dtDisStoreAll.Rows[j]["ITEM"].ToString().Trim() == strITEM && dtDisStoreAll.Rows[j]["PERIOD"].ToString().Trim() == strPERIOD) { dtDisStoreAll.Rows.RemoveAt(j); i32Store++; } } } #endregion } } #region 儲存異動 if (i32Item != 0 && i32Store != 0) { ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); bool bResult = BCO.UpdateDisCRMRecord(dtDisMain, dtDisItem, dtDisItemOld, dtDisStoreAll, dtDisStoreAllOld, s_DIS_NO, null); if (bResult) { ResultMsgLabel.Text = string.Format("刪除成功,品項明細 {0} 筆、門市明細 {1} 筆。", i32Item, i32Store); QueryData(); } else ResultMsgLabel.Text = "刪除失敗"; } else { ResultMsgLabel.Text = "無刪除資料"; } #endregion } else { ResultMsgLabel.Text = "無刪除資料"; } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void gv_DisItem_RowCommand(object sender, GridViewCommandEventArgs e) { #region try { Int32 iRowIndex; Int32.TryParse(e.CommandArgument.ToString(), out iRowIndex); if (e.CommandName == "View") { s_ITEM = ((Label)gv_DisItem.Rows[iRowIndex].FindControl("lbl_ITEM")).Text; s_PERIOD = ((Label)gv_DisItem.Rows[iRowIndex].FindControl("lbl_PERIOD")).Text; string strFilter = string.Format(" ITEM='{0}' and PERIOD='{1}' ", s_ITEM, s_PERIOD); if (dtDisStoreAll != null) { DataView dv = dtDisStoreAll.DefaultView; dv.RowFilter = strFilter; dtDisStore = dv.ToTable().Copy(); gv_DisStore.DataSource = dtDisStore; } gv_DisStore.DataBind(); CountGvDisStoreInfo(); if (CurrentPageMode != PageCurrentMode.Readonly) SwitchGvAddNewBtn(true, true, true); else SwitchGvAddNewBtn(false, false, false); if (ConfirmIsTrueAndRemoveIsFalse) { btn_Confirm.Enabled = false; btn_Remove.Enabled = true; btn_Edit.Enabled = false; btn_Delete.Enabled = false; } if (s_DIS_NO != "" && btn_Confirm.Enabled == false) { ALOModel.MaintainDisCRMRecord BCO2 = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ParameterList.Clear(); ParameterList.Add(s_DIS_NO == "" ? null : s_DIS_NO); DataTable dtTemp = BCO2.QueryDisCRMItemByDisNo(ParameterList); if (dtTemp != null && dtTemp.Rows.Count > 0) { gv_DisItem.DataSource = dtTemp; gv_DisItem.DataBind(); } } } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void btn_Save_Click(object sender, EventArgs e) { #region try { ErrorMsgLabel.Text = ""; ResultMsgLabel.Text = ""; bool bResult = false; DateTime ProcessingDateTime = DateTime.Now; string strDisDate = SLP_SLPDate1_DisDate.Text; string strStAcceptDate = SLP_SLPDate2_StAcceptDate.Text; string strChanNo = SLP_StoreChain1.Text; string strPOSourceNo = txt_POSourceNo.Text.Trim(); string strUserId = Session["UID"].ToString(); string vDisNo; SetDisMain(strDisDate, strStAcceptDate, strChanNo, strPOSourceNo, strUserId, ProcessingDateTime); SetDisItem(strUserId, ProcessingDateTime); SetDisStoreAll(strUserId, ProcessingDateTime); if (CurrentPageMode == PageCurrentMode.Insert) { #region if (CheckPOsourceNoIsExisted()) { ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); bResult = BCO.CreateDisCRMRecord(dtDisMain, dtDisItem, dtDisStoreAll, out vDisNo, null); s_DIS_NO = vDisNo; txt_DisNo.Text = s_DIS_NO; if (bResult) { ResultMsgLabel.Text = "新增成功"; CurrentPageMode = PageCurrentMode.Readonly; QueryData(); } else ResultMsgLabel.Text = "新增失敗"; } #endregion } else if (CurrentPageMode == PageCurrentMode.Edit) { #region ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); bResult = BCO.UpdateDisCRMRecord(dtDisMain, dtDisItem, dtDisItemOld, dtDisStoreAll, dtDisStoreAllOld, s_DIS_NO, null); if (bResult) { ResultMsgLabel.Text = "更新成功"; CurrentPageMode = PageCurrentMode.Readonly; QueryData(); } else ResultMsgLabel.Text = "更新失敗"; #endregion } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void btn_Delete_Click(object sender, EventArgs e) { #region try { if (SLP_SLPDate4_ApproveDate.Text.Trim() == "") { bool bResult = false; ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); DataTable dtTemp = dtDisMain; if (dtTemp != null && dtTemp.Rows.Count > 0) { ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(dtTemp.Rows[0]["DIS_NO"]); ParameterList.Add(dtTemp.Rows[0]["UPDATEUID"]); ParameterList.Add(dtTemp.Rows[0]["UPDATEDATE"]); ParameterList.Add(dtTemp.Rows[0]["DIS_DATE"]); ParameterList.Add(dtTemp.Rows[0]["ST_ACCEPT_DATE"]); bResult = BCO.DeleteDisCRMRecord(ParameterList, null); } if (bResult) { ResultMsgLabel.Text = "刪除成功"; ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("location.href='ALO191.aspx?Code=ALO19&Requery=true&ChanNo={0}'", SLP_StoreChain1.Text), true); } else { ResultMsgLabel.Text = "刪除失敗"; } } else { throw new Exception("已確認不可刪除"); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
private string ProcessConfirm(string strStAcceptDate, string strDisNo) { #region string strCallbackResult = ""; string strResult = "", strErrMsg = ""; string strPrefixed = "POP_DisApproveError"; string strApproveDate = ""; string strITEM_PERIOD_RESERVE_QTY = ""; try { #region //2009-11-04 cyhsu add for 門市進貨日檢查 #region 檢查門市進貨日 if (DateTime.Parse(strStAcceptDate) < DateTime.Today.AddDays(1)) { throw new Exception("門市進貨日必須大於系統日"); } if (DateTime.Parse(strStAcceptDate).DayOfWeek == DayOfWeek.Sunday) { throw new Exception("門市進貨日不可為星期日"); } #endregion fmStatus = FormStatus.fmProcess; ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(strStAcceptDate); ParameterList.Add(strDisNo); ParameterList.Add("VDS_ALO_DIS_STORE"); ParameterList.Add(Session["UID"].ToString()); BCO.ProcessConfirm(ParameterList, out strResult, out strErrMsg, null); // 2009-06-17 cyhsu change if ((strResult == "1") && (strErrMsg.Trim() == ""))//確認成功 { strApproveDate = DateTime.Now.ToString("yyyy/MM/dd"); ConfirmIsTrueAndRemoveIsFalse = true; #region //20091202 ALOModel.MaintainDisCRMRecord BCO2 = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ParameterList.Clear(); ParameterList.Add(strDisNo == "" ? null : strDisNo); DataTable dtTemp = BCO2.QueryDisCRMItemByDisNo(ParameterList); if (dtTemp != null && dtTemp.Rows.Count > 0) { for (Int32 i = 0; i <= dtTemp.Rows.Count - 1; i++) { strITEM_PERIOD_RESERVE_QTY += string.Format("{0}||{1}||{2},", dtTemp.Rows[i]["ITEM"].ToString(), dtTemp.Rows[i]["PERIOD"].ToString(), dtTemp.Rows[i]["RESERVE_QTY"].ToString()); } if (strITEM_PERIOD_RESERVE_QTY.Trim() != "") { if (strITEM_PERIOD_RESERVE_QTY.Substring(strITEM_PERIOD_RESERVE_QTY.Length - 1, 1) == ",") { strITEM_PERIOD_RESERVE_QTY = strITEM_PERIOD_RESERVE_QTY.Substring(0, strITEM_PERIOD_RESERVE_QTY.Length - 1); } } } #endregion } // 只要成功完成檢核,無論筆數 strResult 都=1, 所以要另外檢查strErrMsg 不為空值代表有檢核錯誤資料需要開POP else if ((strResult == "1") && (strErrMsg.Trim() != ""))//確認失敗 { Session[string.Format("{0}_DISNO_{1}", strPrefixed, PageTimeStamp.Value)] = strDisNo; Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, PageTimeStamp.Value)] = "1"; strResult = "0"; } strCallbackResult = string.Format("{0}-{1}-{2}-{3}-{4};{5}-{6}-{7}-{8}", ((TextBox)SLP_SLPDate4_ApproveDate.FindControl("TextBoxCode")).ClientID, btn_Confirm.ClientID, btn_Remove.ClientID, ResultMsgLabel.ClientID, hiddenFrmStatus.ClientID, strApproveDate, strResult, FormStatus.fmBrowse.ToString(), strITEM_PERIOD_RESERVE_QTY ); #endregion } catch (Exception ex) { throw ex; } return strCallbackResult; #endregion }
protected void btn_Remove_Click(object sender, EventArgs e) { #region string strResult = "", strErrMsg = ""; try { fmStatus = FormStatus.fmProcess; ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(txt_DisNo.Text.Trim()); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(DateTime.Now); BCO.ProcessCancelConfirm(ParameterList, out strResult, out strErrMsg, null); if (strResult == "1")//解除成功 { SLP_SLPDate4_ApproveDate.Text = ""; CheckConfirmOrRemove(); QueryData();//20091202 } else//解除失敗 { } ResultMsgLabel.Text = string.Format("{0} {1}", strResult == "1" ? "解除成功" : "解除失敗", strErrMsg); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { fmStatus = FormStatus.fmBrowse; } #endregion }
private string ProcessMultiRemove(string strDisNoForAry, Int32 iProcessingAryIndex, string strUserID, string strPageTimeStamp) { #region bool bResult = false; string strDisNo = "", strNextDisNo = ""; string[] strAryDisAry = strDisNoForAry.Split(";".ToCharArray()); string strCallbackResult = ""; string strResult = "", strErrMsg = ""; string strPrefixed = "POP_DisApproveError"; try { //於執行多筆確認、解除時清空,為了於換頁時可以取得最新資料 string SessionIDName = string.Format("{0}_{1}", "ALO191_MST", strPageTimeStamp); Session[SessionIDName] = null; fmStatus = FormStatus.fmProcess; if (iProcessingAryIndex < strAryDisAry.Length) { strDisNo = strAryDisAry[iProcessingAryIndex]; ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(strDisNo); ParameterList.Add(strUserID); ParameterList.Add(DateTime.Now); BCO.ProcessCancelConfirm(ParameterList, out strResult, out strErrMsg, null); if (strResult == "1")//解除成功 { bResult = true; } else//解除失敗 { Session[string.Format("{0}_REMOVE_{1}", strPrefixed, strPageTimeStamp)] = strDisNo; bResult = false; } iProcessingAryIndex = iProcessingAryIndex + 1; if (iProcessingAryIndex < strAryDisAry.Length) { strNextDisNo = strAryDisAry[iProcessingAryIndex]; } else { strNextDisNo = "X";//表示已執行到最後一筆 } //0:DIS_NO字串For陣列用- //1:下一筆陣列Index- //2:執行結果- //3:錯誤訊息- //4:要關閉執行狀態的DIS_NO- //5:要開啟執行狀態的DIS_NO- //6:是否有累積執行錯誤之DIS_NO strCallbackResult = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}", strDisNoForAry, iProcessingAryIndex, bResult ? "OK" : "NG", string.Format("{0}", strErrMsg), strDisNo, strNextDisNo, Session[string.Format("{0}_REMOVE_{1}", strPrefixed, strPageTimeStamp)] == null ? "0" : "1" ); } } catch (Exception ex) { throw new Exception(string.Format("{0}||{1}", strDisNo, ex.Message)); } return strCallbackResult; #endregion }
private string ProcessMultiConfirm(string strStAcceptDate, string strDisNoForAry, Int32 iProcessingAryIndex, string strUserID, string strPageTimeStamp) { #region string strDisNo = "", strNextDisNo = ""; string[] strAryDisAry = strDisNoForAry.Split(";".ToCharArray()); string strCallbackResult = ""; string strResult = "", strErrMsg = "", strErrMsgFinal = ""; string strPrefixed = "POP_DisApproveError"; string strApproveDate = ""; string strITEM_PERIOD_RESERVE_QTY = ""; try { //於執行多筆確認、解除時清空,為了於換頁時可以取得最新資料 string SessionIDName = string.Format("{0}_{1}", "ALO191_MST", strPageTimeStamp); Session[SessionIDName] = null; #region 檢查門市進貨日 if (DateTime.Parse(strStAcceptDate) < DateTime.Today.AddDays(1)) { strErrMsg += "門市進貨日必須大於系統日 "; } if (DateTime.Parse(strStAcceptDate).DayOfWeek == DayOfWeek.Sunday) { strErrMsg += "門市進貨日不可為星期日 "; } #endregion fmStatus = FormStatus.fmProcess; if (iProcessingAryIndex < strAryDisAry.Length) { //取得當前執行之 DISNO strDisNo = strAryDisAry[iProcessingAryIndex]; if (strErrMsg == "") { #region ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(strStAcceptDate); ParameterList.Add(strDisNo); ParameterList.Add("VDS_ALO_DIS_STORE"); ParameterList.Add(strUserID); BCO.ProcessConfirm(ParameterList, out strResult, out strErrMsg, null); if ((strResult == "1") && (strErrMsg.Trim() == ""))//確認成功 { strApproveDate = DateTime.Now.ToString("yyyy/MM/dd"); #region ALOModel.MaintainDisCRMRecord BCO2 = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ParameterList.Clear(); ParameterList.Add(strDisNo == "" ? null : strDisNo); DataTable dtTemp = BCO2.QueryDisCRMItemByDisNo(ParameterList); BCO2.CloseConnection(); if (dtTemp != null && dtTemp.Rows.Count > 0) { for (Int32 i = 0; i <= dtTemp.Rows.Count - 1; i++) { strITEM_PERIOD_RESERVE_QTY += string.Format("{0}||{1}||{2},", dtTemp.Rows[i]["ITEM"].ToString(), dtTemp.Rows[i]["PERIOD"].ToString(), dtTemp.Rows[i]["RESERVE_QTY"].ToString()); } if (strITEM_PERIOD_RESERVE_QTY.Trim() != "") { if (strITEM_PERIOD_RESERVE_QTY.Substring(strITEM_PERIOD_RESERVE_QTY.Length - 1, 1) == ",") { strITEM_PERIOD_RESERVE_QTY = strITEM_PERIOD_RESERVE_QTY.Substring(0, strITEM_PERIOD_RESERVE_QTY.Length - 1); } } } #endregion } else if ((strResult == "1") && (strErrMsg.Trim() != ""))//確認失敗 { #region 只要成功完成檢核,無論筆數 strResult 都=1, 所以要另外檢查strErrMsg 不為空值代表有檢核錯誤資料需要開POP //Session[string.Format("{0}_DISNO_{1}", strPrefixed, strPageTimeStamp)] = strDisNo; //Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, strPageTimeStamp)] = "1"; Session[string.Format("{0}_DISNO_{1}", strPrefixed, strPageTimeStamp)] += string.Format("{0},", strDisNo); Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, strPageTimeStamp)] = "1"; Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)] += string.Format("配本序號:{0},{1};\r\n", strDisNo, strErrMsg); strResult = "0"; #endregion } #endregion } else { Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)] += string.Format("配本序號:{0},{1};\r\n", strDisNo, strErrMsg); } iProcessingAryIndex = iProcessingAryIndex + 1; if (iProcessingAryIndex < strAryDisAry.Length) { strNextDisNo = strAryDisAry[iProcessingAryIndex]; } else { strNextDisNo = "X";//表示已執行到最後一筆 strErrMsgFinal = Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)] == null ? "" : Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)].ToString(); Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)] = null; } //0:DIS_NO字串For陣列用- //1:下一筆陣列Index- //2:執行結果- //3:錯誤訊息- //4:要關閉執行狀態的DIS_NO- //5:要開啟執行狀態的DIS_NO- //6:是否有累積執行錯誤之DIS_NO strCallbackResult = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}", strDisNoForAry, iProcessingAryIndex, strResult == "1" ? "OK" : "NG", strErrMsgFinal, strDisNo, strNextDisNo, Session[string.Format("{0}_DISNO_{1}", strPrefixed, strPageTimeStamp)] == null ? "0" : "1" ); } } catch (Exception ex) { throw new Exception(string.Format("{0}||{1}", strDisNo, ex.Message)); } return strCallbackResult; #endregion }
private void QueryData() { #region try { ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); DataTable dt = BCO.QueryDisCRMMainByFind(GetQueryParams()); string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); Session[SessionIDName] = dt; aryParamsPKey.Clear(); LabelQueryRecordCount.Visible = false; if (dt != null && dt.Rows.Count > 0) { gv_Result.PageSize = iCurrentGvPageSize; gv_Result.PageIndex = iCurrentGvPageIndex; gv_Result.DataSource = dt; gv_Result.DataBind(); LabelQueryRecordCount.Text = string.Format(" {0} Rows ", dt.Rows.Count.ToString()); foreach (DataRow dr in dt.Rows) { #region aryParamsPKey.Add(dr["DIS_NO"]); #endregion } //有資料才可執行多筆確認、解除 btn_ConfirmMulti.Visible = true; btn_RemoveMulti.Visible = true; } else { btn_ConfirmMulti.Visible = false; btn_RemoveMulti.Visible = false; gv_Result.DataBind(); ResultMsgLabel.Text = "查無資料"; } Session[string.Format("{0}_{1}", strPreFixed, PageTimeStamp.Value)] = aryParamsPKey; } catch (Exception ex) { gv_Result.DataBind(); ErrorMsgLabel.Text = ex.Message; } finally { UpdatePanel2.Update(); } #endregion }
private bool ConfirmDisAgain(string strDisNo, string strStAcceptDate, string strUserID) { #region Int32 iErrCount = 0; try { string strResult = "", strErrMsg = ""; string strDisNo_Err = ""; string strPrefixed = "POP_DisApproveError"; bool bResultCheck = false; string[] strAryDisNO = strDisNo.Split(",".ToCharArray()); ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ArrayList ParameterList = new ArrayList(); for (Int32 i = 0; i <= strAryDisNO.GetUpperBound(0); i++) { ParameterList.Clear(); ParameterList.Add(strStAcceptDate); ParameterList.Add(strAryDisNO[i]); ParameterList.Add("VDS_ALO_DIS_STORE"); ParameterList.Add(strUserID); BCO.ProcessConfirm(ParameterList, out strResult, out strErrMsg, null); if ((strResult == "1") && (strErrMsg.Trim() == ""))//確認成功 { #region 確認成功 //do nothing #endregion } // 只要成功完成檢核,無論筆數 strResult 都=1, 所以要另外檢查strErrMsg 不為空值代表有檢核錯誤資料需要開POP else if ((strResult == "1") && (strErrMsg.Trim() != ""))//確認失敗 { #region 確認失敗 strDisNo_Err += string.Format("{0},", strAryDisNO[i]); strResult = "0"; iErrCount++; #endregion } } if (iErrCount != 0) { Session[string.Format("{0}_DISNO_{1}", strPrefixed, PageTimeStamp.Value)] = strDisNo_Err; Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, PageTimeStamp.Value)] = "1"; } } catch (Exception ex) { throw ex; } return iErrCount == 0 ? true : false; #endregion }
/// <summary> /// 配本確認 2009-07-02 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetupConfirmBtn_Click(object sender, EventArgs e) { #region string strResult = "", strErrMsg = "", strErrMsgCheck = ""; bool bResultCheck = false; string strPrefixed = "POP_DisApproveError"; try { #region #region 門市進貨日判斷 if (DateTime.Parse(SLP_STAcceptDate.Text) < DateTime.Today.AddDays(1))//2010/04/06 added : 門市進貨日必須大於等於系統日+1日 { throw new Exception("門市進貨日必須大於等於系統日+1日!!"); } #endregion #region ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); ArrayList ParameterList = new ArrayList(); //--------------------------------------------------------------------- //2010/02/08 added:確認前檢核 ParameterList.Clear(); ParameterList.Add(DateTime.Parse(SLP_STAcceptDate.Text).ToShortDateString()); ParameterList.Add(DISNOTxt.Text); bResultCheck = BCO.Pick_Control_Check(ParameterList, out strErrMsgCheck); //--------------------------------------------------------------------- ParameterList.Clear(); ParameterList.Add(DateTime.Parse(SLP_STAcceptDate.Text).ToShortDateString()); ParameterList.Add(DISNOTxt.Text); ParameterList.Add("VDS_ALO_DIS_STORE"); ParameterList.Add(Session["UID"].ToString()); BCO.ProcessConfirm(ParameterList, out strResult, out strErrMsg, null); if ((strResult == "1") && (strErrMsg.Trim() == ""))//確認成功 { #region 確認成功 SLP_ApproveDate.Text = DateTime.Now.ToString("yyyy/MM/dd"); Int32 iReserveQty = 0; //保留數 Int32 iMdcQty = 0; //預留數(理論) = 到貨數-保留數-實配數 Int32 iAcceptQTY = 0; //到貨數 Int32 iDisQty = 0; //實配數 //取舊值 iReserveQty = Int32.Parse(this.ReserveQTYtxt.Text); iMdcQty = Int32.Parse(this.DIS_MDCQTYtxt.Text); iAcceptQTY = Int32.Parse(this.AcceptQTYtxt.Text); iDisQty = Int32.Parse(this.DISQTYtxt.Text); //算新值 iReserveQty = iReserveQty + iDisQty; iMdcQty = iAcceptQTY - iReserveQty;//預留數(實際) = 到貨數-新保留數 this.ReserveQTYtxt.Text = iReserveQty.ToString(); this.OLD_ReserveQTYtxtHidden.Value = iReserveQty.ToString(); this.DIS_MDCQTYtxt.Text = iMdcQty.ToString(); this.OLD_DISMDCQTYHidden.Value = iMdcQty.ToString(); //Gridview SessionIDName = "ALO111ItemGridViewDv_" + PageTimeStamp.Value; DataView dv = (DataView)Session[SessionIDName]; for (Int32 i = 0; i <= dv.Table.Rows.Count - 1; i++) { if (dv.Table.Rows[i]["ITEM"].ToString().Trim() == SLP_SKU1.TextBox_Code.Text.Trim() && dv.Table.Rows[i]["PERIOD"].ToString().Trim() == SLP_ItemPeriod1.TextBox_Code.Text.Trim()) { dv.Table.Rows[i]["RESERVE_QTY"] = iReserveQty; dv.Table.Rows[i]["DIS_MDC_QTY"] = iMdcQty; break; } } Session[SessionIDName] = dv; GridView_ItemList.DataSource = dv; GridView_ItemList.DataBind(); //2010/04/20 modified if (!bResultCheck && strErrMsgCheck != "") { ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("alert('{0}');alert('確認成功!');", strErrMsgCheck), true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('確認成功!');", true); } #endregion } // 只要成功完成檢核,無論筆數 strResult 都=1, 所以要另外檢查strErrMsg 不為空值代表有檢核錯誤資料需要開POP else if ((strResult == "1") && (strErrMsg.Trim() != ""))//確認失敗 { #region 確認失敗 Session[string.Format("{0}_DISNO_{1}", strPrefixed, PageTimeStamp.Value)] = DISNOTxt.Text; Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, PageTimeStamp.Value)] = "1"; strResult = "0"; #endregion } if (bResultCheck) { #region check ok && confirm fail if (strResult != "1") { ScriptManager.RegisterStartupScript(this, this.GetType(), "", "POP_DisApproveError();", true); } #endregion } else { #region check fail && confirm fail if (strResult != "1") { ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("alert('{0}');POP_DisApproveError();", strErrMsgCheck), true); } #endregion } FormStatusControl(FormStatus.View); UpdatePanel_ALODisMain.Update(); UpdatePanel_Item.Update(); #endregion #endregion } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.Message; if (!bResultCheck && strErrMsgCheck != "") { ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("alert('{0}');", strErrMsgCheck), true); } } finally { UpdatePanel_ErrorMessage.Update(); } #endregion }