protected void btnAdd_Detl_Click(object sender, EventArgs e) { try { this.TextBox3.Text = Page.Request.Form[TextBox3.UniqueID]; Label8.Text = ""; string SessionIDName = "VAM072_gvA" + PageTimeStamp.Value; DataTable dtA = new DataTable(); if (Session[SessionIDName] == null) { dtA = this.MakeDTForInvDis(); } else { dtA = (DataTable)Session[SessionIDName]; } #region 檢核發票號碼 string V_VANDOR = this.hidVANDOR.Value; string V_INV_NO = this.SLP_VendorInvoice2.Text.Trim(); #region 取得資料 DataTable dt_Return = new DataTable(); BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); dt_Return = bco.QueryInvoiceDetl(V_VANDOR, V_INV_NO); #endregion if (dt_Return.Rows.Count == 0) { this.Label8.Text = "此發票號碼非該廠商開立的發票,請重新輸入!"; this.SetClinetFocus(((TextBox)this.SLP_VendorInvoice2.FindControl("TextBoxCode")).ClientID); return; } else { for (int i = 0; i < dtA.Rows.Count; i++) { if (V_INV_NO == dtA.Rows[i]["INV_NO"].ToString()) { Label8.Text = "此發票號碼已輸入發票折減資料"; this.SetClinetFocus(((TextBox)this.SLP_VendorInvoice2.FindControl("TextBoxCode")).ClientID); return; } } if (this.TextBox4.Text.Trim() == "") { Label8.Text = "[折減金額]欄位不可為空值!"; this.SetClinetFocus(this.TextBox4.ClientID); return; } else { //if (Convert.ToDecimal(this.TextBox4.Text.Trim()) > Convert.ToDecimal(dt_Return.Rows[0]["NON_DISC_AMT"].ToString())) if (Convert.ToDecimal(this.TextBox4.Text.Trim()) > Convert.ToDecimal(this.TextBox3.Text.Trim())) { Label8.Text = "[折減金額]欄位不可大於[未折減金額]欄位!"; //this.TextBox3.Text = dt_Return.Rows[0]["NON_DISC_AMT"].ToString(); this.SetClinetFocus(this.TextBox4.ClientID); return; } } } #endregion DataRow drA = dtA.NewRow(); drA["INV_NO"] = this.SLP_VendorInvoice2.Text.Trim(); drA["INV_UAMT"] = Convert.ToDecimal(dt_Return.Rows[0]["INV_UAMT"].ToString()); drA["NON_DISC_AMT"] = Convert.ToDecimal(this.TextBox3.Text.Trim()); drA["DISC_AMT"] = Convert.ToDecimal(this.TextBox4.Text.Trim()); dtA.Rows.Add(drA); this.GridView2.Visible = true; Session["SessionID"] = SessionIDName; Session[SessionIDName] = dtA; ((TextBox)this.SLP_SLPNumber1.FindControl("TextBoxCode")).Text = "0"; ((TextBox)this.SLP_SLPNumber2.FindControl("TextBoxCode")).Text = "0"; ((TextBox)this.SLP_SLPNumber3.FindControl("TextBoxCode")).Text = "0"; this.GridView2.DataSource = dtA; this.GridView2.DataBind(); } catch (Exception ex) { Label8.Text = ex.Message; } }
public static string GetInvInfo(string V_VANDOR, string V_INV_NO, string V_DISC_AMT, string V_T_DISC_AMT, string V_TAX_TYPE) { #region 取得資料 DataTable dt_Return = new DataTable(); string[] arrVandor = V_VANDOR.Split('/'); BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); dt_Return = bco.QueryInvoiceDetl(arrVandor[0].ToString(), V_INV_NO); #endregion string sReturn = ""; if (dt_Return.Rows.Count > 0) { if (V_TAX_TYPE == dt_Return.Rows[0]["TAX_TYPE"].ToString().Trim()) { if (V_DISC_AMT != "" && V_T_DISC_AMT != "") { decimal iNonDiscAmt; iNonDiscAmt = Convert.ToDecimal(V_DISC_AMT) - Convert.ToDecimal(V_T_DISC_AMT); if (iNonDiscAmt < 0) iNonDiscAmt = 0; if (Convert.ToDecimal(dt_Return.Rows[0]["NON_DISC_AMT"]) < iNonDiscAmt) sReturn = Convert.ToString(dt_Return.Rows[0]["INV_UAMT"]) + "|" + Convert.ToString(dt_Return.Rows[0]["NON_DISC_AMT"]) + "|" + Convert.ToString(dt_Return.Rows[0]["NON_DISC_AMT"]); else sReturn = Convert.ToString(dt_Return.Rows[0]["INV_UAMT"]) + "|" + Convert.ToString(dt_Return.Rows[0]["NON_DISC_AMT"]) + "|" + Convert.ToString(iNonDiscAmt); } else { sReturn = Convert.ToString(dt_Return.Rows[0]["INV_UAMT"]) + "|" + Convert.ToString(dt_Return.Rows[0]["NON_DISC_AMT"]) + "|" + Convert.ToString(dt_Return.Rows[0]["NON_DISC_AMT"]); } } else { sReturn = "||"; } } else { sReturn = "||"; } return sReturn; }
private DataTable DataLoad(string BD, string ED, string V_VANDOR, string V_TAX_TYPE) { #region 傳入參數 ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(BD, "date", false)); ParameterList.Add(GetValueSetParameter(ED, "date", false)); ParameterList.Add(GetValueSetParameter(V_VANDOR, "string", false)); ParameterList.Add(GetValueSetParameter(V_TAX_TYPE, "string", false)); #endregion #region 取得資料 DataTable dt_Return = new DataTable(); BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); dt_Return = bco.QueryDiscountInvoice(ParameterList); return dt_Return; #endregion }
private void SaveData() { try { #region 傳入參數 ParameterList.Clear(); //0.D_DISC_DATE ParameterList.Add(GetValueSetParameter(this.SLP_SLPDate1.Text.Trim(), "date", false)); //1.V_TAX_TYPE ParameterList.Add(GetValueSetParameter(Session["V_TAX_TYPE"].ToString(), "string", false)); //2.V_VENDOR ParameterList.Add(GetValueSetParameter(this.hidVANDOR.Value, "string", false)); //3.N_DISC_UAMT ParameterList.Add(GetValueSetParameter(this.SLP_SLPNumber1.Text.Trim(), "Decimal", false)); //4.N_DISC_TAX ParameterList.Add(GetValueSetParameter(this.SLP_SLPNumber2.Text.Trim(), "Decimal", false)); //5.D_KEYIN_DATE ParameterList.Add(GetValueSetParameter(this.SLP_SLPDate2.Text.Trim(), "date", false)); //6.D_UPDATEDATE ParameterList.Add(System.DateTime.Now); //7.V_UPDATEUID ParameterList.Add(Session["UID"].ToString()); //8.D_CREATEDATE ParameterList.Add(System.DateTime.Now); //9.V_CREATEUID ParameterList.Add(Session["UID"].ToString()); //10.V_TRANS_TAX if (chkTRANS_TAX.Checked == true) ParameterList.Add("1"); else ParameterList.Add("0"); string SessionIDName = "VAM072_gv_ItemInfo" + PageTimeStamp.Value; DataTable dtA = (DataTable)Session[SessionIDName]; for (int i = 0; i < dtA.Rows.Count; i++) { dtA.Rows[i]["AMT"] = Convert.ToDecimal(((TextBox)this.GridView1.Rows[i].FindControl("txtAMT")).Text.Trim()); } SessionIDName = "VAM072_gvA" + PageTimeStamp.Value; DataTable dtB = (DataTable)Session[SessionIDName]; for (int i = 0; i < dtB.Rows.Count; i++) { dtB.Rows[i]["DISC_AMT"] = Convert.ToDecimal(((Label)this.GridView2.Rows[i].FindControl("Label5")).Text.Trim()); } #endregion #region 新增資料 string V_DISC_NO = ""; BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); bco.CreateDiscountInvoice(ParameterList, dtA, dtB, null, out V_DISC_NO); this.btnSave.Enabled = false; this.TextBox5.Text = V_DISC_NO; ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('新增成功');location.replace('VAM071.aspx?Code=VAM07&DISC_NO=" + V_DISC_NO + "');", Session["UID"].ToString().Trim()), true); this.UpdatePanel1.Update(); #endregion } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
private void databind(string V_DISC_NO, string V_SESSIONNAME) { BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); #region 取得發票主檔資料 DataTable dtMain = (DataTable)Session[V_SESSIONNAME]; DataRow drA = dtMain.Select("DISC_NO='" + V_DISC_NO + "'")[0]; //取得原始折讓資料(for delete) ArrayList ParameterDel = new ArrayList(); if (drA != null) { this.hidID.Value = drA["ID"].ToString(); this.TextBox2.Text = drA["VENDOR"].ToString() + "/" + drA["VENDOR_NAME"].ToString(); this.TextBox2.CssClass = "readtxtbox"; this.SLP_VendorBase1.Text = drA["VENDOR"].ToString(); this.TextBox2.ReadOnly = true; //this.SLP_VendorBase1.ReadOnly = true; if (drA["TAX_TYPE"].ToString() == "0") { this.TextBox1.Text = "應稅"; } else if (drA["TAX_TYPE"].ToString() == "1") { this.TextBox1.Text = "免稅"; } else if (drA["TAX_TYPE"].ToString() == "2") { this.TextBox1.Text = "零稅"; } hidTaxType.Value = drA["TAX_TYPE"].ToString(); this.TextBox1.ReadOnly = true; if (drA["TRANS_TAX"].ToString() == "0") { chkTRANS_TAX.Checked = false; } else if (drA["TRANS_TAX"].ToString() == "1") { chkTRANS_TAX.Checked = true; } //稅率 if (drA["TAX_TYPE"].ToString() == "0") { decimal iTaxRate; bco.QueryTaxRate(out iTaxRate); this.hidTaxRate.Value = iTaxRate.ToString(); } else { this.hidTaxRate.Value = "0"; } Session["V_TAX_TYPE"] = drA["TAX_TYPE"].ToString(); this.TextBox5.Text = V_DISC_NO; //this.TextBox2.CssClass = "readtxtbox"; this.TextBox1.CssClass = "readtxtbox"; this.TextBox5.CssClass = "readtxtbox"; ((TextBox)this.SLP_SLPDate1.FindControl("TextBoxCode")).Text = drA["DISC_DATE"].ToString(); ((TextBox)this.SLP_SLPDate2.FindControl("TextBoxCode")).Text = drA["KEYIN_DATE"].ToString(); ((TextBox)this.SLP_SLPNumber1.FindControl("TextBoxCode")).Text = drA["DISC_UAMT"].ToString(); ((TextBox)this.SLP_SLPNumber4.FindControl("TextBoxCode")).Text = drA["DISC_UAMT"].ToString(); ((TextBox)this.SLP_SLPNumber2.FindControl("TextBoxCode")).Text = drA["DISC_TAX"].ToString(); ((TextBox)this.SLP_SLPNumber3.FindControl("TextBoxCode")).Text = drA["DISC_AMT"].ToString(); ParameterDel.Add(GetValueSetParameter(V_DISC_NO, "string", false)); ParameterDel.Add(GetValueSetParameter(drA["UPDATEDATE"].ToString(), "datetime", false)); ParameterDel.Add(GetValueSetParameter(drA["UPDATEUID"].ToString(), "string", false)); ParameterDel.Add(GetValueSetParameter(drA["CREATEUID"].ToString(), "string", false)); ParameterDel.Add(GetValueSetParameter(drA["CREATEDATE"].ToString(), "datetime", false)); string seName = "VAM073_Par" + PageTimeStamp.Value; Session[seName] = ParameterDel; } #endregion #region 取得資料 DataTable dtA = new DataTable(); DataTable dtB = new DataTable(); dtA = bco.QueryDiscountDetl(V_DISC_NO); dtB = bco.QueryDiscountInv(V_DISC_NO); string SessionIDNameA = "VAM073_gvA_ItemInfo" + PageTimeStamp.Value; string SessionIDNameB = "VAM073_gvB_ItemInfo" + PageTimeStamp.Value; this.GridView1.Visible = true; //Session["SessionID"] = SessionIDNameA; Session[SessionIDNameA] = dtA; this.GridView1.DataSource = dtA; this.GridView1.DataBind(); this.GridView2.Visible = true; //Session["SessionID"] = SessionIDNameB; Session[SessionIDNameB] = dtB; ((TextBox)this.SLP_SLPNumber1.FindControl("TextBoxCode")).Text = "0"; ((TextBox)this.SLP_SLPNumber2.FindControl("TextBoxCode")).Text = "0"; ((TextBox)this.SLP_SLPNumber3.FindControl("TextBoxCode")).Text = "0"; this.GridView2.DataSource = dtB; this.GridView2.DataBind(); if (dtA.Rows.Count == 0 && dtB.Rows.Count == 0) { ErrorMsgLabel.Text = "此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕繼續查詢"; this.btnSave.Enabled = false; } else { this.btnSave.Enabled = true; } #endregion }
protected void btnDel_Click(object sender, EventArgs e) { try { string SessionIDName = "VAM071_gv_ItemInfo" + PageTimeStamp.Value; DataTable dtA = new DataTable(); dtA = (DataTable)Session[SessionIDName]; LinkButton btn = sender as LinkButton; GridViewRow gr = (btn.BindingContainer as GridViewRow); int i = gr.RowIndex; DataRow drA = dtA.Select("DISC_NO='" + dtA.Rows[i]["DISC_NO"].ToString() + "'")[0]; ArrayList ParameterDel = new ArrayList(); ParameterDel.Add(GetValueSetParameter(drA["DISC_NO"].ToString(), "string", false)); ParameterDel.Add(GetValueSetParameter(drA["UPDATEDATE"].ToString(), "datetime", false)); ParameterDel.Add(GetValueSetParameter(drA["UPDATEUID"].ToString(), "string", false)); ParameterDel.Add(GetValueSetParameter(drA["CREATEUID"].ToString(), "string", false)); ParameterDel.Add(GetValueSetParameter(drA["CREATEDATE"].ToString(), "datetime", false)); ParameterDel.Add(Session["UID"].ToString()); ParameterDel.Add(System.DateTime.Now); BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); bco.DeleteDiscountInvoice(ParameterDel, null); drA.Delete(); dtA.AcceptChanges(); Session[SessionIDName] = dtA; this.GridView1.DataSource = dtA; this.GridView1.DataBind(); ArrayList NOList = new ArrayList(); for (int j = 0; j < dtA.Rows.Count; j++) { string[] strNO = new string[2]; strNO[0] = dtA.Rows[j]["DISC_NO"].ToString(); strNO[1] = SessionIDName; NOList.Add(strNO); } Session["VAM071Query" + SessionIDName] = NOList; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", "alert('刪除成功');", true); } catch (Exception ex) { if (ex.Message.IndexOf("位置0") == -1) ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者異動,請重新查詢再進行編輯。"; else ErrorMsgLabel.Text = ex.Message; } //finally { } }
}//ButtonNew_Click protected void ButtonQuery_Click(object sender, EventArgs e) { #region try { #region 檢查條件 this.ErrorMsgLabel.Text = ""; string s_CheckPage = CheckPage(sender); if (s_CheckPage != string.Empty) { this.ErrorMsgLabel.Text = s_CheckPage; return; } if (this.SLP_SLPDateRange1.StartDate.ToString() != "" || this.SLP_SLPDateRange1.EndDate.ToString() != "") { ScriptManager.RegisterStartupScript(Page, this.GetType(), "VAM071", "alert('您輸入單據日期條件將忽略不列入查詢');", true); } #endregion #region 傳入參數 string Number1_OP, Number2_OP, Number3_OP; if (this.SLP_SLPNumber1.Operator == "0") Number1_OP = "<"; else if (this.SLP_SLPNumber1.Operator == "1") Number1_OP = "="; else Number1_OP = ">"; if (this.SLP_SLPNumber2.Operator == "0") Number2_OP = "<"; else if (this.SLP_SLPNumber2.Operator == "1") Number2_OP = "="; else Number2_OP = ">"; if (this.SLP_SLPNumber3.Operator == "0") Number3_OP = "<"; else if (this.SLP_SLPNumber3.Operator == "1") Number3_OP = "="; else Number3_OP = ">"; ParameterList.Clear(); ParameterList.Add(GetValueSetParameter("", "int", false)); ParameterList.Add(GetValueSetParameter(this.SLP_VendorDisc1.Text.Trim(), "string", false)); ParameterList.Add(GetValueSetParameter(this.SLP_SLPDateRange2.StartDate.ToString(), "string", false)); ParameterList.Add(GetValueSetParameter(this.SLP_SLPDateRange2.EndDate.ToString(), "string", false)); ParameterList.Add(GetValueSetParameter(this.SLP_EnumBase1.Text.Trim(), "string", false)); ParameterList.Add(GetValueSetParameter(this.SLP_VendorBase1.Text.Trim(), "string", false)); ParameterList.Add(Number1_OP); ParameterList.Add(GetValueSetParameter(this.SLP_SLPNumber1.Text.Trim(), "Decimal", false)); ParameterList.Add(Number2_OP); ParameterList.Add(GetValueSetParameter(this.SLP_SLPNumber2.Text.Trim(), "Decimal", false)); ParameterList.Add(Number3_OP); ParameterList.Add(GetValueSetParameter(this.SLP_SLPNumber3.Text.Trim(), "Decimal", false)); ParameterList.Add(GetValueSetParameter(this.SLP_SLPDateRange3.StartDate.ToString(), "string", false)); ParameterList.Add(GetValueSetParameter(this.SLP_SLPDateRange3.EndDate.ToString(), "string", false)); ParameterList.Add(GetValueSetParameter(this.TextBoxRowCountLimit.Text.Trim(), "int", false)); ParameterList.Add(GetValueSetParameter(this.ddlTRANS_TAX.Text, "string", false)); #endregion #region 取得資料 DataTable dt_Return = new DataTable(); BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); dt_Return = bco.QueryByFind(ParameterList); #endregion #region 資料與GridView繫結 //抓取本頁初次登記的時間 if (dt_Return.Rows.Count == 0) { this.GridView1.Visible = false; ErrorMsgLabel.Text = "查無資料!"; } else { string SessionIDName = "VAM071_gv_ItemInfo" + PageTimeStamp.Value; this.GridView1.Visible = true; Session["SessionID"] = SessionIDName; Session[SessionIDName] = dt_Return; this.GridView1.DataSource = dt_Return; if (this.TextBoxPagesize.Text == "") this.GridView1.PageSize = 10; else this.GridView1.PageSize = Convert.ToInt32(this.TextBoxPagesize.Text); this.GridView1.PageIndex = 0; this.GridView1.DataBind(); ArrayList NOList = new ArrayList(); for (int i = 0; i < dt_Return.Rows.Count; i++) { string[] strNO = new string[2]; strNO[0] = dt_Return.Rows[i]["DISC_NO"].ToString(); strNO[1] = SessionIDName; NOList.Add(strNO); } Session["VAM071Query" + SessionIDName] = NOList; } #endregion } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }//ButtonQuery_Click
private void LoadData(string sDISC_NO) { #region 傳入參數 ParameterList.Clear(); ParameterList.Add(GetValueSetParameter("", "int", false)); ParameterList.Add(GetValueSetParameter(sDISC_NO, "string", false)); ParameterList.Add(GetValueSetParameter("", "string", false)); ParameterList.Add(GetValueSetParameter("", "string", false)); ParameterList.Add(GetValueSetParameter("", "string", false)); ParameterList.Add(GetValueSetParameter("", "string", false)); ParameterList.Add("<"); ParameterList.Add(GetValueSetParameter("", "Decimal", false)); ParameterList.Add("<"); ParameterList.Add(GetValueSetParameter("", "Decimal", false)); ParameterList.Add("<"); ParameterList.Add(GetValueSetParameter("", "Decimal", false)); ParameterList.Add(GetValueSetParameter("", "string", false)); ParameterList.Add(GetValueSetParameter("", "string", false)); ParameterList.Add(GetValueSetParameter("1", "int", false)); ParameterList.Add(""); #endregion #region 取得資料 DataTable dt_Return = new DataTable(); BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); dt_Return = bco.QueryByFind(ParameterList); #endregion #region 資料與GridView繫結 //抓取本頁初次登記的時間 if (dt_Return.Rows.Count == 0) { this.GridView1.Visible = false; ErrorMsgLabel.Text = "查無資料!"; } else { string SessionIDName = "VAM071_gv_ItemInfo" + PageTimeStamp.Value; this.GridView1.Visible = true; Session["SessionID"] = SessionIDName; Session[SessionIDName] = dt_Return; this.GridView1.DataSource = dt_Return; if (this.TextBoxPagesize.Text == "") this.GridView1.PageSize = 10; else this.GridView1.PageSize = Convert.ToInt32(this.TextBoxPagesize.Text); this.GridView1.PageIndex = 0; this.GridView1.DataBind(); ArrayList NOList = new ArrayList(); for (int i = 0; i < dt_Return.Rows.Count; i++) { string[] strNO = new string[2]; strNO[0] = dt_Return.Rows[i]["DISC_NO"].ToString(); strNO[1] = SessionIDName; NOList.Add(strNO); } Session["VAM071Query" + SessionIDName] = NOList; } #endregion }
protected void btnDel_Click(object sender, EventArgs e) { try { DataTable dtA = (DataTable)Session[this.hidSessionName.Value]; DataRow drA = dtA.Select("DISC_NO='" + this.TextBox5.Text + "'")[0]; ArrayList ParameterDel = new ArrayList(); ParameterDel.Add(GetValueSetParameter(drA["DISC_NO"].ToString(), "string", false)); ParameterDel.Add(GetValueSetParameter(drA["UPDATEDATE"].ToString(), "datetime", false)); ParameterDel.Add(GetValueSetParameter(drA["UPDATEUID"].ToString(), "string", false)); ParameterDel.Add(GetValueSetParameter(drA["CREATEUID"].ToString(), "string", false)); ParameterDel.Add(GetValueSetParameter(drA["CREATEDATE"].ToString(), "datetime", false)); ParameterDel.Add(Session["UID"].ToString()); ParameterDel.Add(System.DateTime.Now); BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB); bco.DeleteDiscountInvoice(ParameterDel, null); //drA.Delete(); //dtA.AcceptChanges(); //Session[SessionIDName] = dtA; //this.GridView1.DataSource = dtA; //this.GridView1.DataBind(); //ArrayList NOList = new ArrayList(); //for (int j = 0; j < dtA.Rows.Count; j++) //{ // string[] strNO = new string[2]; // strNO[0] = dtA.Rows[j]["DISC_NO"].ToString(); // strNO[1] = SessionIDName; // NOList.Add(strNO); //} //Session["VAM071Query" + SessionIDName] = NOList; //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", "alert('刪除成功');", true); ErrorMsgLabel.Text = "刪除成功"; this.btnDel.Enabled = false; } catch (Exception ex) { if (ex.Message.IndexOf("位置0") == -1) ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者異動,請重新查詢再進行編輯。"; else ErrorMsgLabel.Text = ex.Message; } //finally { } }