Exemplo n.º 1
0
        private void btn_run_all_Click(object sender, EventArgs e)
        {
            DataTable dt = bbtc.getAllData();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    decimal  subtotal   = Convert.ToDecimal(dt.Rows[i]["sub_total"]);
                    decimal  discount   = Convert.ToDecimal(dt.Rows[i]["discount"]);
                    string   sales_type = dt.Rows[i]["sales_type"].ToString();
                    string   bill_no    = dt.Rows[i]["bill_no"].ToString();
                    DateTime date2      = Convert.ToDateTime(dt.Rows[i]["date2"].ToString());
                    if (subtotal > 0)
                    {
                        decimal        service_charge = 0;
                        decimal        tax_amount     = 0;
                        decimal        subtotal_with_services;
                        decimal        subtotalwithDiscount = subtotal - discount;
                        TaxCalculation tax = new TaxCalculation();
                        if (sales_type != "TA" && service_chargeStatus == "True")
                        {
                            service_charge = tax.service_calculation(subtotalwithDiscount);
                        }
                        subtotal_with_services = (subtotalwithDiscount + service_charge);
                        tax_amount             = tax.tax_calculation(Convert.ToDecimal(subtotal_with_services));
                        int upadateTax    = bbtc.updatetaxandservice(bill_no, date2, tax_amount, service_charge, subtotal_with_services);
                        int upadateTaxmat = bbtc.updatetaxandserviceMet(bill_no, date2, tax_amount, subtotal_with_services);
                    }
                }
            }
        }
 public void DataGridViewLoad()
 {
     if (dtLoad.Rows.Count > 0)
     {
         dataGridView1.Rows.Clear();
         for (int inc = 0; inc < dtLoad.Rows.Count; inc++)
         {
             int ww = dataGridView1.Rows.Add();
             dataGridView1.Rows[inc].Cells["calitem"].Value     = dtLoad.Rows[inc]["item_name"].ToString();
             dataGridView1.Rows[inc].Cells["calquantity"].Value = dtLoad.Rows[inc]["quantity"].ToString();
             string cost = dtLoad.Rows[inc]["total"].ToString();
             dataGridView1.Rows[inc].Cells["caltotal"].Value = cost;
             string sub_total = dtLoad.Rows[inc]["sub_total"].ToString();
             dataGridView1.Rows[inc].Cells["cal_sub_total"].Value = sub_total;
             string discount = dtLoad.Rows[inc]["discount"].ToString();
             dataGridView1.Rows[inc].Cells["calcashier_name"].Value = discount;
             float  discount_amount    = dcr.calculateDiscount(Convert.ToDecimal(cost), Convert.ToDecimal(discount));
             string amountWithDiscount = (Convert.ToSingle(cost) - discount_amount).ToString();
             dataGridView1.Rows[inc].Cells["cal_sub_total_with_dis"].Value = amountWithDiscount;
             decimal service_change = tc.service_calculation(Convert.ToDecimal(amountWithDiscount));
             dataGridView1.Rows[inc].Cells["cal_service_charge"].Value = service_change.ToString();
             decimal taxable_amount = (Convert.ToDecimal(amountWithDiscount) + Convert.ToDecimal(service_change));
             dataGridView1.Rows[inc].Cells["cal_taxable_amount"].Value = taxable_amount.ToString();
             decimal tax_amount = tc.tax_calculation(taxable_amount);
             dataGridView1.Rows[inc].Cells["cal_tax"].Value         = tax_amount.ToString();
             dataGridView1.Rows[inc].Cells["cal_grand_total"].Value = taxable_amount + tax_amount;
             dataGridView1.Rows[inc].Cells["calbill_no"].Value      = dtLoad.Rows[inc]["bill_no"].ToString();
             dataGridView1.Rows[inc].Cells["caldate"].Value         = Convert.ToDateTime(dtLoad.Rows[inc]["date_of_sale"].ToString());
             dataGridView1.Rows[inc].Cells["cal_sales_type"].Value  = dtLoad.Rows[inc]["sales_type"].ToString();
             dataGridView1.Rows[inc].Cells["caldate"].Value         = dtLoad.Rows[inc]["date_of_sale"].ToString();
         }
         grandtotalCalculation();
         backPanel.Show();
         searchPanel.Hide();
         bill_no = null;
     }
 }