protected void btnSave2_Click(object sender, EventArgs e) { //2009/08/17 VGRModel.GetSysData BCOSysData = new VGRModel.GetSysData(ConntionDB); string Apl_Date = BCOSysData.GetBUSDate(); if (Apl_Date == string.Empty) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR01", "alert('未取得檢核日期 ');", true); return; } string VAMClosed = BCOSysData.CheckVAMClosedYN(Apl_Date); if (VAMClosed != "N") { ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR01", "alert('廠商日結資料無法編輯 ');", true); return; } ErrorMsgLabel.Text = ""; if (this.hid_Page_Status.Value == "INSERT") SaveForm(); if (this.hid_Page_Status.Value == "UPDATE") UpdateForm(); }
private void bindMain() { try { if (this.hid_Page_Status.Value == "VIEW")//Model:檢視 { VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB); //將報表列印所需要的報表欄位參數加入HiddenField DataTable dtHidField = BCOVGR.GetPrintRpt01Main(Request.QueryString["ID"].ToString()); if (dtHidField.Rows.Count > 0) { this.hidContract.Value=dtHidField.Rows[0]["Business_Contact"].ToString(); this.hidFax.Value = dtHidField.Rows[0]["Business_Fax"].ToString(); this.hidReturnDate.Value = dtHidField.Rows[0]["Return_Date"].ToString(); this.hid_Tax_Total_Amt.Value = dtHidField.Rows[0]["Tax_Total_Amt"].ToString(); this.hid_UnTax_Total_Amt.Value = dtHidField.Rows[0]["UnTax_Total_Amt"].ToString(); this.hid_Tax_Amt.Value = dtHidField.Rows[0]["Tax_Amt"].ToString(); } DataTable dtResult = BCOVGR.QueryMainByID(Request.QueryString["ID"].ToString()); if (dtResult.Rows.Count == 1) { this.txtRemoveNo.Text = dtResult.Rows[0]["return_no"].ToString(); this.txtAdjNo.Text = dtResult.Rows[0]["adjust_no"].ToString(); this.txtSum.Text = dtResult.Rows[0]["sum_qty"].ToString(); this.SLP_Date.Text = dtResult.Rows[0]["return_date"].ToString(); this.SLP_Vendor.Text = dtResult.Rows[0]["vendor"].ToString(); this.lblCretaeDate.Text = dtResult.Rows[0]["createdate"].ToString(); this.SLP_CUser.Text = dtResult.Rows[0]["createuid"].ToString(); this.lblMaintainDate.Text = dtResult.Rows[0]["UpdateDate"].ToString(); this.SLP_MUser.Text = dtResult.Rows[0]["updateuid"].ToString(); this.hid_UpdateTime.Value = dtResult.Rows[0]["UpdateTime"].ToString(); VGRModel.GetSysData BCOSysData = new VGRModel.GetSysData(ConntionDB); string Apl_Date = BCOSysData.GetBUSDate(); if (Apl_Date == string.Empty) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR01", "alert('未取得檢核日期 ');", true); return; } string VAMClosed = BCOSysData.CheckVAMClosedYN(Apl_Date); this.btnEdit.Enabled = VAMClosed == "N"; this.btnSave.Enabled = false; this.btnCancel.Enabled = false; } else { ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR01", "alert('無資料可供查詢 ');", true); return; } } else if (this.hid_Page_Status.Value == "UPDATE")//Model:編輯(更新) { //取得TARGET LOCATE SECTION ParameterList.Clear(); ParameterList.Add("B"); VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB); string strReturnLocateNo = ""; string strReturnLocateSection = ""; BCOVGR.QueryTargetLocate(ParameterList, out strReturnLocateNo, out strReturnLocateSection); ReturnLocateNo = strReturnLocateNo; ReturnLocateSection = strReturnLocateSection; hid_LocateSection.Value = ReturnLocateSection; if (ReturnLocateSection == string.Empty) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "alert('廠退作業尚未設定對應儲格'); window.location.href = 'VGR011.aspx';", true); } DataTable dtResult = BCOVGR.QueryMainByID(Request.QueryString["ID"].ToString()); if (dtResult.Rows.Count == 1) { this.txtRemoveNo.Text = dtResult.Rows[0]["return_no"].ToString(); this.txtAdjNo.Text = dtResult.Rows[0]["adjust_no"].ToString(); this.txtSum.Text = dtResult.Rows[0]["sum_qty"].ToString(); this.SLP_Date.Text = dtResult.Rows[0]["return_date"].ToString(); this.SLP_Vendor.Text = dtResult.Rows[0]["vendor"].ToString(); this.lblCretaeDate.Text = dtResult.Rows[0]["createdate"].ToString(); this.SLP_CUser.Text = dtResult.Rows[0]["createuid"].ToString(); this.lblMaintainDate.Text = dtResult.Rows[0]["UpdateDate"].ToString(); this.SLP_MUser.Text = dtResult.Rows[0]["updateuid"].ToString(); this.hid_UpdateTime.Value = dtResult.Rows[0]["UpdateTime"].ToString(); this.btnEdit.Visible = false; this.btnAddDetail.Enabled = false; } } else if (this.hid_Page_Status.Value == "INSERT")//Model:新增 { //取得TARGET LOCATE SECTION ParameterList.Clear(); ParameterList.Add("B"); VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB); string strReturnLocateNo = ""; string strReturnLocateSection = ""; BCOVGR.QueryTargetLocate(ParameterList, out strReturnLocateNo, out strReturnLocateSection); ReturnLocateNo = strReturnLocateNo; ReturnLocateSection = strReturnLocateSection; hid_LocateSection.Value = ReturnLocateSection; if (ReturnLocateSection == string.Empty) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "alert('廠退作業尚未設定對應儲格'); window.location.href = 'VGR011.aspx';", true); } this.SLP_Date.Text = strToday; this.SLP_CDate.Text = strToday; this.SLP_CUser.Text = Session["UID"].ToString(); this.SLP_MDate.Text = strToday; this.SLP_MUser.Text = Session["UID"].ToString(); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
//改由DB計算 //private void CalcuTotalTax(DataTable Dt) //{ // decimal TaxTotalAmt = 0; // decimal UnTaxTotalAmt = 0; // decimal TaxAmt = 0; // decimal SubTaxTotalAmt = 0; // decimal TaxRate = 0; // if (Dt != null) // { // for (int TaxTypeNum = 0; TaxTypeNum < TaxTypeList.Count; TaxTypeNum++) // { // VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB); // TaxRate = decimal.Parse(BCOVGR.GetTaxRate(int.Parse(TaxTypeList[TaxTypeNum].ToString()))); // SubTaxTotalAmt = 0; // for (int i = 0; i < Dt.Rows.Count; i++) // { // if(Dt.Rows[i]["tax_type"].ToString() == TaxTypeList[TaxTypeNum].ToString()) // { // if (Dt.Rows[i]["tax_type"].ToString() == "1") // { // UnTaxTotalAmt += (decimal.Parse(Dt.Rows[i]["cost"].ToString()) * int.Parse(Dt.Rows[i]["return_qty"].ToString())); // } // else // { // SubTaxTotalAmt += (decimal.Parse(Dt.Rows[i]["cost"].ToString()) * int.Parse(Dt.Rows[i]["return_qty"].ToString())); // } // } // } // TaxTotalAmt += SubTaxTotalAmt; // TaxAmt += SubTaxTotalAmt * TaxRate; // } // this.hid_Tax_Total_Amt.Value = TaxTotalAmt.ToString(); // this.hid_UnTax_Total_Amt.Value = UnTaxTotalAmt.ToString(); // this.hid_Tax_ReMain_Amt.Value = TaxTotalAmt.ToString(); // this.hid_UnTax_ReMain_Amt.Value = UnTaxTotalAmt.ToString(); // this.hid_Tax_Amt.Value = TaxAmt.ToString(); // } //} //1.取得業務日期 //2.取得供應商日結Flag private bool checkClosed() { try { //1.業務日期 <> ReturnDate & 供應商日結Flag = N,編輯按鈕才可以用 VGRModel.GetSysData dbo = new VGRModel.GetSysData(ConntionDB); string Apl_date = dbo.GetBUSDate(); if (Apl_date != SLP_Date.Text) { return false; } string CloseFlag = dbo.CheckVAMClosedYN(Apl_date); if (CloseFlag != "N") { return false; } return true; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; return false; } }