示例#1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            HangHoa hh = new HangHoa();

            try
            {
                hh.MaHang  = tbMHH.Text;
                hh.TenHang = tbTHH.Text;
                hh.DVT     = tbDVT.Text;
                hh.DonGia  = float.Parse(tbGia.Text);
                hh.GhiChu  = tbGC.Text;
                bool kq1 = HangHoaBLL.ThemHH(hh);
                if (kq1 == true)
                {
                    MessageBox.Show("Thêm hàng hóa thành công!", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("hàng hóa này đã có!", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                MessageBox.Show("Kiểu dữ liệu nhập không chính xác! Vui lòng nhập lại");
                tbMHH.Text = "";
                tbTHH.Text = "";
                tbDVT.Text = "";
                tbGia.Text = "0";
                tbGC.Text  = "";
            }
        }