public string PARAMName(string Code) { string Name = ""; string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase; MaintainDisParameter BCO = new MaintainDisParameter(ConnectionDBStr); if (Code != "") { ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(9999); DataTable Dt = BCO.QuerySwitch(ALOCommon.QueryType.ALL, ParameterList); int res = 0; foreach (DataRow dr in Dt.Rows) { if (dr["Code"].ToString().Trim() == Code) { Name = dr["Name"].ToString().Trim(); res++; } } if (res != 1) { Name = "查無資料"; } } return Name; }
}//Page_Load private void QueryData() { #region //抓取本頁初次登記的時間 string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConnectionDB); ArrayList ParameterList = new ArrayList();//20091113 ParameterList.Clear(); TextBoxCode.Text = TextBoxCode.Text + "%"; TextBoxName.Text = TextBoxName.Text + "%"; ParameterList.Add(TextBoxCode.Text); ParameterList.Add(TextBoxName.Text); ParameterList.Add(TextBoxRowCountLimit.Text.Trim()); DataTable Dt = BCO.QuerySwitch(ALOModel.ALOCommon.QueryType.QryFileForSLP, ParameterList); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; //設定分頁大小 GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); GridView1.SelectedIndex = -1; LabelQueryRecordCount.Text = string.Format(" {0} Rows ", Dt.Rows.Count.ToString()); #endregion }
private void QueryData() { #region string SessionIDName = "ALO021_" + PageTimeStamp.Value; ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConntionDB); DataTable dt = null; ArrayList ParameterList = new ArrayList();//20091112 ParameterList.Clear(); Int32 iTopRowNum; Int32.TryParse(TextBoxRowCountLimit.Text.Trim(), out iTopRowNum); if (TextBoxParam.Text == "") { ParameterList.Add(iTopRowNum); dt = BCO.QuerySwitch(ALOModel.MaintainDisParameter.QueryType.ALL, ParameterList); } else { if (CheckBoxLikeSearch.Checked) { ParameterList.Add(string.Format("%{0}%", TextBoxParam.Text)); ParameterList.Add(null); ParameterList.Add(iTopRowNum); dt = BCO.QuerySwitch(ALOModel.MaintainDisParameter.QueryType.QryFileForSLP, ParameterList); } else { ParameterList.Add(TextBoxParam.Text); ParameterList.Add(iTopRowNum); dt = BCO.QuerySwitch(ALOModel.MaintainDisParameter.QueryType.CODE, ParameterList); } } Session[SessionIDName] = dt; GridView1.DataSource = dt; GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { #region aryParamsPKey.Add(dr["CODE"]); #endregion } } else { ResultMsgLabel.Text = "查無資料"; } Session[string.Format("{0}_{1}", strPreFixed, PageTimeStamp.Value)] = aryParamsPKey; LabelQueryRecordCount.Text = string.Format(" {0} Rows ", dt.Rows.Count.ToString()); #endregion }
//--於新增模式按下存檔鈕 protected void InsertSaveButton_Click(object sender, EventArgs e) { #region if (FormView1.CurrentMode == FormViewMode.Insert) { #region int AddRecord = 0; try { ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConntionDB); #region 取得畫面元件的值 string v_CODE = ((TextBox)FormView1.FindControl("txtCODE")).Text.Trim(); string v_NAME = ((TextBox)FormView1.FindControl("txtNAME")).Text.Trim(); string v_SELECT_SW = (((CheckBox)FormView1.FindControl("chk_SELECT_SW")).Checked) ? "1" : "0"; string v_REFER_SW = (((CheckBox)FormView1.FindControl("chk_REFER_SW")).Checked) ? "1" : "0"; string v_SORT_SW = (((CheckBox)FormView1.FindControl("chk_SORT_SW")).Checked) ? "1" : "0"; string v_POS_SW = (((CheckBox)FormView1.FindControl("chk_POS_SW")).Checked) ? "1" : "0"; string v_RANK_SW = (((CheckBox)FormView1.FindControl("chk_RANK_SW")).Checked) ? "1" : "0";//20090106 added //DateTime v_UPDATEDATE = Convert.ToDateTime(((WUI.SLP.SLPDate)FormView1.FindControl("SLP_SLPDate1")).Text.Trim()); DateTime v_UPDATEDATE = System.DateTime.Now; if (Session["UID"] == null) throw new Exception("Session Time Out"); string v_UPDATEUID = Session["UID"].ToString(); string v_SELECT_CHANGE = (((CheckBox)FormView1.FindControl("chk_SELECT_CHANGE")).Checked) ? "1" : "0"; int v_SELECT_PERIOD = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtPeriod")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtPeriod")).Text.Trim()); int v_SELECT_ITEM = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtItemCount")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtItemCount")).Text.Trim()); int v_SELECT_P_FROM = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtPFrom")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtPFrom")).Text.Trim()); int v_SELECT_P_TO = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtPTo")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtPTo")).Text.Trim()); string v_REFER_CHANGE = (((CheckBox)FormView1.FindControl("chk_REFER_CHANGE")).Checked) ? "1" : "0"; int v_REFER_OTHER = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRateOther")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRateOther")).Text.Trim()); int v_REFER_RATE1 = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate1")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate1")).Text.Trim()); int v_REFER_RATE2 = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate2")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate2")).Text.Trim()); int v_REFER_RATE3 = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate3")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate3")).Text.Trim()); int v_REFER_RATE4 = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate4")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate4")).Text.Trim()); string v_SORT_KEY1 = ((TextBox)FormView1.FindControl("txtSort1")).Text.Trim(); string v_SORT_KEY2 = ((TextBox)FormView1.FindControl("txtSort2")).Text.Trim(); string v_SORT_KEY3 = ((TextBox)FormView1.FindControl("txtSort3")).Text.Trim(); #endregion #region 檢查輸入值 if (GetStringLen(v_NAME) > 20) { ErrorMsgLabel.Text = "參數名稱限制20個字元"; return; } //20090106 marked //if (((TextBox)FormView1.FindControl("txtCODE")).Text.Trim() == "") //{ // ScriptManager.RegisterStartupScript(Page, this.GetType(), "ALO022.aspx", "alert(' 參數編號不得為空白 ');", true); // return; //} //if (((TextBox)FormView1.FindControl("txtNAME")).Text.Trim() == "") //{ // ScriptManager.RegisterStartupScript(Page, this.GetType(), "ALO022.aspx", "alert(' 參數名稱不得為空白 ');", true); // return; //} //if (v_SELECT_P_TO != (v_SELECT_PERIOD + v_SELECT_P_FROM - 1)) //{ // ScriptManager.RegisterStartupScript(Page, this.GetType(), "ALO022.aspx", "alert(' [前幾期To] 須等於 [往前取幾期] + [前幾期From] - 1 ');", true); // return; //} //if ((v_REFER_RATE1 + v_REFER_RATE2 + v_REFER_RATE3 + v_REFER_RATE4) != 100) //{ // ScriptManager.RegisterStartupScript(Page, this.GetType(), "ALO022.aspx", "alert(' 比率1 + 比率2 + 比率3 + 比率4 的總合須為100 ');", true); // return; //} #endregion #region 刪除Table中相同CODE但ENABLE為0的資料 DataTable Dt2 = new DataTable(); ArrayList ParameterList = new ArrayList();//20091112 ParameterList.Clear(); ParameterList.Add(v_CODE); Dt2 = BCO.QuerySwitch(ALOModel.MaintainDisParameter.QueryType.QueryAllDel, ParameterList); for (int i = 0; i <= Dt2.Rows.Count - 1; i++) { if (Dt2.Rows[i]["CODE"].ToString() == v_CODE && Dt2.Rows[i]["ENABLE"].ToString() == "0") { ParameterList.Clear(); ParameterList.Add(v_CODE); BCO.DeleteDisParameter(ParameterList, null); } else { EditSaveButton_Click(null, null); } } #endregion #region 加入輸入條件 ParameterList.Clear(); ParameterList.Add(v_CODE); ParameterList.Add(v_NAME); ParameterList.Add(v_SELECT_SW); ParameterList.Add(v_REFER_SW); ParameterList.Add(v_SORT_SW); ParameterList.Add(v_POS_SW); ParameterList.Add(v_UPDATEDATE); ParameterList.Add(v_UPDATEUID); //取樣控制 ParameterList.Add(v_SELECT_CHANGE); ParameterList.Add(v_SELECT_PERIOD); ParameterList.Add(v_SELECT_ITEM); ParameterList.Add(v_SELECT_P_FROM); ParameterList.Add(v_SELECT_P_TO); //參照比例 ParameterList.Add(v_REFER_CHANGE); ParameterList.Add(v_REFER_OTHER); ParameterList.Add(v_REFER_RATE1); ParameterList.Add(v_REFER_RATE2); ParameterList.Add(v_REFER_RATE3); ParameterList.Add(v_REFER_RATE4); //排序控制 ParameterList.Add(v_SORT_KEY1); ParameterList.Add(v_SORT_KEY2); ParameterList.Add(v_SORT_KEY3); ParameterList.Add(v_RANK_SW);//200901016 added #endregion AddRecord = BCO.CreateDisParameter(ParameterList, null); if (AddRecord == 0) { throw new Exception("新增0筆資料!"); } else { //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", string.Format("alert('新增完成');location.replace('ALO022.aspx?Code={0}&CurrentMode=readonly');", v_CODE), true); s_PARAMCODE = v_CODE; ResultMsgLabel.Text = "新增完成"; SwitchFormviewMode(FormViewMode.ReadOnly); aryParamsPKey.Clear();//清空ID ArrayList } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion } #endregion }
//--於編輯模式按下保存鈕 protected void EditSaveButton_Click(object sender, EventArgs e) { #region if (FormView1.CurrentMode == FormViewMode.Edit) { #region int UpdateRecord = 0; try { ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConntionDB); #region 取得畫面元件的值 string v_CODE = ((TextBox)FormView1.FindControl("txtCODE")).Text.Trim(); string v_NAME = ((TextBox)FormView1.FindControl("txtNAME")).Text.Trim(); string v_SELECT_SW = (((CheckBox)FormView1.FindControl("chk_SELECT_SW")).Checked) ? "1" : "0"; string v_REFER_SW = (((CheckBox)FormView1.FindControl("chk_REFER_SW")).Checked) ? "1" : "0"; string v_SORT_SW = (((CheckBox)FormView1.FindControl("chk_SORT_SW")).Checked) ? "1" : "0"; string v_POS_SW = (((CheckBox)FormView1.FindControl("chk_POS_SW")).Checked) ? "1" : "0"; string v_RANK_SW = (((CheckBox)FormView1.FindControl("chk_RANK_SW")).Checked) ? "1" : "0";//20090106 added DateTime v_UPDATEDATE = Convert.ToDateTime(((WUI.SLP.SLPDate)FormView1.FindControl("SLP_SLPDate1")).Text.Trim()); string v_UPDATEUID = ((WUI.SLP.User)FormView1.FindControl("txtUser")).Text.Trim(); string v_SELECT_CHANGE = (((CheckBox)FormView1.FindControl("chk_SELECT_CHANGE")).Checked) ? "1" : "0"; int v_SELECT_PERIOD = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtPeriod")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtPeriod")).Text.Trim()); int v_SELECT_ITEM = 0; if (((WUI.SLP.SLPNumber)FormView1.FindControl("txtItemCount")).Text.Trim() != "") { v_SELECT_ITEM = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtItemCount")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtItemCount")).Text.Trim()); } int v_SELECT_P_FROM = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtPFrom")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtPFrom")).Text.Trim()); int v_SELECT_P_TO = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtPTo")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtPTo")).Text.Trim()); string v_REFER_CHANGE = (((CheckBox)FormView1.FindControl("chk_REFER_CHANGE")).Checked) ? "1" : "0"; int v_REFER_OTHER = 0; if (((WUI.SLP.SLPNumber)FormView1.FindControl("txtRateOther")).Text.Trim() != "") { v_REFER_OTHER = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRateOther")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRateOther")).Text.Trim()); } int v_REFER_RATE1 = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate1")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate1")).Text.Trim()); int v_REFER_RATE2 = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate2")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate2")).Text.Trim()); int v_REFER_RATE3 = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate3")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate3")).Text.Trim()); int v_REFER_RATE4 = Convert.ToInt32((((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate4")).Text.Trim() == "") ? "0" : ((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate4")).Text.Trim()); string v_SORT_KEY1 = ((TextBox)FormView1.FindControl("txtSort1")).Text.Trim(); string v_SORT_KEY2 = ((TextBox)FormView1.FindControl("txtSort2")).Text.Trim(); string v_SORT_KEY3 = ((TextBox)FormView1.FindControl("txtSort3")).Text.Trim(); #endregion #region 檢查輸入值 if (GetStringLen(v_NAME) > 20) { ErrorMsgLabel.Text = "參數名稱限制20個字元"; return; } //20090106 marked //if (v_SELECT_P_TO != (v_SELECT_PERIOD + v_SELECT_P_FROM - 1)) //{ // ScriptManager.RegisterStartupScript(Page, this.GetType(), "ALO022.aspx", "alert(' [前幾期To] 須等於 [往前取幾期] + [前幾期From] - 1 ');", true); // return; //} //if ((v_REFER_RATE1 + v_REFER_RATE2 + v_REFER_RATE3 + v_REFER_RATE4) != 100) //{ // ScriptManager.RegisterStartupScript(Page, this.GetType(), "ALO022.aspx", "alert(' 比率1 + 比率2 + 比率3 + 比率4 的總合須為100 ');", true); // return; //} #endregion #region 取得更新前舊值 #region 使用XML轉回DataSet //if ( MasterOLDData.InnerHtml //DataSet Ds = new DataSet(); //System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml); //Ds.ReadXml(sr); //DataTable Dt = Ds.Tables[0]; #endregion //if (Ds.Tables[0].Rows.Count == 0) //{ // throw new Exception("抓取不到舊值,更新失敗!"); //} #endregion #region 加入更新條件 ArrayList ParameterList = new ArrayList();//20091112 ParameterList.Clear(); //舊值 ParameterList.Add(v_CODE); ParameterList.Add(v_UPDATEDATE); ParameterList.Add(v_UPDATEUID); //需要更新值 ParameterList.Add(v_CODE); ParameterList.Add(v_NAME); ParameterList.Add(v_SELECT_SW); ParameterList.Add(v_REFER_SW); ParameterList.Add(v_SORT_SW); ParameterList.Add(v_POS_SW); ParameterList.Add(DateTime.Now); if (Session["UID"] == null) throw new Exception("Session Time Out"); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(v_SELECT_CHANGE); ParameterList.Add(v_SELECT_PERIOD); ParameterList.Add(v_SELECT_ITEM); ParameterList.Add(v_SELECT_P_FROM); ParameterList.Add(v_SELECT_P_TO); ParameterList.Add(v_REFER_CHANGE); ParameterList.Add(v_REFER_OTHER); ParameterList.Add(v_REFER_RATE1); ParameterList.Add(v_REFER_RATE2); ParameterList.Add(v_REFER_RATE3); ParameterList.Add(v_REFER_RATE4); ParameterList.Add(v_SORT_KEY1); ParameterList.Add(v_SORT_KEY2); ParameterList.Add(v_SORT_KEY3); ParameterList.Add("1");//ENABLE ParameterList.Add(v_RANK_SW);//200901016 added #endregion UpdateRecord = BCO.UpdateDisParameter(ParameterList, null); if (UpdateRecord == 0) { throw new Exception("更新0筆資料!"); } else { //Response.Write(string.Format("<script>alert('更改完成');location.replace('ALO022.aspx?CODE=ALO02&PARAMCODE={0}&CurrentMode=readonly');</script>", v_CODE)); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", string.Format("alert('更改完成');location.replace('ALO022.aspx?Code=ALO02&PARAMCODE={0}&CurrentMode=readonly');", v_CODE), true); ResultMsgLabel.Text = "更新完成"; SwitchFormviewMode(FormViewMode.ReadOnly); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion } #endregion }
//--於檢視模式按下刪除鈕 protected void ReadonlyDeleteButton_Click(object sender, EventArgs e) { #region int UpdateRecord = 0; try { #region 取得畫面元件的值 string v_CODE = ((TextBox)FormView1.FindControl("txtCODE")).Text.Trim(); string v_NAME = ((TextBox)FormView1.FindControl("txtNAME")).Text.Trim(); string v_SELECT_SW = (((CheckBox)FormView1.FindControl("chk_SELECT_SW")).Checked) ? "1" : "0"; string v_REFER_SW = (((CheckBox)FormView1.FindControl("chk_REFER_SW")).Checked) ? "1" : "0"; string v_SORT_SW = (((CheckBox)FormView1.FindControl("chk_SORT_SW")).Checked) ? "1" : "0"; string v_POS_SW = (((CheckBox)FormView1.FindControl("chk_POS_SW")).Checked) ? "1" : "0"; string v_RANK_SW = (((CheckBox)FormView1.FindControl("chk_RANK_SW")).Checked) ? "1" : "0";//20090106 added DateTime v_UPDATEDATE = Convert.ToDateTime(((WUI.SLP.SLPDate)FormView1.FindControl("SLP_SLPDate1")).Text.Trim()); string v_UPDATEUID = ((WUI.SLP.User)FormView1.FindControl("txtUser")).Text.Trim(); string v_SELECT_CHANGE = (((CheckBox)FormView1.FindControl("chk_SELECT_CHANGE")).Checked) ? "1" : "0"; int v_SELECT_PERIOD = 0; int v_SELECT_ITEM = 0; int v_SELECT_P_FROM = 0; int v_SELECT_P_TO = 0; Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtPeriod")).Text.Trim(), out v_SELECT_PERIOD); Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtItemCount")).Text.Trim(), out v_SELECT_ITEM); Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtPFrom")).Text.Trim(), out v_SELECT_P_FROM); Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtPTo")).Text.Trim(), out v_SELECT_P_TO); string v_REFER_CHANGE = (((CheckBox)FormView1.FindControl("chk_REFER_CHANGE")).Checked) ? "1" : "0"; int v_REFER_OTHER = 0; int v_REFER_RATE1 = 0; int v_REFER_RATE2 = 0; int v_REFER_RATE3 = 0; int v_REFER_RATE4 = 0; Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtRateOther")).Text.Trim(), out v_REFER_OTHER); Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate1")).Text.Trim(), out v_REFER_RATE1); Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate2")).Text.Trim(), out v_REFER_RATE2); Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate3")).Text.Trim(), out v_REFER_RATE3); Int32.TryParse(((WUI.SLP.SLPNumber)FormView1.FindControl("txtRate4")).Text.Trim(), out v_REFER_RATE4); string v_SORT_KEY1 = ((TextBox)FormView1.FindControl("txtSort1")).Text.Trim(); string v_SORT_KEY2 = ((TextBox)FormView1.FindControl("txtSort2")).Text.Trim(); string v_SORT_KEY3 = ((TextBox)FormView1.FindControl("txtSort3")).Text.Trim(); #endregion #region 取得更新前舊值 #region 使用XML轉回DataSet DataSet Ds = new DataSet(); System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml); Ds.ReadXml(sr); DataTable Dt = Ds.Tables[0]; #endregion if (Ds.Tables[0].Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } #endregion #region 加入更新條件 ArrayList ParameterList = new ArrayList();//20091112 ParameterList.Clear(); //舊值 ParameterList.Add(v_CODE); ParameterList.Add(v_UPDATEDATE); ParameterList.Add(v_UPDATEUID); #region deleted //ParameterList.Add(Dt.Rows[0]["NAME"]); //ParameterList.Add(Dt.Rows[0]["SELECT_SW"]); //ParameterList.Add(Dt.Rows[0]["REFER_SW"]); //ParameterList.Add(Dt.Rows[0]["SORT_SW"]); //ParameterList.Add(Dt.Rows[0]["POS_SW"]); //ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]); //ParameterList.Add(Dt.Rows[0]["UPDATEUID"]); //ParameterList.Add(Dt.Rows[0]["SELECT_CHANGE"]); //ParameterList.Add(Dt.Rows[0]["SELECT_PERIOD"]); //ParameterList.Add(Dt.Rows[0]["SELECT_ITEM"]); //ParameterList.Add(Dt.Rows[0]["SELECT_P_FROM"]); //ParameterList.Add(Dt.Rows[0]["SELECT_P_TO"]); //ParameterList.Add(Dt.Rows[0]["REFER_CHANGE"]); //ParameterList.Add(Dt.Rows[0]["REFER_OTHER"]); //ParameterList.Add(Dt.Rows[0]["REFER_RATE1"]); //ParameterList.Add(Dt.Rows[0]["REFER_RATE2"]); //ParameterList.Add(Dt.Rows[0]["REFER_RATE3"]); //ParameterList.Add(Dt.Rows[0]["REFER_RATE4"]); //ParameterList.Add(Dt.Rows[0]["SORT_KEY1"]); //ParameterList.Add(Dt.Rows[0]["SORT_KEY2"]); //ParameterList.Add(Dt.Rows[0]["SORT_KEY3"]); #endregion //需要更新值 ParameterList.Add(v_CODE); ParameterList.Add(v_NAME); ParameterList.Add(v_SELECT_SW); ParameterList.Add(v_REFER_SW); ParameterList.Add(v_SORT_SW); ParameterList.Add(v_POS_SW); ParameterList.Add(DateTime.Now); if (Session["UID"] == null) throw new Exception("Session Time Out"); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(v_SELECT_CHANGE); ParameterList.Add(v_SELECT_PERIOD); ParameterList.Add(v_SELECT_ITEM); ParameterList.Add(v_SELECT_P_FROM); ParameterList.Add(v_SELECT_P_TO); ParameterList.Add(v_REFER_CHANGE); ParameterList.Add(v_REFER_OTHER); ParameterList.Add(v_REFER_RATE1); ParameterList.Add(v_REFER_RATE2); ParameterList.Add(v_REFER_RATE3); ParameterList.Add(v_REFER_RATE4); ParameterList.Add(v_SORT_KEY1); ParameterList.Add(v_SORT_KEY2); ParameterList.Add(v_SORT_KEY3); ParameterList.Add("0");//ENABLE ParameterList.Add(v_RANK_SW);//200901016 added #endregion ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConntionDB); UpdateRecord = BCO.UpdateDisParameter(ParameterList, null); if (UpdateRecord == 0) { throw new Exception("刪除0筆資料!"); } else { ResultMsgLabel.Text = "刪除完成"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", string.Format("location.replace('ALO021.aspx?Code=ALO02');"), true);//alert('刪除完成'); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
private void QueryData(FormViewMode fvm) { #region try { string SessionIDName = "ALO021_" + PageTimeStamp.Value; ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConntionDB); DataTable dtTemp = new DataTable(); ArrayList ParameterList = new ArrayList();//20091112 switch (fvm) { //檢視模式 case FormViewMode.ReadOnly: #region ParameterList.Clear(); ParameterList.Add(s_PARAMCODE); ParameterList.Add(1); dtTemp = BCO.QuerySwitch(ALOModel.MaintainDisParameter.QueryType.CODE, ParameterList); for (int i = 0; i <= dtTemp.Rows.Count - 1; i++) { if (dtTemp.Rows[i]["SORT_KEY1"].ToString() == "") dtTemp.Rows[i]["SORT_KEY1"] = " "; if (dtTemp.Rows[i]["SORT_KEY2"].ToString() == "") dtTemp.Rows[i]["SORT_KEY2"] = " "; if (dtTemp.Rows[i]["SORT_KEY3"].ToString() == "") dtTemp.Rows[i]["SORT_KEY3"] = " "; } #region 使用XML放置到前端資料 MasterOLDData.InnerHtml = dtTemp.DataSet.GetXml(); #endregion break; #endregion //編輯模式 case FormViewMode.Edit: #region ParameterList.Clear(); ParameterList.Add(s_PARAMCODE); ParameterList.Add(1); dtTemp = BCO.QuerySwitch(ALOModel.MaintainDisParameter.QueryType.CODE, ParameterList); for (int i = 0; i <= dtTemp.Rows.Count - 1; i++) { if (dtTemp.Rows[i]["SORT_KEY1"].ToString() == "") dtTemp.Rows[i]["SORT_KEY1"] = " "; if (dtTemp.Rows[i]["SORT_KEY2"].ToString() == "") dtTemp.Rows[i]["SORT_KEY2"] = " "; if (dtTemp.Rows[i]["SORT_KEY3"].ToString() == "") dtTemp.Rows[i]["SORT_KEY3"] = " "; } #region 使用XML放置到前端資料 MasterOLDData.InnerHtml = dtTemp.DataSet.GetXml(); #endregion break; #endregion } //this.hiddenCODE.Value = Request.QueryString["PARAMCODE"].ToString(); //GetAllMasterRecordsForBrowse(); Session[SessionIDName] = dtTemp; FormView1.DataSource = dtTemp; FormView1.DataBind(); GetParamUsedCount(); if (dtTemp == null || dtTemp.Rows.Count <= 0) { throw new Exception("查無此筆資料或已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!"); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
public ALO_SLP_SLP_PARAM() { co_main = new BCO.MaintainDisParameter(ConnectionDB); }
}//Initiziatoin_Component private void dataget() { #region ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConnectionDB); ParameterList.Clear(); ParameterList.Add(9999); DataTable Dt = BCO.QuerySwitch(ALOModel.ALOCommon.QueryType.ALL, ParameterList); int res = 0; foreach (DataRow dr in Dt.Rows) { if (dr["Code"].ToString().Trim() == _Code) { _Name = dr["Name"].ToString().Trim(); res++; } } if (res != 1) { _Name = "查無資料"; } HiddenField1.Value = _Name; TextBoxName.Text = _Name; #endregion }//dataget
/// <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="strParam"></param> /// <param name="iRowCounts"></param> /// <returns></returns> private bool GetDisParameter(string strParam, out Int32 iRowCounts) { #region bool bResult = false; iRowCounts = 0; try { ArrayList ParameterList = new ArrayList();//20091106 ParameterList.Clear(); ParameterList.Add(strParam); ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConnectionDB); ALOModel.QueryALOCommon BCO2 = new ALOModel.QueryALOCommon(ConnectionDB); dtParam = BCO.QuerySwitch(ALOModel.ALOCommon.QueryType.CODE, ParameterList); if (dtParam != null && dtParam.Rows.Count != 0) { bResult = true; iRowCounts = dtParam.Rows.Count; } else { bResult = false; } if (bResult) { iRowCounts = BCO2.GetDisItemReferCount(dtParam); } vItemReferCount = iRowCounts; } catch (Exception ex) { bResult = false; ErrorMsgLabel.Text = ex.Message; } return bResult; #endregion }
/// <summary> /// 檢核配本方式是否合法存在 /// </summary> /// <param name="strDisType"></param> /// <param name="strDisTypeName"></param> /// <returns></returns> private bool CheckDisTypeIsAvaliable(string strDisType, out string strDisTypeName) { #region bool bResult = false; strDisTypeName = ""; ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConnectionDB); try { ArrayList ParameterList = new ArrayList();//20091106 ParameterList.Clear(); ParameterList.Add(strDisType); DataTable dt = BCO.QuerySwitch(PIC.VDS2G.BSM.ALO.ALOCommon.QueryType.CODE, ParameterList); if (dt != null && dt.Rows.Count > 0) { strDisTypeName = dt.Rows[0]["NAME"].ToString().Trim(); bResult = true; } else { strDisTypeName = "查無資料"; } } catch (Exception ex) { throw ex; } return bResult; #endregion }
private void GetAllParamForClientValidation() { #region try { ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConnectionDB); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(9999); DataTable Dt = BCO.QuerySwitch(ALOModel.ALOCommon.QueryType.ALL, ParameterList); string strParam = "", strName = ""; foreach (DataRow dr in Dt.Rows) { strParam += dr["Code"].ToString().Trim() + ";"; strName += dr["Name"].ToString().Trim() + ";"; } hiddenAvailableParam.Value = strParam; hiddenAvailableParamName.Value = strName; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
/// <summary> /// 配本方式暫存參數設定 /// </summary> private void dtParamAndItemReferCountProcess() { #region 取得配本參數設定資訊 ALOModel.MaintainDisParameter DisParaProc = new ALOModel.MaintainDisParameter(ConnectionDB); #region 輸入變數 ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); //配本方式 ParameterList.Add(SLP_PARAM1.Text); #endregion DataTable dtParam = DisParaProc.QuerySwitch(PIC.VDS2G.BSM.ALO.ALOCommon.QueryType.CODE, ParameterList ); //暫存到Session SeesionIDAndParam = "ALO111ItemParam_" + PageTimeStamp.Value; Session[SeesionIDAndParam] = dtParam; PARAMHidden.Value = dtParam.Rows.Count.ToString(); #endregion #region 設定參照品項數 if (dtParam.Rows.Count > 0) { ALOModel.QueryALOCommon ALOCommonProc = new ALOModel.QueryALOCommon(ConnectionDB); int vItemreferCount = ALOCommonProc.GetDisItemReferCount(dtParam); PARAMRefItemCountHidden.Value = vItemreferCount.ToString(); } #endregion #region 判斷新增參照商品按鈕是否啟用 DetailAddRefBtn.Enabled = false; Param_DetailAddRefBtnStatus(); UpdatePanel_RefItemListBtn.Update(); #endregion #region 配本方式異動後加入清空實配數及處理階段 if (OLDPARAMHidden.Value != SLP_PARAM1.Text) { //實配數 DISQTYtxt.Text = "0"; //處理階段 OPStatusHidden.Value = "0"; //PatternCode帶入(因為是唯讀無法設定) SLP_Pattern1.Text = PatternCodeHidden.Value; //大分類帶入(因為是唯讀無法設定) PMAtxt.Text = PMAHidden.Value; UpdatePanel_ItemDetail1.Update(); } #endregion }