protected void Page_Load(object sender, EventArgs e) { try { if (Session["IVM04QueryID"] != null) { IDList = (ArrayList)Session["IVM04QueryID"]; } AuthorityControls(this); ErrorMsgLabel.Text = ""; if (!Page.IsPostBack) { PageTimeStamp.Value = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); this.pnlAdd.Visible = true; this.txtStockTakeQty.Attributes["onblur"] = "CheckQty('ctl00_CPH_txtStockTakeQty')"; this.pnlAdd.Visible = false; if (Request["PageMode"] == "1") { this.hid_Page_Status.Value = "VIEW"; string strLocateNo; string strLocateS; string strLocateE; string strStockDate; string strStocktakeNo; string strTotalQty; string strTakeUserId; string strStatus; IVMModel.MaintainStockTake BCO = new PIC.VDS2G.VSM.IVM.MaintainStockTake(ConntionDB); DataTable dt = new DataTable(); dt = BCO.QueryByID(Request["ID"].ToString(), out strLocateNo, out strLocateS, out strLocateE, out strStockDate, out strStocktakeNo, out strTotalQty, out strTakeUserId, out strStatus); dtForBrowse = dt; OldDt = dt; GridView1.DataSource = dt; GridView1.PageSize = (TextBoxPagesize.Text == "") ? 20 : (int.Parse(TextBoxPagesize.Text) < 0) ? 20 : int.Parse(TextBoxPagesize.Text); TextBoxPagesize.Text = GridView1.PageSize.ToString(); GridView1.PageIndex = 0; GridView1.DataBind(); if (strStatus == "75") ckbStatus.Checked = true; else ckbStatus.Checked = false; SLP_CodeFile1.Text = strLocateNo; Databind(); ddlS.SelectedValue = strLocateS; ddlE.SelectedValue = strLocateE; SLP_SLPDate1.Text = strStockDate; lblStockTakeNo.Text = strStocktakeNo; SLP_User1.Text = strTakeUserId; ViewState["ddlS"] = this.ddlS.SelectedIndex > 0 ? this.ddlS.SelectedIndex : 0; ViewState["ddlE"] = this.ddlE.SelectedIndex > 0 ? this.ddlE.SelectedIndex : 0; ViewState["CodeFile"] = this.SLP_CodeFile1.DropDownListControl.SelectedIndex > 0 ? this.SLP_CodeFile1.DropDownListControl.SelectedIndex : 0; } else if (Request["PageMode"] == "2") { this.hid_Page_Status.Value = "UPDATE"; IVMModel.MaintainStockTake BCO = new PIC.VDS2G.VSM.IVM.MaintainStockTake(ConntionDB); string strLocateNo; string strLocateS; string strLocateE; string strStockDate; string strStocktakeNo; string strTotalQty; string strTakeUserId; string strStatus; DataTable dt = new DataTable(); dt = BCO.QueryByID(Request["ID"].ToString(), out strLocateNo, out strLocateS, out strLocateE, out strStockDate, out strStocktakeNo, out strTotalQty, out strTakeUserId, out strStatus); dtForBrowse = dt; OldDt = dt; GridView1.DataSource = dt; GridView1.PageSize = int.Parse(Request["PageSize"]); TextBoxPagesize.Text = Request["PageSize"]; GridView1.PageIndex = 0; GridView1.DataBind(); if (strStatus == "75") ckbStatus.Checked = true; else ckbStatus.Checked = false; SLP_CodeFile1.Text = strLocateNo; Databind(); ddlS.SelectedValue = strLocateS; ddlE.SelectedValue = strLocateE; SLP_SLPDate1.Text = strStockDate; lblStockTakeNo.Text = strStocktakeNo; SLP_User1.Text = strTakeUserId; if (Request["StockTakeNo"] != null) { SLP_CodeFile1.Text = Request["CodeFile"].ToString(); this.ddlS.SelectedIndex = int.Parse(Request["SectionS"].ToString()); this.ddlE.SelectedIndex = int.Parse(Request["SectionE"].ToString()); SLP_SLPDate1.Text = Request["StockDate"].ToString(); lblStockTakeNo.Text = Request["StockTakeNo"].ToString(); SLP_User1.Text = Request["TakeuserId"].ToString(); } ViewState["ddlS"] = this.ddlS.SelectedIndex > 0 ? this.ddlS.SelectedIndex : 0; ViewState["ddlE"] = this.ddlE.SelectedIndex > 0 ? this.ddlE.SelectedIndex : 0; ViewState["CodeFile"] = this.SLP_CodeFile1.DropDownListControl.SelectedIndex > 0 ? this.SLP_CodeFile1.DropDownListControl.SelectedIndex : 0; } else if (Request["PageMode"] == "21") { //新增 this.hid_Page_Status.Value = "UPDATE2"; IVMModel.MaintainStockTake BCO = new PIC.VDS2G.VSM.IVM.MaintainStockTake(ConntionDB); string strLocateNo = Request["LOCATE_NO"].ToString(); string strLocateS = Request["LOCATE_SECTION_S"].ToString(); string strLocateE = Request["LOCATE_SECTION_E"].ToString(); string strStockDate = Request["StockDate"].ToString(); string strStocktakeNo = string.Empty; string strTotalQty = "0"; string strTakeUserId = Request["TakeUserId"]; string strStatus = string.Empty; DataTable dt = new DataTable(); ParameterList.Clear(); ParameterList.Add(strLocateNo + strLocateS); ParameterList.Add(strLocateNo + strLocateE); dt = BCO.QueryStockTakeItem(ParameterList); dtForBrowse = dt; OldDt = dt; GridView1.DataSource = dt; GridView1.PageSize = int.Parse(Request["PageSize"]); TextBoxPagesize.Text = Request["PageSize"]; GridView1.PageIndex = 0; GridView1.DataBind(); ckbStatus.Checked = false; SLP_CodeFile1.Text = strLocateNo; Databind(); ddlS.SelectedValue = strLocateS; ddlE.SelectedValue = strLocateE; SLP_SLPDate1.Text = strStockDate; lblStockTakeNo.Text = strStocktakeNo; SLP_User1.Text = strTakeUserId; ViewState["ddlS"] = this.ddlS.SelectedIndex > 0 ? this.ddlS.SelectedIndex : 0; ViewState["ddlE"] = this.ddlE.SelectedIndex > 0 ? this.ddlE.SelectedIndex : 0; ViewState["CodeFile"] = this.SLP_CodeFile1.DropDownListControl.SelectedIndex > 0 ? this.SLP_CodeFile1.DropDownListControl.SelectedIndex : 0; } else if (Request["PageMode"] == "3") { this.hid_Page_Status.Value = "INSERT"; TextBoxPagesize.Text = (TextBoxPagesize.Text == "") ? "20" : (int.Parse(TextBoxPagesize.Text) < 0) ? "20" : TextBoxPagesize.Text; IVMModel.MaintainStockTake BCO = new IVMModel.MaintainStockTake(ConntionDB); SLP_CodeFile1.Text = ""; SLP_SLPDate1.Text = DateTime.Now.ToString("yyyy/MM/dd"); SLP_User1.Text = Session["UID"].ToString(); Databind(); ViewState["ddlS"] = this.ddlS.SelectedIndex > 0 ? this.ddlS.SelectedIndex : 0; ViewState["ddlE"] = this.ddlE.SelectedIndex > 0 ? this.ddlE.SelectedIndex : 0; ViewState["CodeFile"] = this.SLP_CodeFile1.DropDownListControl.SelectedIndex > 0 ? this.SLP_CodeFile1.DropDownListControl.SelectedIndex : 0; } GetPageDefault(); } else { SaveBrowseData(); } ToolBarInit(); #region 檢查結束欄位一定要大於或等於開始欄位 ddlS.Attributes.Add("onblur", "Check_End_GreaterThan_Begin('" + ddlS.ClientID + "','" + ddlE.ClientID + "');"); ddlE.Attributes.Add("onblur", "Check_End_GreaterThan_Begin('" + ddlS.ClientID + "','" + ddlE.ClientID + "');"); #endregion ScriptManager.RegisterStartupScript(Page, this.GetType(), "ChangeD1Text", "ChangeD1Text();", true); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } }
}//databind private void databind_Dtl() { #region try { string SessionIDName = "IVM04_DTL_" + PageTimeStamp.Value; IVMModel.MaintainStockTake BCO = new PIC.VDS2G.VSM.IVM.MaintainStockTake(ConntionDB); string strID = ""; if (Request.QueryString["ID"] != null) { strID = Request.QueryString["ID"].ToString(); } else { strID = CraeteMainID; } string strLocateNo; string strLocateS; string strLocateE; string strStockDate; string strStocktakeNo; string strTotalQty; string strTakeUserId; string strStatus; DataTable Dt = new DataTable(); Dt = BCO.QueryByID(strID, out strLocateNo, out strLocateS, out strLocateE, out strStockDate, out strStocktakeNo, out strTotalQty, out strTakeUserId, out strStatus); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; GridView1.PageIndex = 0; GridView1.DataBind(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
}//Page_Init protected void Page_Load(object sender, EventArgs e) { try { AuthorityControls(this); ErrorMsgLabel.Text = ""; if (!Page.IsPostBack) { PageTimeStamp.Value = DateTime.Now.ToString("yyyyMMddHHmmss"); TextBoxPagesize.Text = (TextBoxPagesize.Text == "") ? "20" : (int.Parse(TextBoxPagesize.Text) < 0) ? "20" : TextBoxPagesize.Text; string strID = Request.QueryString["ID"].ToString(); IVMModel.MaintainStockTake BCO = new PIC.VDS2G.VSM.IVM.MaintainStockTake(ConntionDB); string strLocateNo; string strLocateS; string strLocateE; string strStockDate; string strStocktakeNo; string strTotalQty; string strTakeUserId; string strStatus; //取得主檔資料 DataTable dt = new DataTable(); dt = BCO.QueryByID(strID, out strLocateNo, out strLocateS, out strLocateE, out strStockDate, out strStocktakeNo, out strTotalQty, out strTakeUserId, out strStatus); SLP_CodeFile1.Text = strLocateNo; txtS.Text = strLocateS; txtE.Text = strLocateE; SLP_SLPDate1.Text = strStockDate; lblStockTakeNo.Text = strStocktakeNo; SLP_User1.Text = strTakeUserId; hdfPID.Value = strID; //因為只有新增資料 所以不需要用strTotalQty這個資料 txtTotalQty.Text = "0"; TextBoxNoBorder(txtTotalQty); //取得符合條件的儲格資料 GetLOCATE_SECTION(); //設定初始的明細資料 Session["IVM043_DTL_" + PageTimeStamp.Value] = DT_SCHEMA(); for (int i = 0; i < 15; i++) { AddEmptyRow(); } Databind(); GetPageDefault(); ScriptManager.RegisterStartupScript(Page, this.GetType(), "ChangeD1Text", "ChangeD1Text();", true); } ToolBarInit(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } }