private void GetItemNameByItem(string strItem) { #region try { s_ITEM_NAME = ""; s_ROOT_NO = ""; s_PMA = ""; s_PATTERN = ""; s_PMA_NAME = ""; ITMModel.MaintainSKU BCO = new ITMModel.MaintainSKU(ConnectionDB); ITMModel.MaintainItemClassify BCO2 = new ITMModel.MaintainItemClassify(ConnectionDB); ArrayList ParameterList1 = new ArrayList(); ParameterList1.Clear(); ParameterList1.Add(strItem); DataTable dtTemp = BCO.QuerySKUByCode(ParameterList1); if (dtTemp != null && dtTemp.Rows.Count > 0) { DateTime d_MdcStartDate, d_MdcEndDate, d_StAcceptDate; d_MdcEndDate = DateTime.Parse("9999/12/31"); d_MdcStartDate = (DateTime)dtTemp.Rows[0]["MDC_START_DATE"]; d_StAcceptDate = DateTime.Parse(SLP_SLPDate2_StAcceptDate.Text); if (dtTemp.Rows[0]["MDC_END_DATE"].ToString() != "") { d_MdcEndDate = (DateTime)dtTemp.Rows[0]["MDC_END_DATE"]; } // 2009-10-10 加上商品主檔 MDC日期有效日期判斷 if (d_StAcceptDate >= d_MdcStartDate && d_StAcceptDate <= d_MdcEndDate) { s_ITEM_NAME = dtTemp.Rows[0]["ITEM_NAME"].ToString(); s_ROOT_NO = dtTemp.Rows[0]["ROOT_NO"].ToString(); s_PMA = dtTemp.Rows[0]["PMA"].ToString(); s_PATTERN = dtTemp.Rows[0]["PATTERN_NO"].ToString(); ParameterList1.Clear(); ParameterList1.Add(s_PMA); ParameterList1.Add(s_ROOT_NO); DataTable dt2 = BCO2.QueryPMAForSLP(ParameterList1); if (dt2 != null && dt2.Rows.Count > 0) { s_PMA_NAME = dt2.Rows[0]["PMA_NAME"].ToString().Trim(); } } } //else //{ // s_ITEM_NAME = ""; // s_ROOT_NO = ""; // s_PMA = ""; // s_PATTERN = ""; // s_PMA_NAME = ""; //} } catch (Exception ex) { throw ex; } #endregion }
/// <summary> /// 根據傳入參數取得商品庫存 by PageMethod /// </summary> /// <param name="v_RootNo"></param> /// <param name="v_Item"></param> /// <param name="v_Period"></param> /// <param name="strUserID"></param> /// <param name="strPageTimeStamp"></param> private void GetStockByPageMethod(string v_RootNo, string v_Item, string v_Period, string strUserID, string strPageTimeStamp) { #region try { if (v_Item.Trim() == "" || v_Period.Trim() == "") { throw new Exception("輸入之品號、期別不完整"); } ArrayList ParameterList = new ArrayList(); if (v_RootNo.Trim() == "") { #region 依照品號取得所屬[群分類]、[大分類] ParameterList.Clear(); BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", v_Item, "=", "and"); BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB); DataTable dt_Return = bco_itm.QuerySKUByFind_1(ParameterList); if (dt_Return != null && dt_Return.Rows.Count != 0) { Session[string.Format("CRM041_s_PMA_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["PMA"].ToString();//大分類 Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)] = dt_Return.Rows[0]["ROOT_NO"].ToString();//群分類 v_RootNo = Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(); } bco_itm = null; dt_Return.Dispose(); #endregion } if (Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] == null) { ParameterList.Clear(); ParameterList.Add(v_RootNo); ParameterList.Add(v_Item); ParameterList.Add(v_Period); ParameterList.Add(strUserID); BCO_CRM.QueryCRMCommon BCO = new BCO_CRM.QueryCRMCommon(ConntionDB); Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] = BCO.QueryCRMItemPeriodStock(ParameterList); BCO.CloseConnection(); } } catch (Exception ex) { throw ex; } #endregion }
public string GetSKUVenderName(string Code, string RootNo, string PMA, string Category, string SortOut, string PatternNo, string Manufacture ) { string Name = ""; string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase; MaintainSKU co_main = new MaintainSKU(ConnectionDBStr); if (Code != "") { ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(Code); ParameterList.Add(RootNo); ParameterList.Add(PMA); ParameterList.Add(Category); ParameterList.Add(SortOut); ParameterList.Add(PatternNo); ParameterList.Add(Manufacture); DataTable dt = co_main.QueryVenderSLP(ParameterList); Name = ((dt.Rows.Count > 0) ? dt.Rows[0]["ITEM_NAME"].ToString() : "查無資料"); } return Name; }
private bool CheckPOSourceNO(ref string strErrMsg) { #region bool bResult = true; s_ChanNo = SLP_StoreChain1.Text; s_Store = SLP_Store2.Text; s_Item = SLP_SKU2.Text; s_Period = SLP_ItemPeriod1.Text; s_StAcceptDate = SLP_SLPDate2.Text; s_PoSourceNo = txt_POSourceNo.Text.Trim(); ArrayList ParameterList = new ArrayList();//20091113 ArrayList ParameterList1 = new ArrayList();//20091113 #region 比對是否 PK重複 #region 先比對頁面資料 DataTable dtTempMD = dtForMasterAndDetail; dtTempMD.PrimaryKey = new DataColumn[] { dtTempMD.Columns["chan_no"], dtTempMD.Columns["store"], dtTempMD.Columns["item"], dtTempMD.Columns["period"], dtTempMD.Columns["st_accept_date_show"], dtTempMD.Columns["data_source"] //,dtTempMD.Columns["po_source_no"] }; DataRow drFind_1 = dtTempMD.Rows.Find(new object[] { s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate, 1 //,s_PoSourceNo }); DataRow drFind_4 = dtTempMD.Rows.Find(new object[] { s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate, 4 //,s_PoSourceNo }); if (drFind_1 != null || drFind_4 != null) { //strErrMsg = string.Format("『PK重複,資料已存在於頁面(通路,門市,群分類,大分類,進貨日,PO單號)=({0},{1},{2},{3},{4},{5})。』", // s_ChanNo, s_Store, s_ROOT_NO, s_PMA, s_StAcceptDate, s_PoSourceNo); strErrMsg = string.Format("『PK重複,手動匯入或通路單號匯入資料已存在於頁面(通路,門市,品號,期別進貨日)=({0},{1},{2},{3},{4})。』", s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate); bResult = false; return bResult; } #endregion #region 比對待新增明細與實體資料庫 ALOModel.MaintainChainPO BCO = new ALOModel.MaintainChainPO(ConnectionDB); ParameterList1.Clear(); ParameterList1.Add(s_ChanNo); ParameterList1.Add(s_Store); ParameterList1.Add(s_Item); ParameterList1.Add(s_Period); ParameterList1.Add(s_StAcceptDate); ParameterList1.Add(s_PoSourceNo); bool bDataExist = BCO.CheckChainPODetlIsExistedByFind(ParameterList1); if (bDataExist) { strErrMsg = string.Format("『PK重複,資料已存在於實體資料表(通路,門市,品號,期別,進貨日,PO單號)=({0},{1},{2},{3},{4},{5})。』", s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate, s_PoSourceNo); bResult = false; return bResult; } #region 只檢查單店/品項/進貨日 ParameterList1.Clear(); ParameterList1.Add(s_ChanNo); ParameterList1.Add(s_Store); ParameterList1.Add(s_Item); ParameterList1.Add(s_Period); ParameterList1.Add(s_StAcceptDate); ParameterList1.Add(""); bDataExist = BCO.CheckChainPODetlIsExistedByFind(ParameterList1); if (bDataExist) { strErrMsg = string.Format("『PK重複,資料已存在於實體資料表(通路,門市,品號,期別,進貨日)=({0},{1},{2},{3},{4})。』", s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate); bResult = false; return bResult; } #endregion #endregion #endregion ALOModel.MaintainChainPOSetting BCO2 = new ALOModel.MaintainChainPOSetting(ConnectionDB); #region 依照品號取得所屬[群分類]、[大分類] ParameterList.Clear(); BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", s_Item, "=", "and"); BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConnectionDB); DataTable dt_Return = bco_itm.QuerySKUByFind_1(ParameterList); if (dt_Return != null && dt_Return.Rows.Count > 0) { s_PMA = dt_Return.Rows[0]["PMA"].ToString();//大分類 s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();//群分類 } #endregion #region 判斷 is_dis_bypo & is_multipo ParameterList1.Clear(); ParameterList1.Add(s_ChanNo); ParameterList1.Add(s_Store); DataTable dtChainPOSetting = BCO2.QueryStorPOSettingByFind(ParameterList1); if (dtChainPOSetting != null && dtChainPOSetting.Rows.Count > 0) { for (Int32 i = 0; i <= dtChainPOSetting.Rows.Count - 1; i++) { if (s_ROOT_NO == dtChainPOSetting.Rows[i]["root_no"].ToString().Trim() && s_PMA == dtChainPOSetting.Rows[i]["pma"].ToString().Trim()) { if (dtChainPOSetting.Rows[i]["is_dis_bypo"].ToString().Trim() == "0") { if (s_PoSourceNo != "")//1.當[IS_DIS_BYPO]=否時,PO單號應不可輸入。 { #region strErrMsg = string.Format("『(通路,門市,群分類,大分類)=({0},{1},{2},{3})時不可輸入通路單號。』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA); bResult = false; rfv_POSourceNo.Enabled = false; break; #endregion } } else if (dtChainPOSetting.Rows[i]["is_dis_bypo"].ToString().Trim() == "1") { if (s_PoSourceNo == "")//2.當[IS_DIS_BYPO]=是時,允許輸入PO單號為必填欄位,應不可為空白。 { #region strErrMsg = string.Format("『請輸入通路單號。』"); bResult = false; break; #endregion } if (dtChainPOSetting.Rows[i]["is_multipo"].ToString().Trim() == "0")//3.當[IS_DIS_BYPO]=是且[IS_MULTIPO]=否時,代表(同門市/品號期別/門市進貨日)下,只能輸入一個PO單號。 { #region if (bResult) { //20090716 modified if (!bDetailEditing)//如果不是編輯狀態 { //檢查頁面暫存檔 //DataTable dtTempMD = dtForMasterAndDetail; DataRow[] dRows = dtTempMD.Select(string.Format("chan_no='{0}' and store='{1}' and item='{2}' and period = '{3}' and st_accept_date_show='{4}' ", s_ChanNo, s_Store, s_Item, s_Period, s_StAcceptDate)); if (dRows.Length > 0) { strErrMsg = string.Format("『(通路,門市,群分類,大分類)=({0},{1},{2},{3})時,只能輸入一個PO單號』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA); bResult = false; } //檢查資料庫 ParameterList1.Clear(); ParameterList1.Add(s_ChanNo); ParameterList1.Add(s_Store); ParameterList1.Add(s_Item); ParameterList1.Add(s_Period); ParameterList1.Add(s_StAcceptDate); ParameterList1.Add(null); bool bTemp = BCO.CheckChainPODetlIsExistedByFind(ParameterList1); if (bTemp) { strErrMsg = string.Format("『(通路,門市,群分類,大分類,進貨日)=({0},{1},{2},{3},{4})時,只能輸入一個PO單號』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA, s_StAcceptDate); bResult = false; } } } #endregion } else if (dtChainPOSetting.Rows[i]["is_multipo"].ToString().Trim() == "1")//3.當[IS_DIS_BYPO]=是且[IS_MULTIPO]=是時,代表(同門市/品號期別/門市進貨日)下,允許多重PO。 { #region if (bResult) { ParameterList1.Clear(); ParameterList1.Add(s_ChanNo); ParameterList1.Add(s_Store); ParameterList1.Add(s_Item); ParameterList1.Add(s_Period); ParameterList1.Add(s_StAcceptDate); ParameterList1.Add(s_PoSourceNo); DataTable dtTempPoDetl = BCO.QueryChainPODetlByFind(ParameterList1); if (dtTempPoDetl != null && dtTempPoDetl.Rows.Count > 0) { for (Int32 j = 0; j <= dtTempPoDetl.Rows.Count - 1; j++) { if (dtTempPoDetl.Rows[j]["po_source_no"].ToString().Trim() != s_PoSourceNo) { strErrMsg = string.Format("『(通路,門市,群分類,大分類)=({0},{1},{2},{3})時不允許多重PO。』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA); bResult = false; break; } } } } #endregion } } } } } #endregion return bResult; #endregion }
/// <summary> ///1.目的:將上傳檔案內容,存入暫存檔 ///2.傳入參數:@處理檔名、@使用者 /// 回傳參數:@處理筆數、@正確筆數、@錯誤筆數、@錯誤訊息 ///3.處理表格:VDS_ALO_STORESPEC_TMP(T) ///4.處理邏輯: /// 4.1) 先清除前一次,同一使用者執行的匯入暫存資訊與錯誤資訊。 /// 相關Table:VDS_ALO_STORESPEC_TM /// 4.2) 讀取匯入檔案到暫存資料集。 /// 4.3) 檢查匯入檔案格式內容是否正確,如有任何錯誤,則停止上傳流程,並回傳錯誤訊息。 /// 『XX檔案,檔案內容錯誤:@錯誤說明』 (格式請參考資料庫Table Shcema) /// * 日期:檢查日期格式。 /// * 數字:檢查內容是否為數字。 /// * 文字:檢查長度是否溢位。 /// * 檔案欄位數是否不足。 /// * 檢查必填欄位是否有值:通路、店號、品號、數量、原因代碼、設定類別 /// * 工作表匯入內容有任一筆錯,皆視為錯誤,整批放棄。 /// * 匯入表格細節說明請參考:Excel文件 /// 4.4) 格式檢查正確無誤後 /// a) 暫存檔中的[狀態]欄位調整為1:FILE TO TMP /// b) 呼叫 [CheckData] ,檢查資料內容邏輯正確性 /// 4.5) 無論CheckData()檢查結果是否為True, /// 皆將上傳檔案內容新增到資料庫Tmp Table:, /// 並記錄錯誤原因、匯入者、匯入日期、處理檔案名稱=上傳檔名。 ///5. 回傳處理結果(@處理筆數、@正確筆數、@錯誤筆數、@錯誤訊息(無錯誤時=null) ) /// </summary> public ArrayList FileToTmp(DataSet ds_Excel, DateTime d_CreateDate, string s_LoginUser, string s_AP_FileName, string strST_ACCEPT_DATE, string V_SESSION_ID) { #region int i_newTable_Count = 0; ArrayList arl_Return = new ArrayList(); ArrayList arr_CheckData_Table = new ArrayList(); ArrayList arr_CheckData = new ArrayList(); int i_FileToTemp_Total_count = 0; int i_FileToTemp_Right_count = 0; int i_FileToTemp_Wrong_count = 0; bool b_Check_Logic = true; ArrayList paramTemp = new ArrayList(); DataTable dtTemp = new DataTable(); string strErrMsg = ""; string strErrMsgDataFormat = ""; Int32 iErrCount = 0; Int32 iPKCount = 0; try { ParameterList.Clear(); DataTable dt_ALO_IMPORT_TMP = QuerySwitch(QueryType.GetPOSOURCE_NO_TmpSchema, ParameterList); VDS_ALO_POSOURCE_NO_TMP_DBO ALO_POSOURCE_NO_TMP = new VDS_ALO_POSOURCE_NO_TMP_DBO(ref USEDB); MaintainStoreOrderItem ALOM = new MaintainStoreOrderItem(ConnectionDB); MaintainChainPO BCO = new MaintainChainPO(ConnectionDB); MaintainChainPOSetting BCO2 = new MaintainChainPOSetting(ConnectionDB); string s_ROOT_NO = ""; string s_PMA = ""; string s_ChanNo = ""; string s_Store = ""; string s_Item = ""; string s_Period = ""; string s_StAcceptDate = ""; string s_PoSourceNo = ""; bool bResultMultiPO = true; //20090626 added VDS_ALO_POSOURCE_NO_TMP_DBO DBO = new VDS_ALO_POSOURCE_NO_TMP_DBO(ref USEDB); ParameterList2.Clear(); ParameterList2.Add(s_LoginUser); ParameterList2.Add(V_SESSION_ID); DBO.doDelete_POSOURCE_NO_TMP(ParameterList2, null); foreach (System.Data.DataRow dRow in ds_Excel.Tables[0].Rows) { #region iErrCount = 0; iPKCount = 0; strErrMsg = ""; s_ROOT_NO = ""; s_PMA = ""; s_ChanNo = dRow[1].ToString().Trim(); s_Store = dRow[2].ToString().Trim(); s_Item = dRow[3].ToString().Trim(); s_Period = dRow[4].ToString().Trim(); s_StAcceptDate = strST_ACCEPT_DATE; s_PoSourceNo = dRow[0].ToString().Trim(); bResultMultiPO = true; if (!CheckRequiredField(dRow, iAryRequiredColumnsCheck, out strErrMsgDataFormat))//檢查必填欄位 { #region 檢查資料格式正確性 arl_Return.Add("FALSE"); arl_Return.Add(strErrMsgDataFormat); return arl_Return; } else if (!CheckOverFlow(dRow, iAryOverflowColumnsCheck, out strErrMsgDataFormat))//檢查是否為溢位 { arl_Return.Add("FALSE"); arl_Return.Add(strErrMsgDataFormat); return arl_Return; } else if (!CheckInputValueIsInt32(dRow, iAryRequiredColumnsCheck, out strErrMsgDataFormat))//檢查是否為數值 { arl_Return.Add("FALSE"); arl_Return.Add(strErrMsgDataFormat); return arl_Return; #endregion } else { #region 檢查資料邏輯正確性 #region 將資料寫入 TEMP TABLE DataRow dRow_Temp = dt_ALO_IMPORT_TMP.NewRow(); dRow_Temp["CREATEDATE"] = d_CreateDate; dRow_Temp["CREATEUID"] = s_LoginUser; dRow_Temp["ID"] = i_newTable_Count; dRow_Temp["UPDATEDATE"] = d_CreateDate; dRow_Temp["UPDATEUID"] = s_LoginUser; dRow_Temp["CHAN_NO"] = dRow[1].ToString().Trim(); dRow_Temp["STORE"] = dRow[2].ToString().Trim(); dRow_Temp["ITEM"] = dRow[3].ToString().Trim(); dRow_Temp["PERIOD"] = dRow[4].ToString().Trim(); dRow_Temp["PO_SOURCE_NO"] = dRow[0].ToString().Trim(); dRow_Temp["ST_ACCEPT_DATE"] = strST_ACCEPT_DATE; dRow_Temp["SESSION_ID"] = V_SESSION_ID; //------------------------------------- #endregion #region 4.1 驗證新增資料之主檔欄位正確性。 paramTemp.Clear(); paramTemp.Add(dRow[1].ToString().Trim()); paramTemp.Add(dRow[2].ToString().Trim()); paramTemp.Add(dRow[3].ToString().Trim()); paramTemp.Add(dRow[4].ToString().Trim()); DataTable dtCheckMaster = ALO_POSOURCE_NO_TMP.doCheckCurrentMasterStatus(paramTemp); if (dtCheckMaster.Rows[0][0].ToString().Trim() != "1") { strErrMsg += dtCheckMaster.Rows[0][1].ToString().Trim(); } #endregion #region 4.2 驗證主檔是否不存在對應通路,且Type_No=2 (By單店/單項)之資料[@C_1]。 paramTemp.Clear(); paramTemp.Add(s_LoginUser); DataTable dtCheckException = ALO_POSOURCE_NO_TMP.doCheckExceptionChanStatus(paramTemp); if (!(dtCheckException == null || dtCheckException.Rows.Count <= 0)) { strErrMsg += "通路單號主檔未建立,"; } #endregion #region 4.3 檢查是否有PK重複之資料 //a) 檢查暫存檔本身是否有PK重複資料 //b) 檢查與正式表單有是否有PK重複資料 paramTemp.Clear(); paramTemp.Add(dRow[1].ToString().Trim()); paramTemp.Add(dRow[2].ToString().Trim()); paramTemp.Add(dRow[3].ToString().Trim()); paramTemp.Add(dRow[4].ToString().Trim()); paramTemp.Add(strST_ACCEPT_DATE); paramTemp.Add(s_LoginUser); paramTemp.Add(V_SESSION_ID); for (Int32 x = 0; x <= ds_Excel.Tables[0].Rows.Count - 1; x++) { if (s_Store == ds_Excel.Tables[0].Rows[x][2].ToString().Trim() && s_Item == ds_Excel.Tables[0].Rows[x][3].ToString().Trim() && s_Period == ds_Excel.Tables[0].Rows[x][4].ToString().Trim() && s_StAcceptDate == strST_ACCEPT_DATE && s_PoSourceNo == ds_Excel.Tables[0].Rows[x][0].ToString().Trim()) { iPKCount++; } if (iPKCount > 1) { strErrMsg += "匯入檔中(同進貨日/門市/品號/期別/PO單)不可重複,"; break; } } DataTable dtCheckPKConflict = ALO_POSOURCE_NO_TMP.doCheckPOSourcePKConflict(paramTemp); if (dtCheckPKConflict != null && dtCheckPKConflict.Rows.Count > 0) { if (dtCheckPKConflict.Rows[0][0].ToString().Trim() != "0") { strErrMsg += "匯入檔中(同進貨日/門市/品號/期別/PO單)不可重複,"; break; } if (dtCheckPKConflict.Rows[0][1].ToString().Trim() != "0") { strErrMsg += "與通路單號明細檔(同進貨日/門市/品號/期別/PO單)PK重複,"; } } #endregion #region 4.4 通路PO控制檔檢查 #region 依照品號取得所屬[群分類]、[大分類] paramTemp.Clear(); BCO_ITM.SQLHelper.SQLWhere(ref paramTemp, DbType.String, "MA.ITEM", s_Item, "=", "and"); BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConnectionDB); DataTable dt_Return = bco_itm.QuerySKUByFind_1(paramTemp); if (dt_Return != null && dt_Return.Rows.Count != 0) { s_PMA = dt_Return.Rows[0]["PMA"].ToString();//大分類 s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();//群分類 } #endregion #region 判斷 is_dis_bypo & is_multipo paramTemp.Clear(); paramTemp.Add(s_ChanNo); paramTemp.Add(s_Store); DataTable dtTempPOSetting = BCO2.QueryStorPOSettingByFind(paramTemp); if (dtTempPOSetting != null && dtTempPOSetting.Rows.Count > 0) { for (Int32 i = 0; i <= dtTempPOSetting.Rows.Count - 1; i++) { if (s_ROOT_NO == dtTempPOSetting.Rows[i]["root_no"].ToString().Trim() && s_PMA == dtTempPOSetting.Rows[i]["pma"].ToString().Trim()) { if (dtTempPOSetting.Rows[i]["is_dis_bypo"].ToString().Trim() == "0") { //1.IS_DIS_BYPO=否者 //=>代表該通路(或該門市)在某一[群分類+大分類]設定下的品項,不可帶入通路PO單號 if (s_PoSourceNo != "") { #region strErrMsg += string.Format("(通路,門市,群分類,大分類)=({0},{1},{2},{3})不可匯入通路單號", s_ChanNo, s_Store, s_ROOT_NO, s_PMA); break; #endregion } } else if (dtTempPOSetting.Rows[i]["is_dis_bypo"].ToString().Trim() == "1" && dtTempPOSetting.Rows[i]["is_multipo"].ToString().Trim() == "0") { //2.IS_DIS_BYPO=是,且IS_MULTIPO=否者 //=>代表該通路(或該門市)在某一[群分類+大分類]設定下的品項,一定要帶入通路PO單號, //但同門市、同進貨日、同品號、同期別的狀況下,不允許有不同PO單號 #region for (Int32 x = 0; x <= ds_Excel.Tables[0].Rows.Count - 1; x++) { if (s_Store == ds_Excel.Tables[0].Rows[x][2].ToString().Trim() && s_Item == ds_Excel.Tables[0].Rows[x][3].ToString().Trim() && s_Period == ds_Excel.Tables[0].Rows[x][4].ToString().Trim() && s_StAcceptDate == strST_ACCEPT_DATE && s_PoSourceNo != ds_Excel.Tables[0].Rows[x][0].ToString().Trim()) { iPKCount++; } if (iPKCount >= 1) { strErrMsg = string.Format("『(通路,門市,群分類,大分類)=({0},{1},{2},{3})時不允許多重PO。』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA); bResultMultiPO = false; break; } } #endregion #region if (bResultMultiPO) { paramTemp.Clear(); paramTemp.Add(s_ChanNo); paramTemp.Add(s_Store); paramTemp.Add(s_Item); paramTemp.Add(s_Period); paramTemp.Add(s_StAcceptDate); paramTemp.Add(null); DataTable dtTempPoDetl = BCO.QueryChainPODetlByFind(paramTemp); if (dtTempPoDetl != null && dtTempPoDetl.Rows.Count > 0) { for (Int32 j = 0; j <= dtTempPoDetl.Rows.Count - 1; j++) { if (dtTempPoDetl.Rows[j]["po_source_no"].ToString().Trim() != s_PoSourceNo) { strErrMsg = string.Format("『(通路,門市,群分類,大分類)=({0},{1},{2},{3})時不允許多重PO。』", s_ChanNo, s_Store, s_ROOT_NO, s_PMA); break; } } } } #endregion } } } } #endregion #endregion #region 4.5 針對MEMO是否為空字串做檢查 if (strErrMsg.Trim() == string.Empty) { dRow_Temp["MEMO"] = System.DBNull.Value; dRow_Temp["DATASOURCE"] = s_AP_FileName; } else { if (strErrMsg.Trim().Length > 0) { if (strErrMsg.Trim().Substring(strErrMsg.Trim().Length - 1) == ",") { strErrMsg = strErrMsg.Trim().Substring(0, strErrMsg.Trim().Length - 1); } } dRow_Temp["MEMO"] = strErrMsg; dRow_Temp["DATASOURCE"] = s_AP_FileName; iErrCount++; } if (iErrCount != 0) { i_FileToTemp_Wrong_count += 1; dRow_Temp["DATATYPE"] = 2; b_Check_Logic = false; } else { i_FileToTemp_Right_count += 1; dRow_Temp["DATATYPE"] = 1; } #endregion dt_ALO_IMPORT_TMP.Rows.Add(dRow_Temp); i_newTable_Count += 1; #endregion } i_FileToTemp_Total_count += 1; #endregion } #region 先清除前一次,同一使用者執行的匯入暫存資訊與錯誤資訊,並將 Excel 資料匯入 TEMP TABLE ParameterList.Clear(); ParameterList.Add(s_LoginUser); ParameterList.Add(V_SESSION_ID); DELETE_AND_INSERT_TEMP_TABLE(ParameterList, null, dt_ALO_IMPORT_TMP); #endregion arl_Return.Add("TRUE"); arl_Return.Add(b_Check_Logic); arl_Return.Add(i_FileToTemp_Total_count); arl_Return.Add(i_FileToTemp_Right_count); arl_Return.Add(i_FileToTemp_Wrong_count); } catch (Exception ex) { arl_Return.Add("FALSE"); arl_Return.Add(GetNewException(ex).Message); } return arl_Return; #endregion }
/// <summary> /// DOWN BUTTON 更新鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but_down_Update_Click(object sender, EventArgs e) { try { System.Text.StringBuilder sb = new System.Text.StringBuilder(); TextBox txt_down_ITEM = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxCode");//品號 TextBox txt_down_ITEM_NAME = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxName");//品名 TextBox txt_down_REQUEST_QTY = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxCode");//訂貨量 TextBox txt_down_REQUEST_QTY_NAME = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxName");//訂貨量名稱 TextBox txt_down_RTN_DDL = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("TextBoxCode");//退書截止日 CheckBox chk_down_IS_OVERDUE = (CheckBox)((ASP.wui_slp_slp_boolean_ascx)slp_down_IS_OVERDUE).FindControl("C1");//逾期客訂 //string SessionIDName = "CRM041_dt_Detail" + PageTimeStamp.Value; //if (Session[SessionIDName] != null) dt_Detail = (DataTable)Session[SessionIDName]; if (this.hid_PageStatus.Value == "INSERT" || this.hid_PageStatus.Value == "EDIT") { s_PMA = string.Empty; s_ROOT_NO = string.Empty; string s_Is_PO = string.Empty; sb.Remove(0, sb.Length); DataTable dt_Return = new DataTable(); ArrayList ParameterList = new ArrayList();//20091117 #region 依照品號取得所屬[群分類]、[大分類] ParameterList.Clear(); BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", this.slp_down_ITEM.Text, "=", "and"); BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB); dt_Return = bco_itm.QuerySKUByFind_1(ParameterList); if (dt_Return != null && dt_Return.Rows.Count != 0) { s_PMA = dt_Return.Rows[0]["PMA"].ToString();//大分類 s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();//群分類 } #endregion #region 判斷PO單號 //確定PO單號存在 GetChainPOSetting(this.slp_up_CHAN_NO.Text, this.slp_up_STORE.Text); DataView dvChainPOSetting = new DataView(dtChainPOSetting.Copy()); dvChainPOSetting.RowFilter = "PMA = '" + s_PMA + "' and ROOT_NO = '" + s_ROOT_NO + "'"; if (dvChainPOSetting.Count > 0) { if (dvChainPOSetting[0]["IS_DIS_BYPO"].ToString() == "1")//代表是依PO分單 { s_Is_PO = "TRUE"; } else if (dvChainPOSetting[0]["IS_DIS_BYPO"].ToString() == "0")//代表不是依PO分單 { s_Is_PO = "FALSE"; } // 2009-08-12 cyhsu add if (this.slp_up_CHAN_NO.Text == "CB" && s_ROOT_NO == "1") { //當通路=誠品, 群分類=雜誌時,不管通路設定檔設定為何,都先規定要輸入PO單號 s_Is_PO = "TRUE"; } } //s_Is_PO = TRUE 代表是依PO分單>>[PO單號]欄位一定要填 //s_Is_PO = FALSE 代表不是依PO分單>>[PO單號]欄位一定不能填 //s_Is_PO = NULL 代表是依PO分單>>[PO單號]欄位可填可不填 if (s_Is_PO == "TRUE") { if (this.txt_down_PO_SOURCE_NO.Text.ToString().Length == 0) //if (this.txt_down_PO_SOURCE_NO.Text.Trim() == string.Empty) { sb.Append("PO單號不可空白"); } } else if (s_Is_PO == "FALSE") { if (this.txt_down_PO_SOURCE_NO.Text.Trim() != string.Empty) { sb.Append("PO單號不可有值"); } } if (GetStringLen(txt_down_PO_SOURCE_NO.Text.Trim()) > 20) { sb.Append("PO單號欄位輸入資料過長"); } if (sb.ToString() != string.Empty) { ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + this.txt_down_PO_SOURCE_NO.ClientID + "'].focus();", true); return; } #endregion #region 判斷一段碼、二段碼是否屬於該品號、期別 ParameterList.Clear(); ParameterList.Add(this.slp_down_ITEM.Text); // ITEM ParameterList.Add(this.txt_down_PERIOD.Text); // PERIOD ParameterList.Add(this.txt_down_BARCODE.Text); // 一段碼 ParameterList.Add(this.txt_down_PERIOD_BARCODE.Text); // 二段碼 ParameterList.Add(Session["UID"].ToString()); BCO.QueryCRMCommon co_common = new BCO.QueryCRMCommon(ConntionDB); bool b_CheckRes; b_CheckRes = co_common.CheckItemPeriodBarcode(ParameterList); if (!b_CheckRes) { sb.Remove(0, sb.Length); sb.AppendFormat("一段碼[{2}]、二段碼[{3}]不屬於品號[{0}]、期別[{1}]!", this.slp_down_ITEM.Text, this.txt_down_PERIOD.Text, this.txt_down_BARCODE.Text, this.txt_down_PERIOD_BARCODE.Text); } if (sb.ToString() != string.Empty) { ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + this.txt_down_PO_SOURCE_NO.ClientID + "'].focus();", true); return; } #endregion #region 檢查是否可新增 bool bCheck = CheckOrderDetail(this.slp_down_ITEM.Text, this.txt_down_PERIOD.Text); if (!bCheck && hid_ID.Value == string.Empty) { sb.Remove(0, sb.Length); sb.AppendFormat("品號[{0}]、期別[{1}]已存在,不可重複新增!", this.slp_down_ITEM.Text, this.txt_down_PERIOD.Text); } if (sb.ToString() != string.Empty) { ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + txt_down_ITEM.ClientID + "'].focus();", true); return; } string sCheck = CheckCanUpdate(s_CHAN_NO, s_STORE, this.slp_down_ITEM.Text, this.txt_down_PERIOD.Text, txt_down_RTN_DDL.Text, this.txt_up_CODE.Text); if (sCheck != string.Empty) { ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sCheck + "');document.all['" + txt_down_ITEM.ClientID + "'].focus();", true); return; } #endregion // 為了解決頁面儲區空白的問題先暫時設定睡眠對應。 for (int i = 0; i < 10; i++) { if (this.txt_down_RECOMMAND_LOCATION.Text != String.Empty) { break; } System.Threading.Thread.Sleep(500); } #region 更新明細暫存資訊 #region 新增狀態,若是第一筆資料,建立 TEMP TABLE if (this.hid_PageStatus.Value == "INSERT" && hid_ID.Value == string.Empty) { if (dt_Detail == null) { DataTable dtTmp = new DataTable(); ParameterList.Clear(); ParameterList.Add(Session["UID"].ToString()); BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB); dtTmp = bco.QUERY_CRM041_DETL_SCHEMA(ParameterList); DataColumn dcol1 = new DataColumn("BARCODE", System.Type.GetType("System.String"));//一段碼 DataColumn dcol2 = new DataColumn("PERIOD_BARCODE", System.Type.GetType("System.String"));//二段碼 DataColumn dcol3 = new DataColumn("ITEM_NAME", System.Type.GetType("System.String"));//品名 DataColumn dcol4 = new DataColumn("COLUMN_STATUS", System.Type.GetType("System.String"));//欄位狀態 dtTmp.Columns.Add(dcol1); dtTmp.Columns.Add(dcol2); dtTmp.Columns.Add(dcol3); dtTmp.Columns.Add(dcol4); dt_Detail = dtTmp.Copy(); dtTmp.Dispose(); } } #endregion if ((this.hid_PageStatus.Value == "INSERT" || this.hid_PageStatus.Value == "EDIT") && this.hid_ID.Value == string.Empty) { DataRow dRow = dt_Detail.NewRow(); if (dt_Detail.Rows.Count == 0) { dRow["ID"] = 0; } else { DataView dv_Detail = new DataView(dt_Detail.Copy()); dv_Detail.Sort = "ID ASC"; dRow["ID"] = int.Parse(dv_Detail[0]["ID"].ToString()) + 1; } dRow["ROOT_NO"] = s_ROOT_NO;//群分類 dRow["PMA"] = s_PMA;//大分類 dRow["PO_SOURCE_NO"] = this.txt_down_PO_SOURCE_NO.Text.Trim();//PO單號 dRow["BARCODE"] = this.txt_down_BARCODE.Text.Trim();//一段碼 dRow["PERIOD_BARCODE"] = this.txt_down_PERIOD_BARCODE.Text.Trim();//二段碼 dRow["ITEM"] = this.slp_down_ITEM.Text.Trim();//品號 dRow["ITEM_NAME"] = this.slp_down_ITEM.Name.Trim();//品名 //dRow["ITEM_NAME"] = ((TextBox)this.slp_down_ITEM.Controls[1].FindControl("TextBoxName")).Text.Trim();//品名 dRow["PERIOD"] = this.txt_down_PERIOD.Text.Trim();//期別 dRow["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量 dRow["RTN_DDL"] = DateTime.ParseExact(this.slp_down_RTN_DDL.Text.Trim(), "yyyy/MM/dd", null);//退書截止日 b_IS_OVERDUE = CheckIsOverDue(this.slp_down_RTN_DDL.Text.Trim()); if (b_IS_OVERDUE == true) { dRow["IS_OVERDUE"] = 1; }//逾期客訂有被勾選 else { dRow["IS_OVERDUE"] = 0; }//逾期客訂沒有被勾選 // todo cyhsu: 找外雜 Locate_type 與 locate_no 沒有設定的原因 if ((s_SRC_LOCATE_TYPE == String.Empty) && (s_ROOT_NO == "1") && ((s_PMA == "13") || (s_PMA == "14") || (s_PMA == "15") || (s_PMA == "16"))) { s_SRC_LOCATE_TYPE = "2"; this.txt_down_RECOMMAND_LOCATION.Text = "D"; } dRow["SRC_LOCATE_TYPE"] = s_SRC_LOCATE_TYPE;//建議儲區 dRow["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區 dRow["PROC_DESC"] = 0;//處理狀態(0代表未擷轉) dRow["STATUS"] = 25;//結案狀態(25代表未結案,75代表已結案) dRow["DIS_ENABLE"] = int.Parse(this.hid_DIS_ENABLE.Value);//可配量 dt_Detail.Rows.Add(dRow); } else if ((this.hid_PageStatus.Value == "INSERT" || this.hid_PageStatus.Value == "EDIT") && this.hid_ID.Value != string.Empty) { //2009-02-04 cyhsu change DataTable dtTmp = dt_Detail.Copy(); //string s_FilterExpression = string.Empty; //s_FilterExpression = "ID = " + this.hid_ID.Value; //DataRow dRow = dt_Detail.Select(s_FilterExpression)[0]; //dRow["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量 //dRow["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區 int i_index = -1; for (int i = 0; i < dtTmp.Rows.Count; i++) { if (dtTmp.Rows[i]["ID"].ToString() == this.hid_ID.Value) { i_index = i; break; } } if (i_index > -1) { dt_Detail.Rows[i_index]["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量 dt_Detail.Rows[i_index]["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區 dt_Detail.Rows[i_index]["PO_SOURCE_NO"] = this.txt_down_PO_SOURCE_NO.Text.Trim();//建議儲區; } } this.gv_Detail.DataSource = dt_Detail; this.gv_Detail.PageSize = 10; this.gv_Detail.PageIndex = 0; this.gv_Detail.DataBind(); Panel1.Height = gv_Detail.Rows.Count * 45 + 60; //Session[SessionIDName] = dt_Detail; #region 清空 hid_ID,hid_DIS_ENABLE //this.hid_ID.Value = string.Empty;是否不應清空?2009-06-04 cyhsu this.hid_DIS_ENABLE.Value = string.Empty; #endregion #region 清空靜態變數 dtStock = null;//異動欄位[期別] s_PMA = string.Empty;//大分類(異動欄位[品號/品名]) s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名]) s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量]) #endregion #region 設定畫面狀態 sb.Remove(0, sb.Length); sb.Append("新增或編輯模式按下明細區[更新]鈕<partition>"); sb.Append(dt_Detail.Rows.Count.ToString() + "<partition>");//dt_Detail筆數 sb.Append(this.panel_Middle.ClientID + "<partition>");//panel_Middle sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號 sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號 sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名 sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別 sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量 sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱 sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區 ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "but_down_Update_Click('" + sb.ToString() + "');", true); #endregion #endregion } } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } finally { } }
}//page_load /// <summary> /// 繫結資料到控制項 /// </summary> /// <param name="vdb">0:查詢鈕,1:匯出鈕</param> private void databind(char src) { //抓取本頁初次登記的時間 string SessionIDName = "ITM011_" + PageTimeStamp.Value; MaintainSKU BCO = new MaintainSKU(ConntionDB); DataTable Dt = BCO.QuerySKUByFind_2(ParameterList, src); DataTable dt = Dt.Copy(); //複製成另一份,因匯出時有將ID及Enable欄位移除 Session["ITM01" + PageTimeStamp.Value] = dt; DataTable dtTemp = Dt.DefaultView.ToTable("TempTable", true, "ID", "ITEM", "ITEM_NAME", "MANUFACTURE", "PATTERN_NO"); Session["ITM011_" + PageTimeStamp.Value] = dtTemp; if (src == '0') { ViewState["SortField"] = null; GridView1.DataSource = dtTemp; //設定分頁大小 GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); #region 將Key值存到Session中 ArrayList arl_Key = new ArrayList(); foreach (DataRow drRow in Dt.Rows) { arl_Key.Add(drRow["ID"].ToString()); } Session["ITM011_SortKey" + PageTimeStamp.Value] = arl_Key; } #endregion }//databind
public SLP_SKU_Vender() { co_main = new MaintainSKU(ConntionDB); }
public static string GetSKUItemByID(string ItemId) { try { ITMModel.MaintainSKU SKUProc = new ITMModel.MaintainSKU(ConnectionDB); #region 輸入變數 ArrayList ParameterList = new ArrayList();//20091113 ParameterList.Clear(); //品號 ParameterList.Add(ItemId); #endregion DataTable Dt = SKUProc.QuerySKUByCode(ParameterList); if (Dt.Rows.Count == 0) //無資料 { return "查無資料"; } else { return Dt.Rows[0]["ITEM_NAME"].ToString(); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 依配本方式('101','103','104')取得預設參照資訊 /// dtParam(配本參數方式)、dtDisItem(配本商品)、V_DIS_TYPE、V_ITEM、V_PERIOD、I_ITEM_REFER_COUNT /// </summary> /// <param name="dtParam">配本參數方式</param> /// <param name="B1_PERIOD">前一期銷售實績</param> /// <param name="B2_PERIOD">前二期銷售實績</param> /// <param name="B3_PERIOD">前三期銷售實績</param> /// <param name="B4_PERIOD">前四期銷售實績</param> /// <param name="B5_PERIOD">前五期銷售實績</param> /// <param name="B6_PERIOD">前六期銷售實績</param> /// <param name="V_DIS_TYPE">配本方式</param> /// <param name="V_ITEM">品號</param> /// <param name="V_PERIOD">期別</param> /// <param name="I_ITEM_REFER_COUNT">設定品項參照數</param> /// <returns>dtDisItemRefer</returns> public DataTable QueryDisItemReferByDisType(DataTable dtParam, string B1_PERIOD, string B2_PERIOD, string B3_PERIOD, string B4_PERIOD, string B5_PERIOD, string B6_PERIOD, string V_DIS_TYPE, string V_ITEM, string V_PERIOD, Int32 I_ITEM_REFER_COUNT ) { #region #region Variables Int32 iSelect_Period; //往前取前幾期 Int32 iSelect_P_From; //往前取前幾期From Int32 iSelect_P_To; //往前取前幾期To string vOrderBy = ""; //排序方式 string vPeriod_S = ""; //期別起 string vPeriod_E = ""; //期別迄 string vITEM_NAME = ""; DataTable dtItemSales = null; MaintainDisItemRefer BCODIR = new MaintainDisItemRefer(ConnectionDB); DataTable dtDisItemRefer = BCODIR.GetDisItemReferSchema(); ArrayList Paramslist = new ArrayList(); DataRow nRow = null; Int32 iStAcceptQty = 0; Int32 iBackwardQty = 0; Int32 iFoundCount = 0; Int32 iPeriod_S = 0; //期別起 Int32 iPeriod_E = 0; //期別迄 Int32 iPERIOD = 0; Int32 iRowCnt = 0; Int32[] i32AryPeriod = null; string sB1_Period = ""; //前1期期別 string sB2_Period = ""; //前2期期別 string sB3_Period = ""; //前3期期別 string sB4_Period = ""; //前4期期別 string sB5_Period = ""; //前5期期別 string sB6_Period = ""; //前6期期別 Int32 iB1_Period = 0; //前1期期別 Int32 iB2_Period = 0; //前2期期別 Int32 iB3_Period = 0; //前3期期別 Int32 iB4_Period = 0; //前4期期別 Int32 iB5_Period = 0; //前5期期別 Int32 iB6_Period = 0; //前6期期別 int SubQty = 0; Decimal REAL_SALESRATE = 0; Decimal REAL_SALESRATE_Sum = 0; #endregion try { #region //4.1) 判斷配本方式 if (!(V_DIS_TYPE == "101" || V_DIS_TYPE == "103" || V_DIS_TYPE == "104")) { //停止處理流程,離開此涵式 //不視為Exception; return dtDisItemRefer; } //4.2) 取得基本資料與配本參數 MaintainDisParameter BCO1 = new MaintainDisParameter(ConnectionDB); QueryALOCommon BCO2 = new QueryALOCommon(ConnectionDB); ITMModel.MaintainSKU BCO3 = new ITMModel.MaintainSKU(ConnectionDB); Paramslist.Clear(); Paramslist.Add(V_ITEM); DataTable dt = BCO3.QuerySKUByCode(Paramslist); if (dt != null && dt.Rows.Count > 0) { vITEM_NAME = dt.Rows[0]["ITEM_NAME"].ToString(); } //a) 取得配本參數資料 if (dtParam == null || dtParam.Rows.Count == 0) { //重取配本方式參數 Paramslist.Clear(); Paramslist.Add(V_DIS_TYPE); Paramslist.Add(1); dtParam = BCO1.QuerySwitch(QueryType.CODE, Paramslist); } if (dtParam == null || dtParam.Rows.Count == 0) { //顯示錯誤訊息『無此配本方式:V_DIS_TYPE』於訊息區; throw new Exception(string.Format("無此配本方式:{0}", V_DIS_TYPE)); } //b) 取得配本參數資料 Int32.TryParse(dtParam.Rows[0]["SELECT_PERIOD"].ToString().Trim(), out iSelect_Period); //往前取前幾期 Int32.TryParse(dtParam.Rows[0]["SELECT_P_FROM"].ToString().Trim(), out iSelect_P_From); //往前取前幾期From Int32.TryParse(dtParam.Rows[0]["SELECT_P_TO"].ToString().Trim(), out iSelect_P_To); //往前取前幾期To //b) 取得配本商品資料 //DataRow[] ItemRow = dtDisItem.Select("ITEM='" + V_ITEM + "' and PERIOD='" + V_PERIOD + "' "); //取得品項數 if (I_ITEM_REFER_COUNT == 0) { I_ITEM_REFER_COUNT = BCO2.GetDisItemReferCount(dtParam); } if (I_ITEM_REFER_COUNT == 0) { //顯示錯誤訊息『參照品項數=0』於訊息區; throw new Exception("參照品項數=0"); } //c) 取得排序方式 vOrderBy = ""; if (dtParam.Rows[0]["SORT_KEY1"].ToString() != "") { vOrderBy += dtParam.Rows[0]["SORT_KEY1"].ToString() + ","; } if (dtParam.Rows[0]["SORT_KEY2"].ToString() != "") { vOrderBy += dtParam.Rows[0]["SORT_KEY2"].ToString() + ","; } if (dtParam.Rows[0]["SORT_KEY3"].ToString() != "") { vOrderBy += dtParam.Rows[0]["SORT_KEY3"].ToString() + ","; } //# 去掉最後一個逗號 "," if (vOrderBy.Trim().Length > 0) { if (vOrderBy.Substring(vOrderBy.Length - 1, 1) == ",") { vOrderBy = vOrderBy.Substring(0, vOrderBy.Length - 1); } } //4.3) 依照配本方式設定設定不同計算期別 switch (V_DIS_TYPE) { case "101"://a) V_DIS_TYPE = 101 (前期比例)時 #region 前期比例 switch (iSelect_Period) { case 1: vPeriod_S = B1_PERIOD; break; case 2: vPeriod_S = B2_PERIOD; break; case 3: vPeriod_S = B3_PERIOD; break; case 4: vPeriod_S = B4_PERIOD; break; case 5: vPeriod_S = B5_PERIOD; break; case 6: vPeriod_S = B6_PERIOD; break; default: throw new Exception("期別起無資料!"); break; } vPeriod_E = vPeriod_S; #endregion break; case "103"://b) V_DIS_TYPE = 103 (實績加重) 或 104 (移行指數)時 case "104": #region 移行指數 switch (iSelect_P_From) { case 1: vPeriod_E = B1_PERIOD; break; case 2: vPeriod_E = B2_PERIOD; break; case 3: vPeriod_E = B3_PERIOD; break; case 4: vPeriod_E = B4_PERIOD; break; case 5: vPeriod_E = B5_PERIOD; break; case 6: vPeriod_E = B6_PERIOD; break; default: throw new Exception("往前取前幾期From無資料!"); break; } switch (iSelect_P_To) { case 1: vPeriod_S = B1_PERIOD; break; case 2: vPeriod_S = B2_PERIOD; break; case 3: vPeriod_S = B3_PERIOD; break; case 4: vPeriod_S = B4_PERIOD; break; case 5: vPeriod_S = B5_PERIOD; break; case 6: vPeriod_S = B6_PERIOD; break; default: throw new Exception("往前取前幾期To無資料!"); } #endregion break; } //c) 取得前幾期銷售實績 Paramslist.Clear(); Paramslist.Add(V_ITEM == "" ? null : V_ITEM); Paramslist.Add(vPeriod_S == "" ? null : vPeriod_S); Paramslist.Add(vPeriod_E == "" ? null : vPeriod_E); Paramslist.Add(vOrderBy == "" ? null : vOrderBy); dtItemSales = BCO2.QueryP6_PeriodSalesInfo(Paramslist); //4.4) 依照不同配本方式,取得新增參照商品資料 Int32.TryParse(vPeriod_S, out iPeriod_S); Int32.TryParse(vPeriod_E, out iPeriod_E); sB1_Period = B1_PERIOD; sB2_Period = B2_PERIOD; sB3_Period = B3_PERIOD; sB4_Period = B4_PERIOD; sB5_Period = B5_PERIOD; sB6_Period = B6_PERIOD; Int32.TryParse(sB1_Period, out iB1_Period); Int32.TryParse(sB2_Period, out iB2_Period); Int32.TryParse(sB3_Period, out iB3_Period); Int32.TryParse(sB4_Period, out iB4_Period); Int32.TryParse(sB5_Period, out iB5_Period); Int32.TryParse(sB6_Period, out iB6_Period); #endregion switch (V_DIS_TYPE) { case "101"://a) V_DIS_TYPE = 101 (前期比例)時 (vPeriod_S=vPeriod_E=前一期:P_B1) #region if (sB1_Period == "" || sB1_Period == null) { //* 前一期資料不存在時,設定訊息『新品無前期發行資訊』於訊息區。 throw new Exception("新品無前期發行資訊"); } if (dtItemSales.Rows.Count == 0) { //* 前一期資料不存在銷售實績時,設定訊息『無前期實銷資訊』於訊息區。 throw new Exception("無前期實銷資訊,請使用其他配本方式"); } Int32.TryParse(dtItemSales.Rows[0]["ST_ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty); Int32.TryParse(dtItemSales.Rows[0]["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty); nRow = dtDisItemRefer.NewRow(); nRow["ITEM"] = V_ITEM; //--品號 nRow["ITEM_NAME"] = vITEM_NAME; //--品名 nRow["PERIOD"] = sB1_Period; //--期別 nRow["RITEM"] = V_ITEM; //--參照品號 nRow["RITEM_NAME"] = vITEM_NAME; //--參照品名 nRow["RPERIOD"] = vPeriod_S; //--參照期別 nRow["ST_ACCEPT_QTY"] = iStAcceptQty; //--進貨 nRow["BACKWARD_QTY"] = iBackwardQty; //--退貨 nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty; //--實績 SubQty = iStAcceptQty - iBackwardQty; if (iStAcceptQty == 0) { //REAL_SALESRATE = 0; throw new Exception("前一期別無銷售實績,不可作為參照品項!!"); } else { REAL_SALESRATE = Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100; } nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率 nRow["REFER_RATE"] = 100; //--參照比率% dtDisItemRefer.Rows.Add(nRow); break; #endregion case "103"://b) V_DIS_TYPE = 103 (實績加重) 時 #region //# 由配本商品資料 ItemRow 中取前1期~前6期 (B1_PERIOD~B6_PERIOD)作計算基準 if (sB1_Period == "" && sB2_Period == "" && sB3_Period == "" && sB4_Period == "" && sB5_Period == "" && sB6_Period == "") { //顯示訊息『新品請使用其他配本方式』於訊息區,離開涵式處理流程。 throw new Exception("新品請使用其他配本方式"); } //# 比較前1期~前6期 與 計算期別起迄(vPeriod_S~vPeriod_E), // 將符合起迄的期別,記錄相符筆數 i32AryPeriod = new Int32[] { iB1_Period, iB2_Period, iB3_Period, iB4_Period, iB5_Period, iB6_Period }; for (Int32 i = 0; i <= i32AryPeriod.GetUpperBound(0); i++) { //if (iPeriod_S <= i32AryPeriod[i] && i32AryPeriod[i] <= iPeriod_E) if ((i32AryPeriod[i]) >= iPeriod_S && (i32AryPeriod[i] > 0 && i32AryPeriod[i] <= iPeriod_E)) { iFoundCount++; } } if (iFoundCount == 0)//--查無任何一筆相符資料 { //顯示錯誤訊息『存在前六期別銷售資料,但查無可參照期別,請確認配本方式設定是否異常。』 throw new Exception("存在前六期別銷售資料,但查無可參照期別,請確認配本方式設定是否異常。"); } else if (iFoundCount != iSelect_Period)// (往前選幾期)) --可用之參照期別品項數與參數檔設定不相符 { //# 選出前一期別銷售實績 sB1_Period = B1_PERIOD; //# 新增前一期資料作為參照商品,以例外比例作為參照比率% QueryALOCommon BCOCommon = new QueryALOCommon(ConnectionDB); Paramslist.Clear(); Paramslist.Add(V_ITEM); Paramslist.Add(V_PERIOD); DataTable dtTemp = BCOCommon.QueryItemPeriodSalesInfo(Paramslist); if (dtTemp != null && dtTemp.Rows.Count > 0) { Int32.TryParse(dtTemp.Rows[0]["ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty); Int32.TryParse(dtTemp.Rows[0]["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty); } nRow = dtDisItemRefer.NewRow(); nRow["ITEM"] = V_ITEM; //--品號 nRow["ITEM_NAME"] = vITEM_NAME; //--品名 nRow["PERIOD"] = sB1_Period; //--期別 nRow["RITEM"] = V_ITEM; //--參照品號 nRow["RITEM_NAME"] = vITEM_NAME; //--參照品名 nRow["RPERIOD"] = B1_PERIOD; //--參照期別=B1 nRow["ST_ACCEPT_QTY"] = iStAcceptQty; //--進貨 nRow["BACKWARD_QTY"] = iBackwardQty; //--退貨 nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty; //--實績 SubQty = iStAcceptQty - iBackwardQty; if (iStAcceptQty > 0) { REAL_SALESRATE = Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100; } else { REAL_SALESRATE = 0; } nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率 nRow["REFER_RATE"] = dtParam.Rows[0]["REFER_OTHER"]; //--參照比率%,使用例外比率; //--參照比率% dtDisItemRefer.Rows.Add(nRow); } else if (iFoundCount == iSelect_Period)//--可用之參照期別品項數與參數檔設定相符時 { // --因為要考慮排序,所以使用dtItemSales的排序方式,進行資料新增與判斷。 //依照 dtItemSales 的排序 iRowCnt = 0; REAL_SALESRATE_Sum = 0; foreach (DataRow dRow in dtItemSales.Rows) { Int32.TryParse(dRow["PERIOD"].ToString().Trim(), out iPERIOD); if (iPeriod_S <= iPERIOD && iPERIOD <= iPeriod_E) { iRowCnt++; if (iRowCnt > iSelect_Period) { break; } //# 新增一筆資料作為參照商品, 依新增iRowCont 取得參照比率 Int32.TryParse(dRow["ST_ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty); Int32.TryParse(dRow["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty); nRow = dtDisItemRefer.NewRow(); nRow["ITEM"] = V_ITEM; //--品號 nRow["ITEM_NAME"] = vITEM_NAME; //--品名 nRow["PERIOD"] = sB1_Period; //--期別 nRow["RITEM"] = V_ITEM; //--參照品號 nRow["RITEM_NAME"] = vITEM_NAME; //--參照品名 nRow["RPERIOD"] = dRow["PERIOD"]; //--參照期別 nRow["ST_ACCEPT_QTY"] = iStAcceptQty; //--進貨 nRow["BACKWARD_QTY"] = iBackwardQty; //--退貨 nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty; //--實績 SubQty = iStAcceptQty - iBackwardQty; REAL_SALESRATE = (iStAcceptQty == 0) ? 0 : Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100; REAL_SALESRATE_Sum += REAL_SALESRATE;// 實銷率合計 nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率 nRow["REFER_RATE"] = dtParam.Rows[0]["REFER_RATE" + iRowCnt.ToString()]; //--參照比率%,依照排序順序取得參照比率 dtDisItemRefer.Rows.Add(nRow); } }//end for // 新增判斷 所有參照品項的銷售實績均為0時,需alert訊息 if (REAL_SALESRATE_Sum < 1) { throw new Exception("參照品項均無銷售實績,請調整參照品項"); } } break; #endregion case "104"://c) V_DIS_TYPE = 104 (移行指數) 時 #region //# 由配本商品資料 ItemRow 中取前1期~前6期 (B1_PERIOD~B6_PERIOD)作計算基準 if (sB1_Period == "" && sB2_Period == "" && sB3_Period == "" && sB4_Period == "" && sB5_Period == "" && sB6_Period == "") { //顯示訊息『新品請使用其他配本方式』於訊息區,離開涵式處理流程。 throw new Exception("新品請使用其他配本方式"); } //# 比較前1期~前6期 與 計算期別起迄(vPeriod_S~vPeriod_E), // 將符合起迄的期別,記錄相符筆數 i32AryPeriod = new Int32[] { iB1_Period, iB2_Period, iB3_Period, iB4_Period, iB5_Period, iB6_Period }; for (Int32 i = 0; i <= i32AryPeriod.GetUpperBound(0); i++) { if (iPeriod_S <= i32AryPeriod[i] && i32AryPeriod[i] <= iPeriod_E) { iFoundCount++; } } if (iFoundCount == 0 || iFoundCount != iSelect_Period) { //顯示錯誤訊息『銷售期別不足,請使用其他配本方式。』 throw new Exception("銷售期別不足,請使用其他配本方式。"); } else if (iFoundCount == iSelect_Period) { //--因為要考慮排序,所以使用dtItemSales的排序方式,進行資料新增與判斷。 // 依照 dtItemSales 的排序 iRowCnt = 0; REAL_SALESRATE_Sum = 0; foreach (DataRow dRow in dtItemSales.Rows) { Int32.TryParse(dRow["PERIOD"].ToString().Trim(), out iPERIOD); if (iPeriod_S <= iPERIOD && iPERIOD <= iPeriod_E) { iRowCnt++; if (iRowCnt > iSelect_Period) { break; } //# 新增一筆資料作為參照商品, 依新增iRowCont 取得參照比率 Int32.TryParse(dRow["ST_ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty); Int32.TryParse(dRow["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty); nRow = dtDisItemRefer.NewRow(); nRow["ITEM"] = V_ITEM; //--品號 nRow["ITEM_NAME"] = vITEM_NAME; //--品名 nRow["PERIOD"] = dRow["PERIOD"]; //--期別 nRow["RITEM"] = V_ITEM; //--參照品號 nRow["RITEM_NAME"] = vITEM_NAME; //--參照品名 nRow["RPERIOD"] = dRow["PERIOD"]; //--參照期別 nRow["ST_ACCEPT_QTY"] = iStAcceptQty; //--進貨 nRow["BACKWARD_QTY"] = iBackwardQty; //--退貨 nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty; //--實績 SubQty = iStAcceptQty - iBackwardQty; REAL_SALESRATE = (iStAcceptQty == 0) ? 0 : Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100; REAL_SALESRATE_Sum += REAL_SALESRATE;// 實銷率合計 nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率 nRow["REFER_RATE"] = dtParam.Rows[0]["REFER_RATE" + iRowCnt.ToString()]; //--參照比率%,依照排序順序取得參照比率 dtDisItemRefer.Rows.Add(nRow); } } } // 新增判斷 所有參照品項的銷售實績均為0時,需alert訊息 if (REAL_SALESRATE_Sum < 1) { throw new Exception("參照品項均無銷售實績,請調整參照品項"); } #region 取得去年同期資訊 2009-07-16 cyhsu add string sErrMsg = ""; Paramslist.Clear(); Paramslist.Add(V_ITEM); Paramslist.Add(V_PERIOD); DataTable dtLY_Sales = QueryLastYear_PeriodSalesInfo(Paramslist); if (dtLY_Sales != null && dtLY_Sales.Rows.Count > 0) { #region 逐筆新增配本參照資料 foreach (DataRow dRow in dtLY_Sales.Rows) { //# 新增一筆資料作為參照商品, 依新增iRowCont 取得參照比率 Int32.TryParse(dRow["ST_ACCEPT_QTY"].ToString().Trim(), out iStAcceptQty); Int32.TryParse(dRow["BACKWARD_QTY"].ToString().Trim(), out iBackwardQty); nRow = dtDisItemRefer.NewRow(); nRow["ITEM"] = V_ITEM; //--品號 nRow["ITEM_NAME"] = vITEM_NAME; //--品名 nRow["PERIOD"] = dRow["PERIOD"]; //--期別 nRow["RITEM"] = V_ITEM; //--參照品號 nRow["RITEM_NAME"] = vITEM_NAME; //--參照品名 nRow["RPERIOD"] = dRow["PERIOD"]; //--參照期別 nRow["ST_ACCEPT_QTY"] = iStAcceptQty; //--進貨 nRow["BACKWARD_QTY"] = iBackwardQty; //--退貨 nRow["REAL_MERIT"] = iStAcceptQty - iBackwardQty; //--實績 SubQty = iStAcceptQty - iBackwardQty; REAL_SALESRATE = (iStAcceptQty == 0) ? 0 : Decimal.Parse(SubQty.ToString()) / Decimal.Parse(iStAcceptQty.ToString()) * 100; nRow["REAL_SALESRATE"] = (iStAcceptQty == 0) ? 0 : Decimal.Round(REAL_SALESRATE, MidpointRounding.AwayFromZero); //--實銷率 nRow["REFER_RATE"] = dtParam.Rows[0]["REFER_RATE" + iRowCnt.ToString()]; //--參照比率%,依照排序順序取得參照比率 dtDisItemRefer.Rows.Add(nRow); } #endregion } dtLY_Sales.Dispose(); #endregion break; #endregion } } catch (Exception ex) { throw GetNewException(ex); } return dtDisItemRefer; #endregion }
/// <summary> /// 取得商品名稱 /// </summary> /// <param name="strItem"></param> /// <returns></returns> private string GetItemNameByItem(string strItem) { #region string strResult = ""; try { ITMModel.MaintainSKU BCO = new ITMModel.MaintainSKU(ConnectionDB); ArrayList ParameterList1 = new ArrayList();//20091106 ParameterList1.Clear(); ParameterList1.Add(strItem); DataTable dt = BCO.QuerySKUByCode(ParameterList1); if (dt != null && dt.Rows.Count > 0) { strResult = dt.Rows[0]["ITEM_NAME"].ToString(); ; } else { strResult = "查無資料"; } } catch (Exception ex) { throw ex; } return strResult; #endregion }
protected void DoAddDetail() { try { txtCheckQty.Text = txtAdjQty.Text; MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB); DataTable dtPriceInfo = null; //依第一筆商品明細,取得 稅別、群分類、是否檔期、票期 //並更新對應欄位的值 ArrayList parameterList = new ArrayList(); parameterList.Add(Session.SessionID); parameterList.Add(txtStore.Text); parameterList.Add(txtItem.Text); parameterList.Add(txtPeriod.Text); parameterList.Add(Convert.ToDateTime(txtSignDate.Text).ToString("yyyyMMdd")); if (int.Parse(ddlIOType.Text) == 24) parameterList.Add(31); else if (int.Parse(ddlIOType.Text) == 25) parameterList.Add(33); else parameterList.Add(int.Parse(ddlIOType.Text)); dtPriceInfo = bco.GetPriceInfoList_PROMOTE(true, parameterList); if (dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString() == "0") { ErrorMsgLabel.Text = dtPriceInfo.Rows[0]["MESSAGE"].ToString(); return; } if (GridView1.Rows.Count == 0) { string taxType, rootNo, isSchedule; rootNo = dtPriceInfo.Rows[0]["RootNo"].ToString(); taxType = dtPriceInfo.Rows[0]["TaxType"].ToString(); int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString()); isSchedule = i >= 64 ? "1" : "0"; InvoiceDateRange = dtPriceInfo.Rows[0]["ChargeDate"].ToString(); SLP_COL_DAYS.Text = InvoiceDateRange; rblTaxType.Text = taxType; txtRootNo.Text = rootNo; rblIsSchedule.Text = isSchedule; ItemKey = rootNo + taxType + isSchedule + InvoiceDateRange; slpPROMOTE_ID.Text = dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString(); } else { if (RowMode == RowEditMode.Add) { int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString()); string isSchedule = i >= 64 ? "1" : "0"; if (dtPriceInfo.Rows[0]["RootNo"].ToString() + dtPriceInfo.Rows[0]["TaxType"].ToString() + isSchedule + dtPriceInfo.Rows[0]["ChargeDate"].ToString() != ItemKey) { ErrorMsgLabel.Text = "稅別、群分類、是否檔期或票期不同無法新增"; return; } if (slpPROMOTE_ID.Text.Trim() != dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString().Trim()) { ErrorMsgLabel.Text = "檔期編號不同無法新增"; return; } } } //3.4 記錄在暫存的TABLE內,待按下新增時才會存到資料庫 //itemName, stAcceptQty, backwardQty, listDisRate, listPrice, retailPrice //品名 進貨數 退貨數 牌價折扣率 牌價 零售價 MaintainCodeFile BCO = new MaintainCodeFile(ConnectionDB); ArrayList parameters = new ArrayList(); DataTable dt = null; switch (RowMode) { case RowEditMode.Add: MaintainSKU sku = new MaintainSKU(ConnectionDB); ArrayList list = new ArrayList(); list.Add(txtItem.Text); DataTable dtItem = sku.QuerySKUByCode(list); string itemName = dtItem.Rows[0]["ITEM_NAME"].ToString(); IDataReader dr = bco.GetInvInfo(txtStore.Text, txtItem.Text, txtPeriod.Text); string stAcceptQty, backwardQty = ""; if (!dr.Read()) { stAcceptQty = "0"; backwardQty = "0"; } else { stAcceptQty = dr["ST_ACCEPT_QTY"].ToString(); backwardQty = dr["BACKWARD_QTY"].ToString(); } dr.Close(); string listDisRate, listPrice, retailPrice, srcCostPrice, priceDiscountKind; listDisRate = dtPriceInfo.Rows[0]["LISTDISRATE"].ToString(); listPrice = dtPriceInfo.Rows[0]["LISTPRICE"].ToString(); retailPrice = dtPriceInfo.Rows[0]["SRC_RETAILPRICE"].ToString(); srcCostPrice = dtPriceInfo.Rows[0]["SRC_COSTPRICE"].ToString(); priceDiscountKind = dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString(); DataRow row = DiffData.NewRow(); row["Item"] = txtItem.Text; row["ITEM_NAME"] = itemName; row["Period"] = txtPeriod.Text; row["PSS_ST_ACCEPT_QTY"] = stAcceptQty; row["PSS_BACKWARD_QTY"] = backwardQty; row["DIFF_QTY"] = txtAdjQty.Text; if (txtCheckQty.Text.Length > 0) { row["CHECK_QTY"] = txtCheckQty.Text; } else { row["CHECK_QTY"] = System.DBNull.Value; } row["Cost"] = srcCostPrice; row["Cost_Dis_Rate"] = decimal.Parse(listDisRate); row["Cost_Dis"] = decimal.Parse(listPrice); row["Price"] = decimal.Parse(retailPrice); row["PDKIND"] = int.Parse(priceDiscountKind); if (txtReason.Text.Length > 0) { row["CHECK_REASON"] = txtReason.Text; } else { row["CHECK_REASON"] = System.DBNull.Value; } parameters.Add("1"); /* 1是原因判斷的Category */ parameters.Add(txtReason.Text); dt = BCO.QueryLineSwitch(MaintainCodeFile.QueryType.SLP, parameters ); row["EXPLAIN"] = dt.Rows[0]["EXPLAIN"].ToString(); DiffData.Rows.Add(row); break; case RowEditMode.Edit: DataRow[] dra = DiffData.Select(string.Format("Item = '{0}' AND Period = '{1}'", txtItem.Text, txtPeriod.Text)); parameters.Add("1"); /* 1是原因判斷的Category */ parameters.Add(txtReason.Text); dt = BCO.QueryLineSwitch(MaintainCodeFile.QueryType.SLP, parameters ); if (txtReason.Text.Length > 0) { dra[0]["CHECK_REASON"] = txtReason.Text; } else { dra[0]["CHECK_REASON"] = System.DBNull.Value; } dra[0]["EXPLAIN"] = dt.Rows[0]["EXPLAIN"].ToString(); dra[0]["DIFF_QTY"] = txtAdjQty.Text; if (txtCheckQty.Text.Length > 0) { dra[0]["CHECK_QTY"] = txtCheckQty.Text; } else { dra[0]["CHECK_QTY"] = System.DBNull.Value; } break; } GridView1.DataSource = DiffData; GridView1.DataBind(); txtItem.Text = txtPeriod.Text = txtAdjQty.Text = txtCheckQty.Text = txtReason.Text = ""; pnlAddDiffItem1.Visible = false; btnAddDiffItem.Visible = true; } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } finally { Finally_Function(); } }
//新增明細 protected void DoAddDetail() { try { if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(slpTransferDate.Text) || string.IsNullOrEmpty(txtTransferNo.Text) || string.IsNullOrEmpty(this.ddlIOType.Text)) { ErrorMsgLabel.Text = "店號、調撥類別、調撥日期、憑證單號需有值"; return; } if (RowMode == RowEditMode.Add) { DataRow[] dra1 = TransferItem.Select(string.Format("Item = '{0}' AND Period = '{1}'", txtItem.Text, txtPeriod.Text)); if (dra1.Length > 0) { ErrorMsgLabel.Text = "店號及期別不能重複"; return; } } MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB); DataTable dtPriceInfo = null; ArrayList parameterList = new ArrayList(); parameterList.Add(Session.SessionID); parameterList.Add(txtStore.Text); parameterList.Add(txtItem.Text); parameterList.Add(txtPeriod.Text); parameterList.Add(Convert.ToDateTime(slpTransferDate.Text).ToString("yyyyMMdd")); if (int.Parse(ddlIOType.Text) == 24) parameterList.Add(41); else if (int.Parse(ddlIOType.Text) == 25) parameterList.Add(42); else parameterList.Add(int.Parse(ddlIOType.Text)); dtPriceInfo = bco.GetPriceInfoList_PROMOTE(true, parameterList); if (dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString() == "0") { ErrorMsgLabel.Text = dtPriceInfo.Rows[0]["MESSAGE"].ToString(); return; } if (GridView1.Rows.Count == 0) { //依第一筆商品明細,取得 稅別、群分類、是否檔期、票期 //並更新對應欄位的值 string taxType, rootNo, isSchedule; rootNo = dtPriceInfo.Rows[0]["RootNo"].ToString(); taxType = dtPriceInfo.Rows[0]["TaxType"].ToString(); int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString()); isSchedule = i >= 64 ? "1" : "0"; InvoiceDateRange = dtPriceInfo.Rows[0]["ChargeDate"].ToString(); SLP_COL_DAYS.Text = InvoiceDateRange; rblTaxType.Text = taxType; txtRootNo.Text = rootNo; txtIsSchedule.Text = (isSchedule == "1" ? "檔期" : "非檔期"); ItemKey = rootNo + taxType + isSchedule + InvoiceDateRange; slpPROMOTE_ID.Text = dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString(); } else { if (RowMode == RowEditMode.Add) { int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString()); string isSchedule = i >= 64 ? "1" : "0"; if (dtPriceInfo.Rows[0]["RootNo"].ToString() + dtPriceInfo.Rows[0]["TaxType"].ToString() + isSchedule + dtPriceInfo.Rows[0]["ChargeDate"].ToString() != ItemKey) { ErrorMsgLabel.Text = "稅別、群分類、是否檔期或票期不同無法新增"; return; } if (slpPROMOTE_ID.Text.Trim() != dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString().Trim()) { ErrorMsgLabel.Text = "檔期編號不同無法新增"; return; } } } //3.4 記錄在暫存的TABLE內,待按下新增時才會存到資料庫 //itemName, stAcceptQty, backwardQty, listDisRate, listPrice, retailPrice //品名 進貨數 退貨數 牌價折扣率 牌價 零售價 switch (RowMode) { case RowEditMode.Add: MaintainSKU sku = new MaintainSKU(ConnectionDB); ArrayList list = new ArrayList(); list.Add(txtItem.Text); DataTable dtItem = sku.QuerySKUByCode(list); string itemName = dtItem.Rows[0]["ITEM_NAME"].ToString(); IDataReader dr = bco.GetInvInfo(txtStore.Text, txtItem.Text, txtPeriod.Text); string stAcceptQty, backwardQty = ""; if (!dr.Read()) { stAcceptQty = "0"; backwardQty = "0"; } else { stAcceptQty = dr["ST_ACCEPT_QTY"].ToString(); backwardQty = dr["BACKWARD_QTY"].ToString(); } dr.Close(); string listDisRate, listPrice, retailPrice, srcCostPrice, priceDiscountKind; listDisRate = dtPriceInfo.Rows[0]["LISTDISRATE"].ToString(); listPrice = dtPriceInfo.Rows[0]["LISTPRICE"].ToString(); retailPrice = dtPriceInfo.Rows[0]["SRC_RETAILPRICE"].ToString(); srcCostPrice = dtPriceInfo.Rows[0]["SRC_COSTPRICE"].ToString(); priceDiscountKind = dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString(); DataRow row = TransferItem.NewRow(); row["Item"] = txtItem.Text; row["Name"] = itemName; row["Period"] = txtPeriod.Text; row["ST_Accept_Qty"] = stAcceptQty; row["Backward_Qty"] = backwardQty; row["Adj_Qty"] = (ddlIOType.Text == "25" ? -1 : 1) * Convert.ToDecimal(txtAdjQty.Text); row["Cost"] = srcCostPrice; row["Cost_Dis_Rate"] = decimal.Parse(listDisRate); row["Cost_Dis"] = decimal.Parse(listPrice); row["Price"] = decimal.Parse(retailPrice); row["PriceDiscountKind"] = int.Parse(priceDiscountKind); TransferItem.Rows.Add(row); break; case RowEditMode.Edit: DataRow[] dra = TransferItem.Select(string.Format("Item = '{0}' AND Period = '{1}'", txtItem.Text, txtPeriod.Text)); dra[0]["Adj_Qty"] = (ddlIOType.Text == "25" ? -1 : 1) * Convert.ToDecimal(txtAdjQty.Text); break; } GridView1.DataSource = TransferItem; GridView1.DataBind(); txtItem.Text = txtPeriod.Text = txtAdjQty.Text = ""; pnlAddTransferItem1.Visible = false; btnAddTransferItem.Visible = true; ddlIOType.Enabled = false; ddlIOType.CssClass = "readtxtbox"; } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } finally { Finally_Function(); } }
/// <summary> /// 逾期客訂 /// </summary> /// <param name="strItem"></param> /// <param name="strPeriod"></param> /// <param name="strUserID"></param> /// <param name="strPageTimeStamp"></param> /// <param name="strOtherParam"></param> /// <returns></returns> private string GetValueByPageMethod_ISOVERDUE(string strItem, string strPeriod, string strUserID, string strPageTimeStamp, string strOtherParam) { #region string strRtn = "", strTemp1 = "", strTemp2 = ""; try { if (Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] != null) { Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] = null; } if (strOtherParam.Trim().ToUpper() == "TRUE")//繼續編輯。 { #region #region 取得商品主檔資訊 if (Session[string.Format("CRM041_s_PMA_{0}", strPageTimeStamp)] == String.Empty || Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)] == String.Empty) { DataTable dt_Return_2 = new DataTable(); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", slp_down_ITEM.Text, "=", "and"); BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB); dt_Return_2 = bco_itm.QuerySKUByFind_1(ParameterList); if (dt_Return_2 != null && dt_Return_2.Rows.Count != 0) { Session[string.Format("CRM041_s_PMA_{0}", strPageTimeStamp)] = dt_Return_2.Rows[0]["PMA"].ToString();//大分類 Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)] = dt_Return_2.Rows[0]["ROOT_NO"].ToString();//群分類 } else { strTemp1 = string.Format("商品主檔中無對應品號"); #region OLD //sb = sb.Remove(0, sb.Length); //sb.Append("新增或編輯模式下異動欄位[期別]Confirm後<partition>"); //sb.Append("FALSE<partition>"); //sb.Append("商品主檔中無對應品號<partition>"); //sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位 #endregion } } #endregion #region 取得庫存資訊 GetStockByPageMethod(Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), strItem, strPeriod, strUserID, strPageTimeStamp); #endregion #endregion } else if (strOtherParam.Trim().ToUpper() == "FALSE")//取消本筆明細新增。 { #region #region 清空靜態變數 Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] = null;//異動欄位[期別] Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)] = string.Empty;//群分類(異動欄位[品號/品名]) Session[string.Format("CRM041_s_PMA_{0}", strPageTimeStamp)] = string.Empty;//大分類(異動欄位[品號/品名]) Session[string.Format("CRM041_s_SRC_LOCATE_TYPE_{0}", strPageTimeStamp)] = string.Empty;//建議儲區類別(異動欄位[訂貨量]) #endregion #region 計算 dt_Detail 的筆數 int i_dt_Detail_Count = 0; DataTable dtTemp = ((DataTable)Session[string.Format("CRM041_dt_Detail_{0}", strPageTimeStamp)]); if (dtTemp != null) { if (dtTemp.GetChanges(DataRowState.Deleted) == null) { i_dt_Detail_Count = dtTemp.Rows.Count; } else { i_dt_Detail_Count = dtTemp.Rows.Count - dtTemp.GetChanges(DataRowState.Deleted).Rows.Count; } } #endregion strTemp2 = string.Format("{0}", i_dt_Detail_Count); #endregion } } catch (Exception ex) { throw ex; } return strRtn = string.Format("{0};{1}", strTemp1, strTemp2); #endregion }
}//end InsertCancelButton_Click /// <summary> /// 於檢視模式,按下刪除鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteButton_Click(object sender, EventArgs e) { int res = 0; try { ParameterList.Clear(); DataTable dt = bco.ConvertXMLToDataTable(MasterOLDData.InnerHtml); DataRow dr = dt.Rows[0]; MaintainSKU bcoSKU = new MaintainSKU(ConntionDB); ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", dr["PATTERN_NO"].ToString() + "%", "like", "and"); DataTable dtExists = bcoSKU.QuerySKUByFind_1(ParameterList); if (dtExists.Rows.Count > 0) { Alert("PatternNo使用中,無法刪除"); return; } MaintainPreItem bcoPreItem = new MaintainPreItem(ConntionDB); ParameterList.Clear(); ParameterList.Add(DBNull.Value); //N_ID ParameterList.Add(DBNull.Value); //V_ITEM ParameterList.Add(dr["PATTERN_NO"].ToString() + "%"); //V_PATTERN_NO dtExists = bcoPreItem.QueryPreItemByFind_1(ParameterList); if (dtExists.Rows.Count > 0) { Alert("PatternNo使用中,無法刪除"); return; } ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", dr["ID"].ToString()); //OLD_ID SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DateTime.Now); //OLD_CREATEDATE SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //OLD_ENABLE bco.DeleteItemClassify(ParameterList, null); //Response.Write("<script>alert('刪除完成');location.replace('ITM241.aspx?Code=ITM24');</script>"); Script("alert('刪除完成');location.replace('ITM241.aspx?Code=ITM24');"); } catch (Exception ex) { if (ex.Message.IndexOf("其他使用者異動,刪除") != -1) ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者刪除,請重新查詢"; else ErrorMsgLabel.Text = ex.Message; } finally { } }//DeleteButton_Click
public SLP_PreItem() { co_main = new MaintainSKU(ConntionDB); co_PreItem = new MaintainPreItem(ConntionDB); }
/// <summary> /// 編輯模式,按下更新確認鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void EditCommitButton_Click(object sender, EventArgs e) { int res = 0; try { DataTable dt = bco.ConvertXMLToDataTable(MasterOLDData.InnerHtml); DataRow dr = dt.Rows[0]; #region 新舊值比對 ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ID", dr["ID"].ToString(), "=", "and"); SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ENABLE", 1, "=", "and"); DataTable dtOld = bco.QueryItemClassifyByFind_1(ParameterList); if (dtOld.Rows.Count == 0) { Alert("資料已被刪除,更新失敗"); return; } else { DataRow drOld = dtOld.Rows[0]; if (dr["UpdateUid"].ToString() != drOld["UpdateUid"].ToString() || dr["UpdateDate"].ToString() != drOld["UpdateDate"].ToString()) { Alert("更新失敗,此資料已被其他使用者異動,請重新查詢再進行編輯"); return; } } #endregion #region 取得畫面元件的值 string v_ID = ((TextBox)FormView1.FindControl("TextBoxID")).Text.Trim(); string v_ITEM_LAYER = ((RadioButtonList)FormView1.FindControl("rblITEM_LAYER")).Text.Trim(); string v_CODE = ((TextBox)FormView1.FindControl("txtCODE")).Text.Trim(); string v_NAME = ((TextBox)FormView1.FindControl("txtNAME")).Text.Trim(); string v_PATTERN_NAME = ((TextBox)FormView1.FindControl("txtPATTERN_NAME")).Text.Trim(); string v_PATTERN_ALIAS = ((TextBox)FormView1.FindControl("txtPATTERN_ALIAS")).Text.Trim(); object v_PARENTCODE = null; string v_PATTERN_NO = ""; switch (v_ITEM_LAYER) { case "0": if (v_CODE.Length != 1) { ErrorMsgLabel.Text = "群分類代碼須為一位"; return; } v_PATTERN_NO = string.Format("{0}", v_CODE); break; case "1": v_PARENTCODE = ((DropDownList)FormView1.FindControl("ddlROOTNO")).Text.Trim(); if (v_CODE.Length != 2) { ErrorMsgLabel.Text = "大分類代碼須為兩位"; return; } if (v_PARENTCODE.ToString().Length == 0) { ErrorMsgLabel.Text = "未選擇群分類"; return; } v_PATTERN_NO = string.Format("{0}{1}", v_PARENTCODE.ToString().Substring(0, 1), v_CODE); break; case "2": if (v_CODE.Length != 2) { ErrorMsgLabel.Text = "中分類代碼須為兩位"; return; } if (((DropDownList)FormView1.FindControl("ddlPMA")).Text.Trim() == "") v_PARENTCODE = dt.Rows[0]["PARENTCODE"].ToString(); else v_PARENTCODE = ((DropDownList)FormView1.FindControl("ddlPMA")).Text.Trim(); v_PATTERN_NO = string.Format("{0}{1}", v_PARENTCODE.ToString().Substring(0, 3), v_CODE); break; case "3": if (v_CODE.Length != 2) { ErrorMsgLabel.Text = "小分類代碼須為兩位"; return; } if (((DropDownList)FormView1.FindControl("ddlCATEGORY")).Text.Trim() == "") v_PARENTCODE = dt.Rows[0]["PARENTCODE"].ToString(); else v_PARENTCODE = ((DropDownList)FormView1.FindControl("ddlCATEGORY")).Text.Trim(); v_PATTERN_NO = string.Format("{0}{1}", v_PARENTCODE.ToString().Substring(0, 5), v_CODE); break; } #endregion 取得畫面元件的值 #region 資料檢查 if (v_CODE == "") { Alert("分類代碼不可空白"); return; } if (v_NAME == "") { Alert("代碼名稱不可空白"); return; } if (v_PATTERN_NO == "") { Alert("Pattern代碼不可空白"); return; } if (v_ITEM_LAYER == "") { Alert("所屬層級不可空白"); return; } if (Get_Byte_Length(v_PATTERN_NAME) > 30) { Alert("欄位[Pattern名稱]長度不可大於 30 Byte"); return; } if (Get_Byte_Length(v_PATTERN_ALIAS) > 10) { Alert("欄位[Pattern簡稱]長度不可大於 10 Byte"); return; } if (dr["ITEM_LAYER"].ToString() == "3") { ParameterList.Clear(); ParameterList.Add(dr["ID"].ToString()); bool IsExist = bco.CheckInUseItem(ParameterList); if (IsExist == true) { Alert("PATTERN_NO使用中,無法修改"); return; } IsExist = bco.CheckInUsePreItem(ParameterList); if (IsExist == true) { Alert("PATTERN_NO使用中,無法修改"); return; } } else { ParameterList.Clear(); ParameterList.Add(dr["ID"].ToString()); bool IsExist = bco.CheckSubItemExist(ParameterList); if (IsExist == true) { Alert("子項目已存在,無法修改"); return; } } ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", v_PATTERN_NO, "=", "and"); SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", dr["PATTERN_NO"].ToString(), "<>", "and"); DataTable dtExists = bco.QueryItemClassifyByFind_1(ParameterList); if (dtExists.Rows.Count > 0) { Alert("Pattern代碼已經存在"); return; } MaintainSKU bcoSKU = new MaintainSKU(ConntionDB); ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", v_PATTERN_NO + "%", "like", "and"); dtExists = bcoSKU.QuerySKUByFind_1(ParameterList); if (dtExists.Rows.Count > 0) { Alert("PatternNo使用中,無法修改"); return; } MaintainPreItem bcoPreItem = new MaintainPreItem(ConntionDB); ParameterList.Clear(); ParameterList.Add(DBNull.Value); //N_ID ParameterList.Add(DBNull.Value); //V_ITEM ParameterList.Add(v_PATTERN_NO + "%"); //V_PATTERN_NO dtExists = bcoPreItem.QueryPreItemByFind_1(ParameterList); if (dtExists.Rows.Count > 0) { Alert("PatternNo使用中,無法修改"); return; } #endregion ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", dr["ID"].ToString()); //OLD_ID SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CODE", dr["CODE"].ToString()); //OLD_CODE SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_NAME", dr["NAME"].ToString()); //OLD_NAME SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PATTERN_NO", dr["PATTERN_NO"].ToString()); //OLD_PATTERN_NO SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PATTERN_ALIAS", dr["PATTERN_ALIAS"].ToString()); //OLD_PATTERN_ALIAS SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PARENTCODE", dr["PARENTCODE"].ToString()); //OLD_PARENTCODE SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ITEM_LAYER", dr["ITEM_LAYER"].ToString()); //OLD_ITEM_LAYER SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PATTERN_NAME", dr["PATTERN_NAME"].ToString()); //OLD_PATTERN_NAME SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_MEMO", dr["MEMO"].ToString()); //OLD_MEMO SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_UPDATEDATE", dr["UPDATEDATE"].ToString()); //OLD_UPDATEDATE SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_UPDATEUID", dr["UPDATEUID"].ToString()); //OLD_UPDATEUID SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CREATEUID", dr["CREATEUID"].ToString()); //OLD_CREATEUID SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CREATEDATE", dr["CREATEDATE"].ToString()); //OLD_CREATEDATE SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ENABLE", dr["ENABLE"].ToString()); //OLD_ENABLE SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_CODE", v_CODE); //NEW_CODE SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_NAME", v_NAME); //NEW_NAME SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PATTERN_NO", v_PATTERN_NO); //NEW_PATTERN_NO SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PATTERN_ALIAS", v_PATTERN_ALIAS); //NEW_PATTERN_ALIAS SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PARENTCODE", v_PARENTCODE); //NEW_PARENTCODE SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "NEW_ITEM_LAYER", v_ITEM_LAYER); //NEW_ITEM_LAYER SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PATTERN_NAME", v_PATTERN_NAME); //NEW_PATTERN_NAME SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_MEMO", ""); //NEW_MEMO SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DateTime.Now); //NEW_UPDATEDATE SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID bco.UpdateItemClassify(ParameterList, null); Response.Redirect("ITM242.aspx?Code=ITM24&isToolBar=N&SessionName=" + Request.QueryString["SessionName"] + "&arl_Key=" + Request.QueryString["arl_Key"] + "&ID=" + v_ID + "&showalert=YES"); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } }//end EditCommitButton_Click
protected void DoAddDetail() { try { MaintainSKU sku = new MaintainSKU(ConnectionDB); ArrayList list = new ArrayList(); list.Add(SLP_ITEM.Text); DataTable dtItem = sku.QuerySKUByCode(list); string itemName = dtItem.Rows[0]["ITEM_NAME"].ToString(); //記錄在暫存的TABLE內,待按下新增時才會存到資料庫 switch (RowMode) { case RowEditMode.Add: DataRow row = ItemData.NewRow(); row["ITEM"] = SLP_ITEM.Text; row["ITEM_NAME"] = itemName; ItemData.Rows.Add(row); break; } GridView1.DataSource = ItemData; GridView1.DataBind(); SLP_ITEM.Text = ""; pnlAddTranItem1.Visible = false; btnAddTranItem.Visible = true; } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } finally { Finally_Function(); } }
public static string GetCategory(string ItemNo) { string Result = "|"; if (ItemNo.Trim() == "") { return Result; } MaintainSKU bcoSku = new MaintainSKU(ConntionDB); ParameterList.Clear(); ParameterList.Add(ItemNo); DataTable dt = bcoSku.QueryCategoryName(ParameterList); if (dt.Rows.Count > 0) { return Result = dt.Rows[0]["Category"].ToString() + "|" + dt.Rows[0]["name"].ToString(); } return Result; }
/// <summary> /// 根據傳入參數取得商品庫存 /// </summary> /// <param name="CHAN_NO"></param> /// <param name="STORE"></param> private void GetStock(string v_ROOT_NO, string v_Item, string v_Period) { //string SessionIDName = "CRM041_Stock" + PageTimeStamp.Value; if ((v_Item == String.Empty) || (v_Period == String.Empty)) { v_Item = this.slp_down_ITEM.Text; v_Period = this.txt_down_PERIOD.Text; } ArrayList ParameterList = new ArrayList();//20091117 if (v_ROOT_NO == String.Empty) { #region 依照品號取得所屬[群分類]、[大分類] ParameterList.Clear(); BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", v_Item, "=", "and"); BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB); DataTable dt_Return = bco_itm.QuerySKUByFind_1(ParameterList); if (dt_Return != null && dt_Return.Rows.Count != 0) { s_PMA = dt_Return.Rows[0]["PMA"].ToString();//大分類 s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();//群分類 v_ROOT_NO = s_ROOT_NO; } bco_itm = null; dt_Return.Dispose(); #endregion } if (dtStock == null) { ParameterList.Clear(); ParameterList.Add(v_ROOT_NO); ParameterList.Add(v_Item); ParameterList.Add(v_Period); ParameterList.Add(Session["UID"].ToString()); BCO.QueryCRMCommon bco_Common = new BCO.QueryCRMCommon(ConntionDB); dtStock = bco_Common.QueryCRMItemPeriodStock(ParameterList); //Session["SessionID"] = SessionIDName; //Session[SessionIDName] = dtStock; bco_Common = null; } }
protected void GridView1_RowCommand(Object sender, GridViewDeleteEventArgs e) { int index = Convert.ToInt32(e.RowIndex); string v_ID = GridView1.DataKeys[index].Value.ToString(); ParameterList.Clear(); ParameterList.Add(v_ID); DataTable dt = bco.QueryItemClassifyByID(ParameterList); if (dt.Rows.Count == 0) { ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者刪除,請重新查詢"; return; } // Display the selected author. int res = 0; try { ParameterList.Clear(); DataRow dr = dt.Rows[0]; MaintainSKU bcoSKU = new MaintainSKU(ConntionDB); ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", dr["PATTERN_NO"].ToString() + "%", "like", "and"); DataTable dtExists = bcoSKU.QuerySKUByFind_1(ParameterList); if (dtExists.Rows.Count > 0) { Alert("PatternNo使用中,無法刪除"); return; } MaintainPreItem bcoPreItem = new MaintainPreItem(ConntionDB); ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", dr["PATTERN_NO"].ToString() + "%", "like", "and"); dtExists = bcoPreItem.QueryPreItemByFind_1(ParameterList); if (dtExists.Rows.Count > 0) { Alert("PatternNo使用中,無法刪除"); return; } ParameterList.Clear(); SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", dr["ID"].ToString()); //OLD_ID SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DateTime.Now); //NEW_UPDATEDATE SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID bco.DeleteItemClassify(ParameterList, null); Page currentPage = (Page)HttpContext.Current.Handler; string name = "alert"; string script = "alert('資料已刪除');location.replace('ITM241.aspx?Code=ITM24');"; ScriptManager.RegisterClientScriptBlock(currentPage, currentPage.GetType(), name, script, true); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } }
/// <summary> /// 將變更後的內部變量this.CallBackValue返回給前台JavaScript方法ReceiveServerData(string Value)。 /// </summary> /// <returns></returns> string ICallbackEventHandler.GetCallbackResult() { if (CallBackValue != string.Empty) { try { #region 取得頁面元件 TextBox txt_up_CHAN_NO = (TextBox)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("TextBoxCode");//通路 TextBox txt_up_CHAN_NAME = (TextBox)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("TextBoxName");//通路名稱 TextBox txt_up_STORE = (TextBox)((ASP.stm_slp_slp_store_ascx)slp_up_STORE).FindControl("TextBoxCode");//門市 TextBox txt_up_Z_O = (TextBox)((ASP.sys_slp_slp_codefile_ascx)slp_up_Z_O).FindControl("TextBoxCode");//營業所 TextBox txt_up_Z_O_NAME = (TextBox)((ASP.sys_slp_slp_codefile_ascx)slp_up_Z_O).FindControl("TextBoxName");//營業所名稱 TextBox txt_up_BUSDATE = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_up_BUSDATE).FindControl("TextBoxCode");//訂單日期 TextBox txt_up_SALE_ID = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("TextBoxCode");//營業人員 TextBox txt_up_SALE_NAME = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("TextBoxName");//營業人員名稱 TextBox txt_up_BUSUID = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_BUSUID).FindControl("TextBoxCode");//訂單維護者 Image img_up_CHAN_NO = (Image)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("Image1");//通路img Image img_up_STORE = (Image)((ASP.stm_slp_slp_store_ascx)slp_up_STORE).FindControl("Image1");//門市img Image img_up_BUSDATE = (Image)((ASP.wui_slp_slp_slpdate_ascx)slp_up_BUSDATE).FindControl("Image1");//訂單日期img Image img_up_SALE_ID = (Image)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("Image1");//營業人員img Image img_up_BUSUID = (Image)((ASP.sys_slp_slp_user_ascx)slp_up_BUSUID).FindControl("Image1");//訂單維護者img Image img_down_ITEM = (Image)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("Image1");//品號img Image img_down_REQUEST_QTY = (Image)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("Image1");//訂貨量img Image img_down_RTN_DDL = (Image)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("Image1");//退書截止日img TextBox txt_down_ITEM = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxCode");//品號 TextBox txt_down_ITEM_NAME = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxName");//品名 TextBox txt_down_REQUEST_QTY = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxCode");//訂貨量 TextBox txt_down_REQUEST_QTY_NAME = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxName");//訂貨量名稱 TextBox txt_down_RTN_DDL = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("TextBoxCode");//退書截止日 CheckBox chk_down_IS_OVERDUE = (CheckBox)((ASP.wui_slp_slp_boolean_ascx)slp_down_IS_OVERDUE).FindControl("C1");//逾期客訂 #endregion System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Remove(0, sb.Length); CallBackValue = CallBackValue.Trim(); string[] s_Client_String = System.Text.RegularExpressions.Regex.Split(CallBackValue, "<partition>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); ArrayList ParameterList = new ArrayList();//20091117 #region 新增模式下異動欄位[門市] if (s_Client_String[0] == "新增模式下異動欄位[門市]") { if (dtChainPOSetting != null) { dtChainPOSetting = null; } s_STORE = s_Client_String[1].ToString().Trim();//門市 s_CHAN_NO = s_Client_String[2].ToString().Trim();//通路 #region 從資料庫查詢資料 ParameterList.Clear(); ParameterList.Add(s_Client_String[1]);//門市 ParameterList.Add(s_Client_String[2]);//通路 ParameterList.Add(Session["UID"].ToString()); DataTable dt_Return = new DataTable(); BCO.MaintainStore bco = new BCO.MaintainStore(ConntionDB); dt_Return = bco.QUERY_STORE_BY_STOREANDCHAN(ParameterList); #endregion #region 設定回傳Client端資訊 if (dt_Return.Rows.Count == 0) { sb.Append("新增模式下異動欄位[門市]<partition>"); sb.Append("FALSE<partition>"); sb.Append("查無門市資料<partition>"); sb.Append(txt_up_STORE.ClientID + "<partition>");//設定焦點的欄位 sb.Append(txt_up_CHAN_NO.ClientID + "<partition>"); sb.Append(txt_up_Z_O.ClientID + "<partition>"); sb.Append(txt_up_SALE_ID.ClientID); } else { sb.Append("新增模式下異動欄位[門市]<partition>"); sb.Append("TRUE<partition>"); sb.Append(dt_Return.Rows[0]["CHAN_NO"].ToString() + "<partition_Detail>" + txt_up_CHAN_NO.ClientID + "<partition>"); sb.Append(dt_Return.Rows[0]["Z_O"].ToString() + "<partition_Detail>" + txt_up_Z_O.ClientID + "<partition>"); //sb.Append(dt_Return.Rows[0]["SAL_ID"].ToString() + "<partition_Detail>" + txt_up_SALE_ID.ClientID); sb.Append(dt_Return.Rows[0]["SAL_ID"].ToString() + "<partition_Detail>" + txt_up_SALE_ID.ClientID + "<partition>"); sb.Append("<partition_Detail>" + txt_up_CHAN_NAME.ClientID + "<partition>"); sb.Append("<partition_Detail>" + txt_up_Z_O_NAME.ClientID + "<partition>"); sb.Append("<partition_Detail>" + txt_up_SALE_NAME.ClientID); #region 取得通路PO控制設定 GetChainPOSetting(dt_Return.Rows[0]["CHAN_NO"].ToString(), dt_Return.Rows[0]["STORE"].ToString()); #endregion } #endregion } #endregion #region 新增或編輯模式下異動欄位[二段碼] else if (s_Client_String[0] == "新增或編輯模式下異動欄位[二段碼]") { #region 從資料庫查詢資料:群分類、品號、期別 ParameterList.Clear(); ParameterList.Add(s_Client_String[1]);//通路 ParameterList.Add(s_Client_String[2]);//一段碼 ParameterList.Add(s_Client_String[3]);//二段碼 ParameterList.Add(Session["UID"].ToString()); DataTable dt_Return = new DataTable(); BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB); dt_Return = bco.QueryItemPeriodInfoByBarcode(ParameterList); #endregion if (dt_Return.Rows.Count == 0) { sb.Append("新增或編輯模式下異動欄位[二段碼]<partition>"); sb.Append("FALSE<partition>"); sb.Append("此一段碼/二段碼不存在對應商品期別資訊,請重新輸入<partition>"); sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//設定焦點的欄位 sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>"); sb.Append(txt_down_ITEM.ClientID + "<partition>"); sb.Append(this.txt_down_PERIOD.ClientID + "<partition>"); sb.Append(txt_down_RTN_DDL.ClientID); } else { sb.Append("新增或編輯模式下異動欄位[二段碼]<partition>"); sb.Append("TRUE<partition>"); sb.Append(dt_Return.Rows[0]["ITEM"].ToString() + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>"); sb.Append(dt_Return.Rows[0]["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID + "<partition>"); sb.Append(DateTime.Parse(dt_Return.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID); //期別或品號有異動時,重取庫存 if (s_ITEM != dt_Return.Rows[0]["ITEM"].ToString() || s_PERIOD != dt_Return.Rows[0]["PERIOD"].ToString() ) { dtStock = null; } s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString(); s_ITEM = dt_Return.Rows[0]["ITEM"].ToString(); s_PERIOD = dt_Return.Rows[0]["PERIOD"].ToString(); GetStock(s_ROOT_NO, s_ITEM, s_PERIOD); } } #endregion #region 新增或編輯模式下異動欄位[一段碼]onchange else if (s_Client_String[0] == "新增或編輯模式下異動欄位[一段碼]onchange") { #region 根據一段碼帶出品號,最大發行期別,二段碼 ParameterList.Clear(); ParameterList.Add(s_Client_String[1]);//通路 ParameterList.Add(s_STORE);//通路 ParameterList.Add(s_Client_String[3]);//一段碼 ParameterList.Add(string.Empty);//二段碼 ParameterList.Add(Session["UID"].ToString()); DataTable dt_Return = new DataTable(); BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB); dt_Return = bco.QueryItemPeriodInfoByBarcode2(ParameterList); #endregion if (dt_Return.Rows.Count == 0) { sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>"); sb.Append("FALSE<partition>"); sb.Append("此一段碼不存在已發行對應商品期別資訊,請重新輸入<partition>"); sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>"); sb.Append(txt_down_ITEM.ClientID + "<partition>"); sb.Append(this.txt_down_PERIOD.ClientID + "<partition>"); sb.Append(txt_down_RTN_DDL.ClientID + "<partition>"); sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區 sb.Append(this.txt_down_BARCODE.ClientID);//設定焦點的欄位 } else { if (dt_Return.Rows[0]["CAN_DELIVER"].ToString() == "1") { //期別或品號有異動時,重取庫存 dtStock = null; s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString(); s_ITEM = dt_Return.Rows[0]["ITEM"].ToString(); s_PERIOD = dt_Return.Rows[0]["PERIOD"].ToString(); GetStock(s_ROOT_NO, s_ITEM, s_PERIOD); sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");//找到對應商品期別資訊,設定商品期別 sb.Append("TRUE<partition>"); sb.Append(s_ITEM + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>"); sb.Append(dt_Return.Rows[0]["PERIOD_BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>"); sb.Append(DateTime.Parse(dt_Return.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID + "<partition>"); sb.Append(s_PERIOD + "<partition_Detail>" + this.txt_down_PERIOD.ClientID); } else { sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>"); sb.Append("FALSE<partition>"); sb.Append("此一段碼對應品號" + s_ITEM + "客服區域限制不可出貨,請重新輸入<partition>"); sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>"); sb.Append(txt_down_ITEM.ClientID + "<partition>"); sb.Append(this.txt_down_PERIOD.ClientID + "<partition>"); sb.Append(txt_down_RTN_DDL.ClientID + "<partition>"); sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區 sb.Append(this.txt_down_BARCODE.ClientID);//設定焦點的欄位 } } //sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>"); //sb.Append("TRUE<partition>"); //sb.Append(txt_down_ITEM.ClientID + "<partition>"); //異動一段碼時,清空 Item、 Period 、退貨日、儲區、逾期客訂,設定焦點到ITEM //sb.Append(this.txt_down_PERIOD.ClientID + "<partition>"); //期別 //sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>"); //二段碼 //sb.Append(txt_down_RTN_DDL.ClientID + "<partition>"); //預定退貨日 //sb.Append(this.txt_down_RECOMMAND_LOCATION);//建議儲區 } #endregion #region 新增或編輯模式下異動欄位[品號/品名] else if (s_Client_String[0] == "新增或編輯模式下異動欄位[品號/品名]") { //s_PMA = string.Empty;//大分類 //s_ROOT_NO = string.Empty;//群分類 s_ITEM = s_Client_String[1].ToString().Trim();//品號 #region 從資料庫查詢資料 ParameterList.Clear(); ParameterList.Add(s_Client_String[1]);//品號 ParameterList.Add(s_CHAN_NO);//通路 ParameterList.Add(s_STORE);//門市 ParameterList.Add(Session["UID"].ToString()); DataTable dt_Return_1 = new DataTable(); BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB); dt_Return_1 = bco.GetMaxDeiveryPeriod2(ParameterList); #endregion if (dt_Return_1 == null || dt_Return_1.Rows.Count == 0 || dt_Return_1.Rows[0]["PERIOD"].ToString() == string.Empty) { sb.Length = 0; sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>"); sb.Append("FALSE<partition>"); sb.Append("查無資料<partition>"); sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位 } else { //設定品號、期別 s_ITEM = s_Client_String[1]; s_PERIOD = dt_Return_1.Rows[0]["PERIOD"].ToString(); //設定群分類、大分類 s_PMA = dt_Return_1.Rows[0]["PMA"].ToString();//大分類 s_ROOT_NO = dt_Return_1.Rows[0]["ROOT_NO"].ToString();//群分類 if (dt_Return_1.Rows[0]["CAN_DELIVER"].ToString() == "1") { sb.Length = 0; sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>"); sb.Append("TRUE<partition>"); sb.Append(dt_Return_1.Rows[0]["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID); } else { sb.Length = 0; sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>"); sb.Append("FALSE<partition>"); sb.Append("客服區域限制不可出貨<partition>"); sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位 } #region OLD 取得商品主檔資訊 //DataTable dt_Return_2 = new DataTable(); //ParameterList.Clear(); //BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", s_Client_String[1], "=", "and"); //BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB); //dt_Return_2 = bco_itm.QuerySKUByFind_1(ParameterList); //if (dt_Return_2 != null && dt_Return_2.Rows.Count != 0) //{ // s_PMA = dt_Return_2.Rows[0]["PMA"].ToString();//大分類 // s_ROOT_NO = dt_Return_2.Rows[0]["ROOT_NO"].ToString();//群分類 //} //else //{ // sb = sb.Remove(0, sb.Length); // sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>"); // sb.Append("FALSE<partition>"); // sb.Append("商品主檔中無對應品號<partition>"); // sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位 //} #endregion } } #endregion #region 新增或編輯模式下異動欄位[期別] else if (s_Client_String[0] == "新增或編輯模式下異動欄位[期別]") { //期別或品號有異動時,重取庫存 if (s_ITEM != s_Client_String[3].ToString().Trim() || s_PERIOD != s_Client_String[4].ToString().Trim() ) { dtStock = null; } s_CHAN_NO = s_Client_String[1].ToString().Trim();//通路 s_STORE = s_Client_String[2].ToString().Trim();//門市 if (s_ITEM != s_Client_String[3].ToString().Trim()) { } s_ITEM = s_Client_String[3].ToString().Trim();//品號 s_PERIOD = s_Client_String[4].ToString().Trim();//期別 #region 檢查書店是否有未結案同品項訂單 if (s_Client_String[8] == string.Empty) { #region 從資料庫查詢資料 ParameterList.Clear(); ParameterList.Add(s_Client_String[1]);//通路 ParameterList.Add(s_Client_String[2]);//門市 ParameterList.Add(s_Client_String[3]);//品號 ParameterList.Add(s_Client_String[4]);//期別 ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(this.txt_up_CODE.Text);//訂單單號 DataTable dt_Return_1 = new DataTable(); BCO.RecordCRMOrder bco_Record = new BCO.RecordCRMOrder(ConntionDB); dt_Return_1 = bco_Record.CheckOrderItemExist(ParameterList); #endregion if (dt_Return_1.Rows.Count > 0) { sb.Append("新增或編輯模式下異動欄位[期別]<partition>"); sb.Append("檢查書店是否有未結案同品項訂單<partition>"); sb.Append("該門市已存在未結案之同品項訂單於訂單標號:[" + dt_Return_1.Rows[0]["CRM_REQUEST_NO"].ToString() + "],不可新增<partition>"); sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//設定焦點的欄位 sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號 sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號 sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名 sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別 sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量 sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱 sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區 return sb.ToString(); } } #endregion #region 檢查牌價是否已經正確建立 ParameterList.Clear(); ParameterList.Add(s_Client_String[2]);//門市 ParameterList.Add(s_Client_String[3]);//品號 ParameterList.Add(s_Client_String[4]);//期別 ParameterList.Add(DateTime.Today.ToString("yyyy/MM/dd")); // 系統日 ParameterList.Add(Session["UID"].ToString()); PIC.VDS2G.BSM.ALO.ProcessALOCommon co_process = new PIC.VDS2G.BSM.ALO.ProcessALOCommon(ConntionDB); string sRes = co_process.CheckStAcceptDisPrice(ParameterList); //bool bRes = co_process.CheckStAcceptDisPrice(ParameterList, null); if (sRes != string.Empty) { sb.Append("新增或編輯模式下異動欄位[期別]<partition>"); sb.Append("檢查牌價是否已經正確建立<partition>"); sb.Append("期別" + s_PERIOD + "牌價未生效[" + sRes + "],不可新增<partition>"); sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//設定焦點的欄位 sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號 sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號 sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名 sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別 sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量 sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱 sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區 return sb.ToString(); } #endregion #region 設定二段碼、退書截止日與逾期客訂 string s_down_BARCODE = string.Empty;//一段碼 string s_down_PERIOD_BARCODE = string.Empty;//二段碼 string s_down_RTN_DDL = string.Empty;//退書截止日 s_down_BARCODE = s_Client_String[5]; s_down_PERIOD_BARCODE = s_Client_String[6]; s_down_RTN_DDL = s_Client_String[7]; BCO.QueryCRMCommon bco_Common = new BCO.QueryCRMCommon(ConntionDB); // 不管原來有沒有值,只要品號改變,都重新查詢 //if (s_Client_String[5] == string.Empty ||//一段碼 // s_Client_String[6] == string.Empty ||//二段碼 // s_Client_String[7] == string.Empty)//退書截止日 //{ ParameterList.Clear(); ParameterList.Add(s_Client_String[1]);//通路 ParameterList.Add(s_Client_String[3]);//品號 ParameterList.Add(s_Client_String[4]);//期別 ParameterList.Add(Session["UID"].ToString()); DataTable dt_Return_2 = new DataTable(); dt_Return_2 = bco_Common.QueryItemPeriodInfo(ParameterList); if (dt_Return_2.Rows.Count > 0)//有找到資料 { s_down_BARCODE = dt_Return_2.Rows[0]["BARCODE"].ToString(); s_down_PERIOD_BARCODE = dt_Return_2.Rows[0]["PERIOD_BARCODE"].ToString(); s_down_RTN_DDL = DateTime.Parse(dt_Return_2.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd"); } else//查無資料 { sb.Append("新增或編輯模式下異動欄位[期別]<partition>"); sb.Append("設定二段碼、退書截止日與逾期客訂<partition>"); sb.Append("查無[一段碼][二段碼][退書截止日],無法新增<partition>"); sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//設定焦點的欄位 sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號 sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號 sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名 sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別 sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量 sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱 sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區 return sb.ToString(); } //} #endregion #region 逾期客訂確認 TimeSpan time = new TimeSpan(11, 00, 00); bool b_down_IS_OVERDUE = false; DateTime d_Now; DateTime d_RTN_DDL; d_Now = DateTime.Now; d_RTN_DDL = DateTime.Parse(s_down_RTN_DDL); if (d_Now.DayOfWeek == DayOfWeek.Saturday || d_Now.DayOfWeek == DayOfWeek.Sunday || (d_Now.DayOfWeek == DayOfWeek.Friday && d_Now.TimeOfDay.CompareTo(time) >= 0)) { //if (d_RTN_DDL.AddDays(-5).ToShortDateString().CompareTo(d_Now.ToShortDateString()) <= 0) if (d_RTN_DDL.AddDays(-5).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0) { b_down_IS_OVERDUE = true; b_IS_OVERDUE = true; } } else { //if (d_RTN_DDL.AddDays(-2).ToShortDateString().CompareTo(d_Now.ToShortDateString()) <= 0) if (d_RTN_DDL.AddDays(-2).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0) { b_down_IS_OVERDUE = true; b_IS_OVERDUE = true; } } //[@逾期客訂].檢查結果為True時,顯示Confirm訊息『商品已逾期,不可退貨,確定要新增?』 //使用者確認要新增時,可繼續編輯。 //使用者選擇不新增時,取消本筆明細新增。 if (b_down_IS_OVERDUE == true) { sb.Append("新增或編輯模式下異動欄位[期別]<partition>"); sb.Append("[逾期客訂]檢查結果為TRUE<partition>"); sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(s_ROOT_NO + "<partition>");//群分類 sb.Append(s_Client_String[3] + "<partition>");//品號 sb.Append(s_Client_String[4] + "<partition>");//期別 sb.Append(s_down_BARCODE + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(s_down_PERIOD_BARCODE + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(s_down_RTN_DDL + "<partition_Detail>" + txt_down_RTN_DDL.ClientID);//退書截止日 return sb.ToString(); } else { sb.Append("新增或編輯模式下異動欄位[期別]<partition>"); sb.Append("[逾期客訂]檢查結果為FALSE<partition>"); sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(s_down_BARCODE + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(s_down_PERIOD_BARCODE + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(s_down_RTN_DDL + "<partition_Detail>" + txt_down_RTN_DDL.ClientID);//退書截止日 } #endregion #region 取得庫存資訊 GetStock(s_ROOT_NO, s_Client_String[3], s_Client_String[4]); #endregion } #endregion #region 新增或編輯模式下異動欄位[期別]Confirm後 else if (s_Client_String[0] == "新增或編輯模式下異動欄位[期別]Confirm後") { if (dtStock != null) { dtStock = null; } if (s_Client_String[1] == "TRUE")//繼續編輯。 { #region 取得商品主檔資訊 if (s_PMA == String.Empty || s_ROOT_NO == String.Empty) { DataTable dt_Return_2 = new DataTable(); ParameterList.Clear(); BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", slp_down_ITEM.Text, "=", "and"); BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB); dt_Return_2 = bco_itm.QuerySKUByFind_1(ParameterList); if (dt_Return_2 != null && dt_Return_2.Rows.Count != 0) { s_PMA = dt_Return_2.Rows[0]["PMA"].ToString();//大分類 s_ROOT_NO = dt_Return_2.Rows[0]["ROOT_NO"].ToString();//群分類 } else { sb = sb.Remove(0, sb.Length); sb.Append("新增或編輯模式下異動欄位[期別]Confirm後<partition>"); sb.Append("FALSE<partition>"); sb.Append("商品主檔中無對應品號<partition>"); sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位 } } #endregion #region 取得庫存資訊 GetStock(s_ROOT_NO, s_Client_String[3], s_Client_String[4]); #endregion } else if (s_Client_String[1] == "FALSE")//取消本筆明細新增。 { #region 清空靜態變數 dtStock = null;//異動欄位[期別] s_PMA = string.Empty;//大分類(異動欄位[品號/品名]) s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名]) s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量]) #endregion #region 計算 dt_Detail 的筆數 int i_dt_Detail_Count = 0; if (dt_Detail != null) { if (dt_Detail.GetChanges(DataRowState.Deleted) == null) { i_dt_Detail_Count = dt_Detail.Rows.Count; } else { i_dt_Detail_Count = dt_Detail.Rows.Count - dt_Detail.GetChanges(DataRowState.Deleted).Rows.Count; } } #endregion sb.Append("新增或編輯模式下異動欄位[期別]Confirm後<partition>"); sb.Append(i_dt_Detail_Count.ToString() + "<partition>");//dt_Detail的筆數 sb.Append(this.hid_PageStatus.ClientID + "<partition>");//hid_PageStatus sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號 sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號 sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名 sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別 sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量 sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱 sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區 sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路 sb.Append(txt_up_STORE.ClientID + "<partition>");//門市 sb.Append(txt_up_Z_O.ClientID + "<partition>");//營業所 sb.Append(txt_up_BUSDATE.ClientID + "<partition>");//訂單日期 sb.Append(txt_up_SALE_ID.ClientID + "<partition>");//營業人員 sb.Append(txt_up_BUSUID.ClientID + "<partition>");//訂單維護者 sb.Append(((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).ClientID + "<partition>");//訂單來源 sb.Append(this.txt_up_PO_SOURCE_NO.ClientID + "<partition>");//PO單號預設 sb.Append(this.txt_up_CODE.ClientID + "<partition>");//訂單編號 sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>");//流水編號 sb.Append(img_up_CHAN_NO.ClientID + "<partition>");//通路img sb.Append(img_up_STORE.ClientID + "<partition>");//門市img sb.Append(img_up_BUSDATE.ClientID + "<partition>");//訂單日期img sb.Append(img_up_SALE_ID.ClientID + "<partition>");//營業人員img sb.Append(img_up_BUSUID.ClientID);//訂單維護者img } } #endregion #region 新增或編輯模式下異動欄位[訂貨量] else if (s_Client_String[0] == "新增或編輯模式下異動欄位[訂貨量]") { #region 判斷庫存是否足夠 if ((dtStock == null) || (dtStock.Rows.Count < 1)) { GetStock(s_ROOT_NO, s_ITEM, s_PERIOD); } if (((dtStock == null) || (dtStock.Rows.Count < 1)) && (s_ROOT_NO != "2")) { sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); sb.Append("FALSE<partition>"); sb.Append("庫存量不足,請取消新增<partition>"); sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID); return sb.ToString(); } #endregion DataView dvStock = new DataView(dtStock.Copy()); s_SRC_LOCATE_TYPE = string.Empty; int i_REQUEST_QTY = 0;//畫面上使用者輸入的"訂貨量" int i_ONHD_QTY = 0;//現有庫存量 int i_RESERVE_QTY = 0;//配本保留數 int i_Final_QTY = 0;//庫存儲區可配量 int i_DIS_ENABLE = 0;//可配量 string s_SRC_LOCATE_NO = string.Empty;//VDS_CRM_ORDER_DETL.SRC_LOCATE_NO欄位 i_REQUEST_QTY = int.Parse(s_Client_String[1]); // 2009-07-30 cyshu 修改,逾期客訂可取退貨儲區庫存 #region [@群分類]=1(雜誌) 時 //if (s_ROOT_NO == "1" && s_Client_String[2] == "false") if (s_ROOT_NO == "1") { #region 先檢查庫存儲區可用庫存 dvStock.RowFilter = "LOCATETYPE = '2'"; dvStock.Sort = "ONHD_QTY DESC"; #region Old Source //if (dvStock.Count > 0) //{ // i_ONHD_QTY = 0; // i_RESERVE_QTY = 0; // for (int i = 0; i < dvStock.Count; i++) // { // i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString()); // i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString()); // } //} #endregion #region new code i_ONHD_QTY = 0; i_RESERVE_QTY = 0; bool b_Locate_Stock = false; //庫存儲區 for (int i = 0; i < dvStock.Count; i++) { i_ONHD_QTY = int.Parse(dvStock[i]["ONHD_QTY"].ToString()); i_RESERVE_QTY = int.Parse(dvStock[i]["RESERVE_QTY"].ToString()); i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;//庫存儲區可配量 if (i_Final_QTY >= i_REQUEST_QTY) { s_SRC_LOCATE_TYPE = "2"; s_SRC_LOCATE_NO = dvStock[i]["LOCATE_NO"].ToString();//現有庫存儲區 try { i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString()); } catch { i_DIS_ENABLE = 0; } b_Locate_Stock = true; break; } } if (!b_Locate_Stock) //庫存儲區庫存不足 { if (s_PMA == "13" || s_PMA == "14" || s_PMA == "15" || s_PMA == "16") { #region 外雜 sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); sb.Append("FALSE<partition>"); sb.Append("外雜D儲區庫存量不足,無法新增訂單<partition>"); sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID); return sb.ToString(); #endregion } else { #region 檢查退貨儲區可用庫存 i_ONHD_QTY = 0; i_RESERVE_QTY = 0; i_Final_QTY = 0; i_DIS_ENABLE = 0; s_SRC_LOCATE_NO = string.Empty; dvStock.RowFilter = "LOCATETYPE = '1'"; for (int i = 0; i < dvStock.Count; i++) { i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString()); i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString()); } i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY; if (i_Final_QTY >= i_REQUEST_QTY) { s_SRC_LOCATE_TYPE = "1";//退貨儲區 s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區 i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString()); } else { sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); sb.Append("FALSE<partition>"); sb.Append("庫存量不足,請取消新增<partition>"); sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID); return sb.ToString(); } #endregion } } #endregion new code #region old code2 //i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;//庫存儲區可配量 //// 庫存儲區可配量 >= 訂量時,設定建議儲區 = 庫存儲區 //if (i_Final_QTY >= i_REQUEST_QTY) //{ // s_SRC_LOCATE_TYPE = "2";//庫存儲區 // s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區 // try // { // i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString()); // } // catch { i_DIS_ENABLE = 0; } //} //else //{ // if (s_PMA == "13" || // s_PMA == "14" || // s_PMA == "15" || // s_PMA == "16") // { // sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); // sb.Append("FALSE<partition>"); // sb.Append("外雜D儲區庫存量不足,無法新增訂單<partition>"); // sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 // sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID); // return sb.ToString(); // } // else // { // #region 檢查退貨儲區可用庫存 // i_ONHD_QTY = 0; // i_RESERVE_QTY = 0; // i_Final_QTY = 0; // i_DIS_ENABLE = 0; // s_SRC_LOCATE_NO = string.Empty; // dvStock.RowFilter = "LOCATETYPE = '1'"; // for (int i = 0; i < dvStock.Count; i++) // { // i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString()); // i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString()); // } // i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY; // if (i_Final_QTY >= i_REQUEST_QTY) // { // s_SRC_LOCATE_TYPE = "1";//退貨儲區 // s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區 // i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString()); // } // else // { // sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); // sb.Append("FALSE<partition>"); // sb.Append("庫存量不足,請取消新增<partition>"); // sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 // sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID); // return sb.ToString(); // } // #endregion // } //} #endregion old code2 #endregion } #endregion #region [@群分類]=2(圖書) else { dvStock.RowFilter = "LOCATETYPE = '2'"; dvStock.Sort = "ONHD_QTY DESC"; if (dvStock.Count > 0) { // 先作預設值 s_SRC_LOCATE_TYPE = "2"; // 庫存儲區 s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區 for (int i = 0; i < dvStock.Count; i++) { i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString()); i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString()); } i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY; if (i_Final_QTY >= i_REQUEST_QTY) { s_SRC_LOCATE_TYPE = "2";//庫存儲區 s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區 i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString()); } else //圖書庫存不足仍可新增 { s_SRC_LOCATE_TYPE = "2";//庫存儲區 s_SRC_LOCATE_NO = "D"; i_DIS_ENABLE = 0; sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); sb.Append("TRUE_ALERT<partition>"); sb.Append("圖書庫存不足,確認要新增?<partition>"); sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>"); sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID); return sb.ToString(); } } else //圖書庫存不足仍可新增 { #region 圖書庫存不足仍可新增 s_SRC_LOCATE_TYPE = "2";//庫存儲區 s_SRC_LOCATE_NO = "D"; i_DIS_ENABLE = 0; sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); sb.Append("TRUE_ALERT<partition>"); sb.Append("圖書庫存不足,確認要新增?<partition>"); sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>"); sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID); return sb.ToString(); #endregion } } #endregion if (sb.ToString() == string.Empty) { if (i_REQUEST_QTY > 100) { sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); sb.Append("TRUE_ALERT<partition>"); sb.Append("訂貨量大於100<partition>"); sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>"); sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID); return sb.ToString(); } else { sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>"); sb.Append("TRUE_NO_ALERT<partition>"); sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>"); sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID); return sb.ToString(); } } } #endregion #region 新增或編輯模式按下明細區[取消]鈕 else if (s_Client_String[0] == "新增或編輯模式按下明細區[取消]鈕") { #region 清空靜態變數 dtStock = null;//異動欄位[期別] s_PMA = string.Empty;//大分類(異動欄位[品號/品名]) s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名]) s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量]) sb.Remove(0, sb.Length); #endregion #region 計算 dt_Detail 的筆數 int i_dt_Detail_Count = 0; if (dt_Detail != null) { if (dt_Detail.GetChanges(DataRowState.Deleted) == null) { i_dt_Detail_Count = dt_Detail.Rows.Count; } else { i_dt_Detail_Count = dt_Detail.Rows.Count - dt_Detail.GetChanges(DataRowState.Deleted).Rows.Count; } } #endregion sb.Append("新增或編輯模式按下明細區[取消]鈕<partition>"); sb.Append(i_dt_Detail_Count.ToString() + "<partition>");//dt_Detail的筆數 sb.Append(this.hid_PageStatus.ClientID + "<partition>");//hid_PageStatus sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號 sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號 sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名 sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別 sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量 //sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱 sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日 sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區 sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路 sb.Append(txt_up_STORE.ClientID + "<partition>");//門市 sb.Append(txt_up_Z_O.ClientID + "<partition>");//營業所 sb.Append(txt_up_BUSDATE.ClientID + "<partition>");//訂單日期 sb.Append(txt_up_SALE_ID.ClientID + "<partition>");//營業人員 sb.Append(txt_up_BUSUID.ClientID + "<partition>");//訂單維護者 sb.Append(((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).ClientID + "<partition>");//訂單來源 sb.Append(this.txt_up_PO_SOURCE_NO.ClientID + "<partition>");//PO單號預設 sb.Append(this.txt_up_CODE.ClientID + "<partition>");//訂單編號 sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>");//流水編號 sb.Append(img_up_CHAN_NO.ClientID + "<partition>");//通路img sb.Append(img_up_STORE.ClientID + "<partition>");//門市img sb.Append(img_up_BUSDATE.ClientID + "<partition>");//訂單日期img sb.Append(img_up_SALE_ID.ClientID + "<partition>");//營業人員img sb.Append(img_up_BUSUID.ClientID);//訂單維護者img } #endregion #region 新增或編輯模式按下GridView[編輯]鈕 else if (s_Client_String[0] == "新增或編輯模式按下GridView[編輯]鈕") { DataRow dRow = dt_Detail.Select("ID = " + s_Client_String[1])[0]; string s_IS_OVERDUE; //改為已擷轉仍可修改 //if (dRow["TRANS_RESULT"].ToString() == "1")//已擷轉 //{ sb.Append("此筆訂單品項已擷轉,不可編輯或刪除\r\n"); } if (dRow["STATUS"].ToString() == "75")//已結案 { sb.Append("此筆訂單品項已結案,不可編輯或刪除\r\n"); } #region 編輯前檢查錯誤 if (sb.ToString() != string.Empty) { sb.Insert(0, "新增或編輯模式按下GridView[編輯]鈕_編輯前檢查FALSE<partition>"); return sb.ToString(); } #endregion #region 取得庫存 i_Curr_Order_Qty = 0; s_ROOT_NO = dRow["ROOT_NO"].ToString(); //群分類 s_ITEM = dRow["ITEM"].ToString(); //品號 s_PERIOD = dRow["PERIOD"].ToString(); //期別 i_Curr_Order_Qty = (dRow["REQUEST_QTY"].ToString().Trim() == string.Empty) ? 0 : int.Parse(dRow["REQUEST_QTY"].ToString().Trim()); s_SRC_LOCATE_NO = dRow["SRC_LOCATE_NO"].ToString();//原儲區 //取得目前庫存 dtStock = null; GetStock(s_ROOT_NO, s_ITEM, s_PERIOD); //編輯模式下,可用庫存應加上原訂單需求量 AddStockForEditMode(s_SRC_LOCATE_NO, i_Curr_Order_Qty); #endregion #region 編輯前檢查正確 s_IS_OVERDUE = (dRow["IS_OVERDUE"].ToString() == "0") ? "false" : "true"; sb.Append("新增或編輯模式按下GridView[編輯]鈕_編輯前檢查TRUE<partition>"); sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路 sb.Append(txt_up_STORE.ClientID + "<partition>");//門市 sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號 sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別 sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日 sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button sb.Append(s_IS_OVERDUE + "<partition_Detail>" + chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂 sb.Append(dRow["PO_SOURCE_NO"].ToString() + "<partition_Detail>" + this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號 sb.Append(dRow["BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼 sb.Append(dRow["PERIOD_BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼 sb.Append(dRow["ITEM"].ToString() + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>");//品號 sb.Append(dRow["ITEM_NAME"].ToString() + "<partition_Detail>" + txt_down_ITEM_NAME.ClientID + "<partition>");//品名 sb.Append(dRow["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID + "<partition>");//期別 sb.Append(dRow["REQUEST_QTY"].ToString() + "<partition_Detail>" + txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量 //sb.Append(dRow["REQUEST_QTY"].ToString() + ".0000<partition_Detail>" + txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱 sb.Append(DateTime.Parse(dRow["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日 sb.Append(dRow["SRC_LOCATE_NO"].ToString() + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區 sb.Append(dRow["ID"].ToString() + "<partition_Detail>" + this.hid_ID.ClientID);//hid_ID #endregion } #endregion #region 新增或編輯模式按下明細區[新增明細]鈕 else if (s_Client_String[0] == "新增或編輯模式按下明細區[新增明細]鈕") { #region 清空靜態變數 dtStock = null;//異動欄位[期別] s_PMA = string.Empty;//大分類(異動欄位[品號/品名]) s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名]) s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量]) #endregion } #endregion #region 新增模式異動欄位[流水編號] else if (s_Client_String[0] == "新增模式異動欄位[流水編號]") { #region 檢查是否為有效流水編號 DataTable dt_Return = new DataTable(); ParameterList.Clear(); ParameterList.Add(s_Client_String[1]);//流水編號 ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(DateTime.Now); BCO.RecordCRMRecord bco = new BCO.RecordCRMRecord(ConntionDB); dt_Return = bco.QueryCRMRecordByCode_CheckExist(ParameterList); if (dt_Return.Rows.Count == 0) { sb.Append("新增模式異動欄位[流水編號]<partition>"); sb.Append("FALSE<partition>"); sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>"); sb.Append("[流水編號]不為存在的有效編號"); } #endregion } #endregion CallBackValue = sb.ToString(); } catch (Exception ex) { CallBackValue = "發生例外錯誤<partition>" + ex.Message; } } return CallBackValue; }
public string PreItemName(string Code) { string Name = ""; string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase; MaintainSKU co_main = new MaintainSKU(ConnectionDBStr); MaintainPreItem co_PreItem = new MaintainPreItem(ConnectionDBStr); ArrayList ParameterList = new ArrayList(); ParameterList.Add(Code); DataTable dt = co_main.QuerySKUByCode(ParameterList); if (dt.Rows.Count > 0) { Name = "已存在"; } else { dt = co_PreItem.QueryPreItemByCode(ParameterList); if (dt.Rows.Count > 0) Name = "已存在"; else Name = "查無資料"; } return Name; }