// 存檔 protected void btnSave_Click(object sender, EventArgs e) { hidStatus.Value = "1"; GetData(); //先惕除刪除勾選的資料 switch (this.hid_PageStatus.Value) { case "EDIT": #region 處理修改作業 try { if (GridView1.Rows.Count <= 0) { ErrorMsgLabel.Text = "請輸入資料"; return; } else { PURModel.MaintainPurchaseDayGood BCO = new PURModel.MaintainPurchaseDayGood(ConnectionDB); DataTable dt = getDetailData(); if (hid_ButtonStatus.Value == "QUERY") { if (this.checkDetailData()) //判斷Grid資料是否有重覆、是否有錯誤 { // 使用XML轉回DataSet取得更新前舊值 DataSet DsDetail = new DataSet(); System.IO.StringReader srD = new System.IO.StringReader(DetailOLDData.InnerHtml); DsDetail.ReadXml(srD); DataTable dtDetailOLD = DsDetail.Tables[0]; if (dtDetailOLD.Rows.Count == 0) throw new Exception("抓取不到舊值,更新失敗!"); BCO.UpdateMaster(this.getMasterParameterList(), dt, null, dtDetailOLD); } else return; } else //品項載入 { if (this.checkDetailData()) //判斷Grid資料是否有重覆、是否有錯誤 { //先全部刪除~再新增 ParameterList.Clear(); ParameterList.Add(this.txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(this.txtPICK_BATCH.Text); ParameterList.Add(Session["UID"].ToString()); BCO.DeleteAll(ParameterList, null); BCO.InsertMaster(this.getMasterParameterList(), dt, null); hid_ButtonStatus.Value = "QUERY"; } else return; } //由檢視模式切換至編輯模式 this.hid_PageStatus.Value = "VIEW"; SetPageStatus(); databind(); } } 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); #endregion break; default: break; } GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "PUR031.aspx?Code=PUR03", null, WUI_GMToolbarV.ClickAction.LinkURL); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, true, "", this.btnExport, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnExport, 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); }
//檢核 private bool checkDetailData() { string iDray = ""; string jDray = ""; string iDray_Qty = ""; string jDray_Qty = ""; string iDray_PERIOD = ""; string Msg = ""; bool checkFlag = true; SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); DataTable dt = (DataTable)Session[SessionIDName]; foreach (DataRow dr in dt.Rows) { if (dr["ISDEL"] != null) { if (dr["ISDEL"].ToString() == "0" || dr["ISDEL"].ToString() == "") { iDray = dr["VIRTUAL_CODE"].ToString(); iDray_PERIOD = dr["PERIOD"].ToString(); iDray_Qty = dr["PURCHASE_QTY"].ToString(); if (iDray == null || iDray == "") { ErrorMsgLabel.Text = " 品號資料不可空白,請確認"; checkFlag = false; break; } if (iDray_PERIOD == null || iDray_PERIOD == "") { ErrorMsgLabel.Text = "品號:" + iDray + " 期別資料不可空白,請確認"; checkFlag = false; break; } if (iDray_Qty == "0" || iDray_Qty == "") { ErrorMsgLabel.Text = "品號:" + iDray + " 採購數量需大於0,請確認"; checkFlag = false; break; } if (!LengthVaild(dr["MSG"].ToString(), 60)) { ErrorMsgLabel.Text = "品號:" + iDray + "「商品訊息」輸入資料大於系統限制,請確認"; checkFlag = false; break; } ParameterList.Clear(); ParameterList.Add(iDray); ParameterList.Add(null); PURModel.MaintainPurchaseDayGood BCO = new PURModel.MaintainPurchaseDayGood(ConnectionDB); 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; }
// 品項載入 protected void btnLoad_Click(object sender, EventArgs e) { PURModel.MaintainPurchaseDayGood PUR = new PURModel.MaintainPurchaseDayGood(ConnectionDB); ErrorMsgLabel.Text = ""; 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; } //判斷 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; } hid_ButtonStatus.Value = "LOAD"; //抓取本頁初次登記的時間 SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false)); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); PURModel.MaintainPurchaseDayGood BCO = new PURModel.MaintainPurchaseDayGood(ConnectionDB); DataTable Dt = BCO.QuerySwitch(PURModel.MaintainPurchaseDayGood.QueryType.QueryByLOAD, ParameterList); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; #region 將明細資料放至DetailDt中 detailTmpDt = Dt; #endregion #region 將空白的資料做處理 for (int i = 0; i < Dt.Rows.Count; i++) { for (int j = 0; j < Dt.Columns.Count; j++) { if (Dt.Columns[j].DataType == typeof(System.String)) { if (Dt.Rows[i][j].GetType() == typeof(System.DBNull)) { Dt.Rows[i][j] = ""; } } if (Dt.Columns[j].DataType == typeof(System.Decimal)) { if (Dt.Rows[i][j].GetType() == typeof(System.DBNull)) { Dt.Rows[i][j] = 0; } } } } #endregion #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)) { btnPrint.Visible = false; btnExport.Visible = false; btnEdit.Visible = false; ErrorMsgLabel.Text = "查無資料"; } else { btnPrint.Visible = true; btnExport.Visible = true; btnEdit.Visible = true; this.hid_PageStatus.Value = "EDIT"; hidStatus.Value = "2"; //進入編輯狀態 SetPageStatus(); } #region ToolBar設定 if (detailTmpDt == null || (detailTmpDt != null && detailTmpDt.Rows.Count <= 0)) { GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "PUR031.aspx?Code=PUR03", null, WUI_GMToolbarV.ClickAction.LinkURL); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, false, "", this.btnExport, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnExport, 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, false, "PUR031.aspx?Code=PUR03", null, WUI_GMToolbarV.ClickAction.LinkURL); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, false, "", this.btnExport, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnExport, 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 btnEdit_Click(object sender, EventArgs e) { hidStatus.Value = "2"; PURModel.MaintainPurchaseDayGood PUR = new PURModel.MaintainPurchaseDayGood(ConnectionDB); //判斷 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.Value = "EDIT"; SetPageStatus(); GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, false, "PUR031.aspx?Code=PUR03", null, WUI_GMToolbarV.ClickAction.LinkURL); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, false, "", this.btnExport, WUI_GMToolbarV.ClickAction.ButtonClick); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnExport, 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); }
// 列印 protected void btnPrint_Click(object sender, EventArgs e) { if (VerifyFormData() == true) { try { ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); PURModel.MaintainPurchaseDayGood BCO = new PURModel.MaintainPurchaseDayGood(ConnectionDB); DataTable Dt_Print = BCO.QuerySwitch(PURModel.MaintainPurchaseDayGood.QueryType.QueryByPrint, ParameterList); if (Dt_Print.Rows.Count == 0) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "PUR031.aspx", "alert(' 查無資料 ');", true); return; } ShowReport(Dt_Print); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } } }
private void databind() { SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); 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)); PURModel.MaintainPurchaseDayGood BCO = new PURModel.MaintainPurchaseDayGood(ConnectionDB); DataTable Dt = BCO.QuerySwitch(PURModel.MaintainPurchaseDayGood.QueryType.QueryByFIND, ParameterList); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; #region 將明細資料放至DetailDt中 detailTmpDt = Dt; #endregion #region 將空白的資料做處理 for (int i = 0; i < Dt.Rows.Count; i++) for (int j = 0; j < Dt.Columns.Count; j++) { if (Dt.Columns[j].DataType == typeof(System.String)) if (Dt.Rows[i][j].GetType() == typeof(System.DBNull)) Dt.Rows[i][j] = ""; if (Dt.Columns[j].DataType == typeof(System.Decimal)) if (Dt.Rows[i][j].GetType() == typeof(System.DBNull)) Dt.Rows[i][j] = 0; } #endregion #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 = "查無資料"; if (ErrorMsgLabel.Text == "查無資料") hidStatus.Value = "0"; //進入檢視狀態 else hidStatus.Value = "1"; //進入檢視狀態 SetPageStatus(); }
}//設定各種模式預設值 private void databind_Export() { ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); PURModel.MaintainPurchaseDayGood BCO = new PURModel.MaintainPurchaseDayGood(ConnectionDB); DataTable Dt_Export = BCO.QuerySwitch(PURModel.MaintainPurchaseDayGood.QueryType.QueryByExport, ParameterList); GridView2.DataSource = Dt_Export; GridView2.DataBind(); if (Dt_Export == null || (Dt_Export != null && Dt_Export.Rows.Count <= 0)) ErrorMsgLabel.Text = "查無資料"; }
private void getQTY_Data() { ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); ParameterList.Add(SLP_VIRTUAL_CODE.Text); ParameterList.Add(txtPERIOD.Text); PURModel.MaintainPurchaseDayGood BCO = new PURModel.MaintainPurchaseDayGood(ConnectionDB); DataTable Dt_Find = BCO.GetPurchaseItemInfo(ParameterList); ViewState["QTY_Data"] = Dt_Find; if (Dt_Find != null && Dt_Find.Rows.Count > 0) { txtPURCHASE_NO.Text = Dt_Find.Rows[0]["PURCHASE_NO"].ToString(); SLP_PURCHASE_QTY.Text = Dt_Find.Rows[0]["PURCHASE_QTY"].ToString(); txtMSG.Text = Dt_Find.Rows[0]["MSG"].ToString(); } else { txtPURCHASE_NO.Text = ""; SLP_PURCHASE_QTY.Text = ""; txtMSG.Text = ""; ErrorMsgLabel.Text = "此品號、期別無未結採購單號資料,請重新輸入"; } }
private void txtITEM_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 = ""; ParameterList.Clear(); ParameterList.Add(SLP_VIRTUAL_CODE.Text); ParameterList.Add(null); PURModel.MaintainPurchaseDayGood BCO = new PURModel.MaintainPurchaseDayGood(ConnectionDB); BCO.CheckItemData(ParameterList, out Msg); if (Msg != "") { //Focus(((TextBox)SLP_VIRTUAL_CODE.FindControl("TextBoxCode")).ClientID); throw new Exception(Msg); } //Focus(((TextBox)SLP_PERIOD.FindControl("TextBoxCode")).ClientID); if (txtPERIOD.Text != "") { 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 = ""; } }