public static int add(DaiLy daily)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             DAILY dl;
             dl = (from d in db.DAILies
                   where d.masodaily.Equals(daily.MaSoDaiLy)
                   select d).SingleOrDefault();
             if (dl != null) return 0; //Nếu đại lý đã tồn tại
             dl = new DAILY()
             {
                 ten = daily.TenDaiLy,
                 diachi = daily.DiaChi,
                 sodienthoai = daily.SoDienThoai,
                 sotaikhoan = daily.SoTaiKhoan,
                 nganhang = daily.NganHang,
                 masonguoidung = daily.MaSoNguoiDung
             };
             db.DAILies.InsertOnSubmit(dl);
             db.SubmitChanges();
             return dl.masodaily;
         }
     }
     catch(Exception ex)
     {
         Console.WriteLine(ex.Message);
         return 0;
     }
 }
Example #2
0
 public DaiLy(DAILY daily)
 {
     MaSoDaiLy = daily.masodaily;
     TenDaiLy = daily.ten;
     DiaChi = daily.diachi;
     SoDienThoai = daily.sodienthoai;
     SoTaiKhoan = daily.sotaikhoan;
     TrangThai = daily.trangthai;
     MaSoNguoiDung = daily.masonguoidung;
     NganHang = daily.nganhang;
 }
 partial void DeleteDAILY(DAILY instance);
 partial void UpdateDAILY(DAILY instance);
 partial void InsertDAILY(DAILY instance);
 public CongNoDaiLy(CONGNODAILY congno, DAILY daily, SACH sach)
     : this(congno,daily)
 {
     Sach = new Sach(sach);
 }
 public CongNoDaiLy(CONGNODAILY congno, DAILY daily)
     : this(congno)
 {
     DaiLy = new DaiLy(daily);
 }
 public HoaDonDaiLy(HOADONDAILY hoadon, DAILY daily)
     : this(hoadon)
 {
     DaiLy = new DaiLy(daily);
 }
 public NguoiDung(NGUOIDUNG nd, DAILY dl)
     : this(nd)
 {
     MaSoDaiLy = dl.masodaily;
     DaiLy = new DaiLy(dl);
 }
 public PhieuXuat(PHIEUXUAT phieu, DAILY daily)
     : this(phieu)
 {
     Daily = new DaiLy(daily);
 }