Beispiel #1
0
        private void ShowDgv()
        {
            BLL_TypePro bltp = new BLL_TypePro();
            DataTable   dt   = bltp.ShowTypePro();

            dataGridView1.DataSource = dt;
        }
Beispiel #2
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            txtSearch.ForeColor = Color.Black;
            BLL_TypePro bl = new BLL_TypePro();

            if (txtSearch.Text != "")
            {
                DataTable dt = bl.SearchProd(txtSearch.Text);
                dataGridView1.DataSource = dt;
            }
            else
            {
                DataTable dt = bl.ShowTypePro();
                dataGridView1.DataSource = dt;
            }
        }
Beispiel #3
0
 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");
     }
 }
Beispiel #4
0
        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");
                }
            }
        }