Example #1
0
 public void Add(DonDatHang dm)
 {
     //var q = (from p in en.GiaModule select p.Gia_ID).DefaultIfEmpty().Max();
     //var q = en.DonDatHang.Max(i => (int?)i.DatHang_ID) ?? 1;
     //dm.DatHang_ID = q + 1;
     en.AddObject("DonDatHang", dm);
 }
 public string InsertToDonDatHang()
 {
     DateTime dt = DateTime.Now;
     string dateTime = String.Format("{0:yyyy MM dd}", dt);
     string words = Regex.Replace(dateTime, " ", "");
     var maDatHang = words + "-DH" + DHRes.getMaxId();
     var sp = new DonDatHang();
     sp.ngayDat = dt;
     sp.TrangThai = "DangSuLy";
     sp.MaDatHang = maDatHang;
     sp.accountDatHang_ID = 1;
     DHRes.Add(sp);
     DHRes.Save();
     //insert dat hang chi chiet;
     DHRes.UpdateChiTietDonDatHang(sp.MaDatHang, 1);
     return sp.MaDatHang;
 }
Example #3
0
 public void Delete(DonDatHang dm)
 {
     en.DeleteObject(dm);
 }
 private string InsertToDonDatHang(int accountNguoiMuaHangHang, int accountNguoiNhanHang)
 {
     try {
     DateTime dt = DateTime.Now;
     string dateTime = String.Format("{0:yyyy MM dd}", dt);
     string words = Regex.Replace(dateTime, " ", "");
     var maDatHang = words + "-DH" + DHRes.getMaxId();
     var sp = new DonDatHang();
     sp.ngayDat = dt;
     sp.TrangThai = "DangSuLy";
     sp.MaDatHang = maDatHang;
     sp.accountDatHang_ID = accountNguoiMuaHangHang;
     sp.accountNguoiNhan_ID = accountNguoiNhanHang; // nguoi nhan hang
     DHRes.Add(sp);
     DHRes.Save();
     //insert dat hang chi chiet;
     InsertChiTietDonDatHang(sp.MaDatHang, accountNguoiMuaHangHang, accountNguoiNhanHang);
     XoaHetSanPham();
     return sp.MaDatHang;
     }
     catch (Exception e)
     {
         logger.Debug("Error at function InsertToDonDatHang :" + e);
         return "";
     }
 }