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 bunifuFlatButton2_Click(object sender, EventArgs e) { if (db_excel == null) { Loading(); bunifuCustomDataGrid1.DataSource = Loaded_Record(page_number, number_record); } else { try { int totalrecord; using (DataStoreManagementDataContext db = new DataStoreManagementDataContext()) { totalrecord = db.PRODUCTs.Count(); int temp = db.PRODUCTs.OrderByDescending(x => x.ID).First().ID; if (temp <= totalrecord) { temp = totalrecord; } for (int i = 0; i < db_excel.Count; i++) { db_excel[i].ID = db_excel[i].ID + temp; totalrecord = db.PRODUCTs.Count(); db.PRODUCTs.InsertOnSubmit(db_excel[i]); db.SubmitChanges(); } bunifuCustomDataGrid1.DataSource = Loaded_Record(page_number, number_record); } } 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); } } txt_search.Text = ""; }
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); } }
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); } }