Ejemplo n.º 1
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            string MaSP;

            MaSP = txtMaSP.Text;
            SanPhamDTO sanpham = new SanPhamDTO(MaSP);

            if (string.IsNullOrEmpty(txtMaSP.Text))
            {
                MessageBox.Show("Vui lòng nhập mã SP cần xoá ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            int numOfRows = sanphamBUS.Delete(sanpham);

            if (numOfRows == 0)
            {
                MessageBox.Show("Không tìm được dữ liệu để xoá ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Reset();
            }
            else
            {
                MessageBox.Show("Xoá thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Reset();
            }
            GridSP.DataSource = sanphamBUS.GetSanPham();
        }
Ejemplo n.º 2
0
 public bool SanPham_Delete(string masp)
 {
     try
     {
         return(SanPham_bus.Delete(masp));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 protected void btnXoaSanPham_Click(object sender, EventArgs e)
 {
     if (IsValid)
     {
         SanPhamDTO Spham = new SanPhamDTO();
         Spham.IdSanPham     = Convert.ToInt32(Request.QueryString["IdSanPham"]);
         Spham.IdHinhSanPham = LuuTamIdHinhSanPham;
         SanPhamBUS sanPhamBus = new SanPhamBUS();
         sanPhamBus._sanPham = Spham;
         sanPhamBus.Delete();
         Response.Redirect("SanPham.aspx");
     }
 }
Ejemplo n.º 4
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (XtraMessageBox.Show("Bạn có muốn xóa sản phẩm này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             bus.Delete(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[1]).ToString());
             XtraMessageBox.Show("Đã xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             HienThi();
             KhoaDieuKhien();
         }
         catch
         {
         }
     }
 }
Ejemplo n.º 5
0
        private void dgvSanPham_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int col = e.ColumnIndex;

            if (dgvSanPham.Columns[col] is DataGridViewButtonColumn && dgvSanPham.Columns[col].Name == "CotXoa")
            {
                int    row          = e.RowIndex;
                string id           = dgvSanPham.Rows[row].Cells["CotCanLay"].Value.ToString();
                int    NumberOfRows = SPBUS.Delete(id);
                if (NumberOfRows > 0)
                {
                    List <SanPham> list = SPBUS.LoadSanPham();
                    dgvSanPham.DataSource = list;
                    MessageBox.Show("Xóa " + NumberOfRows + " sản phẩm thành công");
                }
                else
                {
                    MessageBox.Show("Xóa thất bại");
                }
            }
            else if (dgvSanPham.Columns[col] is DataGridViewButtonColumn && dgvSanPham.Columns[col].Name == "cotSua")
            {
                int     row = e.RowIndex;
                string  id  = dgvSanPham.Rows[row].Cells["CotCanLay"].Value.ToString();
                SanPham sp  = SPBUS.GetById(id);
                //string name, unit, unitprice;
                //id = txtMaSP.Text;
                //name = txtTenSP.Text;
                //unit = txtDvt.Text;
                //unitprice = txtDonGia.Text;
                //SanPham p = new SanPham(id, name, unit, unitprice);
                sp.TenSP     = txtTenSP.Text;
                sp.TenSP     = txtTenSP.Text;
                sp.Donvitinh = txtDvt.Text;
                sp.Dongia    = txtDonGia.Text;

                int number = SPBUS.Update(sp);

                List <SanPham> list = SPBUS.LoadSanPham();
                dgvSanPham.DataSource = list;
            }
        }
Ejemplo n.º 6
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa thông tin này không!", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    int CurrentIndex = dataSanPham.CurrentCell.RowIndex;
                    string MaSP = Convert.ToString(dataSanPham.Rows[CurrentIndex].Cells[0].Value.ToString());
                    SanPhamBUS bus = new SanPhamBUS();
                    bus.Delete(MaSP);
                    MessageBox.Show("Đã xóa thông tin thành công");

                    LoadDataSanPham();
                }
                catch(Exception ex)
                {
                    MessageBox.Show("Thông báo lỗi: " +ex.Message);

                }
            }

        
    }