private void ThemDV()
        {
            try
            {
                DichVuPhong dv = new DichVuPhong
                {
                    MaDV  = txtMaDV.Text,
                    TenDV = txtTenDV.Text,
                    GiaDV = double.Parse(txtGiaDV.Text),
                    DVT   = txtDonVi.Text,
                };

                if (db.DichVuPhongs.Where(p => p.MaDV == txtMaDV.Text).SingleOrDefault() != null)
                {
                    MessageBox.Show("Mã dịch vụ bạn nhập đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (txtMaDV.Text.Trim() == "" || txtTenDV.Text.Trim() == "" || txtGiaDV.Text.Trim() == "" || txtDonVi.Text.Trim() == "")
                {
                    MessageBox.Show("Một số thông tin còn thiếu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    db.DichVuPhongs.InsertOnSubmit(dv);
                    db.SubmitChanges();
                    MessageBox.Show("Thêm dịch vụ mới thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadDSDV();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi dữ liệu! Vui lòng nhập lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void dgvDichVu_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow dgvr = new DataGridViewRow();

            dgvr = dgvDichVu.Rows[e.RowIndex];
            if (e.RowIndex >= 0)
            {
                txtMaDV.Text  = dgvr.Cells[0].Value.ToString();
                txtTenDV.Text = dgvr.Cells[1].Value.ToString();
                txtGiaDV.Text = dgvr.Cells[2].Value.ToString();
                txtDonVi.Text = dgvr.Cells[3].Value.ToString();
            }
            dv = db.DichVuPhongs.SingleOrDefault(p => p.MaDV == txtMaDV.Text.Trim());
        }
 private void SuaDV()
 {
     try
     {
         DichVuPhong dv = db.DichVuPhongs.SingleOrDefault(p => p.MaDV == txtMaDV.Text);
         {
             dv.TenDV = txtTenDV.Text;
             dv.GiaDV = double.Parse(txtGiaDV.Text);
             dv.DVT   = txtDonVi.Text;
         }
         db.SubmitChanges();
         MessageBox.Show("Sửa thông tin thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         LoadDSDV();
     }
     catch (Exception)
     {
         MessageBox.Show("Lỗi dữ liệu! Vui lòng nhập lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         DichVuPhong  dv = db.DichVuPhongs.SingleOrDefault(p => p.MaDV == txtMaDV.Text);
         DialogResult dr = MessageBox.Show("Bạn có thực sự muốn xóa dịch vụ " + txtTenDV.Text + "?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (dr == DialogResult.OK)
         {
             db.DichVuPhongs.DeleteOnSubmit(dv);
             db.SubmitChanges();
             MessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             LoadDSDV();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Dịch vụ này đang được sủ dụng! Không thể xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }