Ejemplo n.º 1
0
 private void btnEditDV_Click(object sender, EventArgs e)
 {
     if (checkEmpty() && IsNumber())
     {
         if (edit)
         {
             var _dv = db.tbl_dichvus.SingleOrDefault(x => x.MaDichVu.Equals(txtMaDV.Text));
             _dv.TenDichVu = txtTenDV.Text;
             _dv.MieuTa    = txtMT.Text;
             _dv.GiaDichVu = float.Parse(txtGiaDV.Text);
             db.SubmitChanges();
             Load_DV();
         }
         else
         {
             if (checkExistTenDV() && checkMaDV())
             {
                 tbl_dichvu dv = new tbl_dichvu();
                 dv.MaDichVu  = txtMaDV.Text;
                 dv.TenDichVu = txtTenDV.Text;
                 dv.MieuTa    = txtMT.Text;
                 dv.GiaDichVu = float.Parse(txtGiaDV.Text);
                 db.tbl_dichvus.InsertOnSubmit(dv);
                 db.SubmitChanges();
                 Load_DV();
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void btnDelNV_Click(object sender, EventArgs e)
        {
            var _nhanvien = db.tbl_nhanviens.SingleOrDefault(x => x.SoDienThoai.Equals(txtPhone.Text));

            if (MessageBox.Show("Bạn có muốn xóa nhân viên này không", "Hệ Thống", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                db.tbl_nhanviens.DeleteOnSubmit(_nhanvien);
                db.SubmitChanges();
            }
            Load_NhanVien();
        }
Ejemplo n.º 3
0
        private void btnDelKH_Click(object sender, EventArgs e)
        {
            var _khachhang = db.tbl_khachhangs.SingleOrDefault(x => x.SoDienThoai.Equals(txtSDT.Text));

            if (MessageBox.Show("Bạn có muốn xóa khách hàng này không", "Hệ Thống", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (checkHD())
                {
                    db.tbl_khachhangs.DeleteOnSubmit(_khachhang);
                    db.SubmitChanges();
                }
            }
            Load_KH();
        }
Ejemplo n.º 4
0
 private void btnSaveLP_Click(object sender, EventArgs e)
 {
     if (checkEmptyLP() && checkExistMaLP() && checkSoNguoi())
     {
         if (edit)
         {
             var _lp = db.tbl_loaiphongs.SingleOrDefault(x => x.MaLoaiPhong.Equals(txtMaLP.Text));
             _lp.TenLoaiPhong = txtTenLoaiPhong.Text;
             _lp.SoNguoi      = Convert.ToInt32(txtSoNguoi.Text);
             db.SubmitChanges();
             Load_LP();
         }
         else
         {
             tbl_loaiphong lp = new tbl_loaiphong();
             lp.MaLoaiPhong  = txtMaLP.Text;
             lp.TenLoaiPhong = txtTenLoaiPhong.Text;
             lp.SoNguoi      = Convert.ToInt32(txtSoNguoi.Text);
             db.tbl_loaiphongs.InsertOnSubmit(lp);
             db.SubmitChanges();
             Load_LP();
             Load_cboLP();
         }
     }
 }
Ejemplo n.º 5
0
        private void btnDat_Click(object sender, EventArgs e)
        {
            if (checkEmpty() && checkExistMaPD() && IsNumber() && checkNgayDen() && checkDate())
            {
                tbl_datphong dp = new tbl_datphong();
                dp.Mapd = txtMaPD.Text;

                dp.SoDienThoai = (cboKh.SelectedItem as tbl_khachhang).SoDienThoai;
                dp.SoTienDat   = Convert.ToDouble(txtTienCoc.Text);
                dp.NgayDen     = txtNgayDen.Value;
                dp.NgayDi      = txtNgayDi.Value;
                dp.TinhTrang   = false;
                dp.TinhTrangHD = true;
                if (dgvPhongTrong.CurrentRow != null)
                {
                    var r = dgvPhongTrong.CurrentRow;
                    dp.MaPhong = r.Cells["MaPhong"].Value.ToString();
                }

                db.tbl_datphongs.InsertOnSubmit(dp);
                db.SubmitChanges();



                for (int i = 0; i < dgvPhongTrong.SelectedRows.Count; i++)
                {
                    DataGridViewRow row = dgvPhongTrong.SelectedRows[i];
                    tbl_chitietdat  ctd = new tbl_chitietdat();
                    ctd.Mapd    = txtMaPD.Text;
                    ctd.MaPhong = row.Cells["MaPhong"].Value.ToString();
                    db.tbl_chitietdats.InsertOnSubmit(ctd);
                    ;
                }
                db.SubmitChanges();
                txtMaPD.Text = txtTienCoc.Text = "";
                MessageBox.Show("Thành công", "Đặt phòng", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Load_DSDat();
            }
        }
Ejemplo n.º 6
0
        private bool checknumber()
        {
            int sln = 0;
            var r   = dgvDichVuPhong.CurrentRow;

            madv = r.Cells["MaDV"].Value.ToString();
            for (int i = 0; i < dgvDichVuDaChon.Rows.Count; i++)
            {
                if (madv == dgvDichVuDaChon.Rows[i].Cells["MaDichVu"].Value.ToString())
                {
                    sln = (Convert.ToInt32(dgvDichVuDaChon.Rows[i].Cells["SoLuong"].Value.ToString())) + (Convert.ToInt32(txtSoLuong.Text));

                    var _dv = db.tbl_dichvuphongs.FirstOrDefault(x => x.MaDichVu.Equals(madv) && x.Mapd.Equals((cboPhieuDat.SelectedItem as tbl_datphong).Mapd));

                    _dv.SoLuong = sln;

                    db.SubmitChanges();
                    Load_DVDaChon();
                    return(false);
                }
            }
            return(true);
        }