Пример #1
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (gvMenu.GetCheckedRows().Count() <= 0)
         {
             XtraMessageBox.Show("Bạn chưa chọn [Món].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (HDID == null)
         {
             objHD         = new HOADON();
             objHD.BanID   = BanID;
             objHD.NgayHD  = DateTime.Now;
             objHD.IsDaLam = false;
             objHD.UserID  = Properties.Settings.Default.MaNV;
             db.HOADONs.InsertOnSubmit(objHD);
             db.SubmitChanges();
         }
         else
         {
             objHD        = db.HOADONs.SingleOrDefault(p => p.ID == HDID);
             objHD.NgayHD = DateTime.Now;
         }
         //
         foreach (var i in gvMenu.GetCheckedRows())
         {
             var objCT = new CHITIETHOADON();
             objCT.HDID    = objHD.ID;
             objCT.DonGia  = (decimal)gvMenu.GetRowCellValue(i, "GiaBan");
             objCT.MenuID  = (int)gvMenu.GetRowCellValue(i, "ID");
             objCT.SoLuong = (int)gvMenu.GetRowCellValue(i, "SoLuong");
             objCT.GhiChu  = gvMenu.GetRowCellValue(i, "GhiChu").ToString();
             db.CHITIETHOADONs.InsertOnSubmit(objCT);
         }
         //
         if (HDID == null)
         {
             var objBan = db.BANs.SingleOrDefault(p => p.ID == BanID);
             objBan.HDID = objHD.ID;
             objBan.MaTT = 2;
         }
         db.SubmitChanges();
         XtraMessageBox.Show("Đã lưu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtKhu.Text == "")
         {
             XtraMessageBox.Show("Bạn chưa nhập [Khu].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (spinSoBan.Value <= 0)
         {
             XtraMessageBox.Show("Bạn chưa nhập [Số bàn].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         objNK.Name   = txtKhu.Text;
         objNK.Number = (int)spinSoBan.Value;
         if (ID == null)
         {
             objNK.MaTT = 1;
             db.BANs.InsertOnSubmit(objNK);
         }
         db.SubmitChanges();
         XtraMessageBox.Show("Đã lưu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #3
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtHoTen.Text == "" || txtSDT.Text == "")
         {
             XtraMessageBox.Show("Bạn chưa nhập [Họ tên hoặc Số điện thoại].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (spinMucLuong.Value <= 0)
         {
             XtraMessageBox.Show("Bạn chưa nhập [Mức lương].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         objNV.DiaChi     = txtDiaChi.Text;
         objNV.NgayVaoLam = dateNgayVaoLam.DateTime;
         objNV.HoTen      = txtHoTen.Text;
         objNV.MucLuong   = spinMucLuong.Value;
         objNV.Age        = (int)spinTuoi.Value;
         objNV.DienThoai  = txtSDT.Text;
         objNV.DonViTinh  = cbmCachTinh.SelectedIndex;
         if (ID == null)
         {
             db.NHANVIENs.InsertOnSubmit(objNV);
         }
         db.SubmitChanges();
         XtraMessageBox.Show("Đã lưu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #4
0
 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         gcData.Update();
         foreach (ListMenuResult item in ltData)
         {
             if (item.ckChon == true & item.SoLuong > 0)
             {
                 var objDetail = new Order_Detail();
                 objDetail.idClient = Properties.Settings.Default.idClient;
                 objDetail.idCus    = Properties.Settings.Default.idCus;
                 objDetail.idMenu   = item.idMenu;
                 objDetail.quantity = item.SoLuong;
                 objDetail.amount   = item.ThanhTien;
                 objDetail.IsOrder  = true;
                 objDetail.comment  = "Order";
                 db.Order_Details.InsertOnSubmit(objDetail);
                 TongTien += item.sale_price * item.SoLuong;
             }
         }
         if (TongTien > 0)
         {
             db.SubmitChanges();
             this.Close();//lỗi gì?
         }
         else
         {
             MessageBox.Show("Please enter", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);//đổi tiêng anh k tự đổi dc à
         }
     }
     catch { }
 }
Пример #5
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtMatKhauMoi.Text == "" || txtNhapLaiMKM.Text == "")
         {
             XtraMessageBox.Show("Bạn chưa nhập [Mật khẩu mới].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (txtMatKhauMoi.Text != txtNhapLaiMKM.Text)
         {
             XtraMessageBox.Show("[Ô nhập lại mật khẩu mới] chưa khớp với [Ô mật khẩu mới].Vui lòng kiểm tra lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         var objNV = db.TaiKhoans.SingleOrDefault(p => p.UserName == Properties.Settings.Default.UserName);
         objNV.Pass = txtMatKhauMoi.Text;
         db.SubmitChanges();
         XtraMessageBox.Show("Đã thay đổi [Mật khẩu] thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #6
0
 private void itemThanhToanLuong_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         if (db.LichSuTraLuongs.Where(p => p.ThangTra.GetValueOrDefault() == int.Parse(itemThang.EditValue.ToString()) && p.NamTra.GetValueOrDefault() == int.Parse(itemNam.EditValue.ToString())).Count() > 0)
         {
             XtraMessageBox.Show("Tháng này đã được trả lương.Vui lòng kiểm tra lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         var objLS = new LichSuTraLuong();
         objLS.GhiChu   = txtGhiChu.Text;
         objLS.NamTra   = int.Parse(itemNam.EditValue.ToString());
         objLS.NgayTra  = DateTime.Now;
         objLS.NVID     = ID;
         objLS.SoTien   = (decimal)(gridColumn1.SummaryItem.SummaryValue == null ? 0 : gridColumn1.SummaryItem.SummaryValue);
         objLS.TamUng   = (decimal)(gridColumn18.SummaryItem.SummaryValue == null ? 0 : gridColumn18.SummaryItem.SummaryValue);
         objLS.ThangTra = int.Parse(itemThang.EditValue.ToString());
         objLS.ThucNhan = objLS.SoTien - objLS.TamUng;
         db.LichSuTraLuongs.InsertOnSubmit(objLS);
         db.SubmitChanges();
         XtraMessageBox.Show("Đã lưu dữ liệu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception ex) { }
 }
Пример #7
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                objCus    = db.Customer_Informations.SingleOrDefault(p => p.username == txtUser.Text.Trim());
                objClient = db.clients.SingleOrDefault(p => p.clientName.Contains(Environment.MachineName));
                if (objClient == null)
                {
                    MessageBox.Show("Vui lòng tạo tên máy trong hệ thống trước khi login.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (objCus != null)
                {
                    db.Refresh(RefreshMode.KeepChanges, objCus);
                    if (objCus.currentMoney.GetValueOrDefault() > 0)
                    {
                        if (db.Login_Customers.Where(p => p.idCus == objCus.idCus).Count() > 0)
                        {
                            MessageBox.Show("Tài khoản của bạn đang được login tại một máy khác.Vui lòng kiểm tra lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        var objLogin_Cus = new Login_Customer();
                        objLogin_Cus.idClient  = objClient.idClient;
                        objLogin_Cus.idCus     = objCus.idCus;
                        objLogin_Cus.startTime = DateTime.Now;
                        db.Login_Customers.InsertOnSubmit(objLogin_Cus);
                        db.SubmitChanges();

                        Properties.Settings.Default.idCus      = objCus.idCus;
                        Properties.Settings.Default.idLoginCus = objLogin_Cus.ID;
                        Properties.Settings.Default.idClient   = objClient.idClient;
                        Properties.Settings.Default.Save();


                        this.Hide();
                        using (var frm = new frmMain())
                        {
                            frm.ShowDialog();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Tài khoản của bạn hiện không đủ để đăng nhập.Vui lòng nạp thêm tiền!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtUser.Text = "";
                        txtPass.Text = "";
                        txtUser.Focus();
                    }
                }
                else
                {
                    txtUser.Text = "";
                    txtPass.Text = "";
                    txtUser.Focus();
                }
            }
            catch (Exception ex) { MessageBox.Show("Lỗi:" + ex.Message, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Пример #8
0
 private void itemXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         if (gvBan.GetFocusedRowCellValue("ID") == null)
         {
             XtraMessageBox.Show("Bạn chưa chọn dòng cần xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (DialogResult.Yes == XtraMessageBox.Show("Bạn có muốn xóa không?.", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
         {
             var objNK = db.BANs.SingleOrDefault(p => p.ID == (int)gvBan.GetFocusedRowCellValue("ID"));
             db.BANs.DeleteOnSubmit(objNK);
             db.SubmitChanges();
             gvBan.DeleteSelectedRows();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #9
0
 private void btnLogout_Click(object sender, EventArgs e)
 {
     try
     {
         if (objLoginCus != null)
         {
             db.Login_Customers.DeleteOnSubmit(objLoginCus);
             db.SubmitChanges();
         }
         frmLogin frm = new frmLogin();
         frm.ShowDialog();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #10
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName.Text == "")
         {
             XtraMessageBox.Show("Bạn chưa nhập [Tên món].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (lookLoai.EditValue == null)
         {
             XtraMessageBox.Show("Bạn chưa chọn [Loại].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (spinSoTien.Value <= 0)
         {
             XtraMessageBox.Show("Bạn chưa nhập [Giá bán].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         objMN.Name   = txtName.Text;
         objMN.GiaBan = spinSoTien.Value;
         objMN.LoaiID = (int?)lookLoai.EditValue;
         MemoryStream st = new MemoryStream();
         picAnh.Image.Save(st, ImageFormat.Png);
         objMN.HinhAnh = st.ToArray();
         if (ID == null)
         {
             db.MENUs.InsertOnSubmit(objMN);
         }
         else
         {
             objMN_Select.Name    = txtName.Text;
             objMN_Select.GiaBan  = spinSoTien.Value;
             objMN_Select.LoaiID  = (int)lookLoai.EditValue;
             objMN_Select.HinhAnh = picAnh.Image;
         }
         db.SubmitChanges();
         XtraMessageBox.Show("Đã lưu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #11
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtHangNhap.Text == "")
         {
             XtraMessageBox.Show("Bạn chưa nhập [Hàng nhập].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (spinSoTien.Value <= 0)
         {
             XtraMessageBox.Show("Bạn chưa nhập [Số tiền].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         objNK.Name     = txtHangNhap.Text;
         objNK.NgayNhap = dateNgayNhap.DateTime;
         objNK.TienNhap = spinSoTien.Value;
         if (ID == null)
         {
             db.NHAPKHOs.InsertOnSubmit(objNK);
         }
         else
         {
             objNK_Select.Name     = txtHangNhap.Text;
             objNK_Select.NgayNhap = dateNgayNhap.DateTime;
             objNK_Select.TienNhap = spinSoTien.Value;
         }
         db.SubmitChanges();
         XtraMessageBox.Show("Đã lưu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         if (ID == null)
         {
             Reset();
         }
         else
         {
             this.Close();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #12
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (spinSoBan.Value <= 0)
         {
             XtraMessageBox.Show("Bạn chưa nhập [Số lượng].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         objNK.GhiChu  = txtKhu.Text;
         objNK.SoLuong = (int)spinSoBan.Value;
         db.SubmitChanges();
         XtraMessageBox.Show("Đã lưu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #13
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (spinSoTien.Value <= 0)
         {
             XtraMessageBox.Show("Bạn chưa nhập [Số tiền ứng].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         var objTU = new BangLuong();
         objTU.GhiChu    = txtHangNhap.Text;
         objTU.NgayLuong = dateNgayNhap.DateTime;
         objTU.NVID      = ID;
         objTU.SoTien    = spinSoTien.Value;
         db.BangLuongs.InsertOnSubmit(objTU);
         db.SubmitChanges();
         XtraMessageBox.Show("Hoàn thành.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #14
0
 private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     db.SubmitChanges();
     LoadData();
 }