private void materialButton1_Click_1(object sender, EventArgs e)
        {
            var savecreditnote = new Models.creditnote()
            {
                amount           = betterTextBox_total.decVal,
                bill_id          = invoicenumber_text.intVal,
                date             = Dashboard.Instance.nepaliCalender1.DATESTAMP,
                checkreturnbills = false,
                updated_at       = DateTime.Now,
                created_at       = DateTime.Now,
            };

            db.creditnotes.Add(savecreditnote);
            var bill     = db.bills.Find(invoicenumber_text.intVal);
            var customer = db.customers.Find(bill.customer_id);

            if (customer != null)
            {
                customer.due            -= betterTextBox_total.decVal;
                db.Entry(customer).State = System.Data.Entity.EntityState.Modified;
            }
            bill.checkreturnbills = false;
            db.Entry(bill).State  = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            foreach (var item in betterListView_salesreturn.Items.Cast <SalesReturns.Viewer>().ToList())
            {
                item.save(savecreditnote.id);
            }
            SalesReturns.Printcreditnote print = new Printcreditnote();
            print.print(savecreditnote);
            betterListView_salesreturn.Items.Clear();
            invoicenumber_text.Clear();
            betterTextBox_discount.Clear();
            betterTextBox_total.Clear();
        }
Exemplo n.º 2
0
 private void label2_Click(object sender, EventArgs e)
 {
     if (amount_txt.Text.Trim() == "")
     {
         notificationMAnager1.show("please enter the amount", 1000);
         return;
     }
     try
     {
         supplierpaid paidvendor = new supplierpaid()
         {
             paiddate    = nepaliCalender1.engdate,
             amount      = Convert.ToDecimal(amount_txt.Text),
             supplier_id = this.id
         };
         db.supplierpaids.Add(paidvendor);
         db.SaveChanges();
         notificationMAnager1.show("data are successfully saved", 1000);
     }
     catch (Exception ex)
     {
         notificationMAnager1.show("some error please try again", 1000);
         return;
     }
     this.Dispose();
 }
 private void label2_Click(object sender, EventArgs e)
 {
     try
     {
         employee emp = db.employees.Where(o => o.id == id).First();
         {
             emp.name            = EmpName.Text;
             emp.adress          = EmpAdr.Text;
             emp.phone           = EmpPhn.Text;
             emp.salary          = Convert.ToDecimal(EmpSalary.Text);
             emp.email           = EmpEmail.Text;
             emp.photo           = EmpImage.ImageLoc;
             emp.startdate       = nepaliCalender2EmpsrtDate.engdate;
             db.Entry(emp).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             notificationMAnager1.show("data are successully edited....", 2000);
             this.Close();
         }
     }
     catch (Exception ex)
     {
         notificationMAnager1.show("some error data are not edited please try again", 2000);
         return;
     }
 }
        private void label2_Click(object sender, EventArgs e)
        {
            if (expname_txt.Text.Trim() == "")
            {
                notificationMAnager1.show("please fill the expenses category name", 2000);
                return;
            }
            try
            {
                expencecategory expense = db.expencecategories.Where(o => o.id == id).First();
                expense.name = expname_txt.Text;

                db.Entry(expense).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                if (edit != null)
                {
                    edit(this, new Custom.DataSaveargs
                    {
                        data = expense
                    });
                }
                notificationMAnager1.show("data are successfully saved", 2000);
                this.Dispose();
            }
            catch (Exception ex)
            {
                notificationMAnager1.show(" please try again", 2000);
            }
        }
