Beispiel #1
0
        public void CapNhapDVTinh(DonViTinh_DTO a)
        {
            var b = DB.DONVITINHs.Single(x => x.MaDonViTinh == a.MaDonViTinh);

            b.TenDonViTinh = a.TenDonViTinh;
            DB.SubmitChanges();
        }
Beispiel #2
0
        public void ThemDVTinh(DonViTinh_DTO a)
        {
            DONVITINH b = new DONVITINH();

            b.TenDonViTinh = a.TenDonViTinh;
            DB.DONVITINHs.InsertOnSubmit(b);
            DB.SubmitChanges();
        }
Beispiel #3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenDV.Text == "")
            {
                MessageBox.Show("Bạn còn dữ liệu chưa nhập");
                return;
            }
            DonViTinh_DTO a = new DonViTinh_DTO();

            a.TenDonViTinh = txtTenDV.Text;
            if (dv.CheckDonViTinh(a.TenDonViTinh) == 0)
            {
                dv.ThemDVTinh(a);
                // MessageBox.Show("Thêm thành công");
                this.Close();
            }
            else
            {
                MessageBox.Show("Đơn vị tính này đã trùng tên, bạn vui lòng chọn tên khác");
                return;
            }
        }
Beispiel #4
0
 private void btnCapNhat_Click(object sender, EventArgs e)
 {
     if (txtMaDV.Text != "")
     {
         DonViTinh_DTO a = new DonViTinh_DTO();
         a.MaDonViTinh  = MaDV;
         a.TenDonViTinh = txtTenDV.Text;
         if (a.TenDonViTinh == dv.Lay1DV(MaDV).TenDonViTinh)
         {
             if (dv.CheckDonViTinh(a.TenDonViTinh) == 1)
             {
                 dv.CapNhapDVTinh(a);
                 this.Close();
                 //MessageBox.Show("Cập nhật thành công");
             }
             else
             {
                 MessageBox.Show("Đơn vị tính này đã trùng tên, bạn vui lòng chọn tên khác");
                 return;
             }
         }
         else
         {
             if (dv.CheckDonViTinh(a.TenDonViTinh) == 0)
             {
                 dv.CapNhapDVTinh(a);
                 //MessageBox.Show("Cập nhật thành công");
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Đơn vị tính này đã trùng tên, bạn vui lòng chọn tên khác");
                 return;
             }
         }
     }
 }