private void materialButton3_Click(object sender, EventArgs e) { betterlistview1.Items.Clear(); Grosstotal_txt.Clear(); Discount_txt.Clear(); tax_txt.Clear(); nettotal_txt.Clear(); paid_txt.Clear(); due_txt.Clear(); qty_fltb.Clear(); return_fltb.Clear(); comboBox_item.SelectedIndex = -1; comboBox_customer.SelectedIndex = -1; floattb_wholesalerate.Clear(); retailrate_fltb.Clear(); stock_qty.Clear(); }
private void materialButton2_Click(object sender, EventArgs e) { if (billnum_txt.Text.Trim() == "") { notificationMAnager1.show("please fill the bill number", 1000); return; } supply Supply = new supply() { bill_no = billnum_txt.Text, paid = paid, discount = discount, due = due, dates = Dashboard.Instance.nepaliCalender1.engdate, tax = taxs, grosstotal = Grosstotal, total = nettotal, day = Dashboard.Instance.nepaliCalender1.DATESTAMP, created_at = DateTime.Now, updated_at = DateTime.Now }; if (SupplierCheck_btn.Checked) { if (combobox_supplier.SelectedIndex < 0) { MessageBox.Show("Please select A supplier"); return; } var selvendor = (vendor)combobox_supplier.getSelectedItem().data; Supply.vendor_id = selvendor.id; var supplier = db.vendors.First(o => o.id == selvendor.id); if (checkBox_useadvance.Checked) { if (advance_fltb.value >= supplier.advance.Value) { supplier.advance = 0; } else { supplier.advance -= advance_fltb.value; } } if (due > 0) { if (checkBox_useadvance.Checked) { if (advance_fltb.value >= due) { due = 0; } else { due -= advance_fltb.value; } } supplier.due += due; } db.Entry(supplier).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } db.supplies.Add(Supply); db.SaveChanges(); foreach (ListViewItem item in betterlistview1.Items) { var Item_id = Convert.ToInt32(item.SubItems[4].Text); var Rate = Convert.ToDecimal(item.SubItems[1].Text); var Quantity = Convert.ToDecimal(item.SubItems[2].Text); var Amount = Convert.ToDecimal(item.SubItems[3].Text); var Item = db.items.Find(Item_id); Item.stock += Quantity; Item.buyrate = Rate; db.Entry(Item).State = System.Data.Entity.EntityState.Modified; supplyitem supplyitem = new supplyitem() { rate = Rate, item_id = Item_id, quantity = Quantity, amount = Amount, supply_id = Supply.id }; db.supplyitems.Add(supplyitem); db.SaveChanges(); } betterlistview1.Items.Clear(); billnum_txt.Clear(); Grostotal_txt.Clear(); Discount_txt.Clear(); paid_txt.Clear(); tax_txt.Clear(); due_txt.Clear(); SupplierCheck_btn.Checked = false; }
private void materialButton_SavenPrint_Click(object sender, EventArgs e) { if (due_txt.decVal > 0 && comboBox_customer.SelectedItem == null) { notificationMAnager1.show("Please select customer for dueable amount.", 3000); return; } if (betterlistview1.Items.Count == 0) { notificationMAnager1.show("please select your items and enter quantity.", 2000); return; } bill savebill = new bill() { paid = paid_txt.decVal, due = due_txt.decVal, grosstotal = Grosstotal_txt.decVal, discount = Discount_txt.decVal, tax = tax_txt.decVal, dates = Dashboard.Instance.nepaliCalender1.engdate, total = nettotal_txt.decVal, day = Dashboard.Instance.nepaliCalender1.DATESTAMP, returns = return_fltb.decVal, checkreturnbills = true, created_at = DateTime.Now, updated_at = DateTime.Now }; if (checkBox1.Checked == true) { if (comboBox_customer.SelectedItem != null) { var selcustomer = (customer)comboBox_customer.SelectedItem; savebill.customer_id = selcustomer.id; if (Convert.ToDecimal(due_txt.Text) > 0) { var cus = db.customers.Find(selcustomer.id); cus.due += Convert.ToDecimal(due_txt.Text); db.Entry(cus).State = System.Data.Entity.EntityState.Modified; } } else { notificationMAnager1.show("please select old customer or add a new customer ", 2000); return; } } else { if (due_txt.decVal > 0 && comboBox_customer.SelectedItem == null) { notificationMAnager1.show("Please select customer for dueable amount.", 3000); return; } } db.bills.Add(savebill); db.SaveChanges(); foreach (var item in betterlistview1.Items.Cast <Bills_form.Viwer>().ToList()) { item.save(savebill.id); } var printer = new Bills_form.BillPrinter(); printer.print(savebill); betterlistview1.Items.Clear(); Grosstotal_txt.Clear(); Discount_txt.Clear(); tax_txt.Clear(); nettotal_txt.Clear(); paid_txt.Clear(); due_txt.Clear(); qty_fltb.Clear(); return_fltb.Clear(); comboBox_item.SelectedIndex = -1; comboBox_customer.SelectedIndex = -1; comboBox_barcode.SelectedIndex = -1; floattb_wholesalerate.Clear(); retailrate_fltb.Clear(); stock_qty.Clear(); }