private void databind() { #region ErrorMsgLabel.Text = ""; string TOTAL_DIS_QTY = ""; string SessionIDName = string.Format("{0}", PAGE_DT_01); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); ParameterList.Clear(); ParameterList.Add(this.SLP_ACCEPT_DATE.Text); ParameterList.Add(this.SLP_ITEM.Text); ParameterList.Add(this.SLP_PERIOD.Text); DataTable Dt = BCO.QueryAloItemNum(ParameterList, out TOTAL_DIS_QTY); LabelQueryRecordCount.Text = "合計:" + TOTAL_DIS_QTY; GridView1.DataSource = Dt; Session[SessionIDName] = Dt; GridView1.DataBind(); if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { ErrorMsgLabel.Text = "查無資料"; //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true); } #endregion }
/// <summary> /// 異動VDS_PUR_PICK_CONTROL_CHK,變更使用者鎖定編輯(為了保原使用者資訊) /// </summary> /// <param name="UID">原始使用者</param> /// <param name="oldTime">原始異動時間</param> /// <param name="newTime">建立時間</param> private void UpdateControlChk(string UID, DateTime oldTime, DateTime newTime) { try { ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(UID); ParameterList.Add(oldTime); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(newTime); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); BCO.UpdateControlChk(ParameterList, null); } catch (Exception ex) { throw ex; } }
/// 取得該日期、批號是否有人在編輯 /// <returns>false:無人使用、true:使用中,不可編輯</returns> private DataTable getControlChk() { try { ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); return BCO.QueryControlChk(ParameterList); } catch (Exception ex) { throw ex; } }
private void getQTY_Data() { ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(SLP_VIRTUAL_CODE.Text); ParameterList.Add(txtPERIOD.Text); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable Dt_Find = BCO.GetPurchaseItemInfo(ParameterList); if (Dt_Find != null && Dt_Find.Rows.Count > 0) { lblONWAY_QTY.Text = Dt_Find.Rows[0]["ONWAY_QTY"].ToString(); lblONHD_QTY.Text = Dt_Find.Rows[0]["ONHD_QTY"].ToString(); lblDIS_QTY.Text = Dt_Find.Rows[0]["DIS_QTY"].ToString(); lblDIFF_QTY.Text = Dt_Find.Rows[0]["DIFF_QTY"].ToString(); } else { lblONWAY_QTY.Text = ""; lblONHD_QTY.Text = ""; lblDIS_QTY.Text = ""; lblDIFF_QTY.Text = ""; } //品號或期別變更時,清除PickControl裏的值 string SessionIDName_Pick = "PUR041_Pick" + PageTimeStamp.Value; DataTable dt = (DataTable)Session[SessionIDName_Pick]; //通路管制設定 if (dt != null) { DataRow[] drs = dt.Select("VIRTUAL_CODE = '" + SLP_VIRTUAL_CODE.Text + "' and PERIOD = '" + txtPERIOD.Text + "'"); if (drs.Length > 0) foreach (DataRow dr in drs) dt.Rows.Remove(dr); } if (hidPERIOD.Value != txtPERIOD.Text) { radPICK_SELECT1.Checked = false; radPICK_SELECT2.Checked = true; btn_GV_Set.Enabled = false; } string Item_Name = ((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)SLP_VIRTUAL_CODE).FindControl("TextBoxName")).Text; if (Item_Name != "" && Item_Name != "查無資料" && txtPERIOD.Text != "") { SLP_VIRTUAL_CODE.ReadOnly = true; txtPERIOD.ReadOnly = true; txtPERIOD.CssClass = "readtxtbox"; } }
// 存檔 protected void btnSave_Click(object sender, EventArgs e) { panAdd.Visible = false; Btn_InsertItem.Enabled = true; GridView1.AllowSorting = true; //解除新增狀態時禁止排序 switch (this.hid_PageStatus.Text) { case "EDIT": case "LOAD": case "ADD_DETAIL": try { if (GridView1.Rows.Count <= 0) { ErrorMsgLabel.Text = "請輸入資料"; return; } else { DateTime dNow = DateTime.Now; PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable dt = getDetailData(); if (dt != null) if (this.checkDetailData(dt)) //判斷Grid資料是否有重覆 { try { UnLockControlChk();//取消對ControlChk的鎖定編輯 ViewState["ControlChk"] = null; } catch (Exception Ex) { DataTable ddt = getControlChk(); if (ddt.Rows.Count > 0) { if (Ex.Message.IndexOf("刪除資料失敗") > 0) { ErrorMsgLabel.Text = "資料已被" + ddt.Rows[0]["UPDATEUID"].ToString() + "鎖定,請按「取消」後重新操作"; return; } } else if (Ex.Message.IndexOf("刪除資料失敗") > 0) { ErrorMsgLabel.Text = "資料已被他人異動過,請按「取消」後重新操作"; return; } } #region 取得更新前舊值,使用XML轉回DataSet DataTable dtDetailOLD = new DataTable(); //進入畫面直接新增明細時,並不會有舊資料 if (hid_PageStatus.Text != "ADD_DETAIL") { DataSet DsDetail = new DataSet(); System.IO.StringReader srD = new System.IO.StringReader(DetailOLDData.InnerHtml); DsDetail.ReadXml(srD); dtDetailOLD = DsDetail.Tables[0]; if (dtDetailOLD.Rows.Count == 0) throw new Exception("抓取不到舊值,更新失敗!"); } #endregion GetData(); //先惕除刪除勾選的資料 dt = getDetailData(); //再抓一次(惕除刪除勾選的資料) BCO.UpdateMaster(this.getMasterParameterList(), dt, null, dtDetailOLD, this.getPickData(), dNow); btnDelItem.Visible = false; //btnImportOnDate.Visible = true; //進入畫面直接新增明細後,將資料放到XML if (hid_PageStatus.Text == "ADD_DETAIL") { dt.TableName = "Table"; DataSet Ds = new DataSet(); foreach (DataRow dr in dt.Rows) { if (dr["UPDATEUID"] == System.DBNull.Value) { dr["UPDATEUID"] = Session["UID"].ToString(); dr["UPDATEDATE"] = dNow; } } try { Ds.Tables.Add(dt); } catch (Exception ex) { Ds = dt.DataSet; } DetailOLDData.InnerHtml = Ds.GetXml(); } } else return; ViewState["Insert"] = "0"; //解除新增狀態 ViewState["ChkAll"] = "0"; //解除刪除全選狀態 //進入畫面直接新增明細儲存後,不要重新查詢 if (hid_PageStatus.Text != "ADD_DETAIL" && hid_AddDetail.Value != "ADD_DETAIL") databind(); else { GridView1.DataSource = dt; GridView1.DataBind(); SetPageStatus(); } //由檢視模式切換至編輯模式 this.hid_PageStatus.Text = "VIEW"; //改成檢視模式 btnPrint.Visible = false; btnEdit.Visible = true; btnCancel.Visible = true; btnSave.Visible = false; Btn_InsertItem.Enabled = false; if (GridView1.Rows.Count > 0) { for (int i = 0; i < GridView1.Rows.Count; i++) { if (GridView1.Rows[i].RowType == DataControlRowType.DataRow) { ((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)GridView1.Rows[i].FindControl("VIRTUAL_CODE")).ReadOnly = true; ((PIC.VDS2G.WebUI.SLP.SLP_ItemPeriod)GridView1.Rows[i].FindControl("PERIOD")).ReadOnly = true; ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Enabled = false; ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT2")).Enabled = false; ((CheckBox)GridView1.Rows[i].FindControl("chkGV_Del")).Enabled = false; ((Button)GridView1.Rows[i].FindControl("btn_GV_Set")).Enabled = true; ((Button)GridView1.Rows[i].FindControl("btn_GV_Find")).Enabled = true; } ((CheckBox)GridView1.HeaderRow.FindControl("chkAll")).Enabled = false; } btnPrint.Visible = true; string outPick = "", outRestrain = ""; getGridPickCnt(out outPick, out outRestrain); LabelQueryRecordCount.Text = "品項數:理貨品:" + outPick + " 筆 管制品:" + outRestrain + " 筆 "; } Session["PageStatus" + PageTimeStamp.Value] = hid_PageStatus.Text; //檢視模式(隱藏查詢鈕,顯示取消鈕) this.txtPLAN_ACCEPT_DATE.ReadOnly = true; this.txtPICK_BATCH.ReadOnly = true; this.txtPICK_BATCH.CssClass = "readtxtbox"; if (hid_PageStatus.Text == "EDIT") this.Btn_InsertItem.Enabled = false; this.chkPICK_SELECT_1.Enabled = false; this.chkPICK_SELECT_2.Enabled = false; btnLoad.Visible = false; ButtonQuery.Visible = false; btnCancel.Visible = true; UpdatePanel1.Update(); btnImportOnDate.Enabled = false; GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "PUR041.aspx?Code=PUR04", null, WUI_GMToolbarV.ClickAction.LinkURL); // GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, true, "", this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, string.Empty, this.btnSave, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); } } catch (Exception ex) { if (ex.Message.IndexOf("資料已被他人異動") > 0) ErrorMsgLabel.Text = "資料已被他人異動,請重新查詢"; else ErrorMsgLabel.Text = ex.Message; } SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); DataTable Dt = (DataTable)Session[SessionIDName]; if (Dt.Rows.Count == 0) btnCancel_Click(null, null); break; default: break; } }
private bool checkDetailData(DataTable dt) { string iDray = ""; string iDray_PERIOD = ""; string Msg = ""; bool checkFlag = true; try { foreach (DataRow dr in dt.Rows) if (dr["ITEM"].ToString() == "") throw new Exception("品號、期別資料重複,請確認"); for (Int32 i = 0; i < dt.Rows.Count; i++) { iDray = dt.Rows[i]["VIRTUAL_CODE"].ToString(); iDray_PERIOD = dt.Rows[i]["PERIOD"].ToString(); if (dt.Rows[i]["ISDEL"].ToString() == "" || dt.Rows[i]["ISDEL"].ToString() == "0") { if (iDray == null || iDray == "") { ErrorMsgLabel.Text = " 品號資料不可空白,請確認"; checkFlag = false; break; } if (iDray_PERIOD == null || iDray_PERIOD == "") { ErrorMsgLabel.Text = iDray + " 期別資料不可空白,請確認"; checkFlag = false; break; } PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); ParameterList.Clear(); ParameterList.Add(iDray); ParameterList.Add(null); BCO.CheckItemData(ParameterList, out Msg); if (Msg != "") { ErrorMsgLabel.Text = iDray + " " + Msg + ",請確認"; checkFlag = false; break; } ParameterList.Clear(); ParameterList.Add(iDray); ParameterList.Add(iDray_PERIOD); BCO.CheckItemData(ParameterList, out Msg); if (Msg != "") { ErrorMsgLabel.Text = iDray + " " + Msg + ",請確認"; checkFlag = false; break; } } } return checkFlag; } catch (Exception ex) { return checkFlag; ErrorMsgLabel.Text = ex.Message; } }
// 品項載入(續2) private void Item_Load2() { string vPICK_SELECT_1 = "0"; string vPICK_SELECT_2 = "0"; if (this.chkPICK_SELECT_1.Checked == true) //正常品 vPICK_SELECT_1 = "1"; if (this.chkPICK_SELECT_2.Checked == true) //客服查補 vPICK_SELECT_2 = "1"; SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); string SessionIDName_Pick = "PUR041_Pick" + PageTimeStamp.Value; Session[SessionIDName_Pick] = null; //第一次查詢,為了餵給BCO.InsertMaster Dt資料 ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false)); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(vPICK_SELECT_1, "int", false)); ParameterList.Add(GetValueSetParameter(vPICK_SELECT_2, "int", false)); ParameterList.Add(GetValueSetParameter(Session["UID"].ToString(), "string", false)); ParameterList.Add(GetValueSetParameter(DateTime.Now.ToString(), "datetime", false)); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable Dt = BCO.QuerySwitch(PURModel.MaintainPurchaseDeliveryGoods.QueryType.QueryByLOAD, ParameterList); string msg = "", msg1 = "", msg2 = ""; if (getDataType() == "1") { for (int i = 0; i < Dt.Rows.Count; i++) if (ChkDup(Dt.Rows[i]["ST_ACCEPT_DATE"].ToString(), Dt.Rows[i]["VIRTUAL_CODE"].ToString(), Dt.Rows[i]["PERIOD"].ToString(), "2")) { msg1 += "品號:" + Dt.Rows[i]["VIRTUAL_CODE"].ToString() + "、期別:" + Dt.Rows[i]["PERIOD"].ToString() + "<br \\>"; Dt.Rows.Remove(Dt.Rows[i]); } if (msg1 != "") msg1 += "已存在客服查補裏,故未載入<br \\>"; } else if (getDataType() == "2") { for (int i = 0; i < Dt.Rows.Count; i++) if (ChkDup(Dt.Rows[i]["ST_ACCEPT_DATE"].ToString(), Dt.Rows[i]["VIRTUAL_CODE"].ToString(), Dt.Rows[i]["PERIOD"].ToString(), "1")) { msg2 += "品號:" + Dt.Rows[i]["VIRTUAL_CODE"].ToString() + "、期別:" + Dt.Rows[i]["PERIOD"].ToString() + "<br \\>"; Dt.Rows.Remove(Dt.Rows[i]); } if (msg2 != "") msg2 += "已存在正常品裏,故未載入"; } msg = msg1 + msg2; if (msg != "") lblMsg.Text = msg; //2009/9/17 修改流程:「品項載入」後即可經由管制鈕的選擇而ENABLE「通路管制設定」鈕,所以要先Reset該DB的資料 //先全部刪除~再新增 ParameterList.Clear(); ParameterList.Add(this.txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(this.txtPICK_BATCH.Text); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(getDataType()); // 2010/3/8 By Tony 新增資料來源條件:1:正常品 2:客服查補 3:正常品 + 客服查補 DateTime dNow = DateTime.Now; //DeleteAll、InsertMaster、QuerySwitch使用統一的時間 BCO.DeleteAll(ParameterList, null, dNow); BCO.InsertMaster(this.getMasterParameterList(), Dt, null, dNow); //第二次查詢,為了找出BCO.InsertMaster後的Update資訊 string v_PICK_CNT = "0"; string v_RESTRAIN_CNT = "0"; ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false)); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(getDataType()); Dt = BCO.QueryPICK_CONTROL(ParameterList); GridView1.DataSource = Dt; Session[SessionIDName] = Dt; #region 將明細資料放至DetailDt中 detailTmpDt = Dt; #endregion //將空白的資料做處理 Dt = ProcessDBNull(Dt); #region 使用XML放置到前端資料 DataSet Ds = Dt.DataSet; DetailOLDData.InnerHtml = Ds.GetXml(); #endregion //設定分頁大小 GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { LabelQueryRecordCount.Text = ""; this.hid_PICK_CNT.Value = "0"; this.hid_RESTRAIN_CNT.Value = "0"; btnPrint.Visible = false; btnEdit.Visible = false; ErrorMsgLabel.Text = "查無資料"; btnDelItem.Visible = false; //btnImportOnDate.Visible = false; this.hid_PageStatus.Text = "VIEW"; } else { LabelQueryRecordCount.Text = "品項數:理貨品:" + Dt.Rows.Count + "筆 管制品:0筆"; this.hid_PICK_CNT.Value = Dt.Rows.Count.ToString(); this.hid_RESTRAIN_CNT.Value = "0"; btnPrint.Visible = true; btnEdit.Visible = true; this.hid_PageStatus.Text = "LOAD"; SetPageStatus(); LockControlChk();//對ControlChk鎖定編輯 btnDelItem.Visible = true; //btnImportOnDate.Visible = true; btnImportOnDate.Enabled = true; } #region ToolBar設定 if (detailTmpDt == null || (detailTmpDt != null && detailTmpDt.Rows.Count <= 0)) { GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "PUR041.aspx?Code=PUR04", null, WUI_GMToolbarV.ClickAction.LinkURL); //GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, false, "", this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, string.Empty, this.btnSave, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); } else { GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "PUR041.aspx?Code=PUR04", null, WUI_GMToolbarV.ClickAction.LinkURL); // GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, false, "", this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, string.Empty, this.btnSave, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); } #endregion }
// 品項載入 protected void btnLoad_Click(object sender, EventArgs e) { #region 欄位檢核 if (txtPLAN_ACCEPT_DATE.Text == "") { ErrorMsgLabel.Text = "門市進貨日不可空白"; return; } if (txtPICK_BATCH.Text == "") { ErrorMsgLabel.Text = "理貨批次不可空白"; return; } string nowDate = DateTime.Now.ToString("yyy/MM/dd"); int v = nowDate.CompareTo(this.txtPLAN_ACCEPT_DATE.Text); if (v > 0) { ErrorMsgLabel.Text = "門市進貨日小於系統日,不可進行品項轉入"; return; } if (this.chkPICK_SELECT_1.Checked == false && this.chkPICK_SELECT_2.Checked == false) { ErrorMsgLabel.Text = "正常品、客服查補 須至少勾選一項"; return; } //判斷 PURModel.MaintainPurchaseDeliveryGoods PUR = new PURModel.MaintainPurchaseDeliveryGoods(ConntionDB); ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); if (PUR.CheckStAcceptData(ParameterList) == "0") { ErrorMsgLabel.Text = "門市進貨日及批次已存在轉門市進貨單檔,不可修改每日預定出貨明細資料 !!"; return; } #endregion DataTable dt = getControlChk(); if (dt.Rows.Count > 0) { ViewState["ControlChk"] = dt; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "if (confirm('該進貨日期、理貨批次目前仍由(" + dt.Rows[0]["UPDATEUID"].ToString() + ")於" + dt.Rows[0]["UPDATEDATE"].ToString() + "編輯中\\n\\n如繼續,將會重新鎖定該日期、批號\\n\\n於編輯期間由(" + dt.Rows[0]["UPDATEUID"].ToString() + ")編輯中的資料將無法存檔\\n\\n是否確定仍要繼續載入品項?')){__doPostBack('','Item_Load1');}", true); return; } ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(""); ParameterList.Add(""); ParameterList.Add(""); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable Dtt = BCO.QueryChanPickControl(ParameterList); if (Dtt.Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "if (confirm('將會正式「清除通路管制設定的資料」,再重新載入\\n\\n是否確定仍要載入品項?')){__doPostBack('','Item_Load2');}", true); return; } Item_Load2(); }
private void LoadFromDate2() { if (hid_PageStatus.Text == "VIEW") LockControlChk();//對ControlChk鎖定編輯 DataTable Dt = (DataTable)Session["LoadFromDate1" + PageTimeStamp.Value]; DataTable dt_main_tmp = (DataTable)Session["dt_main_tmp" + PageTimeStamp.Value]; #region 移除匯入主檔品號、期別的通路管制資料 DataTable dt_Pick = (DataTable)Session[SessionIDName_Pick]; if (dt_Pick != null) if (dt_Pick.Rows.Count > 0) foreach (DataRow dr in Dt.Rows) { DataRow[] ddrs = dt_Pick.Select("VIRTUAL_CODE = '" + dr["VIRTUAL_CODE"].ToString() + "' and PERIOD = '" + dr["PERIOD"].ToString() + "'"); if (ddrs.Length > 0) foreach (DataRow drDetail in ddrs) dt_Pick.Rows.Remove(drDetail); } Session[SessionIDName_Pick] = dt_Pick; #endregion //2009/9/17 修改流程:「品項載入」後即可經由管制鈕的選擇而ENABLE「通路管制設定」鈕,所以要先Reset該DB的資料 //新增 ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); //匯入日期同主頁的進貨日 ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add("1"); // 2010/3/8 By Tony 新增資料來源條件:1:正常品 2:客服查補 3:正常品 + 客服查補(匯入的資料一律使用正常品) DateTime dNow = DateTime.Now; //CreateDetail、QuerySwitch使用統一的時間 PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); //逐筆寫入未存在於主檔的資料 foreach (DataRow dr in Dt.Rows) BCO.CreateDetail(ParameterList, dr, null, dNow, "0"); //第二次查詢,為了找出BCO.CreateDetail後的Update資訊 string v_PICK_CNT = "0"; string v_RESTRAIN_CNT = "0"; ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false)); //0 N_ROWNUM ParameterList.Add(GetValueSetParameter(txtPLAN_ACCEPT_DATE.Text, "string", false)); //1 V_ST_ACCEPT_DATE ParameterList.Add(txtPICK_BATCH.Text); //2 V_PICK_BATCH ParameterList.Add(GetValueSetParameter("1", "int", false)); //3 N_PICK_SELECT_1 ParameterList.Add(GetValueSetParameter("1", "int", false)); //4 N_PICK_SELECT_2 ParameterList.Add("1"); //5 V_DATATYPE Dt = BCO.QueryDeliveryGoodsByFind_1(ParameterList, out v_PICK_CNT, out v_RESTRAIN_CNT); #region 製作新的原始資料 //處理DBNull的資料 Dt = ProcessDBNull(Dt); DataSet Ds = Dt.DataSet; DetailOLDData.InnerHtml = Ds.GetXml(); #endregion //復原理貨、管制的狀態(因異動理貨、管制鈕時並未存檔((只存在Session裏)) if (dt_main_tmp.Rows.Count > 0) foreach (DataRow dr in Dt.Rows) { DataRow[] drs = dt_main_tmp.Select("VIRTUAL_CODE = '" + dr["VIRTUAL_CODE"].ToString() + "' and PERIOD = '" + dr["PERIOD"].ToString() + "'"); if (drs.Length > 0) dr["Pick_Select"] = drs[0]["Pick_Select"]; } if (ButtonQuery.Visible) { btnSave.Visible = true; btnCancel.Visible = true; ButtonQuery.Visible = false; btnLoad.Visible = false; } SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); if (Session[SessionIDName] != "" && Session[SessionIDName] != null) { DataTable DetailDt = (DataTable)Session[SessionIDName]; DataRow[] drsDetail = DetailDt.Select("DataType='0'"); DataTable DtCopy = Dt.Copy(); foreach (DataRow dr in drsDetail) { DataRow[] drs = DtCopy.Select("VIRTUAL_CODE = '" + dr["VIRTUAL_CODE"].ToString() + "' and PERIOD = '" + dr["PERIOD"].ToString() + "'"); if (drs.Length == 0) Dt.ImportRow(dr); } } Session[SessionIDName] = Dt; GridView1.DataSource = Dt; GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.DataBind(); if (hid_PageStatus.Text != "LOAD") hid_PageStatus.Text = "EDIT"; GridView1_Control(); UpdatePanel1.Update(); string outPick = "", outRestrain = ""; getGridPickCnt(out outPick, out outRestrain); LabelQueryRecordCount.Text = "品項數:理貨品:" + outPick + " 筆 管制品:" + outRestrain + " 筆 "; this.txtPLAN_ACCEPT_DATE.ReadOnly = true; this.txtPICK_BATCH.ReadOnly = true; this.txtPICK_BATCH.CssClass = "readtxtbox"; this.chkPICK_SELECT_1.Enabled = false; this.chkPICK_SELECT_2.Enabled = false; }
//指定日期匯入(續) private void LoadFromDate1(string importDate) { SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); string SessionIDName_Pick = "PUR041_Pick" + PageTimeStamp.Value; string vPICK_SELECT_1 = "0"; string vPICK_SELECT_2 = "0"; if (this.chkPICK_SELECT_1.Checked == true) //正常品 vPICK_SELECT_1 = "1"; if (this.chkPICK_SELECT_2.Checked == true) //客服查補 vPICK_SELECT_2 = "1"; DataTable dt_main_tmp = new DataTable(); //第一次查詢,為了餵給BCO.InsertMaster Dt資料 ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false)); ParameterList.Add(GetValueSetParameter(importDate, "string", false)); ParameterList.Add(GetValueSetParameter("1", "int", false)); //只取得正常品的資料 ParameterList.Add(GetValueSetParameter("0", "int", false)); ParameterList.Add(GetValueSetParameter(Session["UID"].ToString(), "string", false)); ParameterList.Add(GetValueSetParameter(DateTime.Now.ToString(), "datetime", false)); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable Dt = BCO.QuerySwitch(PURModel.MaintainPurchaseDeliveryGoods.QueryType.QueryByLOAD, ParameterList); if (Session[SessionIDName] != null && Session[SessionIDName] != "") dt_main_tmp = (DataTable)Session[SessionIDName]; Session["dt_main_tmp" + PageTimeStamp.Value] = dt_main_tmp;//為了給變更Lock使用者後,繼續執行程式用 int Dt_Count = Dt.Rows.Count; DataTable Dt_Copy = Dt.Copy(); //已存在的資料就不再寫入了 if (dt_main_tmp.Rows.Count > 0) for (int i = 0; i < Dt_Count; i++) //刪除虛擬品號、期別已存在於dt_main_tmp的資料 { Dt_Copy.Rows[i]["ST_ACCEPT_DATE"] = txtPLAN_ACCEPT_DATE.Text; DataRow[] drsTmp = dt_main_tmp.Select("VIRTUAL_CODE = '" + Dt_Copy.Rows[i]["VIRTUAL_CODE"].ToString() + "' and PERIOD = '" + Dt_Copy.Rows[i]["PERIOD"].ToString() + "'"); DataRow[] drsCop = Dt.Select("VIRTUAL_CODE = '" + Dt_Copy.Rows[i]["VIRTUAL_CODE"].ToString() + "' and PERIOD = '" + Dt_Copy.Rows[i]["PERIOD"].ToString() + "'"); if (drsTmp.Length > 0) Dt.Rows.Remove(drsCop[0]); } if (Dt.Rows.Count > 0) { Session["LoadFromDate1" + PageTimeStamp.Value] = Dt;//為了給變更Lock使用者後,繼續執行程式用 if (hid_PageStatus.Text == "VIEW") { DataTable dtLock = getControlChk(); if (dtLock.Rows.Count > 0) { ViewState["ControlChk"] = dtLock; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "if (confirm('該進貨日期、理貨批次目前仍由(" + dtLock.Rows[0]["UPDATEUID"].ToString() + ")於" + dtLock.Rows[0]["UPDATEDATE"].ToString() + "編輯中\\n\\n如繼續,將會重新鎖定該日期、批號\\n\\n於編輯期間由(" + dtLock.Rows[0]["UPDATEUID"].ToString() + ")編輯中的資料將無法存檔\\n\\n是否確定仍要繼續匯入品項?')){__doPostBack('','LoadFromDate2');}", true); return; } } LoadFromDate2(); } else ErrorMsgLabel.Text = "無資料可載入 !!"; }
//新增明細區 -- 管制/理貨鈕 protected void radPICK_SELECT_CheckedChanged(object sender, EventArgs e) { string Item_Name = ((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)SLP_VIRTUAL_CODE).FindControl("TextBoxName")).Text; //顯示錯誤訊息並還原前管制/理貨鈕 if (Item_Name == "" || Item_Name == "查無資料" || txtPERIOD.Text == "") { if (radPICK_SELECT1.Checked) { radPICK_SELECT1.Checked = false; radPICK_SELECT2.Checked = true; } else { radPICK_SELECT1.Checked = true; radPICK_SELECT2.Checked = false; } ErrorMsgLabel.Text = "請先輸入正確之品號、期別"; Focus(((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)SLP_VIRTUAL_CODE).FindControl("TextBoxCode")).ClientID); return; } ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(SLP_VIRTUAL_CODE.Text); ParameterList.Add(txtPERIOD.Text); ParameterList.Add(Session["UID"].ToString()); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable Dt = BCO.QueryChanPickControl(ParameterList); string SessionIDName_Pick = "PUR041_Pick" + PageTimeStamp.Value; DataTable dt = (DataTable)Session[SessionIDName_Pick]; if (dt != null) if (dt.Rows.Count > 0) { DataRow[] drs = dt.Select("VIRTUAL_CODE='" + SLP_VIRTUAL_CODE.Text + "' and PERIOD='" + txtPERIOD.Text + "'"); if (drs.Length != 0) foreach (DataRow dr in drs) dr["PICK_SELECT"] = radPICK_SELECT1.Checked ? "2" : "1"; else { foreach (DataRow dr in Dt.Rows) dr["PICK_SELECT"] = radPICK_SELECT1.Checked ? "2" : "1"; dt.Merge(Dt); } Session[SessionIDName_Pick] = dt; } else { foreach (DataRow dr in Dt.Rows) dr["PICK_SELECT"] = radPICK_SELECT1.Checked ? "2" : "1"; Session[SessionIDName_Pick] = Dt; } else { foreach (DataRow dr in Dt.Rows) dr["PICK_SELECT"] = radPICK_SELECT1.Checked ? "2" : "1"; Session[SessionIDName_Pick] = Dt; } if (radPICK_SELECT1.Checked) { btn_GV_Set.Enabled = true; Session["Control" + PageTimeStamp.Value] = "1"; //管制 } else if (radPICK_SELECT2.Checked) { btn_GV_Set.Enabled = false; Session["Control" + PageTimeStamp.Value] = "0"; //理貨 } }
//新增明細區 -- 更新 protected void btnUpdate_Click(object sender, EventArgs e) { #region 欄位檢核 if (SLP_VIRTUAL_CODE.Text == "" || txtPERIOD.Text == "") { ErrorMsgLabel.Text = "請輸入品號、期別"; Focus(((TextBox)SLP_VIRTUAL_CODE.FindControl("TextBoxCode")).ClientID); return; } if (ChkPUR04Dup()) { ErrorMsgLabel.Text = "品號" + SLP_VIRTUAL_CODE.Text + "、期別" + txtPERIOD.Text + "、門市進貨日" + txtPLAN_ACCEPT_DATE.Text + "已有相同品號存在,請確認"; return; } SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); DataTable DetailDt = new DataTable(); if (Session[SessionIDName] != "" && Session[SessionIDName] != null) { DetailDt = (DataTable)Session[SessionIDName]; //檢核重複 DataRow[] ddrs = DetailDt.Select("VIRTUAL_CODE = '" + SLP_VIRTUAL_CODE.Text + "' and PERIOD = '" + txtPERIOD.Text + "'"); if (ddrs.Length > 0) { ErrorMsgLabel.Text = "品號、期別資料已存在,請重新輸入"; Focus(((TextBox)SLP_VIRTUAL_CODE.FindControl("TextBoxCode")).ClientID); return; } if (ViewState["NoPeriod"].ToString() != "1") { ErrorMsgLabel.Text = "期別不存在於該品號"; return; } } else { DetailDt.Columns.Add("ID"); DetailDt.Columns.Add("ITEM"); DetailDt.Columns.Add("VIRTUAL_CODE"); DetailDt.Columns.Add("VIRTUAL_NAME"); DetailDt.Columns.Add("PERIOD"); DetailDt.Columns.Add("PICK_SELECT"); DetailDt.Columns.Add("ONWAY_QTY"); DetailDt.Columns.Add("ONHD_QTY"); DetailDt.Columns.Add("DIS_QTY"); DetailDt.Columns.Add("DIFF_QTY"); DetailDt.Columns.Add("CREATEUID"); DetailDt.Columns.Add("CREATEDATE"); DetailDt.Columns.Add("UPDATEUID"); DetailDt.Columns.Add("UPDATEDATE"); DetailDt.Columns.Add("ISDEL"); DetailDt.Columns.Add("DATATYPE"); } #endregion string vPICK_SELECT = ""; string SessionIDName_Pick = "PUR041_Pick" + PageTimeStamp.Value; DataTable Dt_Set = (DataTable)Session[SessionIDName_Pick]; //通路管制設定 DataTable dtTmp_Set = new DataTable();//通路管制設定(PUR432傳回的DataTable) if (Session[string.Format("POP_PUR0432_dtSelectDisChain_{0}", PageTimeStamp.Value)] != "") dtTmp_Set = (DataTable)Session[string.Format("POP_PUR0432_dtSelectDisChain_{0}", PageTimeStamp.Value)]; if (Dt_Set == null || (Dt_Set != null && Dt_Set.Rows.Count <= 0)) { if (dtTmp_Set == null || dtTmp_Set != null && dtTmp_Set.Rows.Count == 0) { string pick = ""; ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(SLP_VIRTUAL_CODE.Text); ParameterList.Add(txtPERIOD.Text); ParameterList.Add(Session["UID"].ToString()); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); Dt_Set = BCO.QueryChanPickControl(ParameterList); if (radPICK_SELECT1.Checked) pick = "2"; else pick = "1"; foreach (DataRow dr1 in Dt_Set.Rows) dr1["PICK_SELECT"] = pick; Session[SessionIDName_Pick] = Dt_Set; } else { Session[SessionIDName_Pick] = dtTmp_Set.Copy(); DataView dv_Pick = new DataView(dtTmp_Set); dv_Pick.RowFilter = "PICK_SELECT = '2'"; if (dv_Pick.Count != 0) vPICK_SELECT = "2"; //有一筆以上管制 else vPICK_SELECT = "1"; //無管制 } } else { if (Dt_Set.PrimaryKey.Length <= 0) { DataColumn[] keys_pick = new DataColumn[6]; keys_pick[0] = Dt_Set.Columns["ST_ACCEPT_DATE"]; keys_pick[1] = Dt_Set.Columns["PICK_BATCH"]; keys_pick[2] = Dt_Set.Columns["ITEM"]; keys_pick[3] = Dt_Set.Columns["PERIOD"]; keys_pick[4] = Dt_Set.Columns["CHAN_NO"]; keys_pick[5] = Dt_Set.Columns["VIRTUAL_CODE"]; Dt_Set.CaseSensitive = true; Dt_Set.PrimaryKey = keys_pick; } vPICK_SELECT = "1"; if (dtTmp_Set != null) { if (dtTmp_Set.Rows.Count > 0) { DataRow[] DDrs1 = dtTmp_Set.Select("VIRTUAL_CODE = '" + SLP_VIRTUAL_CODE.Text + "' and PERIOD = '" + txtPERIOD.Text + "'"); if (DDrs1.Length > 0) { DataRow[] DDrs = Dt_Set.Select("VIRTUAL_CODE = '" + SLP_VIRTUAL_CODE.Text + "' and PERIOD = '" + txtPERIOD.Text + "'"); foreach (DataRow dr in DDrs) Dt_Set.Rows.Remove(dr); for (int i = 0; i < dtTmp_Set.Rows.Count; i++) //再全部新增該品號、期別的「通路管制設定」資料 { DataRow dr = Dt_Set.NewRow(); dr["ST_ACCEPT_DATE"] = dtTmp_Set.Rows[i]["ST_ACCEPT_DATE"].ToString(); dr["PICK_BATCH"] = dtTmp_Set.Rows[i]["PICK_BATCH"].ToString(); dr["ITEM"] = dtTmp_Set.Rows[i]["ITEM"].ToString(); dr["PERIOD"] = dtTmp_Set.Rows[i]["PERIOD"].ToString(); dr["CHAN_NO"] = dtTmp_Set.Rows[i]["CHAN_NO"].ToString(); dr["VIRTUAL_CODE"] = dtTmp_Set.Rows[i]["VIRTUAL_CODE"].ToString(); dr["CHAN_NAME"] = dtTmp_Set.Rows[i]["CHAN_NAME"].ToString(); dr["PICK_SELECT"] = dtTmp_Set.Rows[i]["PICK_SELECT"].ToString(); dr["CREATEUID"] = dtTmp_Set.Rows[i]["CREATEUID"].ToString(); dr["CREATEDATE"] = dtTmp_Set.Rows[i]["CREATEDATE"]; dr["UPDATEUID"] = dtTmp_Set.Rows[i]["UPDATEUID"].ToString(); dr["UPDATEDATE"] = dtTmp_Set.Rows[i]["UPDATEDATE"]; Dt_Set.Rows.Add(dr); if (dtTmp_Set.Rows[i]["PICK_SELECT"].ToString() == "2") vPICK_SELECT = "2"; } } else { string pick = ""; ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(SLP_VIRTUAL_CODE.Text); ParameterList.Add(txtPERIOD.Text); ParameterList.Add(Session["UID"].ToString()); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable dt_Set = BCO.QueryChanPickControl(ParameterList); if (radPICK_SELECT1.Checked) pick = "2"; else pick = "1"; foreach (DataRow dr1 in dt_Set.Rows) dr1["PICK_SELECT"] = pick; Dt_Set.Merge(dt_Set); } } Session[SessionIDName_Pick] = Dt_Set; } else { DataRow[] DDrs = Dt_Set.Select("VIRTUAL_CODE = '" + SLP_VIRTUAL_CODE.Text + "' and PERIOD = '" + txtPERIOD.Text + "'"); foreach (DataRow dr in DDrs) { if (radPICK_SELECT1.Checked) dr["PICK_SELECT"] = "2"; else dr["PICK_SELECT"] = "1"; } Session[SessionIDName_Pick] = Dt_Set; } } //重新再判斷一次(若使用者只按管制鈕,不進入管制設定裏,就不會執行上述程式碼 if (radPICK_SELECT1.Checked) vPICK_SELECT = "2"; else vPICK_SELECT = "1"; DataRow dRow = DetailDt.NewRow(); dRow["VIRTUAL_CODE"] = SLP_VIRTUAL_CODE.Text; dRow["ITEM"] = SLP_VIRTUAL_CODE.Text.Substring(0, 6); dRow["PERIOD"] = txtPERIOD.Text; dRow["PICK_SELECT"] = vPICK_SELECT; dRow["ONWAY_QTY"] = lblONWAY_QTY.Text; dRow["ONHD_QTY"] = lblONHD_QTY.Text; dRow["DIS_QTY"] = lblDIS_QTY.Text; dRow["DIFF_QTY"] = lblDIFF_QTY.Text; dRow["DATATYPE"] = "0"; DetailDt.Rows.Add(dRow); Session[SessionIDName] = DetailDt; GridView1.DataSource = DetailDt; GridView1.DataBind(); if (GridView1.Rows.Count > 0) { for (int i = 0; i < GridView1.Rows.Count; i++) { if (GridView1.Rows[i].RowType == DataControlRowType.DataRow) { ((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)GridView1.Rows[i].FindControl("VIRTUAL_CODE")).ReadOnly = true; ((PIC.VDS2G.WebUI.SLP.SLP_ItemPeriod)GridView1.Rows[i].FindControl("PERIOD")).ReadOnly = true; if (hid_PageStatus.Text == "LOAD") { ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Enabled = true; ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT2")).Enabled = true; if (((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked) ((Button)GridView1.Rows[i].FindControl("btn_GV_Set")).Enabled = true; else ((Button)GridView1.Rows[i].FindControl("btn_GV_Set")).Enabled = false; } else { ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Enabled = false; ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT2")).Enabled = false; ((Button)GridView1.Rows[i].FindControl("btn_GV_Set")).Enabled = true; } ((CheckBox)GridView1.Rows[i].FindControl("chkGV_Del")).Enabled = true; ((Button)GridView1.Rows[i].FindControl("btn_GV_Find")).Enabled = true; } ((CheckBox)GridView1.HeaderRow.FindControl("chkAll")).Enabled = true; } ReBindBtn_Set(); this.txtPLAN_ACCEPT_DATE.ReadOnly = true; this.txtPICK_BATCH.ReadOnly = true; this.txtPICK_BATCH.CssClass = "readtxtbox"; this.chkPICK_SELECT_1.Enabled = false; this.chkPICK_SELECT_2.Enabled = false; } panAdd.Visible = false; Btn_InsertItem.Enabled = true; btnSave.Enabled = true; //存檔 btnCancel.Enabled = true; //取消 btnDelItem.Enabled = true; //刪除品號 btnImportOnDate.Enabled = true; //指定日期匯入 ViewState["Insert"] = "0"; //解除新增狀態 Session["isFirst" + PageTimeStamp.Value] = "1"; //解除第一次執行通路管制設定 string outPick = "", outRestrain = ""; getGridPickCnt(out outPick, out outRestrain); LabelQueryRecordCount.Text = "品項數:理貨品:" + outPick + " 筆 管制品:" + outRestrain + " 筆 "; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, string.Empty, this.btnSave, WUI_GMToolbarV.ClickAction.ButtonClick); SLP_VIRTUAL_CODE.ReadOnly = false; txtPERIOD.ReadOnly = false; txtPERIOD.CssClass = ""; GridView1_Control(); //if (hid_AddDetail.Value == "ADD_DETAIL") //{ // txtPLAN_ACCEPT_DATE.ReadOnly = false; // txtPICK_BATCH.ReadOnly = false; // txtPICK_BATCH.CssClass = ""; // chkPICK_SELECT_1.Enabled = true; // chkPICK_SELECT_2.Enabled = true; //} }
// 新增明細 protected void Btn_InsertItem_Click(object sender, EventArgs e) { bool isAddDetail = false; //在檢視模式下直接按「新增明細」鈕 if (hid_PageStatus.Text == "VIEW") { #region 欄位檢核 if (txtPLAN_ACCEPT_DATE.Text == "") { ErrorMsgLabel.Text = "門市進貨日不可空白"; return; } if (txtPICK_BATCH.Text == "") { ErrorMsgLabel.Text = "理貨批次不可空白"; return; } string nowDate = DateTime.Now.ToString("yyy/MM/dd"); int v = nowDate.CompareTo(this.txtPLAN_ACCEPT_DATE.Text); if (v > 0) { ErrorMsgLabel.Text = "門市進貨日不可小於系統日"; return; } //判斷 PURModel.MaintainPurchaseDeliveryGoods PUR = new PURModel.MaintainPurchaseDeliveryGoods(ConntionDB); ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); if (PUR.CheckStAcceptData(ParameterList) == "0") { ErrorMsgLabel.Text = "門市進貨日及批次已存在轉門市進貨單檔,不可修改每日預定出貨明細資料 !!"; return; } DataTable dt = getControlChk(); if (dt.Rows.Count > 0) { ViewState["ControlChk"] = dt; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "if (confirm('該進貨日期、理貨批次目前仍由(" + dt.Rows[0]["UPDATEUID"].ToString() + ")於" + dt.Rows[0]["UPDATEDATE"].ToString() + "編輯中\\n\\n如繼續,將會重新鎖定該日期、批號\\n\\n於編輯期間由(" + dt.Rows[0]["UPDATEUID"].ToString() + ")編輯中的資料將無法存檔\\n\\n是否確定仍要繼續編輯?')){__doPostBack('','btn_InsertItem_Contnue');}", true); return; } #endregion //進入頁面程式後,直接按下「新增明細」鈕,定義為「ADD_DETAIL」 hid_PageStatus.Text = "ADD_DETAIL"; //多一個物件,因hid_PageStatus無法於新增明細儲存後(狀態變為EDIT)再處理ADD_DETAIL的資料 hid_AddDetail.Value = "ADD_DETAIL"; isAddDetail = true; SetPageStatus(); LockControlChk();//對ControlChk鎖定編輯 GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "PUR041.aspx?Code=PUR04", null, WUI_GMToolbarV.ClickAction.LinkURL); // GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, false, "", this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, string.Empty, this.btnSave, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); } TextBox txt_DATE = ((TextBox)((ASP.wui_slp_slp_slpdate_ascx)txtPLAN_ACCEPT_DATE).FindControl("TextBoxCode")); TextBox txt_VIRTUAL_CODE = SLP_VIRTUAL_CODE.TextBox_Code; Session["PageStatus" + PageTimeStamp.Value] = hid_PageStatus.Text; btn_GV_Set.Attributes.Add("OnClick", "document.all['" + progress.ClientID + "'].style.top = document.documentElement.scrollTop;document.all['" + progress.ClientID + "'].left = document.documentElement.scrollLeft;document.all['" + progress.ClientID + "'].style.display = 'block';Set_Open('" + txt_DATE.ClientID + "','" + txtPICK_BATCH.ClientID + "','" + txt_VIRTUAL_CODE.ClientID + "','" + txtPERIOD.ClientID + "','" + hid_PageStatus.ClientID + "','3','" + PageTimeStamp.Value + "');"); btn_GV_Find.Attributes.Add("OnClick", "Set_Open('" + txt_DATE.ClientID + "','" + txtPICK_BATCH.ClientID + "','" + txt_VIRTUAL_CODE.ClientID + "','" + txtPERIOD.ClientID + "','" + hid_PageStatus.ClientID + "','2','" + PageTimeStamp.Value + "');"); SLP_VIRTUAL_CODE.TextBox_Code.Attributes["onblur"] = "if($get('" + SLP_VIRTUAL_CODE.TextBox_Code.ClientID + "').value!=''){__doPostBack('" + UpdatePanel1.UniqueID + "','ItemBlur');} else {$get('" + lblONWAY_QTY.ClientID + "').innerHTML='';$get('" + lblONHD_QTY.ClientID + "').innerHTML='';$get('" + lblDIS_QTY.ClientID + "').innerHTML='';$get('" + lblDIFF_QTY.ClientID + "').innerHTML='';}"; txtPERIOD.Attributes["onblur"] = "if($get('" + txtPERIOD.ClientID + "').value!=''){__doPostBack('" + UpdatePanel1.UniqueID + "','PeriodBlur');} else {$get('" + lblONWAY_QTY.ClientID + "').innerHTML='';$get('" + lblONHD_QTY.ClientID + "').innerHTML='';$get('" + lblDIS_QTY.ClientID + "').innerHTML='';$get('" + lblDIFF_QTY.ClientID + "').innerHTML='';}"; ErrorMsgLabel.Text = ""; panAdd.Visible = true; ViewState["Insert"] = "1";//新增狀態 SLP_VIRTUAL_CODE.Text = ""; txtPERIOD.Text = ""; lblONWAY_QTY.Text = ""; lblONHD_QTY.Text = ""; lblDIS_QTY.Text = ""; lblDIFF_QTY.Text = ""; Btn_InsertItem.Enabled = false; //新增 btnSave.Enabled = false; //存檔 btnCancel.Enabled = false; //取消 btnDelItem.Enabled = false; //刪除品號 btnImportOnDate.Enabled = false; //指定日期匯入 radPICK_SELECT1.Checked = false; radPICK_SELECT2.Checked = true; Focus(((TextBox)SLP_VIRTUAL_CODE.FindControl("TextBoxCode")).ClientID); //進入頁面程式後,直接按下「新增明細」鈕 if (isAddDetail) { txtPLAN_ACCEPT_DATE.ReadOnly = true; txtPICK_BATCH.ReadOnly = true; txtPICK_BATCH.CssClass = "readtxtbox"; chkPICK_SELECT_1.Enabled = false; chkPICK_SELECT_2.Enabled = false; ButtonQuery.Visible = false; //查詢鈕 btnLoad.Visible = false; //品項載入鈕 btnSave.Visible = true; //編輯鈕 btnCancel.Visible = true; //取消鈕 } Session["isFirst" + PageTimeStamp.Value] = "0"; //設定為第一次執行通路管制設定(進入PopUp視窗後預設為理貨) Session["Control" + PageTimeStamp.Value] = "0"; //理貨(PopUp視窗判斷用) ViewState["NoPeriod"] = "1"; //預設會存在該期別 radPICK_SELECT1.Enabled = false; radPICK_SELECT2.Enabled = false; GridView_ReadOnly(); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, string.Empty, this.btnSave, WUI_GMToolbarV.ClickAction.ButtonClick); }
//箱數計算 protected void Btn_Count_Click(object sender, EventArgs e) { #region ErrorMsgLabel.Text = ""; string CountQty = "0"; UpdatePanel1.Update(); if (txtPLAN_ACCEPT_DATE.Text == "") { ErrorMsgLabel.Text = "門市進貨日不可空白"; UpdatePanel1.Update(); return; } if (txtPICK_BATCH.Text == "") { ErrorMsgLabel.Text = "理貨批次不可空白"; UpdatePanel1.Update(); return; } PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); BCO.CalBoxNum(ParameterList, out CountQty); if (CountQty == "") this.txtCount.Text = "0"; else this.txtCount.Text = CountQty; #endregion }
/// <summary> /// 刪除VDS_PUR_PICK_CONTROL_CHK,取消鎖定編輯 /// </summary> /// <param name="oldUID">原始使用者</param> /// <param name="oldTime">原始異動時間</param> private void DeleteControlChk(string oldUID, DateTime oldTime) { try { ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(oldUID); ParameterList.Add(oldTime); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); BCO.DeleteControlChk(ParameterList, null); } catch (Exception ex) { //throw ex; } }
// 列印 protected void btnPrint_Click(object sender, EventArgs e) { ErrorMsgLabel.Text = ""; try { PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); string vPICK_SELECT_1 = "0"; string vPICK_SELECT_2 = "0"; //固定傳 1 vPICK_SELECT_1 = "1"; vPICK_SELECT_2 = "1"; ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); ParameterList.Add(GetValueSetParameter(vPICK_SELECT_1, "int", false)); ParameterList.Add(GetValueSetParameter(vPICK_SELECT_2, "int", false)); DataTable Dt_Print = BCO.QuerySwitch(PURModel.MaintainPurchaseDeliveryGoods.QueryType.QueryByPrint, ParameterList); if (Dt_Print.Rows.Count == 0) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "PUR041.aspx", "alert(' 查無資料 ');", true); return; } ShowReport(Dt_Print); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } }
// 檢核資料是否已存在DB -> true:已存在、false:不存在 private bool ChkDup(string date, string code, string period, string datatype) { PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); ParameterList.Clear(); ParameterList.Add(date); //門市進貨日 ParameterList.Add(code); //虛擬品號 ParameterList.Add(period); //期別 ParameterList.Add(datatype); //正常品或客服查補 string V_RESULT = ""; BCO.ChkDup(ParameterList, out V_RESULT); if (V_RESULT != "0") return true; else return false; }
// 品項載入(續1) private void Item_Load1() { ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(""); ParameterList.Add(""); ParameterList.Add(""); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable Dtt = BCO.QueryChanPickControl(ParameterList); if (Dtt.Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "if (confirm('將會正式「清除通路管制設定的資料」,再重新載入\\n\\n是否確定仍要載入品項?')){window.setTimeout(function do_postback(){__doPostBack('','Item_Load2');} , 800);}", true);//發生錯誤,所以先做延遲的動作 return; } Item_Load2(); }
//GridView管制/理貨鈕 protected void rdoPICK_SELECT_CheckedChanged(object sender, EventArgs e) { RadioButton btn = sender as RadioButton; GridViewRow gr = (btn.BindingContainer as GridViewRow); int i = gr.RowIndex; SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); string Item_Name=((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)GridView1.Rows[i].FindControl("VIRTUAL_CODE")).FindControl("TextBoxName")).Text; if (ViewState["Insert"] != null) if (ViewState["Insert"].ToString() == "1") if (Item_Name == "" || Item_Name == "查無資料" || ((TextBox)((PIC.VDS2G.WebUI.SLP.SLP_ItemPeriod)GridView1.Rows[i].FindControl("PERIOD")).FindControl("TextBoxCode")).Text == "") { if (((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked) { ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked = false; ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT2")).Checked = true; } else { ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked = true; ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT2")).Checked = false; } ErrorMsgLabel.Text = "請先輸入品號、期別"; return; } ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)GridView1.Rows[i].FindControl("VIRTUAL_CODE")).FindControl("TextBoxCode")).Text); ParameterList.Add(((TextBox)((PIC.VDS2G.WebUI.SLP.SLP_ItemPeriod)GridView1.Rows[i].FindControl("PERIOD")).FindControl("TextBoxCode")).Text); ParameterList.Add(Session["UID"].ToString()); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); DataTable Dt = BCO.QueryChanPickControl(ParameterList); string SessionIDName_Pick = "PUR041_Pick" + PageTimeStamp.Value; DataTable dt = (DataTable)Session[SessionIDName_Pick]; if (dt != null) if (dt.Rows.Count > 0) { DataRow[] drs = dt.Select("VIRTUAL_CODE='" + ((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)GridView1.Rows[i].FindControl("VIRTUAL_CODE")).FindControl("TextBoxCode")).Text + "' and PERIOD='" + ((TextBox)((PIC.VDS2G.WebUI.SLP.SLP_ItemPeriod)GridView1.Rows[i].FindControl("PERIOD")).FindControl("TextBoxCode")).Text + "'"); if (drs.Length != 0) foreach (DataRow dr in drs) dr["PICK_SELECT"] = ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked ? "2" : "1"; else { foreach (DataRow dr in Dt.Rows) dr["PICK_SELECT"] = ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked ? "2" : "1"; dt.Merge(Dt); } Session[SessionIDName_Pick] = dt; } else { foreach (DataRow dr in Dt.Rows) dr["PICK_SELECT"] = ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked ? "2" : "1"; Session[SessionIDName_Pick] = Dt; } else { foreach (DataRow dr in Dt.Rows) dr["PICK_SELECT"] = ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked ? "2" : "1"; Session[SessionIDName_Pick] = Dt; } if (((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked) { ((Button)GridView1.Rows[i].FindControl("btn_GV_Set")).Enabled = true; ((Label)GridView1.Rows[i].FindControl("PICK_SELECT")).Text = "2"; } else if (((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT2")).Checked) { ((Button)GridView1.Rows[i].FindControl("btn_GV_Set")).Enabled = false; ((Label)GridView1.Rows[i].FindControl("PICK_SELECT")).Text = "1"; } DataTable DetailDt = (DataTable)Session[SessionIDName]; DataRow[] Drs; if(ViewState["Insert"]!=null) if (ViewState["Insert"].ToString() == "1") Drs = DetailDt.Select("VIRTUAL_CODE=''"); else Drs = DetailDt.Select("VIRTUAL_CODE='" + ((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)GridView1.Rows[i].FindControl("VIRTUAL_CODE")).FindControl("TextBoxCode")).Text + "' and PERIOD='" + ((TextBox)((PIC.VDS2G.WebUI.SLP.SLP_ItemPeriod)GridView1.Rows[i].FindControl("PERIOD")).FindControl("TextBoxCode")).Text + "'"); else Drs = DetailDt.Select("VIRTUAL_CODE='" + ((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)GridView1.Rows[i].FindControl("VIRTUAL_CODE")).FindControl("TextBoxCode")).Text + "' and PERIOD='" + ((TextBox)((PIC.VDS2G.WebUI.SLP.SLP_ItemPeriod)GridView1.Rows[i].FindControl("PERIOD")).FindControl("TextBoxCode")).Text + "'"); Drs[0]["PICK_SELECT"] = ((RadioButton)GridView1.Rows[i].FindControl("rdoPICK_SELECT1")).Checked ? "2" : "1"; Session[SessionIDName] = DetailDt; string outPick = "", outRestrain = ""; getGridPickCnt(out outPick, out outRestrain); LabelQueryRecordCount.Text = "品項數:理貨品:" + outPick + " 筆 管制品:" + outRestrain + " 筆 "; }
private void btnEdit_Continue() { PURModel.MaintainPurchaseDeliveryGoods PUR = new PURModel.MaintainPurchaseDeliveryGoods(ConntionDB); //判斷 ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); if (PUR.CheckStAcceptData(ParameterList) == "0") { ErrorMsgLabel.Text = "門市進貨日及批次已轉門市進貨單,不可修改出貨品項明細資料 !!"; return; } //由檢視模式切換至編輯模式 this.hid_PageStatus.Text = "EDIT"; SetPageStatus(); LockControlChk(); //對ControlChk鎖定編輯 btnDelItem.Visible = true; //btnImportOnDate.Visible = true; btnImportOnDate.Enabled = true; GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "PUR041.aspx?Code=PUR04", null, WUI_GMToolbarV.ClickAction.LinkURL); // GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, false, "", this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, string.Empty, this.btnSave, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, false, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); }
private void databind() { try { //抓取本頁初次登記的時間 SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); Session[SessionIDName] = null; PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); string v_PICK_CNT = "0"; string v_RESTRAIN_CNT = "0"; string vPICK_SELECT_1 = "0"; string vPICK_SELECT_2 = "0"; //固定傳 1 vPICK_SELECT_1 = "1"; vPICK_SELECT_2 = "1"; ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false)); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); ParameterList.Add(GetValueSetParameter(vPICK_SELECT_1, "int", false)); ParameterList.Add(GetValueSetParameter(vPICK_SELECT_2, "int", false)); ParameterList.Add(getDataType()); DataTable Dt = BCO.QueryDeliveryGoodsByFind_1(ParameterList, out v_PICK_CNT, out v_RESTRAIN_CNT); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; string outPick = "", outRestrain = ""; getGridPickCnt(out outPick, out outRestrain); LabelQueryRecordCount.Text = "品項數:理貨品:" + outPick + " 筆 管制品:" + outRestrain + " 筆 "; this.hid_PICK_CNT.Value = v_PICK_CNT; this.hid_RESTRAIN_CNT.Value = v_RESTRAIN_CNT; //將明細資料放至DetailDt中 detailTmpDt = Dt; //將空白的資料做處理 Dt = ProcessDBNull(Dt); #region 使用XML放置到前端資料 DataSet Ds = Dt.DataSet; DetailOLDData.InnerHtml = Ds.GetXml(); #endregion //設定分頁大小 GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { ErrorMsgLabel.Text = "查無資料"; LabelQueryRecordCount.Text = ""; } SetPageStatus(); UpdatePanel1.Update(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
private void txtPERIOD_Blur() { radPICK_SELECT1.Enabled = false; radPICK_SELECT2.Enabled = false; SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); string Item_Name = SLP_VIRTUAL_CODE.TextBox_Name.Text; if (Item_Name != "" && Item_Name != "查無資料" && txtPERIOD.Text != "") { //檢核重複 if (Session[SessionIDName] != "" && Session[SessionIDName] != null) { DataTable DetailDt = (DataTable)Session[SessionIDName]; DataRow[] ddrs = DetailDt.Select("VIRTUAL_CODE = '" + SLP_VIRTUAL_CODE.Text + "' and PERIOD = '" + txtPERIOD.Text + "'"); if (ddrs.Length > 0) { ErrorMsgLabel.Text = "品號、期別資料已存在,請重新輸入"; //Focus(txtPERIOD.ClientID); hidPERIOD.Value = txtPERIOD.Text; return; } } } if (SLP_VIRTUAL_CODE.Text != "") { try { if(txtPERIOD.Text!="") if (ChkPUR04Dup()) { ErrorMsgLabel.Text = "品號" + SLP_VIRTUAL_CODE.Text + "、期別" + txtPERIOD.Text + "、門市進貨日" + txtPLAN_ACCEPT_DATE.Text + "已有相同品號存在,請確認"; return; } string Msg = ""; ViewState["NoPeriod"] = "1"; //預設會存在該期別 string v_PLAN_ACCEPT_DATE = txtPLAN_ACCEPT_DATE.Text; string v_ITEM = SLP_VIRTUAL_CODE.Text; string v_PERIOD = txtPERIOD.Text; ParameterList.Clear(); ParameterList.Add(v_ITEM); ParameterList.Add(v_PERIOD); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); if (SLP_VIRTUAL_CODE.Text.Length > 6) { if (!BCO.QueryPeriod(ParameterList)) { ViewState["NoPeriod"] = "0"; //期別不存在於該品號 throw new Exception("期別不存在於該品號"); } } else { BCO.CheckItemData(ParameterList, out Msg); if (Msg != "") { ViewState["NoPeriod"] = "0"; //期別不存在於該品號 throw new Exception(Msg); } } getQTY_Data(); radPICK_SELECT1.Enabled = true; radPICK_SELECT2.Enabled = true; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } } if (SLP_VIRTUAL_CODE.Text == "" || txtPERIOD.Text == "") { lblONWAY_QTY.Text = ""; lblONHD_QTY.Text = ""; lblDIS_QTY.Text = ""; lblDIFF_QTY.Text = ""; } hidPERIOD.Value = txtPERIOD.Text; }
private void txtPERIOD_Blur() { SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); string Item_Name = ((TextBox)((PIC.VDS2G.WebUI.SLP.MKT_SLP_GiftItem)SLP_VIRTUAL_CODE).FindControl("TextBoxName")).Text; if (Item_Name != "" && Item_Name != "查無資料" && txtPERIOD.Text != "" && txtPURCHASE_NO.Text.Trim() != "") { //檢核重複 DataTable DetailDt = (DataTable)Session[SessionIDName]; DataRow[] ddrs = DetailDt.Select("VIRTUAL_CODE = '" + SLP_VIRTUAL_CODE.Text + "' and PERIOD = '" + txtPERIOD.Text + "' and PURCHASE_NO = '" + txtPURCHASE_NO.Text + "'"); if (ddrs.Length > 0) { ErrorMsgLabel.Text = "品號、期別、採購單號資料已存在,請重新輸入"; //Focus(((TextBox)SLP_PERIOD.FindControl("TextBoxCode")).ClientID); return; } } if (SLP_VIRTUAL_CODE.Text != "") { try { string Msg = ""; ViewState["NoPeriod"] = "1"; //預設會存在該期別 ParameterList.Clear(); ParameterList.Add(SLP_VIRTUAL_CODE.Text); ParameterList.Add(txtPERIOD.Text); PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); if (SLP_VIRTUAL_CODE.Text.Length > 6) { if (!BCO.QueryPeriod(ParameterList)) { //Focus(txtPERIOD.ClientID); ViewState["NoPeriod"] = "0"; //期別不存在於該品號 throw new Exception("期別不存在於該品號"); } } else { BCO.CheckItemData(ParameterList, out Msg); if (Msg != "") { ViewState["NoPeriod"] = "0"; //期別不存在於該品號 throw new Exception(Msg); } } getQTY_Data(); //if (ErrorMsgLabel.Text == "此品號、期別無未結採購單號資料,請重新輸入") // Focus(((TextBox)SLP_PERIOD.FindControl("TextBoxCode")).ClientID); //else // Focus(txtPURCHASE_NO.ClientID); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } } if (SLP_VIRTUAL_CODE.Text == "" || txtPERIOD.Text == "") { txtPURCHASE_NO.Text = ""; SLP_PURCHASE_QTY.Text = ""; txtMSG.Text = ""; } }