Esempio n. 1
0
 public Loader(Model.bill bill, int sn)
 {
     for (int i = 1; i <= 10; i++)
     {
         SubItems.Add(new ListViewSubItem());
     }
     SubItems[0].Text = sn.ToString();
     invoice_no       = bill.invoice_number;
     vehicle_number   = (bill.vehicle as Model.vehicle).vehicle_no;
     date             = bill.date;
     totalamount      = bill.total_amount;
     totalweight      = bill.total_Weight;
     expamount        = bill.total_exp;
     id = bill.id;
 }
        private void Save_Click(object sender, EventArgs e)
        {
            var save_bill = new Model.bill()
            {
                vehicle_number = (comboBox_vechiclenumber.SelectedItem as Model.vehicle).id,
                date           = nepaliCalender_DAte.Datestamp,
                invoice_number = betterTextBox_invoicenumber.Text,
                total_amount   = betterTextBox_totalamount.decVal,
                total_Weight   = betterTextBox_totalweight.decVal,
                total_exp      = betterTextBox_totalexpenses.decVal,
                created_at     = DateTime.Now,
                updated_at     = DateTime.Now
            };

            db.bills.Add(save_bill);
            db.SaveChanges();
            foreach (var item in betterListView_billitems.Items.Cast <viewer>().ToList())
            {
                item.save(save_bill.id, nepaliCalender_DAte.Datestamp);
            }
            foreach (ListViewItem item in betterListView_addexp.Items)
            {
                var title  = item.SubItems[1].Text;
                var amount = Convert.ToDecimal(item.SubItems[2].Text);
                var exp    = new Model.delivered_expences()
                {
                    title          = title,
                    amount         = amount,
                    bill_id        = save_bill.id,
                    vehicle_number = (comboBox_vechiclenumber.SelectedItem as Model.vehicle).id,
                    admin_id       = INFO.admin_id,
                    updated_at     = DateTime.Now,
                    created_at     = DateTime.Now
                };
                db.delivered_expences.Add(exp);
                db.SaveChanges();
            }
            betterListView_billitems.Items.Clear();
            betterTextBox_invoicenumber.Clear();
            comboBox_vechiclenumber.SelectedIndex = -1;
            betterTextBox_Exptitle.Clear();
            betterListView_addexp.Items.Clear();
            betterTextBox_Expamount.Clear();
            betterTextBox_totalamount.Clear();
            betterTextBox_totalexpenses.Clear();
            betterTextBox_totalweight.Clear();
            clear();
        }