Exemplo n.º 5
0
 private void vendors_nsme_Click(object sender, EventArgs e)
 {
     using (var db = new HamroSuperMarketEntities())
     {
         if (textBox_name.Text.Trim() == "")
         {
             notificationMAnager1.show("Please Enter Category Name", 1000);
             return;
         }
         try
         {
             category category = new category
             {
                 name       = textBox_name.Text,
                 created_at = DateTime.Now,
                 updated_at = DateTime.Now
             };
             db.categories.Add(category);
             db.SaveChanges();
             listBox1.Items.Add(category);
             textBox_name.Clear();
         }
         catch (Exception ex)
         {
             notificationMAnager1.show(" your category is not save please try again", 1000);
         }
     }
 }
 private void label2_Click(object sender, EventArgs e)
 {
     if (expname.Text.Trim() == "" || expamount.Text.Trim() == "" || expdescription.Text.Trim() == "")
     {
         notificationMAnager1.show("please fill the data", 2000);
         return;
     }
     try
     {
         expence exp = db.expences.Where(o => o.id == id).First();
         exp.name            = expname.Text;
         exp.amount          = Convert.ToDecimal(expamount.Text);
         exp.descriptions    = expdescription.Text;
         exp.dates           = nepaliCalender1.engdate;
         exp.day             = nepaliCalender1.DATESTAMP;
         exp.created_at      = DateTime.Now;
         exp.updated_at      = DateTime.Now;
         db.Entry(exp).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         notificationMAnager1.show("data are successfully edited", 2000);
         this.Dispose();
     }
     catch (Exception ex)
     {
         notificationMAnager1.show("some error please try again", 2000);
     }
 }
        private void label2_Click(object sender, EventArgs e)
        {
            try
            {
                expencecategory exp = new expencecategory();
                exp.name       = itemname.Text;
                exp.created_at = DateTime.Now;
                exp.updated_at = DateTime.Now;
                db.expencecategories.Add(exp);

                db.SaveChanges();
                if (add != null)
                {
                    add(this, new Custom.DataSaveargs
                    {
                        data = exp
                    });
                }
                notificationMAnager1.show("data has been successfully seved", 2000);
                itemname.Clear();
                this.Dispose();
            }
            catch (Exception ex)
            {
            }
        }
        private void save_btn_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1_name.Text.Trim() == "")
                {
                    notificationMAnager1.show("please enter category", 1000);
                    return;
                }
                var editcate = db.categories.Where(o => o.id == id).First();
                editcate.name            = textBox1_name.Text;
                editcate.updated_at      = DateTime.Now;
                editcate.created_at      = DateTime.Now;
                db.Entry(editcate).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                notificationMAnager1.show("successfully modify your category", 1000);
                this.Close();
                if (edit != null)
                {
                    edit(this, new DataSaveargs()
                    {
                        data = editcate
                    });
                }
            }catch (Exception ex)
            {
                notificationMAnager1.show("your category is not modify please try agarin", 1000);
            }
        }
