Ejemplo 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)
     {
         loaivattu = new BusinessLayer.LoaiVattuBsn(txtTen.Text);
         loaivattu.Update();
         dt = loaivattu.Select();
         dgrvLoaivattu.DataSource = dt.DefaultView;
     }
     if (dr == DialogResult.No)
     {
         dt = loaivattu.Select();
         dgrvLoaivattu.DataSource = dt.DefaultView;
     }
 }
Ejemplo n.º 2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtTen.Text == "")
     {
         MessageBox.Show("Mời bạn nhập dữ liệu!", "Thông báo");
     }
     else
     {
         loaivattu = new BusinessLayer.LoaiVattuBsn(txtTen.Text);
         loaivattu.Insert();
         dt = loaivattu.Select();
         dgrvLoaivattu.DataSource = dt.DefaultView;
         btnAdd.Enabled           = true;
         btnEdit.Enabled          = true;
         btnDelete.Enabled        = true;
         btnSave.Enabled          = false;
     }
 }
Ejemplo n.º 3
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)
            {
                loaivattu = new BusinessLayer.LoaiVattuBsn(txtTen.Text);
                loaivattu.Update();
                dt = loaivattu.Select();
                dgrvLoaivattu.DataSource = dt.DefaultView;
            }
            if (dr == DialogResult.No)
            {
                dt = loaivattu.Select();
                dgrvLoaivattu.DataSource = dt.DefaultView;
            }
        }
Ejemplo n.º 4
0
 public void Update(BusinessLayer.LoaiVattuBsn loaivattu)
 {
     try
     {
         cmd             = new SqlCommand();
         cmd.CommandType = CommandType.Text;
         cmd.CommandText = "UPDATE " + this.tableName
                           + " SET Ten= '" + loaivattu.TenVT + "' WHERE MaLoai = '"
                           + loaivattu.MaVT + "' ";
         DataTable dt = new DataTable();
         dt = data.GetData(cmd);
         MessageBox.Show("Sửa thành công");
     }
     catch (Exception)
     {
         MessageBox.Show("Sửa thất bại");
     }
     finally
     {
         data.closeConnect();
     }
 }
Ejemplo n.º 5
0
 public void Insert(BusinessLayer.LoaiVattuBsn loaivattu)
 {
     try
     {
         SqlCommand cmd = new SqlCommand();
         cmd.CommandType = CommandType.Text;
         cmd.CommandText = "INSERT INTO " + this.tableName
                           + "(" + this.fieldList + ") values ('"
                           + loaivattu.TenVT + "')";
         dt = new DataTable();
         dt = data.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
     {
         data.closeConnect();
         // conn.Close();
     }
 }
Ejemplo n.º 6
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtTen.Text == "")
     {
         MessageBox.Show("Mời bạn nhập dữ liệu!", "Thông báo");
     }
     else
     {
         loaivattu = new BusinessLayer.LoaiVattuBsn(txtTen.Text);
         loaivattu.Insert();
         dt = loaivattu.Select();
         dgrvLoaivattu.DataSource = dt.DefaultView;
         btnAdd.Enabled = true;
         btnEdit.Enabled = true;
         btnDelete.Enabled = true;
         btnSave.Enabled = false;
     }
 }