Пример #1
0
        public ActionResult LoadUnit(string lstUnit, string Mabao, string typestr)
        {
            string[] lstids = lstUnit.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            //check session unitmodel
            UnitModel objUnitNew = new UnitModel();
            //check session để xem thông tin
            objUnitNew = BuildSession(Mabao);
            List<v_Unit> units = new List<v_Unit>();
            //typestr : 1: getUnitNotMap, 2: getUnitMap
            if (string.IsNullOrWhiteSpace(typestr) || typestr == "1")
            {
                units = objUnitNew.getUnitNotMap(lstids, "2");
            }
            else if (!string.IsNullOrWhiteSpace(typestr) && typestr == "2")
            {
               units = objUnitNew.getUnitMap(lstids, "2");
            }
            return PartialView("_inputFormBuuCuc", units);
        }
Пример #2
0
 // GET: Admin/PHNC/Edit/5
 public ActionResult EditPHNC(string id)
 {
     string districtcode = "";
     UnitModel objUnitNew = new UnitModel();
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     BPhanHuongNhuCau bPhanHuongNhuCau = db.getById(id);
     if (bPhanHuongNhuCau == null)
     {
         return HttpNotFound();
     }
     bindCombobox(1, bPhanHuongNhuCau);
     ViewBag.UnitCode = new SelectList(db.getAllUnit(), "UnitCode", "UnitName", bPhanHuongNhuCau.UnitCode);
     string[] lstids = { bPhanHuongNhuCau.UnitCode };
     objUnitNew = BuildSession(bPhanHuongNhuCau.ThongTinBaoId);
     List<v_Unit> lstUnits = objUnitNew.getUnitMap(lstids, "3");
     districtcode = lstUnits.FirstOrDefault().DistrictCode;
     ViewBag.DistrictCodeDetail = districtcode;
     return View(new BPhanHuongNhuCauModel(bPhanHuongNhuCau));
 }
Пример #3
0
 public ActionResult EditPHNC([Bind(Include = "Id,UnitCode,ThongTinBaoId,DiemTiepNhanId,CreateDate,CreateBy")] BPhanHuongNhuCauModel bPhanHuongNhuCau)
 {
     UnitModel objUnitNew = new UnitModel();
     if (ModelState.IsValid)
     {
         bPhanHuongNhuCau.ModifyDate = DateTime.Now;
         bPhanHuongNhuCau.ModifyBy = userInfo.Id;
         db.Update(bPhanHuongNhuCau.toBPhanHuongNhuCau());
         objUnitNew = BuildSession(bPhanHuongNhuCau.ThongTinBaoId);
         string[] lstids = { bPhanHuongNhuCau.UnitCode };
         List<v_Unit> lstUnits = objUnitNew.getUnitMap(lstids, "3");
         objUnitNew.UpdateListUnitMap(lstUnits, bPhanHuongNhuCau.DiemTiepNhanId);
         buildMessage("Bạn đã sửa thành công");
         return RedirectToAction("Details", new { Mabao = bPhanHuongNhuCau.ThongTinBaoId, districtcode = lstUnits.FirstOrDefault().DistrictCode });
     }
     bindCombobox(0, bPhanHuongNhuCau.toBPhanHuongNhuCau());
     ViewBag.UnitCode = new SelectList(db.getAllUnit(), "UnitCode", "UnitName", bPhanHuongNhuCau.UnitCode);
     buildMessage("Bạn đã sửa thiết lập thất bại !");
     return View(bPhanHuongNhuCau);
 }
Пример #4
0
        public ActionResult Edit([Bind(Include = "Id,UnitCode,ThongTinBaoId,DiemTiepNhanId,CreateDate,CreateBy")] BPhanHuongNhuCau bPhanHuongNhuCau, string listId, string typeid)
        {
            string Mabao = null;
            //check session unitmodel
            UnitModel objUnitNew = new UnitModel();
            List<v_Unit> lstUnits = new List<v_Unit>();
            string currentprv = "";
            if (ModelState.IsValid)
            {
                Mabao = bPhanHuongNhuCau.ThongTinBaoId;
                objUnitNew = BuildSession(Mabao);
                //lstids typeid: 1: list province, 2: list district, 3: list unit
                string[] lstids = listId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                lstUnits = objUnitNew.getUnitMap(lstids, typeid);
                //get current province to back
                currentprv = lstUnits.Select(t => t.ProvinceCode).FirstOrDefault();
                //bind data
                bPhanHuongNhuCau.CreateBy = userInfo.Id;
                bPhanHuongNhuCau.CreateDate = DateTime.Now;
                bPhanHuongNhuCau.ModifyBy = userInfo.Id;
                bPhanHuongNhuCau.ModifyDate = DateTime.Now;
                //add action
                db.Add(bPhanHuongNhuCau, lstUnits);
                //remap unit lai cho object
                objUnitNew.UpdateListUnitMap(lstUnits, bPhanHuongNhuCau.DiemTiepNhanId);
                Session[Application.Session.UnitModel] = objUnitNew;
                buildMessage("Bạn đã sửa thành công .");
                return RedirectToAction("Edit", new { provincecode = currentprv, Mabao = bPhanHuongNhuCau.ThongTinBaoId });
            }

            buildMessage("Bạn đã sửa thiết lập thất bại !");
            return RedirectToAction("Edit", new { provincecode = currentprv, Mabao = bPhanHuongNhuCau.ThongTinBaoId });
        }