Exemplo n.º 9
0
 private void materialButton1_Click(object sender, EventArgs e)
 {
     using (HamroSuperMarketEntities db = new HamroSuperMarketEntities())
     {
         advance advance = db.advances.Where(o => o.id == this.id).First();
         db.Entry(advance).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
 private void label2_Click(object sender, EventArgs e)
 {
     if (customername.Text.Trim() == "")
     {
         notificationMAnager1.show("Please enter and customer name ", 1000);
         return;
     }
     if (customeradress.Text.Trim() == "")
     {
         notificationMAnager1.show("Please enter and customer address ", 1000);
         return;
     }
     if (customerphoneno.Text.Trim() == "")
     {
         notificationMAnager1.show("Please enter and customer address ", 1000);
         return;
     }
     try
     {
         using (var db = new HamroSuperMarketEntities())
         {
             customer i = new customer()
             {
                 name       = customername.Text,
                 adress     = customeradress.Text,
                 phone      = customerphoneno.Text,
                 email      = customeremail.Text,
                 due        = Convert.ToDecimal(due_txt.Text),
                 created_at = DateTime.Now,
                 updated_at = DateTime.Now
             };
             db.customers.Add(i);
             db.SaveChanges();
             if (onDataSaved != null)
             {
                 onDataSaved(this, new DataSaveargs()
                 {
                     data = i
                 });
             }
             notificationMAnager1.show("Customer added", 1000);
             this.Close();
             this.Dispose();
         }
     }
     catch (Exception ex)
     {
         notificationMAnager1.show("Data Cannot be Saved Pleasetry again", 1000);
         Console.WriteLine(ex.Message);
     }
 }
        private void label2_Click(object sender, EventArgs e)
        {
            if (venname_txt.Text.Trim() == "")
            {
                notificationMAnager1.show("please fill the name", 1000);
                return;
            }
            if (venaddr_txt.Text.Trim() == "")
            {
                notificationMAnager1.show("please fill the address", 1000);
                return;
            }
            if (venphn_txt.Text == "")
            {
                notificationMAnager1.show("please fill the phone", 1000);
                return;
            }
            try
            {
                vendor ven = new vendor
                {
                    name       = venname_txt.Text,
                    adress     = venaddr_txt.Text,
                    panno      = pannum_txt.Text,
                    email      = vanemail_txt.Text,
                    phoneno    = venphn_txt.Text,
                    vatno      = vatnum_txt.Text,
                    advance    = Convert.ToDecimal(vanadvnc_txt.Text),
                    due        = Convert.ToDecimal(vendue_txt.Text),
                    created_at = DateTime.Now,
                    updated_at = DateTime.Now
                };
                db.vendors.Add(ven);
                db.SaveChanges();

                if (onDataSaved != null)
                {
                    onDataSaved(this, new DataSaveargs()
                    {
                        data = ven
                    });
                }
                notificationMAnager1.show("data are successfully saved", 1000);
                this.Close();
            }catch (Exception ex)
            {
                notificationMAnager1.show("data are is not save please try again", 1000);
                this.Close();
            }
        }
 private void materialButton1_delete_Click(object sender, EventArgs e)
 {
     try
     {
         expencecategory exp = db.expencecategories.Where(o => o.id == this.id).First();
         db.Entry(exp).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
         notificationMAnager1.show("the data are successfully deleted", 2000);
         this.Parent.Controls.Remove(this);
     }
     catch (Exception ex)
     {
         notificationMAnager1.show("it has many sub type of expences first delete all sub type of expences", 4000);
         return;
     }
 }
        private void label2_Click(object sender, EventArgs e)
        {
            expence exp = new expence();

            exp.expencecategory_id = category_id;
            exp.name         = expname.Text;
            exp.amount       = Convert.ToDecimal(expamount.Text);
            exp.descriptions = expdescription.Text;
            exp.dates        = nepaliCalender1.engdate;
            exp.day          = nepaliCalender1.DATESTAMP;
            exp.updated_at   = DateTime.Now;
            exp.created_at   = DateTime.Now;
            db.expences.Add(exp);
            db.SaveChanges();
            this.Close();
        }
 private void label2_Click(object sender, EventArgs e)
 {
     if (venname_txt.Text.Trim() == "")
     {
         notificationMAnager1.show("please fill the name", 1000);
         return;
     }
     if (venaddr_txt.Text.Trim() == "")
     {
         notificationMAnager1.show("please fill the address", 1000);
         return;
     }
     if (venphn_txt.Text == "")
     {
         notificationMAnager1.show("please fill the phone", 1000);
         return;
     }
     try
     {
         vendor vendor = db.vendors.Where(o => o.id == id).First();
         vendor.name            = venname_txt.Text;
         vendor.adress          = venaddr_txt.Text;
         vendor.panno           = pannum_txt.Text;
         vendor.email           = vanemail_txt.Text;
         vendor.vatno           = vatnum_txt.Text;
         vendor.phoneno         = venphn_txt.Text;
         vendor.due             = Convert.ToDecimal(vendue_txt.Text);
         vendor.advance         = Convert.ToDecimal(vanadvnc_txt.Text);
         vendor.created_at      = DateTime.Now;
         vendor.updated_at      = DateTime.Now;
         db.Entry(vendor).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         notificationMAnager1.show("successfully data has been saved", 10000);
         if (onDataEdited != null)
         {
             onDataEdited(this, new DataSaveargs()
             {
                 data = vendor
             });
         }
     }
     catch (Exception)
     {
         notificationMAnager1.show("please try again", 1000);
     }
     this.Close();
 }
Exemplo n.º 15
0
        private void delete_btn_Click(object sender, EventArgs e)
        {
            try
            {
                expence exp = db.expences.Where(o => o.id == this.id).First();
                db.Entry(exp).State = System.Data.Entity.EntityState.Deleted;
                db.SaveChanges();
                this.Parent.Controls.Remove(this);

                notificationMAnager1.show("data are successfully deleted", 2000);
            }
            catch (Exception ex)
            {
                notificationMAnager1.show("it has some problem please try again", 2000);
                return;
            }
        }
        private void label2_Click(object sender, EventArgs e)
        {
            if (nepaliCalender1From.engdate > nepaliCalender2To.engdate)
            {
                var notification = new RetailControls.NotificationMAnager();
                notification.show("beging date can not be bigger then finising date", 2000);
                return;
            }
            if (Amountofsalary.Text.Trim() == "")
            {
                var notification = new RetailControls.NotificationMAnager();
                notification.show("please enter the amout", 2000);
                return;
            }
            if (!(Convert.ToDecimal(Amountofsalary.Text) > 0))
            {
                var notification = new RetailControls.NotificationMAnager();
                notification.show("enter the salary'amount in positive value", 2000);
                return;
            }
            try
            {
                salary sal = new salary();
                sal.employee_id = this.id;
                sal.form        = nepaliCalender1From.engdate;
                sal.toto        = nepaliCalender2To.engdate;
                sal.amount      = Convert.ToDecimal(Amountofsalary.Text);
                sal.dates       = Dashboard.Instance.nepaliCalender1.engdate;
                sal.day         = nepaliCalender1From.DATESTAMP;
                sal.today       = nepaliCalender2To.DATESTAMP;
                db.salaries.Add(sal);
                db.SaveChanges();
                var notification = new RetailControls.NotificationMAnager();
                notification.show("Salary Added for " + this.name, 2000);
                this.Dispose();
            }

            catch (Exception ex)
            {
                var notification = new RetailControls.NotificationMAnager();
                notification.show("please enter the correct value" + this.name, 2000);
            }
        }
 private void label2_Click(object sender, EventArgs e)
 {
     if (cusname.Text.Trim() == "")
     {
         notificationMAnager1.show("plese Enter customer name", 1000);
         return;
     }
     if (cusadr.Text.Trim() == "")
     {
         notificationMAnager1.show("plese Enter customer address", 1000);
         return;
     }
     if (cusphn.Text.Trim() == "")
     {
         notificationMAnager1.show("plese Enter customer phone", 1000);
         return;
     }
     try
     {
         customer c = db.customers.Where(o => o.id == id).First();
         c.name            = customername.Text;
         c.adress          = customeradress.Text;
         c.email           = customeremail.Text;
         c.phone           = customerphoneno.Text;
         c.due             = Convert.ToDecimal(cusdue_txt.Text);
         c.created_at      = DateTime.Now;
         c.updated_at      = DateTime.Now;
         db.Entry(c).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         if (onDataEdited != null)
         {
             onDataEdited(this, new DataSaveargs()
             {
                 data = c
             });
         }
     }
     catch (Exception)
     {
         notificationMAnager1.show("data are not saved ", 1000);
     }
     this.Close();
 }
Exemplo n.º 18
0
 private void DelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView1.SelectedItems.Count > 0)
         {
             if (MessageBox.Show("Do You want To Delete this Customer", "Customers", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 var sel = listView1.SelectedItems[0] as VenViwer;
                 using (var db = new HamroSuperMarketEntities())
                 {
                     var cus = db.vendors.Find(sel.id);
                     db.Entry(cus).State = System.Data.Entity.EntityState.Deleted;
                     db.SaveChanges();
                 }
                 sel.Remove();
             }
         }
     }catch (Exception ex)
     {
         notificationMAnager1.show("you can not delete this party records", 2000);
     }
 }
 private void delToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (betterListView1.SelectedItems.Count > 0)
     {
         if (MessageBox.Show("Do you Delete this item?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             try
             {
                 using (var db = new HamroSuperMarketEntities())
                 {
                     var sel = betterListView1.SelectedItems[0] as ItemViwer;
                     var itm = db.items.Find(sel.id);
                     db.Entry(itm).State = System.Data.Entity.EntityState.Deleted;
                     db.SaveChanges();
                     sel.Remove();
                 }
             }
             catch (Exception ex)
             {
                 notificationMAnager1.show("this item you can not delete", 2000);
             }
         }
     }
 }
