private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = XtraMessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                listProductCategory.RemoveAt(listProductCategory.Position);
                db.SubmitChanges();
            }
        }
Exemplo n.º 2
0
 private void btnInsert_Click(object sender, EventArgs e)
 {
     try
     {
         tblHangHoaBindingSource.EndEdit();
         db.SubmitChanges();
         DevExpress.XtraEditors.XtraMessageBox.Show("Lưu vào CSDL thành công", "Thông báo");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 3
0
 private void btnInsert_Click(object sender, EventArgs e)
 {
     try
     {
         listCustomerAccount.EndCurrentEdit();
         db.SubmitChanges();
         DevExpress.XtraEditors.XtraMessageBox.Show("Lưu vào CSDL thành công", "Thông báo");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtName.Text.Length == 0 || txtPrice.Text.Length == 0 || cboProductCategory.SelectedIndex == -1)
     {
         XtraMessageBox.Show("Thông tin không được trống!", "Thông báo");
         return;
     }
     try
     {
         ListProduct.EndCurrentEdit();
         db.SubmitChanges();
         XtraMessageBox.Show("Lưu vào CSDL thành công", "Thông báo");
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message);
     }
     // Interface
     NormalInterface = true;
 }
Exemplo n.º 5
0
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            if (lblNameOfCustomer.Text.Trim().Length == 0)
            {
                XtraMessageBox.Show("Hãy nhập thông tin khách hàng", "Thông báo");
                return;
            }
            try
            {
                tbl_Bill bill = new tbl_Bill();
                bill.AdminID    = SessionInfo.adminID;
                bill.BilledDate = int.Parse(DateTime.Today.ToString("yyyyMMdd"));
                bill.CustomerID = int.Parse(txtCustomerID.Text);
                tbl_Bill.InsertOnSubmit(bill);

                db.SubmitChanges();

                tbl_Bill curBill = db.tbl_Bills.OrderByDescending(res => res.BillID).FirstOrDefault();

                foreach (DataRow dr in dt.Rows)
                {
                    tbl_DetailedBill detailedBill = new tbl_DetailedBill();
                    detailedBill.IDBill    = curBill.BillID;
                    detailedBill.IDProduct = int.Parse(dr[0].ToString());
                    detailedBill.UnitPrice = int.Parse(dr[3].ToString());
                    detailedBill.Amount    = int.Parse(dr[2].ToString());
                    db.tbl_DetailedBills.InsertOnSubmit(detailedBill);
                }

                db.SubmitChanges();
                XtraMessageBox.Show("Thanh toán thành công", "Thông báo");
                btnCheckOut.Enabled = false;
                btnCreate.Enabled   = false;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Thanh toán thất bại" + ex.Message, "Thông báo");
            }
        }
Exemplo n.º 6
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         tbl_Admin admin = db.tbl_Admins.SingleOrDefault(res => res.AdminID == SessionInfo.adminID);
         admin.NameOfAdmin     = txtName.Text;
         admin.PasswordOfAdmin = (txtPassword.Text.Length == 0 ? admin.PasswordOfAdmin : txtPassword.Text);
         admin.TelOfAdmin      = txtPhone.Text;
         db.SubmitChanges();
         XtraMessageBox.Show("Lưu vào CSDL thành công", "Thông báo");
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("Lỗi khi lưu vào CSDL", "Thông báo");
     }
 }
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     listProductCategory.RemoveAt(listProductCategory.Position);
     db.SubmitChanges();
 }