Beispiel #1
0
 private void btnCapNhat_Click(object sender, EventArgs e)
 {
     if (txtMaLoaiSP.Text != "")
     {
         LoaiSP_DTO a = new LoaiSP_DTO();
         a.TenLoaiSP        = txtTenLoaiSP.Text;
         a.MaDonViTinh      = Int16.Parse(cbbDV.SelectedValue.ToString());
         a.PhanTramLoiNhuan = float.Parse(txtPhantramloinhuan.Text);
         a.MaLoaiSP         = MaLoaiSP;
         if (a.PhanTramLoiNhuan <= 0)
         {
             MessageBox.Show("Phần trăm lợi nhuận phải lớn hơn 0");
             return;
         }
         if (a.TenLoaiSP == lo.Lay1LSP(MaLoaiSP).TenLoaiSP)
         {
             if (lo.CheckTenLoaiSP(a.TenLoaiSP) == 1)
             {
                 lo.CapNhapLoaiSP(a);
                 this.Close();
                 //MessageBox.Show("Cập nhật thành công");
             }
             else
             {
                 MessageBox.Show("Loại sản phẩm này đã trùng tên, bạn vui lòng chọn tên khác");
                 return;
             }
         }
         else
         {
             if (lo.CheckTenLoaiSP(a.TenLoaiSP) == 0)
             {
                 lo.CapNhapLoaiSP(a);
                 this.Close();
                 //MessageBox.Show("Cập nhật thành công");
             }
             else
             {
                 MessageBox.Show("Loại sản phẩm này đã trùng tên, bạn vui lòng chọn tên khác");
                 return;
             }
         }
     }
 }