Beispiel #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="thongTinBaoModel"></param>
 /// <returns></returns>
 public ErrorObject Create(ThongTinBaoModel thongTinBaoModel)
 {
     ErrorObject err = new ErrorObject();
     err = checkThongTinToBao(thongTinBaoModel.Id, thongTinBaoModel.MaBao, thongTinBaoModel.TenBao);
     if (err.HasError)
     {
         return err;
     }
     else
     {
         ////BThongTinBao bThongTinBao = new BThongTinBao();
         //mapObject(thongTinBaoModel, bThongTinBao);
         db.BThongTinBaos.Add(thongTinBaoModel.toCreate());
         int i = db.SaveChanges();
         if (i < 1)
         {
             err.HasError = false;
         }
     }
     return err;
 }
Beispiel #2
0
 private void buildThongTinBao(ThongTinBaoModel item)
 {
     if (item != null)
     {
         item.BaoNgoaiVanDesc = Enums.BaoNgoaiVanDesc(item.BaoNgoaiVan ? Enums.BaoNgoaiVan.BaoNhapKhau : Enums.BaoNgoaiVan.BaoNhapKhau);
         item.BaoCongIchNgoaiCongIchDesc = Enums.BaoCongIchNgoaiCongIchDesc(item.BaoCongIchNgoaiCongIch ? Enums.BaoCongIchNgoaiCongIch.BaoCongIch : Enums.BaoCongIchNgoaiCongIch.BaoNgoaiCongIch);
         item.BaoTrongMucLucDesc = Enums.BaoTrongDanhMucDesc(item.BaoTrongMucLuc?Enums.BaoTrongDanhMuc.BaoNgoaiDanhMuc:Enums.BaoTrongDanhMuc.BaoTrongDanhMuc);
         item.BaoTrungUongDiaPhuongDesc = Enums.BaoTrungUongDiaPhuongDesc(item.BaoTrungUongDiaPhuong ? Enums.BaoTrungUongDiaPhuong.BaoDiaPhuong : Enums.BaoTrungUongDiaPhuong.BaoTrungUong);
         item.CoThueDesc = Enums.BaoCoThueKhongThueDesc(item.CoThue?Enums.BaoCoThueKhongThue.BaoCoThue:Enums.BaoCoThueKhongThue.BaoKhongThue);
         item.ParentName = getParentNameByParentId(item.ParentId);
     }
 }
 // GET: Bao/ThongTinBao/Create
 public ActionResult Create()
 {
     ThongTinBaoModel thongTinBaoModel = new ThongTinBaoModel();
     getValueForDropDownList(null);
     return View();
 }
Beispiel #4
0
 /// <summary>    
 /// Edit
 /// </summary>
 /// <returns></returns>
 /// <Modify>
 /// Author  Date      Comment
 /// Longth  02/07/2015  Create new
 /// </Modify>
 public ErrorObject Edit(ThongTinBaoModel thongTinBaoModel)
 {
     ErrorObject err = new ErrorObject();
     err = checkThongTinToBao(thongTinBaoModel.Id, thongTinBaoModel.MaBao, thongTinBaoModel.TenBao);
     if (err.HasError)
     {
         return err;
     }
     else
     {
         BThongTinBao bThongTinBao = db.BThongTinBaos.Find(thongTinBaoModel.Id);
         thongTinBaoModel.changeEdit(bThongTinBao);
         db.Entry(bThongTinBao).State = EntityState.Modified;
         int i = db.SaveChanges();
         if (i < 1)
         {
             err.HasError = false;
         }
     }
     return err;
 }
        private void getValueForDropDownList(ThongTinBaoModel thongTinBaoModel)
        {
            if(thongTinBaoModel != null)
            {
                List<DefineSelectItem> toaSoan = db.getListDMToanSoan();
                ViewBag.MaToaSoan = new SelectList(toaSoan, "Value", "Text", thongTinBaoModel.MaToaSoan);

                List<DefineSelectItem> loaiAnPham = db.getListLoaiAnPham();
                ViewBag.LoaiAnPham = new SelectList(loaiAnPham, "Value", "Text", thongTinBaoModel.TenLoaiAnPham);
            }
            else
            {
                List<DefineSelectItem> toaSoan = db.getListDMToanSoan();
                ViewBag.MaToaSoan = new SelectList(toaSoan, "Value", "Text");

                List<DefineSelectItem> loaiAnPham = db.getListLoaiAnPham();
                ViewBag.LoaiAnPham = new SelectList(loaiAnPham, "Value", "Text");
            }
        }