Esempio n. 1
0
        private void btThem_Click(object sender, EventArgs e)
        {
            try
            {
                string MaLSP, TenLSP;
                MaLSP  = txtMaloai.Text;
                TenLSP = txtTenloai.Text;

                LoaiSanPhamDTO lsp = new LoaiSanPhamDTO(MaLSP, TenLSP);

                if (string.IsNullOrEmpty(txtMaloai.Text))
                {
                    MessageBox.Show("Vui lòng nhập mã loại sản phẩm cần thêm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                int numOfRows = loaisanphamBUS.Add(lsp);
                if (numOfRows > 0)
                {
                    MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Reset();
                }
                GridLoaiSP.DataSource = loaisanphamBUS.GetLoaiSP();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Thêm thất bại, mã loại bị trùng\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Reset();
            }
        }