/// <summary> /// BUTTON [載入檔案]鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but_LoadFile_Click(object sender, EventArgs e) { try { #region 將Client端的檔案上傳至AP端 #region 宣告變數 string s_UploadPath = string.Empty; ArrayList arl_Return = new ArrayList(); #endregion #region 將Client端的檔案上傳至AP端 s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "ITM\\"; ITM07_BCO bco = new ITM07_BCO(ConntionDB); arl_Return = bco.FileUpload(s_UploadPath, this.fileupload_Path, Session["UID"].ToString()); #endregion #region 檢查回傳結果 if (arl_Return[0].ToString() == "FALSE") { #region 清空上傳匯入結果 this.UploadStatusPanel1.UploadSum = 0;//上傳結果總筆數 this.UploadStatusPanel1.UploadOK = 0;//上傳結果正常筆數 this.UploadStatusPanel1.UploadNG = 0;//上傳結果錯誤筆數 this.UploadStatusPanel1.ImportSum = 0;//匯入結果總筆數 this.UploadStatusPanel1.ImportOK = 0;//匯入結果正常筆數 this.UploadStatusPanel1.ImportNG = 0;//匯入結果錯誤筆數 #endregion #region 設定控制項 this.but_Import.Enabled = false;//確定匯入 this.but_Error.Enabled = false;//檢視異常 #endregion this.ErrorMsgLabel.Text = arl_Return[1].ToString(); return; } #endregion #endregion #region 依據AP端檔案資料匯入TmpTable #region 取得 TempTable VDS_ITM_CHAN_TMP 的 SCHEMA ITMCommon ITMComm = new ITMCommon(); DataTable dt_Temp = new DataTable(); ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UID dt_Temp = bco.GET_VDS_ITM_CHAN_TMP_SCHEMA(ParameterList); #endregion #region 將資料寫入 TempTable DateTime d_Now = DateTime.Now; #region 讀取 Excel 資料 OleDbConnection oleConnection = null; DataSet ds_Excel = new DataSet(); try { //HDR=YES是表示Excel中的第一列為欄名。 //IMEX=1是表示儲存格內容若是文字和數字混合的內容, 要當做文字處理。 String connString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source =" + arl_Return[1].ToString() + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1';"; oleConnection = new OleDbConnection(connString); oleConnection.Open(); OleDbCommand oleCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", oleConnection); OleDbDataAdapter oleAdapter = new OleDbDataAdapter(oleCommand); oleAdapter.Fill(ds_Excel); #region 請注意如果EXCEL檔欄位有值,但到DB卻沒有資料 //請修改,機碼 HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\Excel\TypeGuessRows 值 //預設是 8, 表示會先讀取前 8 列來決定每一個欄位的型態, 所以如果前 8 列的資料都是數字, 到了第 9 列以後出現的文字資料都會變成 null //如果要解決這個問題, 只要把 TypeGuessRows 機碼值改成 0 #endregion } catch (Exception ex) { throw new Exception("讀取 Excel 資料失敗:" + ex.Message); } finally { if (oleConnection != null) { oleConnection.Close(); oleConnection.Dispose(); } } #endregion foreach (DataRow dr in ds_Excel.Tables[0].Rows) { #region 檢查條件 ArrayList arl_ConditionReturn = Check_Condition_DataLine(dr); #endregion #region 檢查正確 if (arl_ConditionReturn[1].ToString() == string.Empty) { DataRow dr_Temp = dt_Temp.NewRow(); dr_Temp["ID"] = ITMComm.GetValueSetParameter(dr["序號"].ToString(), "int", false);//ID dr_Temp["STATUS"] = ITMComm.GetValueSetParameter("1", "int", false);//處理狀態(1:正常資料;2:錯誤資料) dr_Temp["DATASOURCE"] = ITMComm.GetValueSetParameter(arl_Return[3].ToString(), "string", false);//匯入檔案 dr_Temp["DATATYPE"] = ITMComm.GetValueSetParameter("1", "int", false);//資料類別(1:FILE TO TMP;2:TMP TO DB) dr_Temp["MEMO"] = ITMComm.GetValueSetParameter(string.Empty, "string", false);//說明 dr_Temp["CHAN_NO"] = ITMComm.GetValueSetParameter(dr["通路代號"].ToString(), "string", false);//通路代號 dr_Temp["ITEM_MAP"] = ITMComm.GetValueSetParameter(dr["對照號"].ToString(), "string", false);//對照號 dr_Temp["ITEM"] = ITMComm.GetValueSetParameter(dr["品號"].ToString(), "string", false);//品號 dr_Temp["PERIOD"] = ITMComm.GetValueSetParameter(dr["期別"].ToString(), "string", false);//期別 dr_Temp["CREATEUID"] = ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//建立人員 dr_Temp["CREATEDATE"] = ITMComm.GetValueSetParameter(d_Now.ToString(), "datetime", false);//建立日期 dr_Temp["UPDATEUID"] = ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//異動人員 dr_Temp["UPDATEDATE"] = ITMComm.GetValueSetParameter(d_Now.ToString(), "datetime", false);//異動日期 dt_Temp.Rows.Add(dr_Temp); } #endregion #region 檢查不正確 else { DataRow dr_Temp = dt_Temp.NewRow(); string s_ErrorMsg = string.Empty; s_ErrorMsg = arl_ConditionReturn[1].ToString().Replace("<br/>", ","); s_ErrorMsg = ITMComm.Get_Byte_Length(s_ErrorMsg) > 500 ? s_ErrorMsg.Substring(0, 250) : s_ErrorMsg;//MEMO欄位=VARCHAR2(500) dr_Temp["ID"] = ITMComm.GetValueSetParameter((arl_ConditionReturn[1].ToString().IndexOf("欄位[ID]數字格式錯誤") == -1) ? dr["序號"].ToString() : string.Empty, "int", false); dr_Temp["STATUS"] = ITMComm.GetValueSetParameter("2", "int", false);//處理狀態(1:正常資料;2:錯誤資料) dr_Temp["DATASOURCE"] = ITMComm.GetValueSetParameter(arl_Return[3].ToString(), "string", false);//匯入檔案 dr_Temp["DATATYPE"] = ITMComm.GetValueSetParameter("1", "int", false);//資料類別(1:FILE TO TMP;2:TMP TO DB) dr_Temp["MEMO"] = s_ErrorMsg;//說明 dr_Temp["CREATEUID"] = ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false); dr_Temp["CREATEDATE"] = ITMComm.GetValueSetParameter(d_Now.ToString(), "datetime", false); dr_Temp["UPDATEUID"] = ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false); dr_Temp["UPDATEDATE"] = ITMComm.GetValueSetParameter(d_Now.ToString(), "datetime", false); dt_Temp.Rows.Add(dr_Temp); } #endregion } #endregion #region 連結資料庫 if (dt_Temp.Rows.Count == 0) { this.ErrorMsgLabel.Text = "無匯入資料"; return; } else { #region 將資料寫入TempTable DataTable dt_Return = bco.FileToTmp(null, Session["UID"].ToString(), dt_Temp); #endregion #region 計算[總筆數][正常筆數][錯誤筆數] int i_Total_Count = 0;//總筆數 int i_Success_Count = 0;//正常筆數 int i_Failure_Count = 0;//錯誤筆數 string s_FilterExpression = string.Empty; s_FilterExpression = "STATUS ='1'";//1:正常資料; DataRow[] dr_Success = dt_Return.Select(s_FilterExpression); if (dr_Success.Length == 1) { i_Success_Count = int.Parse(dr_Success[0]["count"].ToString()); } s_FilterExpression = "STATUS ='2'";//2:錯誤資料; DataRow[] dr_Failure = dt_Return.Select(s_FilterExpression); if (dr_Failure.Length == 1) { i_Failure_Count = int.Parse(dr_Failure[0]["count"].ToString()); } i_Total_Count = i_Success_Count + i_Failure_Count; this.UploadStatusPanel1.UploadSum = i_Total_Count;//上傳結果總筆數 this.UploadStatusPanel1.UploadOK = i_Success_Count;//上傳結果正常筆數 this.UploadStatusPanel1.UploadNG = i_Failure_Count;//上傳結果錯誤筆數 this.UploadStatusPanel1.ImportSum = 0;//匯入結果總筆數 this.UploadStatusPanel1.ImportOK = 0;//匯入結果正常筆數 this.UploadStatusPanel1.ImportNG = 0;//匯入結果錯誤筆數 #endregion #region 設定控制項 if ((i_Total_Count == i_Success_Count) && (i_Failure_Count == 0)) { this.but_Import.Enabled = true;//確定匯入 this.but_Error.Enabled = false;//檢視異常 } if (i_Failure_Count > 0) { this.but_Import.Enabled = false;//確定匯入 this.but_Error.Enabled = true;//檢視異常 } #endregion } #endregion #endregion } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } finally { //#region 設定 TabContainer 的 ActiveTabIndex //this.TabContainer1.ActiveTabIndex = 1; //#endregion } }
/// <summary> /// 檢查文字檔條件 /// </summary> /// <param name="dr"></param> /// <returns></returns> private ArrayList Check_Condition_DataLine(DataRow dr) { #region 宣告 ITMCommon ITMComm = new ITMCommon(); ArrayList arl_Return = new ArrayList(); arl_Return.Add(string.Empty);//該欄位放Focus欄位之ClientID arl_Return.Add(string.Empty);//該欄位放錯誤訊息 #endregion #region 檢查各個欄位型別,長度,是否必填 #region Column[序號] arl_Return = ITMComm.Check_MustFillin_Column(dr["序號"].ToString(), "text", "欄位[序號]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["序號"].ToString(), "欄位[序號]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["序號"].ToString()) > 38) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[序號]長度不可大於 38 Byte", "1", string.Empty); } #endregion #region Column[通路代號] arl_Return = ITMComm.Check_MustFillin_Column(dr["通路代號"].ToString(), "text", "欄位[通路代號]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["通路代號"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[通路代號]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[品號] arl_Return = ITMComm.Check_MustFillin_Column(dr["品號"].ToString(), "text", "欄位[品號]為必填欄位", "1", string.Empty, arl_Return); System.Text.RegularExpressions.Regex reg_SIX = new System.Text.RegularExpressions.Regex(@"^[0-9]{6}$"); if (reg_SIX.IsMatch(dr["品號"].ToString()) == false) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[品號]必需為六位數目字", "1", string.Empty); } #endregion #region Column[期別] arl_Return = ITMComm.Check_MustFillin_Column(dr["期別"].ToString(), "text", "欄位[期別]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["期別"].ToString()) > 6) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[期別]長度不可大於 6 Byte", "1", string.Empty); } #endregion #endregion #region 如果基本檢查有誤,則Return if (arl_Return[1].ToString() != string.Empty) { return arl_Return; } #endregion return arl_Return; }
/// <summary> /// 檢查條件 /// </summary> /// <param name="s_Type"></param> /// <returns></returns> private ArrayList Check_Condition() { #region 宣告 BCO.ITMCommon ITMComm = new BCO.ITMCommon(); ArrayList arl_Return = new ArrayList(); arl_Return.Add(string.Empty);//該欄位放Focus欄位之ClientID arl_Return.Add(string.Empty);//該欄位放錯誤訊息 #endregion #region SLP轉型 TextBox txt_MDC_END_DATE = (TextBox)this.slp_MDC_END_DATE.FindControl("TextBoxCode"); //DC結束日 TextBox txt_PERIOD_END_DATE = (TextBox)this.slp_PERIOD_END_DATE.FindControl("TextBoxCode"); //期別結束日 TextBox txt_EFFECTIVE_DATE = (TextBox)this.slp_EFFECTIVE_DATE.FindControl("TextBoxCode"); //通路生效日 TextBox txt_CHAN_END_DATE = (TextBox)this.slp_CHAN_END_DATE.FindControl("TextBoxCode"); //通路結束日 TextBox txt_NOTICE_RETURN_DATE = (TextBox)this.slp_NOTICE_RETURN_DATE.FindControl("TextBoxCode"); //退貨通知日 TextBox txt_PLAN_RETURN_DATE = (TextBox)this.slp_PLAN_RETURN_DATE.FindControl("TextBoxCode"); //首次預退日 TextBox txt_RTN_DDL = (TextBox)this.slp_RTN_DDL.FindControl("TextBoxCode"); //退書截止日 #endregion #region 檢查欄位的Byte長度 if (ITMComm.Get_Byte_Length(this.txt_ITEM_NAME.Text) > 30) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[品名]長度不可大於 30 Byte", "1", this.txt_ITEM_NAME.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_EDIT_REASON.Text) > 50) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[異動原因]長度不可大於 50 Byte", "1", this.txt_EDIT_REASON.ClientID); } #endregion #region 檢查SLP日期格式 arl_Return = ITMComm.Check_Format_Date(this.slp_MDC_END_DATE.Text, "欄位[DC結束日]日期格式錯誤", "1", txt_MDC_END_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_PERIOD_END_DATE.Text, "欄位[期別結束日]日期格式錯誤", "1", txt_PERIOD_END_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_EFFECTIVE_DATE.Text, "欄位[通路生效日]日期格式錯誤", "1", txt_EFFECTIVE_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_CHAN_END_DATE.Text, "欄位[通路結束日]日期格式錯誤", "1", txt_CHAN_END_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_NOTICE_RETURN_DATE.Text, "欄位[退貨通知日]日期格式錯誤", "1", txt_NOTICE_RETURN_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_PLAN_RETURN_DATE.Text, "欄位[首次預退日]日期格式錯誤", "1", txt_PLAN_RETURN_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_RTN_DDL.Text, "欄位[退書截止日]日期格式錯誤", "1", txt_RTN_DDL.ClientID, arl_Return); #endregion #region 檢查必填欄位(除了欄位[品名][DC結束日]外,如果其他欄位有值才做以下檢查) if ((this.slp_PERIOD_END_DATE.Text.Trim() == string.Empty &&//期別結束日 this.slp_EFFECTIVE_DATE.Text.Trim() == string.Empty &&//通路生效日 this.slp_CHAN_END_DATE.Text.Trim() == string.Empty &&//通路結束日 this.slp_NOTICE_RETURN_DATE.Text.Trim() == string.Empty &&//退貨通知日 this.slp_PLAN_RETURN_DATE.Text.Trim() == string.Empty &&//首次預退日 this.slp_RTN_DDL.Text.Trim() == string.Empty)//退書截止日 == false) { //欄位[品號][期別(起)][期別(迄)],每一行的資料只要三個欄位其中一個有值,則其他兩個皆為必填欄位 if (this.slp_ITEM_1.Text != string.Empty || this.slp_PERIOD_B_1.Text != string.Empty || this.slp_PERIOD_E_1.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_1.Text, "text", "欄位[序號(1)品號]為必填欄位", "1", this.slp_ITEM_1.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_1.Text, "text", "欄位[序號(1)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_1.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_1.Text, "text", "欄位[序號(1)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_1.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_2.Text != string.Empty || this.slp_PERIOD_B_2.Text != string.Empty || this.slp_PERIOD_E_2.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_2.Text, "text", "欄位[序號(2)品號]為必填欄位", "1", this.slp_ITEM_2.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_2.Text, "text", "欄位[序號(2)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_2.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_2.Text, "text", "欄位[序號(2)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_2.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_3.Text != string.Empty || this.slp_PERIOD_B_3.Text != string.Empty || this.slp_PERIOD_E_3.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_3.Text, "text", "欄位[序號(3)品號]為必填欄位", "1", this.slp_ITEM_3.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_3.Text, "text", "欄位[序號(3)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_3.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_3.Text, "text", "欄位[序號(3)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_3.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_4.Text != string.Empty || this.slp_PERIOD_B_4.Text != string.Empty || this.slp_PERIOD_E_4.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_4.Text, "text", "欄位[序號(4)品號]為必填欄位", "1", this.slp_ITEM_4.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_4.Text, "text", "欄位[序號(4)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_4.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_4.Text, "text", "欄位[序號(4)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_4.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_5.Text != string.Empty || this.slp_PERIOD_B_5.Text != string.Empty || this.slp_PERIOD_E_5.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_5.Text, "text", "欄位[序號(5)品號]為必填欄位", "1", this.slp_ITEM_5.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_5.Text, "text", "欄位[序號(5)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_5.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_5.Text, "text", "欄位[序號(5)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_5.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_6.Text != string.Empty || this.slp_PERIOD_B_6.Text != string.Empty || this.slp_PERIOD_E_6.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_6.Text, "text", "欄位[序號(6)品號]為必填欄位", "1", this.slp_ITEM_6.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_6.Text, "text", "欄位[序號(6)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_6.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_6.Text, "text", "欄位[序號(6)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_6.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_7.Text != string.Empty || this.slp_PERIOD_B_7.Text != string.Empty || this.slp_PERIOD_E_7.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_7.Text, "text", "欄位[序號(7)品號]為必填欄位", "1", this.slp_ITEM_7.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_7.Text, "text", "欄位[序號(7)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_7.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_7.Text, "text", "欄位[序號(7)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_7.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_8.Text != string.Empty || this.slp_PERIOD_B_8.Text != string.Empty || this.slp_PERIOD_E_8.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_8.Text, "text", "欄位[序號(8)品號]為必填欄位", "1", this.slp_ITEM_8.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_8.Text, "text", "欄位[序號(8)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_8.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_8.Text, "text", "欄位[序號(8)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_8.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_9.Text != string.Empty || this.slp_PERIOD_B_9.Text != string.Empty || this.slp_PERIOD_E_9.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_9.Text, "text", "欄位[序號(9)品號]為必填欄位", "1", this.slp_ITEM_9.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_9.Text, "text", "欄位[序號(9)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_9.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_9.Text, "text", "欄位[序號(9)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_9.TextBox_Code.ClientID, arl_Return); } if (this.slp_ITEM_10.Text != string.Empty || this.slp_PERIOD_B_10.Text != string.Empty || this.slp_PERIOD_E_10.Text != string.Empty) { arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM_10.Text, "text", "欄位[序號(10)品號]為必填欄位", "1", this.slp_ITEM_10.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_B_10.Text, "text", "欄位[序號(10)期別(起)]為必填欄位", "1", this.slp_PERIOD_B_10.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_E_10.Text, "text", "欄位[序號(10)期別(迄)]為必填欄位", "1", this.slp_PERIOD_E_10.TextBox_Code.ClientID, arl_Return); } } #endregion #region 如果基本檢查有誤,則Return if (arl_Return[1].ToString() != string.Empty) { return arl_Return; } #endregion #region 檢查Between欄位 #region 欄位[期別]_1 if (this.slp_PERIOD_B_1.Text != string.Empty || this.slp_PERIOD_E_1.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_1.Text, this.slp_PERIOD_E_1.Text, "(序號1)期別", "1", this.slp_PERIOD_B_1.TextBox_Code.ClientID, this.slp_PERIOD_E_1.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_1.Text, this.slp_PERIOD_E_1.Text, "string", "欄位[(序號1)期別(迄)]一定要大於或等於欄位[(序號1)期別(起)]", "1", this.slp_PERIOD_E_1.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_2 if (this.slp_PERIOD_B_2.Text != string.Empty || this.slp_PERIOD_E_2.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_2.Text, this.slp_PERIOD_E_2.Text, "(序號2)期別", "1", this.slp_PERIOD_B_2.TextBox_Code.ClientID, this.slp_PERIOD_E_2.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_2.Text, this.slp_PERIOD_E_2.Text, "string", "欄位[(序號2)期別(迄)]一定要大於或等於欄位[(序號2)期別(起)]", "1", this.slp_PERIOD_E_2.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_3 if (this.slp_PERIOD_B_3.Text != string.Empty || this.slp_PERIOD_E_3.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_3.Text, this.slp_PERIOD_E_3.Text, "(序號3)期別", "1", this.slp_PERIOD_B_3.TextBox_Code.ClientID, this.slp_PERIOD_E_3.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_3.Text, this.slp_PERIOD_E_3.Text, "string", "欄位[(序號3)期別(迄)]一定要大於或等於欄位[(序號3)期別(起)]", "1", this.slp_PERIOD_E_3.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_4 if (this.slp_PERIOD_B_4.Text != string.Empty || this.slp_PERIOD_E_4.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_4.Text, this.slp_PERIOD_E_4.Text, "(序號4)期別", "1", this.slp_PERIOD_B_4.TextBox_Code.ClientID, this.slp_PERIOD_E_4.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_4.Text, this.slp_PERIOD_E_4.Text, "string", "欄位[(序號4)期別(迄)]一定要大於或等於欄位[(序號4)期別(起)]", "1", this.slp_PERIOD_E_4.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_5 if (this.slp_PERIOD_B_5.Text != string.Empty || this.slp_PERIOD_E_5.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_5.Text, this.slp_PERIOD_E_5.Text, "(序號5)期別", "1", this.slp_PERIOD_B_5.TextBox_Code.ClientID, this.slp_PERIOD_E_5.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_5.Text, this.slp_PERIOD_E_5.Text, "string", "欄位[(序號5)期別(迄)]一定要大於或等於欄位[(序號5)期別(起)]", "1", this.slp_PERIOD_E_5.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_6 if (this.slp_PERIOD_B_6.Text != string.Empty || this.slp_PERIOD_E_6.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_6.Text, this.slp_PERIOD_E_6.Text, "(序號6)期別", "1", this.slp_PERIOD_B_6.TextBox_Code.ClientID, this.slp_PERIOD_E_6.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_6.Text, this.slp_PERIOD_E_6.Text, "string", "欄位[(序號6)期別(迄)]一定要大於或等於欄位[(序號6)期別(起)]", "1", this.slp_PERIOD_E_6.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_7 if (this.slp_PERIOD_B_7.Text != string.Empty || this.slp_PERIOD_E_7.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_7.Text, this.slp_PERIOD_E_7.Text, "(序號7)期別", "1", this.slp_PERIOD_B_7.TextBox_Code.ClientID, this.slp_PERIOD_E_7.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_7.Text, this.slp_PERIOD_E_7.Text, "string", "欄位[(序號7)期別(迄)]一定要大於或等於欄位[(序號7)期別(起)]", "1", this.slp_PERIOD_E_7.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_8 if (this.slp_PERIOD_B_8.Text != string.Empty || this.slp_PERIOD_E_8.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_8.Text, this.slp_PERIOD_E_8.Text, "(序號8)期別", "1", this.slp_PERIOD_B_8.TextBox_Code.ClientID, this.slp_PERIOD_E_8.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_8.Text, this.slp_PERIOD_E_8.Text, "string", "欄位[(序號8)期別(迄)]一定要大於或等於欄位[(序號8)期別(起)]", "1", this.slp_PERIOD_E_8.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_9 if (this.slp_PERIOD_B_9.Text != string.Empty || this.slp_PERIOD_E_9.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_9.Text, this.slp_PERIOD_E_9.Text, "(序號9)期別", "1", this.slp_PERIOD_B_9.TextBox_Code.ClientID, this.slp_PERIOD_E_9.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_9.Text, this.slp_PERIOD_E_9.Text, "string", "欄位[(序號9)期別(迄)]一定要大於或等於欄位[(序號9)期別(起)]", "1", this.slp_PERIOD_E_9.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #region 欄位[期別]_10 if (this.slp_PERIOD_B_10.Text != string.Empty || this.slp_PERIOD_E_10.Text != string.Empty) { #region 檢查Between欄位如果輸入其中一個欄位則另一個欄位也必須填值 arl_Return = ITMComm.Check_Between_BeginEnd_Value (this.slp_PERIOD_B_10.Text, this.slp_PERIOD_E_10.Text, "(序號10)期別", "1", this.slp_PERIOD_B_10.TextBox_Code.ClientID, this.slp_PERIOD_E_10.TextBox_Code.ClientID, arl_Return); #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位 arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_PERIOD_B_10.Text, this.slp_PERIOD_E_10.Text, "string", "欄位[(序號10)期別(迄)]一定要大於或等於欄位[(序號10)期別(起)]", "1", this.slp_PERIOD_E_10.TextBox_Code.ClientID, arl_Return); #endregion } #endregion #endregion #region 自訂檢查 #region 檢查是否至少填一組修改條件 if (this.txt_ITEM_NAME.Text.Trim() == string.Empty &&//品名 this.slp_MDC_END_DATE.Text.Trim() == string.Empty &&//DC結束日 this.slp_PERIOD_END_DATE.Text.Trim() == string.Empty &&//期別結束日 this.slp_EFFECTIVE_DATE.Text.Trim() == string.Empty &&//通路生效日 this.slp_CHAN_END_DATE.Text.Trim() == string.Empty &&//通路結束日 this.slp_NOTICE_RETURN_DATE.Text.Trim() == string.Empty &&//退貨通知日 this.slp_PLAN_RETURN_DATE.Text.Trim() == string.Empty &&//首次預退日 this.slp_RTN_DDL.Text.Trim() == string.Empty &&//退書截止日 this.txt_EDIT_REASON.Text.Trim() == string.Empty)//異動原因 { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "至少填一組修改條件", "1", this.txt_ITEM_NAME.ClientID); } #endregion #region 檢查是否至少填一組品號 string s_Check_FileName = string.Empty; string s_Check_ITEM = string.Empty; for (int i = 1; i <= 10; i++) { s_Check_FileName = "slp_ITEM_" + i.ToString(); s_Check_ITEM += ((ASP.itm_slp_slp_sku_ascx)this.table1.FindControl(s_Check_FileName)).Text.Trim(); } if (s_Check_ITEM == string.Empty) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "至少填一組品號條件", "1", this.slp_ITEM_1.TextBox_Code.ClientID); } #endregion #endregion return arl_Return; }
/// <summary> /// 檢查條件 /// </summary> /// <param name="s_Type"></param> /// <returns></returns> private ArrayList Check_Condition(string s_Type, DataTable dt_CHK) { #region 宣告 BCO.ITMCommon ITMComm = new BCO.ITMCommon(); BCO.ITM04_BCO bco = new BCO.ITM04_BCO(ConntionDB); ArrayList arl_Return = new ArrayList(); arl_Return.Add(string.Empty);//該欄位放Focus欄位之ClientID arl_Return.Add(string.Empty);//該欄位放錯誤訊息 #endregion #region SLP轉型 TextBox txt_MDC_START_DATE = (TextBox)this.slp_MDC_START_DATE.FindControl("TextBoxCode");//[DC開始日] TextBox txt_MDC_END_DATE = (TextBox)this.slp_MDC_END_DATE.FindControl("TextBoxCode");//[DC結束日] TextBox txt_PUBLISH_DATE = (TextBox)this.slp_PUBLISH_DATE.FindControl("TextBoxCode");//[出版日期] TextBox txt_PERIOD_END_DATE = (TextBox)this.slp_PERIOD_END_DATE.FindControl("TextBoxCode");//[期別結束日] DropDownList drop_PUBLISH_TYPE = (DropDownList)this.slp_PUBLISH_TYPE.FindControl("D1");//出刊種類 DropDownList drop_UNIT = (DropDownList)this.slp_UNIT.FindControl("D1");//銷售單位 DropDownList drop_TARGET_RULE = (DropDownList)this.slp_TARGET_RULE.FindControl("D1");//物流費規則 DropDownList drop_TAX_TYPE = (DropDownList)this.slp_TAX_TYPE.FindControl("D1");//稅別 #endregion #region 新增模式 & 編輯模式 BUTTON [儲存]鈕,編輯模式 BUTTON [產生異動序號]鈕 if (s_Type == "BUTTON [儲存]鈕,新增狀態" || s_Type == "BUTTON [儲存]鈕,編輯狀態" || s_Type == "BUTTON [產生異動序號]鈕,編輯狀態_1") { #region 檢查欄位的Byte長度 #region 頁籤=商品主檔 if (ITMComm.Get_Byte_Length(this.slp_ITEM.Text) > 10) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[品號]長度不可大於 10 Byte", "1", this.slp_ITEM.TextBox_Code.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_ITEM_NAME.Text) > 30) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[品名]長度不可大於 30 Byte", "1", this.txt_ITEM_NAME.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_VICE_ITEM_NAME.Text) > 20) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[副主題]長度不可大於 20 Byte", "1", this.txt_VICE_ITEM_NAME.ClientID); } if (ITMComm.Get_Byte_Length(this.slp_MANUFACTURE.Text) > 12) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[供應商]長度不可大於 12 Byte", "1", this.slp_MANUFACTURE.TextBox_Code.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_EDIT_NO.Text) > 11) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[異動序號]長度不可大於 11 Byte", "1", this.txt_EDIT_NO.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_EDIT_REASON.Text) > 50) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[異動原因]長度不可大於 50 Byte", "1", this.txt_EDIT_REASON.ClientID); } if (ITMComm.Get_Byte_Length(this.slp_ROOT_NO.Text) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[群分類]長度不可大於 2 Byte", "1", this.slp_ROOT_NO.TextBox_Code.ClientID); } if (ITMComm.Get_Byte_Length(this.slp_PMA.Text) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[大分類]長度不可大於 2 Byte", "1", this.slp_PMA.TextBox_Code.ClientID); } if (ITMComm.Get_Byte_Length(this.slp_CATEGORY.Text) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[中分類]長度不可大於 2 Byte", "1", this.slp_CATEGORY.TextBox_Code.ClientID); } if (ITMComm.Get_Byte_Length(this.slp_SORT_OUT.Text) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[小分類]長度不可大於 2 Byte", "1", this.slp_SORT_OUT.TextBox_Code.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_STATEMENTS.Text) > 30) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[敘述]長度不可大於 30 Byte", "1", this.txt_STATEMENTS.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_FIRST_PERIOD.Text) > 6) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[首期期別]長度不可大於 6 Byte", "1", this.txt_FIRST_PERIOD.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_OPEN_SIZE.Text) > 10) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[開本]長度不可大於 10 Byte", "1", this.txt_OPEN_SIZE.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_AUTHOR.Text) > 20) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[作者]長度不可大於 20 Byte", "1", this.txt_AUTHOR.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_CIP.Text) > 8) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[中央圖書分類碼(CIP)]長度不可大於 8 Byte", "1", this.txt_CIP.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_PUBLISH.Text) > 10) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[VCMS出版社]長度不可大於 10 Byte", "1", this.txt_PUBLISH.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_ITEM_PUBLISHER_NO.Text) > 10) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品出版商代號]長度不可大於 10 Byte", "1", this.txt_ITEM_PUBLISHER_NO.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_ITEM_PUBLISHER_NAME.Text) > 20) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品出版商名稱]長度不可大於 20 Byte", "1", this.txt_ITEM_PUBLISHER_NAME.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_PUBLISHER_TYPE.Text) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[出版社書系]長度不可大於 2 Byte", "1", this.txt_PUBLISHER_TYPE.ClientID); } #endregion #region 頁籤=首期期別 if (ITMComm.Get_Byte_Length(this.txt_BARCODE.Text) > 15) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品條碼]長度不可大於 15 Byte", "1", this.txt_BARCODE.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_PERIOD_BARCODE.Text) > 13) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[二段條碼]長度不可大於 13 Byte", "1", this.txt_PERIOD_BARCODE.ClientID); } #endregion #region 頁籤=商品指定參照 if (ITMComm.Get_Byte_Length(this.txt_RESEMBLE_GOODS.Text) > 100) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[類似商品]長度不可大於 100 Byte", "1", this.txt_RESEMBLE_GOODS.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_GOODS_MATTER.Text) > 100) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品說明]長度不可大於 100 Byte", "1", this.txt_GOODS_MATTER.ClientID); } if (ITMComm.Get_Byte_Length(this.txt_COMMEND_CAUSE.Text) > 100) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[推薦理由]長度不可大於 100 Byte", "1", this.txt_COMMEND_CAUSE.ClientID); } #endregion #endregion #region 檢查必填欄位 arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ITEM.Text, "text", "欄位[品號]為必填欄位", "1", this.slp_ITEM.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.txt_ITEM_NAME.Text, "text", "欄位[品名]為必填欄位", "1", this.txt_ITEM_NAME.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_MDC_START_DATE.Text, "text", "欄位[DC開始日]為必填欄位", "1", txt_MDC_START_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_MDC_END_DATE.Text, "text", "欄位[DC結束日]為必填欄位", "1", txt_MDC_END_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_MANUFACTURE.Text, "text", "欄位[供應商]為必填欄位", "1", this.slp_MANUFACTURE.TextBox_Code.ClientID, arl_Return); if (s_Type == "BUTTON [產生異動序號]鈕,編輯狀態_1") { arl_Return = ITMComm.Check_MustFillin_Column(this.txt_EDIT_REASON.Text, "text", "欄位[異動原因]為必填欄位", "1", this.txt_EDIT_REASON.ClientID, arl_Return); } arl_Return = ITMComm.Check_MustFillin_Column(this.slp_ROOT_NO.Text, "text", "欄位[群分類]為必填欄位", "1", this.slp_ROOT_NO.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.radl_OUT_OF_PRINT.SelectedIndex.ToString(), "radio", "欄位[絕版]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PMA.Text, "text", "欄位[大分類]為必填欄位", "1", this.slp_PMA.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_CATEGORY.Text, "text", "欄位[中分類]為必填欄位", "1", this.slp_CATEGORY.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_SORT_OUT.Text, "text", "欄位[小分類]為必填欄位", "1", this.slp_SORT_OUT.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.radl_ATTRIBUTE.SelectedIndex.ToString(), "radio", "欄位[是否定期]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.txt_FIRST_PERIOD.Text, "text", "欄位[首期期別]為必填欄位", "1", this.txt_FIRST_PERIOD.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.radl_NEW_SW.SelectedIndex.ToString(), "radio", "欄位[新商品]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PERIOD_STEP.Text, "text", "欄位[期別累加值]為必填欄位", "1", this.slp_PERIOD_STEP.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_INTERVAL.Text, "text", "欄位[出刊間隔]為必填欄位", "1", this.slp_INTERVAL.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(drop_PUBLISH_TYPE.SelectedIndex.ToString(), "drop", "欄位[出刊種類]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(drop_UNIT.SelectedIndex.ToString(), "drop", "欄位[銷售單位]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.txt_ITEM_PUBLISHER_NO.Text, "text", "欄位[商品出版商代號]為必填欄位", "1", this.txt_ITEM_PUBLISHER_NO.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.txt_ITEM_PUBLISHER_NAME.Text, "text", "欄位[商品出版商名稱]為必填欄位", "1", this.txt_ITEM_PUBLISHER_NAME.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.radl_DISTRIBUTE_MODE.SelectedIndex.ToString(), "radio", "欄位[配量方式]為必填欄位", "1", string.Empty, arl_Return); if (s_Type == "BUTTON [儲存]鈕,新增狀態") { arl_Return = ITMComm.Check_MustFillin_Column(this.txt_BARCODE.Text, "text", "欄位[商品條碼]為必填欄位", "1", this.txt_BARCODE.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_PRICE.Text, "text", "欄位[零售價]為必填欄位", "1", this.slp_PRICE.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.slp_COST.Text, "text", "欄位[成本價]為必填欄位", "1", this.slp_COST.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(this.radl_PERIOD_PAY_TYPE.SelectedIndex.ToString(), "radio", "欄位[物流費基準]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(drop_TARGET_RULE.SelectedIndex.ToString(), "drop", "欄位[物流費規則]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_MustFillin_Column(drop_TAX_TYPE.SelectedIndex.ToString(), "drop", "欄位[稅別]為必填欄位", "1", string.Empty, arl_Return); } #endregion #region 檢查SLP日期格式 arl_Return = ITMComm.Check_Format_Date(this.slp_MDC_START_DATE.Text, "欄位[DC開始日]日期格式錯誤", "1", txt_MDC_START_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_MDC_END_DATE.Text, "欄位[DC開始日]日期格式錯誤", "1", txt_MDC_END_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_PUBLISH_DATE.Text, "欄位[出版日期]日期格式錯誤", "1", txt_PUBLISH_DATE.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Date(this.slp_PERIOD_END_DATE.Text, "欄位[期別結束日]日期格式錯誤", "1", txt_PERIOD_END_DATE.ClientID, arl_Return); #endregion #region 檢查SLP數字格式 arl_Return = ITMComm.Check_Format_Int(this.slp_PERIOD_STEP.Text, "欄位[期別累加值]數字格式錯誤", "32", "1", this.slp_PERIOD_STEP.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Int(this.slp_INTERVAL.Text, "欄位[出刊間隔]數字格式錯誤", "32", "1", this.slp_INTERVAL.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Int(this.slp_PAGE_NUM.Text, "欄位[頁數]數字格式錯誤", "32", "1", this.slp_PAGE_NUM.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Int(this.slp_PRICE.Text, "欄位[零售價]數字格式錯誤", "32", "1", this.slp_PRICE.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Int(this.slp_QUANTITY.Text, "欄位[每店]數字格式錯誤", "32", "1", this.slp_QUANTITY.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Int(this.slp_ACCEPT_TOTAL.Text, "欄位[總進貨量]數字格式錯誤", "32", "1", this.slp_ACCEPT_TOTAL.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Double(this.slp_WIDTH.Text, "欄位[寬]數字格式錯誤", "寬", true, 3, 2, "1", this.slp_WIDTH.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Double(this.slp_HIEGHT.Text, "欄位[高]數字格式錯誤", "高", true, 3, 2, "1", this.slp_HIEGHT.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Double(this.slp_LENGTH.Text, "欄位[深]數字格式錯誤", "深", true, 3, 2, "1", this.slp_LENGTH.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Double(this.slp_COST.Text, "欄位[成本價]數字格式錯誤", "成本價", true, 5, 2, "1", this.slp_COST.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Double(this.slp_ACCEPT_RATE.Text, "欄位[進貨物流費(%)]數字格式錯誤", "進貨物流費(%)", true, 4, 3, "1", this.slp_ACCEPT_RATE.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Double(this.slp_RETURN_RATE.Text, "欄位[退貨物流費(%)]數字格式錯誤", "退貨物流費(%)", true, 4, 3, "1", this.slp_RETURN_RATE.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Double(this.slp_ACCEPT_AMT.Text, "欄位[進貨物流費(元)]數字格式錯誤", "進貨物流費(元)", true, 5, 2, "1", this.slp_ACCEPT_AMT.TextBox_Code.ClientID, arl_Return); arl_Return = ITMComm.Check_Format_Double(this.slp_RETURN_AMT.Text, "欄位[退貨物流費(元)]數字格式錯誤", "退貨物流費(元)", true, 5, 2, "1", this.slp_RETURN_AMT.TextBox_Code.ClientID, arl_Return); #endregion #region 欄位[品號]不可顯示[資料重覆] if (Request[this.slp_ITEM.TextBox_Name.UniqueID] == "資料重覆") { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, " 該品號已存在,請重新輸入品號", "1", this.slp_ITEM.TextBox_Code.ClientID); } #endregion #region 欄位[品號]必需為六位數目字 System.Text.RegularExpressions.Regex reg_SIX = new System.Text.RegularExpressions.Regex(@"^[0-9]{6}$"); if (reg_SIX.IsMatch(this.slp_ITEM.Text) == false) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[品號]必需為六位數目字", "1", this.slp_ITEM.TextBox_Code.ClientID); } #endregion #region 欄位[首期期別]必需為六位數目字 if (reg_SIX.IsMatch(this.txt_FIRST_PERIOD.Text) == false) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[首期期別]必需為六位數目字", "1", this.txt_FIRST_PERIOD.ClientID); } #endregion #region 如果基本檢查有誤,則Return if (arl_Return[1].ToString() != string.Empty) { return arl_Return; } #endregion #region 自訂檢查 #region 檢查Between欄位結束欄位一定要大於或等於開始欄位(DC開始日 & DC結束日) arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (this.slp_MDC_START_DATE.Text, this.slp_MDC_END_DATE.Text, "date", "欄位[DC結束日]一定要大於或等於欄位[DC開始日]", "1", txt_MDC_END_DATE.ClientID, arl_Return); #endregion #region 檢查[群分類][大分類][中分類][小分類]的階層關係是否正確 #region 設定變數 string s_PATTERN_NO = string.Empty; string s_Result = string.Empty; #endregion #region 傳入參數 s_PATTERN_NO = this.slp_ROOT_NO.Text + this.slp_PMA.Text + this.slp_CATEGORY.Text + this.slp_SORT_OUT.Text; ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter(s_PATTERN_NO, "string", false));//[PATTERN_NO] ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//[登入人員] #endregion #region 連結資料庫 s_Result = bco.CHK_ITM042_PATTERN_NO(ParameterList).Rows[0]["result"].ToString(); #endregion #region 檢查回傳值 if (s_Result == "NO") { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "[群分類][大分類][中分類][小分類]的階層關係不正確", "1", string.Empty); } #endregion #endregion #region 新增模式下,才需要的檢查 if (s_Type == "BUTTON [儲存]鈕,新增狀態") { #region 欄位[期別結束日]必需大於或等於系統日 if (this.slp_PERIOD_END_DATE.Text != string.Empty) { DateTime d_PERIOD_END_DATE = DateTime.Parse(this.slp_PERIOD_END_DATE.Text); if (d_PERIOD_END_DATE < DateTime.Now.Date) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[期別結束日]必需大於或等於系統日", "1", txt_PERIOD_END_DATE.ClientID); } } #endregion #region 欄位[零售價]必需大於欄位[成本價] if (double.Parse(this.slp_COST.Text) > int.Parse(this.slp_PRICE.Text)) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[零售價]必需大於欄位[成本價]", "1", this.slp_PRICE.TextBox_Code.ClientID); } #endregion #region 欄位[折扣率]計算是否正確 //若欄位[零售價]=0,則欄位[折扣率]必須=0 //折扣率=成本/零售價 if ((double.Parse(this.slp_PRICE.Text) == 0 && this.txt_DISCOUNT_RATE.Text != "0") && (Convert.ToString(System.Math.Round(double.Parse(this.slp_COST.Text) / int.Parse(this.slp_PRICE.Text), 2, MidpointRounding.AwayFromZero)) != this.txt_DISCOUNT_RATE.Text)) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折扣率]計算錯誤", "1", this.txt_DISCOUNT_RATE.ClientID); } #endregion #region 判斷欄位[物流費基準] if (this.radl_PERIOD_PAY_TYPE.SelectedValue == "1")//元 { if (this.slp_ACCEPT_RATE.Text != string.Empty || this.slp_RETURN_RATE.Text != string.Empty) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[物流費基準]選擇[元]時,只能填寫進退貨物流費(元)", "1", string.Empty); } } else if (this.radl_PERIOD_PAY_TYPE.SelectedValue == "2")//率 { if (this.slp_ACCEPT_AMT.Text != string.Empty || this.slp_RETURN_AMT.Text != string.Empty) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[物流費基準]選擇[率]時,只能填寫進退貨物流費(%)", "1", string.Empty); } } #endregion } #endregion #endregion } #endregion #region 編輯模式 BUTTON [產生異動序號]鈕 else if (s_Type == "BUTTON [產生異動序號]鈕,編輯狀態_2") { #region 規則 /* 規則 * 檢查所有欄位是否有更新, * 如果可修改欄位(不含異動原因欄位)都沒有修改, * 則顯示[沒有更新任何資料] */ #endregion #region 宣告變數 bool b_Is_All_Same = true; ArrayList arl_Chk_Column = new ArrayList(); #endregion #region 設定要檢查的欄位 arl_Chk_Column.Clear(); arl_Chk_Column.Add("ITEM_NAME,VARCHAR2");//品名 arl_Chk_Column.Add("VICE_ITEM_NAME,VARCHAR2");//副主題 arl_Chk_Column.Add("MDC_START_DATE,DATE");//DC開始日 arl_Chk_Column.Add("MDC_END_DATE,DATE");//DC結束日 arl_Chk_Column.Add("MANUFACTURE,VARCHAR2");//供應商 arl_Chk_Column.Add("ROOT_NO,VARCHAR2");//群分類 arl_Chk_Column.Add("OUT_OF_PRINT,NUMBER");//絕版 arl_Chk_Column.Add("PMA,VARCHAR2");//大分類 arl_Chk_Column.Add("CATEGORY,VARCHAR2");//中分類 arl_Chk_Column.Add("SORT_OUT,VARCHAR2");//小分類 arl_Chk_Column.Add("STATEMENTS,VARCHAR2");//敘述 arl_Chk_Column.Add("ATTRIBUTE,NUMBER");//是否定期 arl_Chk_Column.Add("FIRST_PERIOD,VARCHAR2");//首期期別 arl_Chk_Column.Add("NEW_SW,VARCHAR2");//新商品 arl_Chk_Column.Add("PERIOD_STEP,NUMBER");//期別累加值 arl_Chk_Column.Add("INTERVAL,NUMBER");//出刊間隔 arl_Chk_Column.Add("PUBLISH_TYPE,VARCHAR2");//出刊種類 arl_Chk_Column.Add("UNIT,NUMBER");//銷售單位 arl_Chk_Column.Add("OPEN_SIZE,VARCHAR2");//開本 arl_Chk_Column.Add("PAGE_NUM,NUMBER");//頁數 arl_Chk_Column.Add("WIDTH,NUMBER");//寬 arl_Chk_Column.Add("HIEGHT,NUMBER");//高 arl_Chk_Column.Add("LENGTH,NUMBER");//深 arl_Chk_Column.Add("AUTHOR,VARCHAR2");//作者 arl_Chk_Column.Add("CIP,VARCHAR2");//中央圖書分類碼(CIP) arl_Chk_Column.Add("PUBLISH,VARCHAR2");//VCMS出版社 arl_Chk_Column.Add("ITEM_PUBLISHER_NO,VARCHAR2");//商品出版商代號 arl_Chk_Column.Add("ITEM_PUBLISHER_NAME,VARCHAR2");//商品出版商名稱 arl_Chk_Column.Add("PUBLISHER_TYPE,VARCHAR2");//出版社書系 arl_Chk_Column.Add("PUBLISH_DATE,DATE");//出版日期 arl_Chk_Column.Add("DISTRIBUTE_MODE,VARCHAR2");//配量方式 arl_Chk_Column.Add("QUANTITY,NUMBER");//每店 arl_Chk_Column.Add("ACCEPT_TOTAL,NUMBER");//總進貨量 arl_Chk_Column.Add("RESEMBLE_GOODS,VARCHAR2");//類似商品 arl_Chk_Column.Add("GOODS_MATTER,VARCHAR2");//商品說明 arl_Chk_Column.Add("COMMEND_CAUSE,VARCHAR2");//推薦理由 #endregion #region 檢查資料是否有異動 for (int i = 0; i < arl_Chk_Column.Count; i++) { string[] s_Chk = arl_Chk_Column[i].ToString().Split(','); if (s_Chk[1] == "VARCHAR2") { if (dt_CHK.Rows[0]["OLD_" + s_Chk[0]].ToString() != dt_CHK.Rows[0]["NEW_" + s_Chk[0]].ToString()) { b_Is_All_Same = false; } } else if (s_Chk[1] == "NUMBER") { if (ITMComm.GetValueSetParameter(dt_CHK.Rows[0]["OLD_" + s_Chk[0]].ToString(), "double", false).ToString() != ITMComm.GetValueSetParameter(dt_CHK.Rows[0]["NEW_" + s_Chk[0]].ToString(), "double", false).ToString()) { b_Is_All_Same = false; } } else if (s_Chk[1] == "DATE") { if (ITMComm.GetValueSetParameter(dt_CHK.Rows[0]["OLD_" + s_Chk[0]].ToString(), "date", false).ToString() != ITMComm.GetValueSetParameter(dt_CHK.Rows[0]["NEW_" + s_Chk[0]].ToString(), "date", false).ToString()) { b_Is_All_Same = false; } } } #endregion #region 如果可修改欄位(不含異動原因欄位)都沒有修改,則顯示[沒有更新任何資料] if (b_Is_All_Same == true) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "沒有更新任何資料!", "1", string.Empty); } #endregion } #endregion #region 檢視模式 BUTTON [確定複製]鈕 else if (s_Type == "BUTTON [確定複製]鈕,檢視狀態") { #region 檢查必填欄位 arl_Return = ITMComm.Check_MustFillin_Column(this.slp_CopyInsert_ITEM.Text, "text", "欄位[品號]為必填欄位", "1", this.slp_CopyInsert_ITEM.TextBox_Code.ClientID, arl_Return); #endregion #region 欄位[品號]不可顯示[資料重覆] if (Request[this.slp_CopyInsert_ITEM.TextBox_Name.UniqueID] == "資料重覆") { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, " 該品號已存在,請重新輸入品號", "1", this.slp_CopyInsert_ITEM.TextBox_Code.ClientID); } #endregion } #endregion return arl_Return; }
/// <summary> /// 檢查文字檔條件 /// </summary> /// <param name="dr">要檢查的資料</param> /// <param name="dt_Temp">寫入TempTable的資料</param> /// <param name="dt_PUBLISH_TYPE">出刊種類 CODE</param> /// <param name="dt_UNIT">銷售單位 CODE</param> /// <param name="dt_PRINT_CNTY">印製國家 CODE</param> /// <param name="dt_LANGUAGE">語文 CODE</param> /// <returns></returns> private ArrayList Check_Condition_DataLine(DataRow dr, DataTable dt_Temp, DataTable dt_PUBLISH_TYPE,//出刊種類 DataTable dt_UNIT,//銷售單位 DataTable dt_PRINT_CNTY,//印製國家 DataTable dt_LANGUAGE,//語文 DataTable dt_Excel)//匯入的Excel檔 { #region 宣告 ITMCommon ITMComm = new ITMCommon(); ArrayList arl_Return = new ArrayList(); arl_Return.Add(string.Empty);//該欄位放Focus欄位之ClientID arl_Return.Add(string.Empty);//該欄位放錯誤訊息 #endregion #region 檢查各個欄位型別,長度,是否必填 #region Column[ID] ID arl_Return = ITMComm.Check_MustFillin_Column(dr["ID"].ToString(), "text", "欄位[ID]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["ID"].ToString(), "欄位[ID]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["ID"].ToString()) > 38) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[ID]長度不可大於 38 Byte", "1", string.Empty); } #endregion #region Column[ITEM] 品號 arl_Return = ITMComm.Check_MustFillin_Column(dr["ITEM"].ToString(), "text", "欄位[品號]為必填欄位", "1", string.Empty, arl_Return); System.Text.RegularExpressions.Regex reg_SIX = new System.Text.RegularExpressions.Regex(@"^[0-9]{6}$"); if (reg_SIX.IsMatch(dr["ITEM"].ToString()) == false) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[品號]必需為六位數目字", "1", string.Empty); } #endregion #region Column[ITEM_NAME] 品名 arl_Return = ITMComm.Check_MustFillin_Column(dr["ITEM_NAME"].ToString(), "text", "欄位[品名]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["ITEM_NAME"].ToString()) > 30) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[品名]長度不可大於 30 Byte", "1", string.Empty); } #endregion #region Column[VICE_ITEM_NAME] 副主題 if (ITMComm.Get_Byte_Length(dr["VICE_ITEM_NAME"].ToString()) > 20) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[副主題]長度不可大於 20 Byte", "1", string.Empty); } #endregion #region Column[MDC_START_DATE] DC開始日 arl_Return = ITMComm.Check_MustFillin_Column(dr["MDC_START_DATE"].ToString(), "text", "欄位[DC開始日]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Date(dr["MDC_START_DATE"].ToString(), "欄位[DC開始日]日期格式錯誤(YYYYMMDD)", "yyyyMMdd", "1", string.Empty, arl_Return); #endregion #region Column[MDC_END_DATE] DC結束日 arl_Return = ITMComm.Check_MustFillin_Column(dr["MDC_END_DATE"].ToString(), "text", "欄位[DC結束日]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Date(dr["MDC_END_DATE"].ToString(), "欄位[DC結束日]日期格式錯誤(YYYYMMDD)", "yyyyMMdd", "1", string.Empty, arl_Return); #endregion #region Column[MANUFACTURE] 供應商 arl_Return = ITMComm.Check_MustFillin_Column(dr["MANUFACTURE"].ToString(), "text", "欄位[供應商]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["MANUFACTURE"].ToString()) > 12) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[供應商]長度不可大於 12 Byte", "1", string.Empty); } #endregion #region Column[EDIT_NO] 異動序號 if (dr["EDIT_NO"].ToString() != "0") { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[異動序號]固定為0", "1", string.Empty); } #endregion #region Column[EDIT_REASON] 異動原因 if (dr["EDIT_REASON"].ToString() != string.Empty) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[異動原因]固定為空值", "1", string.Empty); } #endregion #region Column[ROOT_NO] 群分類 arl_Return = ITMComm.Check_MustFillin_Column(dr["ROOT_NO"].ToString(), "text", "欄位[群分類]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["ROOT_NO"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[群分類]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[OUT_OF_PRINT] 絕版 arl_Return = ITMComm.Check_MustFillin_Column(dr["OUT_OF_PRINT"].ToString(), "text", "欄位[絕版]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["OUT_OF_PRINT"].ToString(), "欄位[絕版]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["OUT_OF_PRINT"].ToString()) > 1) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[絕版]長度不可大於 1 Byte", "1", string.Empty); } #endregion #region Column[PMA] 大分類 arl_Return = ITMComm.Check_MustFillin_Column(dr["PMA"].ToString(), "text", "欄位[大分類]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["PMA"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[大分類]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[CATEGORY] 中分類 arl_Return = ITMComm.Check_MustFillin_Column(dr["CATEGORY"].ToString(), "text", "欄位[中分類]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["CATEGORY"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[中分類]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[SORT_OUT] 小分類 arl_Return = ITMComm.Check_MustFillin_Column(dr["SORT_OUT"].ToString(), "text", "欄位[小分類]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["SORT_OUT"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[小分類]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[STATEMENTS] 敘述 if (ITMComm.Get_Byte_Length(dr["STATEMENTS"].ToString()) > 30) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[敘述]長度不可大於 30 Byte", "1", string.Empty); } #endregion #region Column[ATTRIBUTE] 是否定期 arl_Return = ITMComm.Check_MustFillin_Column(dr["ATTRIBUTE"].ToString(), "text", "欄位[是否定期]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["ATTRIBUTE"].ToString(), "欄位[是否定期]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["ATTRIBUTE"].ToString()) > 1) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[是否定期]長度不可大於 1 Byte", "1", string.Empty); } #endregion #region Column[FIRST_PERIOD] 首期期別 arl_Return = ITMComm.Check_MustFillin_Column(dr["FIRST_PERIOD"].ToString(), "text", "欄位[首期期別]為必填欄位", "1", string.Empty, arl_Return); if (reg_SIX.IsMatch(dr["FIRST_PERIOD"].ToString()) == false) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[首期期別]必需為六位數目字", "1", string.Empty); } #endregion #region Column[NEW_SW] 新商品 arl_Return = ITMComm.Check_MustFillin_Column(dr["NEW_SW"].ToString(), "text", "欄位[新商品]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["NEW_SW"].ToString()) > 1) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[新商品]長度不可大於 1 Byte", "1", string.Empty); } #endregion #region Column[PERIOD_STEP] 期別累加值 arl_Return = ITMComm.Check_MustFillin_Column(dr["PERIOD_STEP"].ToString(), "text", "欄位[期別累加值]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["PERIOD_STEP"].ToString(), "欄位[期別累加值]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["PERIOD_STEP"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[期別累加值]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[INTERVAL] 出刊間隔 arl_Return = ITMComm.Check_MustFillin_Column(dr["INTERVAL"].ToString(), "text", "欄位[出刊間隔]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["INTERVAL"].ToString(), "欄位[出刊間隔]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["INTERVAL"].ToString()) > 6) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[出刊間隔]長度不可大於 6 Byte", "1", string.Empty); } #endregion #region Column[PUBLISH_TYPE] 出刊種類 arl_Return = ITMComm.Check_MustFillin_Column(dr["PUBLISH_TYPE"].ToString(), "text", "欄位[出刊種類]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["PUBLISH_TYPE"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[出刊種類]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[UNIT] 銷售單位 arl_Return = ITMComm.Check_MustFillin_Column(dr["UNIT"].ToString(), "text", "欄位[銷售單位]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["UNIT"].ToString(), "欄位[銷售單位]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["UNIT"].ToString()) > 1) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[銷售單位]長度不可大於 1 Byte", "1", string.Empty); } #endregion #region Column[OPEN_SIZE] 開本 if (ITMComm.Get_Byte_Length(dr["OPEN_SIZE"].ToString()) > 10) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[開本]長度不可大於 10 Byte", "1", string.Empty); } #endregion #region Column[PAGE_NUM] 頁數 arl_Return = ITMComm.Check_Format_Int(dr["PAGE_NUM"].ToString(), "欄位[頁數]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["PAGE_NUM"].ToString()) > 3) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[頁數]長度不可大於 3 Byte", "1", string.Empty); } #endregion #region Column[WIDTH] 寬 arl_Return = ITMComm.Check_Format_Double(dr["WIDTH"].ToString(), "欄位[寬]數字格式錯誤", "WIDTH", true, 3, 2, "1", string.Empty, arl_Return); #endregion #region Column[HIEGHT] 高 arl_Return = ITMComm.Check_Format_Double(dr["HIEGHT"].ToString(), "欄位[高]數字格式錯誤", "WIDTH", true, 3, 2, "1", string.Empty, arl_Return); #endregion #region Column[LENGTH] 深 arl_Return = ITMComm.Check_Format_Double(dr["LENGTH"].ToString(), "欄位[深]數字格式錯誤", "WIDTH", true, 3, 2, "1", string.Empty, arl_Return); #endregion #region Column[AUTHOR] 作者 if (ITMComm.Get_Byte_Length(dr["AUTHOR"].ToString()) > 20) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[作者]長度不可大於 20 Byte", "1", string.Empty); } #endregion #region Column[CIP] 中央圖書分類碼 if (ITMComm.Get_Byte_Length(dr["CIP"].ToString()) > 8) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[中央圖書分類碼]長度不可大於 8 Byte", "1", string.Empty); } #endregion #region Column[PUBLISH] VCMS出版社 if (ITMComm.Get_Byte_Length(dr["PUBLISH"].ToString()) > 10) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[VCMS出版社]長度不可大於 10 Byte", "1", string.Empty); } #endregion #region Column[ITEM_PUBLISHER_NO] 商品出版商代號 arl_Return = ITMComm.Check_MustFillin_Column(dr["ITEM_PUBLISHER_NO"].ToString(), "text", "欄位[商品出版商代號]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["ITEM_PUBLISHER_NO"].ToString()) > 10) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品出版商代號]長度不可大於 10 Byte", "1", string.Empty); } #endregion #region Column[ITEM_PUBLISHER_NAME] 商品出版商名稱 arl_Return = ITMComm.Check_MustFillin_Column(dr["ITEM_PUBLISHER_NAME"].ToString(), "text", "欄位[商品出版商名稱]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["ITEM_PUBLISHER_NAME"].ToString()) > 20) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品出版商名稱]長度不可大於 20 Byte", "1", string.Empty); } #endregion #region Column[PUBLISHER_TYPE] 出版社書系 if (ITMComm.Get_Byte_Length(dr["PUBLISHER_TYPE"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[出版社書系]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[PUBLISH_DATE] 出版日期 arl_Return = ITMComm.Check_Format_Date(dr["PUBLISH_DATE"].ToString(), "欄位[出版日期]日期格式錯誤", "yyyyMMdd", "1", string.Empty, arl_Return); #endregion #region Column[PERIOD_END_DATE] 期別結束日 arl_Return = ITMComm.Check_Format_Date(dr["PERIOD_END_DATE"].ToString(), "欄位[期別結束日]日期格式錯誤", "yyyyMMdd", "1", string.Empty, arl_Return); #endregion #region Column[BARCODE] 商品條碼 arl_Return = ITMComm.Check_MustFillin_Column(dr["BARCODE"].ToString(), "text", "欄位[商品條碼]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["BARCODE"].ToString()) > 15) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品條碼]長度不可大於 15 Byte", "1", string.Empty); } if (dr["BARCODE"].ToString().Trim() != "") { DataRow[] FindBarcode = dt_Excel.Select("BARCODE='" + dr["BARCODE"].ToString().Trim() + "'"); if (FindBarcode.Length > 1) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品條碼]與匯入檔案內的其他商品條碼重覆", "1", string.Empty); } //if (CheckDup_BARCODE(dr["BARCODE"].ToString(), "") == true) //{ // arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品條碼]和已存在的商品條碼重覆", "1", string.Empty); //} } #endregion #region Column[PERIOD_BARCODE] 二段條碼 if (ITMComm.Get_Byte_Length(dr["PERIOD_BARCODE"].ToString()) > 13) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[二段條碼]長度不可大於 13 Byte", "1", string.Empty); } #endregion #region Column[PRICE] 零售價 arl_Return = ITMComm.Check_MustFillin_Column(dr["PRICE"].ToString(), "text", "欄位[零售價]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["PRICE"].ToString(), "欄位[零售價]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["PRICE"].ToString()) > 5) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[零售價]長度不可大於 5 Byte", "1", string.Empty); } #endregion #region Column[COST] 成本價 arl_Return = ITMComm.Check_MustFillin_Column(dr["COST"].ToString(), "text", "欄位[成本價]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Double(dr["COST"].ToString(), "欄位[成本價]數字格式錯誤", "COST", true, 5, 2, "1", string.Empty, arl_Return); #endregion #region Column[DISCOUNT_RATE] 折扣率 if (dr["DISCOUNT_RATE"].ToString() != string.Empty) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折扣率]固定為空值", "1", string.Empty); } #endregion #region Column[PERIOD_PAY_TYPE] 物流費基準 arl_Return = ITMComm.Check_MustFillin_Column(dr["PERIOD_PAY_TYPE"].ToString(), "text", "欄位[物流費基準]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["PERIOD_PAY_TYPE"].ToString(), "欄位[物流費基準]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["PERIOD_PAY_TYPE"].ToString()) > 1) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[物流費基準]長度不可大於 1 Byte", "1", string.Empty); } #endregion #region Column[TARGET_RULE] 物流費規則 arl_Return = ITMComm.Check_MustFillin_Column(dr["TARGET_RULE"].ToString(), "text", "欄位[物流費規則]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["TARGET_RULE"].ToString(), "欄位[物流費規則]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["TARGET_RULE"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[物流費規則]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[TAX_TYPE] 稅別 arl_Return = ITMComm.Check_MustFillin_Column(dr["TAX_TYPE"].ToString(), "text", "欄位[稅別]為必填欄位", "1", string.Empty, arl_Return); arl_Return = ITMComm.Check_Format_Int(dr["TAX_TYPE"].ToString(), "欄位[稅別]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["TAX_TYPE"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[稅別]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[DIS_ACCEPT_RATE] 進貨物流費(%) arl_Return = ITMComm.Check_Format_Double(dr["DIS_ACCEPT_RATE"].ToString(), "欄位[進貨物流費(%)]數字格式錯誤", "DIS_ACCEPT_RATE", true, 4, 3, "1", string.Empty, arl_Return); #endregion #region Column[DIS_RETURN_RATE] 退貨物流費(%) arl_Return = ITMComm.Check_Format_Double(dr["DIS_RETURN_RATE"].ToString(), "欄位[退貨物流費(%)]數字格式錯誤", "DIS_RETURN_RATE", true, 4, 3, "1", string.Empty, arl_Return); #endregion #region Column[DIS_ACCEPT_DOLLAR] 進貨物流費(元) arl_Return = ITMComm.Check_Format_Double(dr["DIS_ACCEPT_DOLLAR"].ToString(), "欄位[進貨物流費(元)]數字格式錯誤", "DIS_ACCEPT_DOLLAR", true, 5, 2, "1", string.Empty, arl_Return); #endregion #region Column[DIS_RETURN_DOLLAR] 退貨物流費(元) arl_Return = ITMComm.Check_Format_Double(dr["DIS_RETURN_DOLLAR"].ToString(), "欄位[退貨物流費(元)]數字格式錯誤", "DIS_RETURN_DOLLAR", true, 5, 2, "1", string.Empty, arl_Return); #endregion #region Column[PRINT_CNTY] 印製國家 arl_Return = ITMComm.Check_MustFillin_Column(dr["PRINT_CNTY"].ToString(), "text", "欄位[印製國家]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["PRINT_CNTY"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[印製國家]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[LANGUAGE] 語文 arl_Return = ITMComm.Check_MustFillin_Column(dr["LANGUAGE"].ToString(), "text", "欄位[語文]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["LANGUAGE"].ToString()) > 2) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[語文]長度不可大於 2 Byte", "1", string.Empty); } #endregion #region Column[DISTRIBUTE_MODE] 配量方式 arl_Return = ITMComm.Check_MustFillin_Column(dr["DISTRIBUTE_MODE"].ToString(), "text", "欄位[配量方式]為必填欄位", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["DISTRIBUTE_MODE"].ToString()) > 1) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[配量方式]長度不可大於 1 Byte", "1", string.Empty); } #endregion #region Column[QUANTITY] 每店 arl_Return = ITMComm.Check_Format_Int(dr["QUANTITY"].ToString(), "欄位[每店]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["QUANTITY"].ToString()) > 3) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[每店]長度不可大於 3 Byte", "1", string.Empty); } #endregion #region Column[ACCEPT_TOTAL] 總進貨量 arl_Return = ITMComm.Check_Format_Int(dr["ACCEPT_TOTAL"].ToString(), "欄位[總進貨量]數字格式錯誤", "32", "1", string.Empty, arl_Return); if (ITMComm.Get_Byte_Length(dr["ACCEPT_TOTAL"].ToString()) > 8) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[總進貨量]長度不可大於 8 Byte", "1", string.Empty); } #endregion #region Column[RESEMBLE_GOODS] 類似商品 if (ITMComm.Get_Byte_Length(dr["RESEMBLE_GOODS"].ToString()) > 100) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[類似商品]長度不可大於 100 Byte", "1", string.Empty); } #endregion #region Column[GOODS_MATTER] 商品說明 if (ITMComm.Get_Byte_Length(dr["GOODS_MATTER"].ToString()) > 100) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[商品說明]長度不可大於 100 Byte", "1", string.Empty); } #endregion #region Column[COMMEND_CAUSE] 推薦理由 if (ITMComm.Get_Byte_Length(dr["COMMEND_CAUSE"].ToString()) > 100) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[推薦理由]長度不可大於 100 Byte", "1", string.Empty); } #endregion #endregion #region 如果基本檢查有誤,則Return if (arl_Return[1].ToString() != string.Empty) { return arl_Return; } #endregion #region 自訂檢查 #region 檢查代號是否有正確對應 #region 檢查[供應商]代號 ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter(dr["MANUFACTURE"].ToString(), "string", false)); ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//[登入人員] if (bco.QUERY_VENDOR(ParameterList).Rows[0][0].ToString() == "0") { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[供應商]的代號不正確", "1", string.Empty); } #endregion #region 檢查[出刊種類]代號 if (dt_PUBLISH_TYPE.Select("CODE = '" + dr["PUBLISH_TYPE"].ToString() + "'").Length == 0) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[出刊種類]的代號不正確", "1", string.Empty); } #endregion #region 檢查[銷售單位]代號 if (dt_UNIT.Select("CODE = '" + dr["UNIT"].ToString() + "'").Length == 0) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[銷售單位]的代號不正確", "1", string.Empty); } #endregion #region 檢查[印製國家]代號 if (dt_PRINT_CNTY.Select("CODE = '" + dr["PRINT_CNTY"].ToString() + "'").Length == 0) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[印製國家]的代號不正確", "1", string.Empty); } #endregion #region 檢查[語文]代號 if (dt_LANGUAGE.Select("CODE = '" + dr["LANGUAGE"].ToString() + "'").Length == 0) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[語文]的代號不正確", "1", string.Empty); } #endregion #region 檢查[配量方式]代號 if (dr["DISTRIBUTE_MODE"].ToString() != "1" && dr["DISTRIBUTE_MODE"].ToString() != "2" && dr["DISTRIBUTE_MODE"].ToString() != "3" && dr["DISTRIBUTE_MODE"].ToString() != "4" && dr["DISTRIBUTE_MODE"].ToString() != "5") { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[配量方式]的代號不正確", "1", string.Empty); } #endregion #endregion #region 檢查Between欄位結束欄位一定要大於或等於開始欄位(DC開始日 & DC結束日) arl_Return = ITMComm.Check_Between_End_GreaterThan_Begin (dr["MDC_START_DATE"].ToString(), dr["MDC_END_DATE"].ToString(), "date", "欄位[DC結束日]一定要大於或等於欄位[DC開始日]", "1", string.Empty, arl_Return); #endregion #region 檢查[群分類][大分類][中分類][小分類]的階層關係是否正確 #region 設定變數 string s_PATTERN_NO = string.Empty; string s_Result = string.Empty; #endregion #region 傳入參數 s_PATTERN_NO = dr["ROOT_NO"].ToString() + dr["PMA"].ToString() + dr["CATEGORY"].ToString() + dr["SORT_OUT"].ToString(); ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter(s_PATTERN_NO, "string", false));//[PATTERN_NO] ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//[登入人員] #endregion #region 連結資料庫 s_Result = bco.CHK_ITM_PATTERN_NO(ParameterList).Rows[0]["result"].ToString(); #endregion #region 檢查回傳值 if (s_Result == "NO") { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[群分類][大分類][中分類][小分類]的階層關係不正確", "1", string.Empty); } #endregion #endregion #region 欄位[期別結束日]必需大於或等於系統日 if (dr["PERIOD_END_DATE"].ToString() != string.Empty) { DateTime d_PERIOD_END_DATE = DateTime.ParseExact(dr["PERIOD_END_DATE"].ToString(), "yyyyMMdd", null); if (d_PERIOD_END_DATE < DateTime.Now.Date) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[期別結束日]必需大於或等於系統日", "1", string.Empty); } } #endregion #region 欄位[零售價]必需大於欄位[成本價] if (double.Parse(dr["COST"].ToString()) > int.Parse(dr["PRICE"].ToString())) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[零售價]必需大於欄位[成本價]", "1", string.Empty); } #endregion #region 欄位[折扣率]計算是否正確 //整批匯入直接幫使用者算,不必檢查 #endregion #region 判斷欄位[物流費基準] if (dr["PERIOD_PAY_TYPE"].ToString() == "1")//元 { if (dr["DIS_ACCEPT_RATE"].ToString() != string.Empty || dr["DIS_RETURN_RATE"].ToString() != string.Empty) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[物流費基準]=1時,[進貨物流費(%)][退貨物流費(%)]必須為空值", "1", string.Empty); } } else if (dr["PERIOD_PAY_TYPE"].ToString() == "2")//率 { if (dr["DIS_ACCEPT_DOLLAR"].ToString() != string.Empty || dr["DIS_RETURN_DOLLAR"].ToString() != string.Empty) { arl_Return = ITMComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[物流費基準]=2時,[進貨物流費(元)][退貨物流費(元)]必須為空值", "1", string.Empty); } } #endregion #endregion return arl_Return; }
/// <summary> /// BUTTON [載入檔案]鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but_LoadFile_Click(object sender, EventArgs e) { try { #region 將Client端的檔案上傳至AP端 #region 宣告變數 string s_UploadPath = string.Empty; ArrayList arl_Return = new ArrayList(); #endregion #region 將Client端的檔案上傳至AP端 s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "ITM\\"; arl_Return = bco.FileUpload(s_UploadPath, this.fileupload_Path, Session["UID"].ToString()); #endregion #region 檢查回傳結果 if (arl_Return[0].ToString() == "FALSE") { #region 清空上傳匯入結果 this.UploadStatusPanel1.UploadSum = 0;//上傳結果總筆數 this.UploadStatusPanel1.UploadOK = 0;//上傳結果正常筆數 this.UploadStatusPanel1.UploadNG = 0;//上傳結果錯誤筆數 this.UploadStatusPanel1.ImportSum = 0;//匯入結果總筆數 this.UploadStatusPanel1.ImportOK = 0;//匯入結果正常筆數 this.UploadStatusPanel1.ImportNG = 0;//匯入結果錯誤筆數 #endregion #region 設定控制項 this.but_Import.Enabled = false;//確定匯入 this.but_Error.Enabled = false;//檢視異常 #endregion this.ErrorMsgLabel.Text = arl_Return[1].ToString(); return; } #endregion #endregion #region 依據AP端檔案資料匯入TmpTable #region 取得 TempTable VDS_ITM_ITEM_TMP 的 SCHEMA ITMCommon ITMComm = new ITMCommon(); DataTable dt_Temp = new DataTable(); ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID dt_Temp = bco.GET_ITM_PRE_ITEM_TMP_SCHEMA(ParameterList); #endregion #region 將資料寫入 TempTable DateTime d_Now = DateTime.Now; #region 讀取 Excel 資料 OleDbConnection oleConnection = null; DataSet ds_Excel = new DataSet(); try { //HDR=YES是表示Excel中的第一列為欄名。 //IMEX=1是表示儲存格內容若是文字和數字混合的內容, 要當做文字處理。 String connString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source =" + arl_Return[1].ToString() + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1';"; oleConnection = new OleDbConnection(connString); oleConnection.Open(); OleDbCommand oleCommand = new OleDbCommand("SELECT * FROM [Sheet1$] where (ID is not null and ID <> 'ID')", oleConnection); OleDbDataAdapter oleAdapter = new OleDbDataAdapter(oleCommand); oleAdapter.Fill(ds_Excel); #region 請注意如果EXCEL檔欄位有值,但到DB卻沒有資料 //請修改,機碼 HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\Excel\TypeGuessRows 值 //預設是 8, 表示會先讀取前 8 列來決定每一個欄位的型態, 所以如果前 8 列的資料都是數字, 到了第 9 列以後出現的文字資料都會變成 null //如果要解決這個問題, 只要把 TypeGuessRows 機碼值改成 0 #endregion } catch (Exception ex) { throw new Exception("讀取 Excel 資料失敗:" + ex.Message); } finally { if (oleConnection != null) { oleConnection.Close(); oleConnection.Dispose(); } } #endregion #region 取得[出刊種類][銷售單位][印製國家][語文]的代號表 #region 設定變數 DataTable dt_PUBLISH_TYPE = new DataTable();//出刊種類 DataTable dt_UNIT = new DataTable();//銷售單位 DataTable dt_PRINT_CNTY = new DataTable();//印製國家 DataTable dt_LANGUAGE = new DataTable();//語文 #endregion #region 取得[出刊種類]代號表 ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter("5", "string", false)); ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//[登入人員] dt_PUBLISH_TYPE = bco.QUERY_SYS_CODE_DETL_CODE(ParameterList); #endregion #region 取得[銷售單位]代號表 ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter("ITM", "string", false)); ParameterList.Add(ITMComm.GetValueSetParameter("ITEM_UNIT", "string", false)); ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//[登入人員] dt_UNIT = bco.QUERY_SYS_ENUMBASE_CODE(ParameterList); #endregion #region 取得[印製國家]代號表 ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter("I8", "string", false)); ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//[登入人員] dt_PRINT_CNTY = bco.QUERY_SYS_CODE_DETL_CODE(ParameterList); #endregion #region 取得[語文]代號表 ParameterList.Clear(); ParameterList.Add(ITMComm.GetValueSetParameter("I6", "string", false)); ParameterList.Add(ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//[登入人員] dt_LANGUAGE = bco.QUERY_SYS_CODE_DETL_CODE(ParameterList); #endregion #endregion foreach (DataRow dr in ds_Excel.Tables[0].Rows) { #region 檢查條件 ArrayList arl_ConditionReturn = Check_Condition_DataLine(dr, dt_Temp, dt_PUBLISH_TYPE,//出刊種類 dt_UNIT,//銷售單位 dt_PRINT_CNTY,//印製國家 dt_LANGUAGE, ds_Excel.Tables[0]);//語文 #endregion if (arl_ConditionReturn[1].ToString() == string.Empty) { #region 檢查正確 DataRow dr_Temp = dt_Temp.NewRow(); #region 計算[折扣率] //若欄位[零售價]=0,則欄位[折扣率]必須=0 //折扣率=成本/零售價 if (dr["PRICE"].ToString() == "0") { dr["DISCOUNT_RATE"] = 0; } else { dr["DISCOUNT_RATE"] = System.Math.Round(double.Parse(dr["COST"].ToString()) / int.Parse(dr["PRICE"].ToString()), 2, MidpointRounding.AwayFromZero); } #endregion dr_Temp["ID"] = ITMComm.GetValueSetParameter(dr["ID"].ToString(), "int", false);//ID dr_Temp["STATUS"] = ITMComm.GetValueSetParameter("1", "int", false);//處理狀態(1:正常資料;2:錯誤資料) dr_Temp["DATASOURCE"] = ITMComm.GetValueSetParameter(arl_Return[3].ToString(), "string", false);//匯入檔案 dr_Temp["DATATYPE"] = ITMComm.GetValueSetParameter("1", "int", false);//資料類別(1:FILE TO TMP;2:TMP TO DB) dr_Temp["MEMO"] = ITMComm.GetValueSetParameter(string.Empty, "string", false);//說明 dr_Temp["ITEM"] = ITMComm.GetValueSetParameter(dr["ITEM"].ToString(), "string", false);//品號 dr_Temp["ITEM_NAME"] = ITMComm.GetValueSetParameter(dr["ITEM_NAME"].ToString(), "string", false);//品名 dr_Temp["VICE_ITEM_NAME"] = ITMComm.GetValueSetParameter(dr["VICE_ITEM_NAME"].ToString(), "string", false);//副主題 dr_Temp["MDC_START_DATE"] = ITMComm.GetValueSetParameter(dr["MDC_START_DATE"].ToString(), "datecustom", "yyyyMMdd", false);//DC開始日 dr_Temp["MDC_END_DATE"] = ITMComm.GetValueSetParameter(dr["MDC_END_DATE"].ToString(), "datecustom", "yyyyMMdd", false);//DC結束日 dr_Temp["MANUFACTURE"] = ITMComm.GetValueSetParameter(dr["MANUFACTURE"].ToString(), "string", false);//供應商 dr_Temp["EDIT_NO"] = ITMComm.GetValueSetParameter(dr["EDIT_NO"].ToString(), "string", false);//異動序號 dr_Temp["EDIT_REASON"] = ITMComm.GetValueSetParameter(dr["EDIT_REASON"].ToString(), "string", false);//異動原因 dr_Temp["ROOT_NO"] = ITMComm.GetValueSetParameter(dr["ROOT_NO"].ToString(), "string", false);//群分類 dr_Temp["OUT_OF_PRINT"] = ITMComm.GetValueSetParameter(dr["OUT_OF_PRINT"].ToString(), "int", false);//絕版 dr_Temp["PMA"] = ITMComm.GetValueSetParameter(dr["PMA"].ToString(), "string", false);//大分類 dr_Temp["CATEGORY"] = ITMComm.GetValueSetParameter(dr["CATEGORY"].ToString(), "string", false);//中分類 dr_Temp["SORT_OUT"] = ITMComm.GetValueSetParameter(dr["SORT_OUT"].ToString(), "string", false);//小分類 dr_Temp["STATEMENTS"] = ITMComm.GetValueSetParameter(dr["STATEMENTS"].ToString(), "string", false);//敘述 dr_Temp["ATTRIBUTE"] = ITMComm.GetValueSetParameter(dr["ATTRIBUTE"].ToString(), "int", false);//是否定期 dr_Temp["FIRST_PERIOD"] = ITMComm.GetValueSetParameter(dr["FIRST_PERIOD"].ToString(), "string", false);//首期期別 dr_Temp["NEW_SW"] = ITMComm.GetValueSetParameter(dr["NEW_SW"].ToString(), "string", false);//新商品 dr_Temp["PERIOD_STEP"] = ITMComm.GetValueSetParameter(dr["PERIOD_STEP"].ToString(), "int", false);//期別累加值 dr_Temp["INTERVAL"] = ITMComm.GetValueSetParameter(dr["INTERVAL"].ToString(), "int", false);//出刊間隔 dr_Temp["PUBLISH_TYPE"] = ITMComm.GetValueSetParameter(dr["PUBLISH_TYPE"].ToString(), "string", false);//出刊種類 dr_Temp["UNIT"] = ITMComm.GetValueSetParameter(dr["UNIT"].ToString(), "int", false);//銷售單位 dr_Temp["OPEN_SIZE"] = ITMComm.GetValueSetParameter(dr["OPEN_SIZE"].ToString(), "string", false);//開本 dr_Temp["PAGE_NUM"] = ITMComm.GetValueSetParameter(dr["PAGE_NUM"].ToString(), "int", false);//頁數 dr_Temp["WIDTH"] = ITMComm.GetValueSetParameter(dr["WIDTH"].ToString(), "double", false);//寬 dr_Temp["HIEGHT"] = ITMComm.GetValueSetParameter(dr["HIEGHT"].ToString(), "double", false);//高 dr_Temp["LENGTH"] = ITMComm.GetValueSetParameter(dr["LENGTH"].ToString(), "double", false);//深 dr_Temp["AUTHOR"] = ITMComm.GetValueSetParameter(dr["AUTHOR"].ToString(), "string", false);//作者 dr_Temp["CIP"] = ITMComm.GetValueSetParameter(dr["CIP"].ToString(), "string", false);//中央圖書分類碼 dr_Temp["PUBLISH"] = ITMComm.GetValueSetParameter(dr["PUBLISH"].ToString(), "string", false);//VCMS出版社 dr_Temp["ITEM_PUBLISHER_NO"] = ITMComm.GetValueSetParameter(dr["ITEM_PUBLISHER_NO"].ToString(), "string", false);//商品出版商代號 dr_Temp["ITEM_PUBLISHER_NAME"] = ITMComm.GetValueSetParameter(dr["ITEM_PUBLISHER_NAME"].ToString(), "string", false);//商品出版商名稱 dr_Temp["PUBLISHER_TYPE"] = ITMComm.GetValueSetParameter(dr["PUBLISHER_TYPE"].ToString(), "string", false);//出版社書系 dr_Temp["PUBLISH_DATE"] = ITMComm.GetValueSetParameter(dr["PUBLISH_DATE"].ToString(), "datecustom", "yyyyMMdd", false);//出版日期 dr_Temp["PERIOD_END_DATE"] = ITMComm.GetValueSetParameter(dr["PERIOD_END_DATE"].ToString(), "datecustom", "yyyyMMdd", false);//期別結束日 dr_Temp["BARCODE"] = ITMComm.GetValueSetParameter(dr["BARCODE"].ToString(), "string", false);//商品條碼 dr_Temp["PERIOD_BARCODE"] = ITMComm.GetValueSetParameter(dr["PERIOD_BARCODE"].ToString(), "string", false);//二段條碼 dr_Temp["PRICE"] = ITMComm.GetValueSetParameter(dr["PRICE"].ToString(), "int", false);//零售價 dr_Temp["COST"] = ITMComm.GetValueSetParameter(dr["COST"].ToString(), "double", false);//成本價 dr_Temp["DISCOUNT_RATE"] = ITMComm.GetValueSetParameter(dr["DISCOUNT_RATE"].ToString(), "double", false);//折扣率 dr_Temp["PERIOD_PAY_TYPE"] = ITMComm.GetValueSetParameter(dr["PERIOD_PAY_TYPE"].ToString(), "int", false);//物流費基準 dr_Temp["TARGET_RULE"] = ITMComm.GetValueSetParameter(dr["TARGET_RULE"].ToString(), "int", false);//物流費規則 dr_Temp["TAX_TYPE"] = ITMComm.GetValueSetParameter(dr["TAX_TYPE"].ToString(), "int", false);//稅別 dr_Temp["DIS_ACCEPT_RATE"] = ITMComm.GetValueSetParameter(dr["DIS_ACCEPT_RATE"].ToString(), "double", false);//進貨物流費 dr_Temp["DIS_RETURN_RATE"] = ITMComm.GetValueSetParameter(dr["DIS_RETURN_RATE"].ToString(), "double", false);//退貨物流費 dr_Temp["DIS_ACCEPT_DOLLAR"] = ITMComm.GetValueSetParameter(dr["DIS_ACCEPT_DOLLAR"].ToString(), "double", false);//進貨物流費 dr_Temp["DIS_RETURN_DOLLAR"] = ITMComm.GetValueSetParameter(dr["DIS_RETURN_DOLLAR"].ToString(), "double", false);//退貨物流費 dr_Temp["PRINT_CNTY"] = ITMComm.GetValueSetParameter(dr["PRINT_CNTY"].ToString(), "string", false);//印製國家 dr_Temp["LANGUAGE"] = ITMComm.GetValueSetParameter(dr["LANGUAGE"].ToString(), "string", false);//語文 dr_Temp["DISTRIBUTE_MODE"] = ITMComm.GetValueSetParameter(dr["DISTRIBUTE_MODE"].ToString(), "string", false);//配量方式 dr_Temp["QUANTITY"] = ITMComm.GetValueSetParameter(dr["QUANTITY"].ToString(), "int", false);//每店 dr_Temp["ACCEPT_TOTAL"] = ITMComm.GetValueSetParameter(dr["ACCEPT_TOTAL"].ToString(), "int", false);//總進貨量 dr_Temp["RESEMBLE_GOODS"] = ITMComm.GetValueSetParameter(dr["RESEMBLE_GOODS"].ToString(), "string", false);//類似商品 dr_Temp["GOODS_MATTER"] = ITMComm.GetValueSetParameter(dr["GOODS_MATTER"].ToString(), "string", false);//商品說明 dr_Temp["COMMEND_CAUSE"] = ITMComm.GetValueSetParameter(dr["COMMEND_CAUSE"].ToString(), "string", false);//推薦理由 dr_Temp["CREATEUID"] = ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//建立人員 dr_Temp["CREATEDATE"] = ITMComm.GetValueSetParameter(d_Now.ToString(), "datetime", false);//建立日期 dr_Temp["UPDATEUID"] = ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//異動人員 dr_Temp["UPDATEDATE"] = ITMComm.GetValueSetParameter(d_Now.ToString(), "datetime", false);//異動日期 dt_Temp.Rows.Add(dr_Temp); #endregion } else { #region 檢查不正確 DataRow dr_Temp = dt_Temp.NewRow(); string s_ErrorMsg = string.Empty; s_ErrorMsg = arl_ConditionReturn[1].ToString().Replace("<br/>", ","); s_ErrorMsg = ITMComm.Get_Byte_Length(s_ErrorMsg) > 500 ? s_ErrorMsg.Substring(0, 250) : s_ErrorMsg;//MEMO欄位=VARCHAR2(500) dr_Temp["ID"] = ITMComm.GetValueSetParameter((arl_ConditionReturn[1].ToString().IndexOf("欄位[ID]數字格式錯誤") == -1) ? dr["ID"].ToString() : string.Empty, "int", false); dr_Temp["STATUS"] = ITMComm.GetValueSetParameter("2", "int", false);//處理狀態(1:正常資料;2:錯誤資料) dr_Temp["DATASOURCE"] = ITMComm.GetValueSetParameter(arl_Return[3].ToString(), "string", false);//匯入檔案 dr_Temp["DATATYPE"] = ITMComm.GetValueSetParameter("1", "int", false);//資料類別(1:FILE TO TMP;2:TMP TO DB) dr_Temp["MEMO"] = s_ErrorMsg;//說明 dr_Temp["CREATEUID"] = ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false); dr_Temp["CREATEDATE"] = ITMComm.GetValueSetParameter(d_Now.ToString(), "datetime", false); dr_Temp["UPDATEUID"] = ITMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false); dr_Temp["UPDATEDATE"] = ITMComm.GetValueSetParameter(d_Now.ToString(), "datetime", false); dt_Temp.Rows.Add(dr_Temp); #endregion } } #endregion #region 連結資料庫 if (dt_Temp.Rows.Count == 0) { this.ErrorMsgLabel.Text = "無匯入資料"; return; } else { #region 將資料寫入TempTable DataTable dt_Return = bco.FileToTmp(null, Session["UID"].ToString(), dt_Temp); #endregion #region 計算[總筆數][正常筆數][錯誤筆數] int i_Total_Count = 0;//總筆數 int i_Success_Count = 0;//正常筆數 int i_Failure_Count = 0;//錯誤筆數 string s_FilterExpression = string.Empty; s_FilterExpression = "STATUS ='1'";//1:正常資料; DataRow[] dr_Success = dt_Return.Select(s_FilterExpression); if (dr_Success.Length == 1) { i_Success_Count = int.Parse(dr_Success[0]["count"].ToString()); } s_FilterExpression = "STATUS ='2'";//2:錯誤資料; DataRow[] dr_Failure = dt_Return.Select(s_FilterExpression); if (dr_Failure.Length == 1) { i_Failure_Count = int.Parse(dr_Failure[0]["count"].ToString()); } i_Total_Count = i_Success_Count + i_Failure_Count; this.UploadStatusPanel1.UploadSum = i_Total_Count;//上傳結果總筆數 this.UploadStatusPanel1.UploadOK = i_Success_Count;//上傳結果正常筆數 this.UploadStatusPanel1.UploadNG = i_Failure_Count;//上傳結果錯誤筆數 this.UploadStatusPanel1.ImportSum = 0;//匯入結果總筆數 this.UploadStatusPanel1.ImportOK = 0;//匯入結果正常筆數 this.UploadStatusPanel1.ImportNG = 0;//匯入結果錯誤筆數 #endregion #region 設定控制項 if ((i_Total_Count == i_Success_Count) && (i_Failure_Count == 0)) { this.but_Import.Enabled = true;//確定匯入 this.but_Error.Enabled = false;//檢視異常 } if (i_Failure_Count > 0) { this.but_Import.Enabled = false;//確定匯入 this.but_Error.Enabled = true;//檢視異常 } #endregion } #endregion #endregion } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } finally { #region 設定 TabContainer 的 ActiveTabIndex this.TabContainer1.ActiveTabIndex = 1; #endregion } }