Example #1
0
        private void btnSaveLSP_Click(object sender, EventArgs e)
        {
            if (txtNAMELSP.Text != "" && txtDVTLSP.Text != "")
            {
                if (txtIDLSP.Text != "")
                {
                    int             id     = Convert.ToInt16(txtIDLSP.Text);
                    DTO_LoaiSanPham dtolsp = new DTO_LoaiSanPham(id, txtNAMELSP.Text, txtDVTLSP.Text);
                    if (busloaisanpham.suaLoaiSanPham(dtolsp))
                    {
                        MessageBox.Show("Cập nhật hoàn tất");
                    }
                    else
                    {
                        MessageBox.Show("Cập nhật thất bại");
                    }
                }
                else
                {
                    // toi tao doi tuong
                    DTO_LoaiSanPham dtolsp = new DTO_LoaiSanPham(0, txtNAMELSP.Text, txtDVTLSP.Text);
                    // dùng buss thêm đối tượng
                    if (busloaisanpham.themLoaiSanPham(dtolsp))
                    {
                        MessageBox.Show("Thêm thành công");
                    }
                    else
                    {
                        MessageBox.Show("Không thêm được");
                    }
                }

                clearLoaiSanPham();
            }
            else
            {
                MessageBox.Show("Nhập thông tin đầy đủ ở  các ô có `*`;");
            }
        }