public void Delete(DTO_TypePro ex) { sqlCm.Connection = cnnTypePro.OpenConnection(); sqlCm.CommandText = "XoaLoaiSP"; sqlCm.CommandType = CommandType.StoredProcedure; sqlCm.Parameters.AddWithValue("@maLoai", ex.MaLoai); sqlCm.ExecuteReader(); sqlCm.Parameters.Clear(); }
public void Update(DTO_TypePro ex) { sqlCm.Connection = cnnTypePro.OpenConnection(); sqlCm.CommandText = "SuaLoaiSP"; sqlCm.CommandType = CommandType.StoredProcedure; sqlCm.Parameters.AddWithValue("@ghiChu", ex.GhiChu); sqlCm.Parameters.AddWithValue("@maLSP", ex.MaLoai); sqlCm.Parameters.AddWithValue("@tenLSP", ex.TenLoai); sqlCm.ExecuteNonQuery(); sqlCm.Parameters.Clear(); }
private void btnDeleteProduct_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { BLL_TypePro bltp = new BLL_TypePro(); DTO_TypePro ex = new DTO_TypePro(); txtLoaiSP.Text = dataGridView1.CurrentRow.Cells["Mã loại sản phẩm"].Value.ToString(); ex.MaLoai = Convert.ToInt32(txtLoaiSP.Text); MessageBox.Show("Bạn có chắn chắn muốn xóa loại sản phẩm này!", "", MessageBoxButtons.YesNo); bltp.Delete(ex); ShowDgv(); } else { MessageBox.Show("Hãy chọn sản phẩm để xóa"); } }
private void btnUpdateProduct_Click(object sender, EventArgs e) { BLL_TypePro bltp = new BLL_TypePro(); DTO_TypePro ex = new DTO_TypePro(); if (Edit == false) { try { ex.TenLoai = txtTenLoaiSP.Text; ex.GhiChu = txtNote.Text; bltp.InsertType(ex); MessageBox.Show("Thêm thành công!"); ShowDgv(); } catch { MessageBox.Show("Thêm thất bại!"); } } if (Edit == true) { try { ex.MaLoai = Convert.ToInt32(txtLoaiSP.Text); ex.TenLoai = txtTenLoaiSP.Text; ex.GhiChu = txtNote.Text; bltp.Update(ex); MessageBox.Show("Sửa thành công!"); ShowDgv(); } catch { MessageBox.Show("Sửa thất bại"); } } }
public void Delete(DTO_TypePro ex) { dttp.Delete(ex); }
public void Update(DTO_TypePro ex) { dttp.Update(ex); }
public void InsertType(DTO_TypePro ex) { dttp.Insert(ex); }