コード例 #1
0
ファイル: VAM072.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    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;

    }
コード例 #2
0
ファイル: VAM072.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    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;
        }

    }