partial void DeleteBILL(BILL instance);
 partial void InsertBILL(BILL instance);
 partial void UpdateBILL(BILL instance);
コード例 #4
0
 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);
     }
 }