Exemplo n.º 20
0
        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;
        }
Exemplo n.º 21
0
        private void vendors_nsme_Click(object sender, EventArgs e)
        {
            if (itemname.Text.Trim() == "")
            {
                notificationMAnager1.show("please enter the item name", 1000);
                itemname.Focus();
                return;
            }
            if (pricce_fltb.value == 0)
            {
                notificationMAnager1.show("please enter the item price", 1000);
                pricce_fltb.Focus();
                return;
            }
            if (textBox_barcode.Text.Trim() == "")
            {
                notificationMAnager1.show("Point Barcode Reader properly to the product or, if product has no Barcode then, type 'Na' in barcode field", 2000);
                textBox_barcode.Focus();
                return;
            }
            if (comboBox_category.SelectedIndex < 0)
            {
                notificationMAnager1.show("Please Select a Category", 1000);
                return;
            }
            if (floattb_cost.value > pricce_fltb.value)
            {
                if (Comformation.ShowModal("Please Confirm Your Selling Rate", ", Your selling price is less then cost price please check and confirm", true) == DialogResult.OK)
                {
                    ;
                }
            }
            if (floattb_wholesaleprice.value > pricce_fltb.value)
            {
                if (Comformation.ShowModal("Please Confirm Your wholesale Rate", ", are you  sure your selling price is less then wholesale ?", true) == DialogResult.OK)
                {
                    ;
                }
            }
            if (floattb_wholesaleprice.value == 0)
            {
                floattb_wholesaleprice.value = pricce_fltb.value;
            }
            else
            {
                floattb_wholesaleprice.value = floattb_wholesaleprice.value;
            }
            try
            {
                item i = new item();
                i.name           = itemname.Text;
                i.stock          = qty_fltb.value;
                i.rate           = pricce_fltb.value;
                i.buyrate        = floattb_cost.value;
                i.barcode        = textBox_barcode.Text;
                i.wholesaleprice = floattb_wholesaleprice.value;
                i.category_id    = (comboBox_category.SelectedItem as category).id;
                i.created_at     = DateTime.Now;
                i.updated_at     = DateTime.Now;
                db.items.Add(i);
                db.SaveChanges();

                if (onDataSaved != null)
                {
                    onDataSaved(this, new DataSaveargs()
                    {
                        data = i
                    });
                }
                notificationMAnager1.show("Successfully Data are Saved......", 10000);
                this.Close();
            }
            catch (Exception ex)
            {
                notificationMAnager1.show("data is not save Please Try Again" + ex.Message, 10000);
            }
        }
