Esempio n. 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Bạn có muốn sửa dòng này? ",
                                              "Xác nhận sửa", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                ctphong = new BusinessLayer.CTPhongBsn(int.Parse(cbbTenphong.ValueMember));
                ctphong.Update();
                dt = ctphong.Select();
                dgrvCTPhong.DataSource = dt.DefaultView;
            }
            if (dr == DialogResult.No)
            {
                dt = ctphong.Select();
                dgrvCTPhong.DataSource = dt.DefaultView;
            }
        }
 public void Insert(BusinessLayer.CTPhongBsn ctphong)
 {
     try
     {
         cmd             = new SqlCommand();
         cmd.CommandType = CommandType.Text;
         cmd.CommandText = "INSERT INTO " + this.tableName
                           + "(" + this.fieldList + ") VALUES ('"
                           + ctphong.MaP + "')";
         dt = new DataTable();
         dt = GetData(cmd);
         MessageBox.Show("Thêm mới thành công", "Thông báo");
     }
     catch (Exception)
     {
         MessageBox.Show("Thêm mới thất bại", "Thông báo");
     }
     finally
     {
         closeConnect();
     }
 }
 public void Update(BusinessLayer.CTPhongBsn ctphong)
 {
     try
     {
         cmd             = new SqlCommand();
         cmd.CommandType = CommandType.Text;
         cmd.CommandText = "UPDATE " + this.tableName
                           + " SET MaPhong = '" + ctphong.MaP + "' WHERE MaCT= '"
                           + ctphong.MaCT + "' ";
         dt = new DataTable();
         dt = GetData(cmd);
         MessageBox.Show("Sửa thành công");
     }
     catch (Exception)
     {
         MessageBox.Show("Sửa thất bại");
     }
     finally
     {
         closeConnect();
     }
 }
 private void btnEdit_Click(object sender, EventArgs e)
 {
     DialogResult dr = MessageBox.Show("Bạn có muốn sửa dòng này? ",
        "Xác nhận sửa", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     if (dr == DialogResult.Yes)
     {
         ctphong = new BusinessLayer.CTPhongBsn(int.Parse(cbbTenphong.ValueMember));
         ctphong.Update();
         dt = ctphong.Select();
         dgrvCTPhong.DataSource = dt.DefaultView;
     }
     if (dr == DialogResult.No)
     {
         dt = ctphong.Select();
         dgrvCTPhong.DataSource = dt.DefaultView;
     }
 }