private void button2_Click(object sender, EventArgs e)
        {
            if (txt_path.Text != "")
            {
                try
                {
                    string           constr = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + txt_path.Text + "; Extended Properties =\"Excel 8.0; HDR = Yes;\";";
                    OleDbConnection  con    = new OleDbConnection(constr);
                    string           str    = "Sheet" + vl_sheet.Value.ToString();
                    OleDbDataAdapter sda    = new OleDbDataAdapter("Select * From [" + str + "$]", con);
                    DataTable        dt     = new DataTable();
                    sda.Fill(dt);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        PRODUCT prdct = new PRODUCT();
                        prdct.ID             = Convert.ToInt32(dt.Rows[i]["ID"]);
                        prdct.NAME           = dt.Rows[i]["NAME"].ToString();
                        prdct.CATEGORY       = dt.Rows[i]["CATEGORY"].ToString();
                        prdct.PRODUCER       = dt.Rows[i]["PRODUCER"].ToString();
                        prdct.PURCHASE_PRICE = Convert.ToInt32(dt.Rows[i]["PURCHASE_PRICE"]);
                        prdct.PRICE          = Convert.ToInt32(dt.Rows[i]["PRICE"]);
                        prdct.INVENTORY      = Convert.ToInt32(dt.Rows[i]["INVENTORY"]);
                        db_form.Add(prdct);
                        this.Close();
                    }
                }

                catch
                {
                    MessageBox.Show("Khong doc duoc file");
                }
            }
        }
        private void btn_delete_Click(object sender, EventArgs e)
        {
            if (!add)
            {
                using (DataStoreManagementDataContext db = new DataStoreManagementDataContext())
                {
                    try
                    {
                        int index = bunifuCustomDataGrid1.CurrentRow.Index;
                        index = int.Parse(bunifuCustomDataGrid1.Rows[index].Cells[0].Value.ToString());

                        PRODUCT prdct = db.PRODUCTs.SingleOrDefault(x => x.ID == index);
                        db.PRODUCTs.DeleteOnSubmit(prdct);
                        db.SubmitChanges();
                        notifyIcon1.Visible         = true;
                        notifyIcon1.Icon            = SystemIcons.Exclamation;
                        notifyIcon1.BalloonTipTitle = "Delete Successful";
                        notifyIcon1.BalloonTipText  = "Your product has been deleted in Database!";
                        notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
                        notifyIcon1.ShowBalloonTip(1000);
                    }
                    catch
                    {
                        notifyIcon1.Visible         = true;
                        notifyIcon1.Icon            = SystemIcons.Exclamation;
                        notifyIcon1.BalloonTipTitle = "Can't Delete new Product to Database";
                        notifyIcon1.BalloonTipText  = "Check your id is Valid!";
                        notifyIcon1.BalloonTipIcon  = ToolTipIcon.Error;
                        notifyIcon1.ShowBalloonTip(1000);
                    }
                }
                Loading();
                bunifuCustomDataGrid1.DataSource = Loaded_Record(page_number, number_record);
            }
        }
        private void btn_update_Click(object sender, EventArgs e)
        {
            if (!add)
            {
                using (DataStoreManagementDataContext db = new DataStoreManagementDataContext())
                {
                    try
                    {
                        PRODUCT prodct = new PRODUCT
                        {
                            ID             = int.Parse(txt_id.Text),
                            NAME           = txt_name.Text,
                            CATEGORY       = txt_category.Text,
                            PRODUCER       = txt_producer.Text,
                            PURCHASE_PRICE = int.Parse(txt_purchase.Text),
                            PRICE          = int.Parse(txt_price.Text),
                            INVENTORY      = int.Parse(txt_inventory.Text),
                        };
                        PRODUCT temp = db.PRODUCTs.SingleOrDefault(x => x.ID == prodct.ID);
                        temp.ID             = int.Parse(txt_id.Text);
                        temp.NAME           = txt_name.Text;
                        temp.CATEGORY       = txt_category.Text;
                        temp.PRODUCER       = txt_producer.Text;
                        temp.PURCHASE_PRICE = int.Parse(txt_purchase.Text);
                        temp.PRICE          = int.Parse(txt_price.Text);
                        temp.INVENTORY      = int.Parse(txt_inventory.Text);

                        db.SubmitChanges();

                        notifyIcon1.Visible         = true;
                        notifyIcon1.Icon            = SystemIcons.Exclamation;
                        notifyIcon1.BalloonTipTitle = "Update Successful!";
                        notifyIcon1.BalloonTipText  = "Your product has been updated in Database!";
                        notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
                        notifyIcon1.ShowBalloonTip(1000);
                    }
                    catch
                    {
                        notifyIcon1.Visible         = true;
                        notifyIcon1.Icon            = SystemIcons.Exclamation;
                        notifyIcon1.BalloonTipTitle = "Can't Delete new Product to Database";
                        notifyIcon1.BalloonTipText  = "Check your id is Valid!";
                        notifyIcon1.BalloonTipIcon  = ToolTipIcon.Error;
                        notifyIcon1.ShowBalloonTip(1000);
                    }
                }
                Loading();
                bunifuCustomDataGrid1.DataSource = Loaded_Record(page_number, number_record);
            }
        }
 private void btn_add_Click(object sender, EventArgs e)
 {
     if (add)
     {
         using (DataStoreManagementDataContext db = new DataStoreManagementDataContext())
         {
             try
             {
                 PRODUCT prodct = new PRODUCT
                 {
                     ID             = int.Parse(txt_id.Text),
                     NAME           = txt_name.Text,
                     CATEGORY       = txt_category.Text,
                     PRODUCER       = txt_producer.Text,
                     PURCHASE_PRICE = int.Parse(txt_purchase.Text),
                     PRICE          = int.Parse(txt_price.Text),
                     INVENTORY      = int.Parse(txt_inventory.Text),
                 };
                 db.PRODUCTs.InsertOnSubmit(prodct);
                 db.SubmitChanges();
                 notifyIcon1.Visible         = true;
                 notifyIcon1.Icon            = SystemIcons.Exclamation;
                 notifyIcon1.BalloonTipTitle = "Add Successfull!";
                 notifyIcon1.BalloonTipText  = "Your product is added in Database!";
                 notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
                 notifyIcon1.ShowBalloonTip(1000);
             }
             catch
             {
                 notifyIcon1.Visible         = true;
                 notifyIcon1.Icon            = SystemIcons.Exclamation;
                 notifyIcon1.BalloonTipTitle = "Can't Add new Product to Database";
                 notifyIcon1.BalloonTipText  = "Check your input is Valid!";
                 notifyIcon1.BalloonTipIcon  = ToolTipIcon.Error;
                 notifyIcon1.ShowBalloonTip(1000);
             }
         }
         Loading();
         bunifuCustomDataGrid1.DataSource = Loaded_Record(page_number, number_record);
     }
 }
 partial void DeletePRODUCT(PRODUCT instance);
 partial void UpdatePRODUCT(PRODUCT instance);
 partial void InsertPRODUCT(PRODUCT instance);
 private void btn_printbill_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_namecustomer.Text != "")
         {
             using (DataStoreManagementDataContext db = new DataStoreManagementDataContext())
             {
                 bool type_pay;
                 if (bunifuDropdown1.selectedIndex != 1)
                 {
                     type_pay = false;
                 }
                 else
                 {
                     type_pay = true;
                 }
                 BILL bil = new BILL
                 {
                     ID_BILL       = int.Parse(txt_bill.Text),
                     ID_PRODUCT    = int.Parse(txt_id.Text),
                     NAME_CUSTOMER = txt_namecustomer.Text,
                     NAME_PRODUCT  = txt_name.Text,
                     PRODUCER      = txt_category.Text,
                     PRICE         = int.Parse(txt_price.Text),
                     AMOUNT        = Convert.ToInt32(numericUpDown1.Value),
                     DATE_TIME     = bunifuDatepicker1.Value,
                     ADVANCE       = int.Parse(txt_price.Text),
                     TYPE_PAY      = bunifuDropdown1.selectedValue,
                     TOTAL         = int.Parse(txt_total.Text),
                     TRANGTHAI     = type_pay,
                 };
                 PRODUCT temp = db.PRODUCTs.SingleOrDefault(x => x.ID == bil.ID_PRODUCT);
                 temp.INVENTORY--;
                 if (temp.INVENTORY < 0)
                 {
                     notifyIcon1.Visible         = true;
                     notifyIcon1.Icon            = SystemIcons.Exclamation;
                     notifyIcon1.BalloonTipTitle = "Don't have any product in Inventory";
                     notifyIcon1.BalloonTipText  = "Please choose another Product, this Product is sold out!";
                     notifyIcon1.BalloonTipIcon  = ToolTipIcon.Error;
                     notifyIcon1.ShowBalloonTip(1000);
                 }
                 else
                 {
                     db.BILLs.InsertOnSubmit(bil);
                     db.SubmitChanges();
                     notifyIcon1.Visible         = true;
                     notifyIcon1.Icon            = SystemIcons.Exclamation;
                     notifyIcon1.BalloonTipTitle = "Add Successfull!";
                     notifyIcon1.BalloonTipText  = "Your Bill is added in Database!";
                     notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
                     notifyIcon1.ShowBalloonTip(1000);
                     bunifuFlatButton2_Click(sender, e);
                 }
             };
         }
     }
     catch
     {
         notifyIcon1.Visible         = true;
         notifyIcon1.Icon            = SystemIcons.Exclamation;
         notifyIcon1.BalloonTipTitle = "Can't Add new Bill to Database";
         notifyIcon1.BalloonTipText  = "Check your input is Valid!";
         notifyIcon1.BalloonTipIcon  = ToolTipIcon.Error;
         notifyIcon1.ShowBalloonTip(1000);
     }
 }