Exemplo n.º 22
0
        private void materialButton2_Click(object sender, EventArgs e)
        {
            if (betterlistview1.Items.Count == 0)
            {
                notificationMAnager1.show("please select your items and enter quantity.", 2000);
                return;
            }
            if (due_txt.decVal > 0 && comboBox_customer.SelectedItem == null)
            {
                notificationMAnager1.show("Please select customer for dueable amount.", 3000);
                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);
            }


            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 label2_Click(object sender, EventArgs e)
        {
            if (itemeditname_txt.Text.Trim() == "")
            {
                notificationMAnager1.show("please enter your item name", 1000);
                return;
            }
            if (comboBox_category.SelectedItem == null)
            {
                notificationMAnager1.show("please select catrgory", 1000);
                return;
            }


            if (bettertextbox_barcode.Text.Trim() == "")
            {
                notificationMAnager1.show("Point Barcode Reader properly to the product or, if product has no Barcode then, type 'Na' in barcode field", 2000);
                bettertextbox_barcode.Focus();
                return;
            }
            if (floattb_cost.value > price_fltb.value)
            {
                if (Comformation.ShowModal("Please Confirm Your Selling Rate", ", Your selling price is less then cost price please check and confirm", true) == DialogResult.OK)
                {
                    ;
                }
            }
            if (floattb_wholesaleprice.value > price_fltb.value)
            {
                if (Comformation.ShowModal("Please Confirm Your wholesale Rate", ", are you  sure your selling price is less then wholesale ?", true) == DialogResult.OK)
                {
                    ;
                }
            }
            if (floattb_wholesaleprice.value == 0)
            {
                floattb_wholesaleprice.value = price_fltb.value;
            }
            else
            {
                floattb_wholesaleprice.value = floattb_wholesaleprice.value;
            }
            try
            {
                item a = db.items.Where(o => o.id == id).First();
                a.name            = itemeditname_txt.Text;
                a.category_id     = (comboBox_category.SelectedItem as Models.category).id;
                a.stock           = stock_fltb.value;
                a.rate            = price_fltb.value;
                a.buyrate         = floattb_cost.value;
                a.barcode         = bettertextbox_barcode.Text;
                a.wholesaleprice  = floattb_wholesaleprice.value;
                a.created_at      = DateTime.Now;
                a.updated_at      = DateTime.Now;
                db.Entry(a).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                if (onDataEdited != null)
                {
                    onDataEdited(this, new DataSaveargs()
                    {
                        data = a
                    });
                }
            }
            catch (Exception)
            {
                notificationMAnager1.show("data can not be saved", 1000);
            }
            this.Close();
        }
        private void label2_Click_1(object sender, EventArgs e)
        {
            string image     = "";
            string documents = "";

            if (!(System.IO.Directory.Exists("employee/images/")))
            {
                System.IO.Directory.CreateDirectory("employee/images/");
            }
            if (EmpDocument.documents.Count > 0)
            {
                foreach (var document in EmpDocument.documents)
                {
                    string timestamp       = DateTime.Now.ToFileTime().ToString();
                    var    destinationpath = "employee/images/" + timestamp + System.IO.Path.GetExtension(document.Value);
                    System.IO.File.Copy(document.Value, destinationpath);
                    documents += destinationpath + "|";
                }
            }

            if (EmpImage.ImageLoc != null)
            {
                if (EmpImage.ImageLoc != "")
                {
                    string timestamp       = DateTime.Now.ToFileTime().ToString();
                    var    destinationpath = "employee/images/" + timestamp + System.IO.Path.GetExtension(EmpImage.ImageLoc);
                    System.IO.File.Copy(EmpImage.ImageLoc, destinationpath);
                    image = destinationpath;
                }
            }
            if (EmpName.Text.Trim() == "" || EmpAdr.Text.Trim() == "" || EmpPhn.Text.Trim() == "" || EmpEmail.Text.Trim() == "" || EmpSalary.Text.Trim() == "")
            {
                notificationMAnager1.show("please enter correct data", 1000);
                return;
            }
            if (!(Convert.ToDecimal(EmpSalary.Text) > 0))
            {
                notificationMAnager1.show("please enter the right value", 1000);
                return;
            }
            employee emp = new employee()
            {
                photo = image,
                docs  = documents
            };

            emp.name      = EmpName.Text;
            emp.adress    = EmpAdr.Text;
            emp.phone     = EmpPhn.Text;
            emp.email     = EmpEmail.Text;
            emp.startdate = Convert.ToDateTime(Dashboard.Instance.nepaliCalender1.engdate);
            emp.salary    = Convert.ToDecimal(EmpSalary.Text);
            db.employees.Add(emp);
            db.SaveChanges();
            if (ondatasaved != null)
            {
                ondatasaved(this, new Advanceformclosedargs()
                {
                    data = emp
                });
            }
            notificationMAnager1.show("data are successfully added in list", 10000);
            this.Dispose();
        }