コード例 #1
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (GridViewBillList.Rows.Count > 0)
     {
         TotalCost = 0;
         GridViewBillList.DataSource = (List <Product>)ViewState["ProductsList"];
         GridViewBillList.DataBind();
     }
 }
コード例 #2
0
 private void BindBill(long Bill_ID)
 {
     GridViewBillList.DataSource = Bill_Content.Get_Bill_Items(Bill_ID);
     GridViewBillList.DataBind();
 }
コード例 #3
0
        protected void BtnBill_Click(object sender, EventArgs e)
        {
            Bill bill = new Bill();

            bill.Discount            = txtDiscount.Text == "" ? 0 : Convert.ToDouble(txtDiscount.Text);
            bill.Bill_Date           = new DateTime(Convert.ToInt32(txtYear.Text), Convert.ToInt32(txtMonth.Text), Convert.ToInt32(txtDay.Text), DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            bill.AdditionalCost      = txtAdditionalCost.Text == "" ? 0 : Convert.ToDouble(txtAdditionalCost.Text);
            bill.AdditionalCostNotes = txtAdditionalcostNotes.Text;
            Client client = new Client();

            client.C_name  = txtClient_Name.Text;
            client.Address = txtAddress.Text;

            long         Bill_ID = bill.Generate_Bill(client, Convert.ToDouble(lblTotalCost.Text) + bill.AdditionalCost, Convert.ToDouble(txtPaid_Amount.Text), TxtDesc.Text);
            Bill_Content content = new Bill_Content();
            string       m       = "";
            bool         AllDone = true;

            foreach (Product p in (List <Product>)ViewState["ProductsList"])
            {
                if (!content.Add_Bill_Contents(out m, Bill_ID, p))
                {
                    Response.Write("<script>alert('" + m + "')</script>");
                    AllDone = false;
                    break;
                }
            }
            if (AllDone)
            {
                lblBillDate.Text   = bill.Bill_Date.ToShortDateString();
                lblBill_ID.Text    = Bill_ID.ToString();
                lblClientName.Text = txtClient_Name.Text;
                lblAddress.Text    = txtAddress.Text;
                lblBillCost.Text   = lblTotalCost.Text;
                lblPaid_Value.Text = txtPaid_Amount.Text;
                if (!string.IsNullOrEmpty(txtDiscount.Text))
                {
                    lblDiscountValue.Text = txtDiscount.Text;
                }
                else
                {
                    lblDiscount.Visible      = false;
                    lblDiscountValue.Visible = false;
                }
                if (txtAdditionalCost.Text == "")
                {
                    lblAddtionalCost.Visible       = false;
                    lblAdditionalCostValue.Visible = false;
                    lblAdditionalcostNotes.Visible = false;
                }
                else
                {
                    lblAdditionalCostValue.Text = txtAdditionalCost.Text;
                    lblAdditionalcostNotes.Text = txtAdditionalcostNotes.Text;
                }
                lblRest.Text                = ((Convert.ToDouble(lblBillCost.Text) + bill.AdditionalCost) - Convert.ToDouble(lblDiscountValue.Text) - Convert.ToDouble(lblPaid_Value.Text)).ToString();
                PanelClientInfo.Visible     = false;
                PanelBill.Visible           = true;
                GridViewBillList.DataSource = (List <Product>)ViewState["ProductsList"];
                GridViewBillList.DataBind();
            }
        }