Пример #1
0
 public ActionResult EditPHNCDieuChinhPHNC([Bind(Include = "Id,DieuChinhKHXBDetailId,SoBao,Nam,Quy,UnitCode,ThongTinBaoId,DieuChinhKHXBDetailId,DiemTiepNhanId,CreateDate,CreateBy")] BDieuChinhPhanHuongUnitModel BDieuChinhPhanHuongUnit)
 {
     UnitModelDieuChinh objUnitNew = new UnitModelDieuChinh();
     if (ModelState.IsValid)
     {
         BDieuChinhPhanHuongUnit.ModifyDate = DateTime.Now;
         BDieuChinhPhanHuongUnit.ModifyBy = userInfo.Id;
         dbDieuChinhPHNC.Update(BDieuChinhPhanHuongUnit.toBDieuChinhPhanHuongUnit());
         objUnitNew = BuildSessionDieuChinhPHNC(BDieuChinhPhanHuongUnit.ThongTinBaoId);
         string[] lstids = { BDieuChinhPhanHuongUnit.UnitCode };
         List<v_Unit> lstUnits = objUnitNew.getUnitMap(lstids, "3");
         objUnitNew.UpdateListUnitMap(lstUnits, BDieuChinhPhanHuongUnit.DiemTiepNhanId);
         buildMessage("Bạn đã sửa thông tin phân hướng thành công");
         return RedirectToAction("Details" + subAction, new { DieuChinhKHXBDetailId = BDieuChinhPhanHuongUnit.DieuChinhKHXBDetailId, districtcode = lstUnits.FirstOrDefault().DistrictCode });
     }
     bindComboboxDieuChinhPHNC(0, BDieuChinhPhanHuongUnit.toBDieuChinhPhanHuongUnit());
     ViewBag.UnitCode = new SelectList(dbDieuChinhPHNC.getAllUnit(), "UnitCode", "UnitName", BDieuChinhPhanHuongUnit.UnitCode);
     buildMessage("Bạn đã sửa thông tin phân hướng thât bại !");
     return View(BDieuChinhPhanHuongUnit);
 }
Пример #2
0
        public ActionResult EditDieuChinhPHNC([Bind(Include = "Id,UnitCode,DieuChinhKHXBDetailId,DiemTiepNhanId,CreateDate,CreateBy")] BDieuChinhPhanHuongUnit BDieuChinhPhanHuongUnit, string listId, string typeid)
        {
            string DieuChinhKHXBDetailId = null;
            //check session unitmodel
            UnitModelDieuChinh objUnitNew = new UnitModelDieuChinh();
            List<v_Unit> lstUnits = new List<v_Unit>();
            List<QuanHuyen> lstQuanHuyen = new List<QuanHuyen>();
            string currentprv = "";
            if (ModelState.IsValid)
            {
                DieuChinhKHXBDetailId = BDieuChinhPhanHuongUnit.DieuChinhKHXBDetailId;
                objUnitNew = BuildSessionDieuChinhPHNC(DieuChinhKHXBDetailId);
                //lstids typeid: 1: list province, 2: list district, 3: list unit
                string[] lstids = listId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                if (lstids.Count() == 0)
                {
                    return this.Json(new { MSG = "Bạn chưa chọn quận huyện hay bưu cục nào !" });
                }
                if (!string.IsNullOrWhiteSpace(typeid) && typeid == "3")
                {
                    lstUnits = objUnitNew.getUnitMap(lstids, typeid);
                    //get current province to back
                    currentprv = lstUnits.Select(t => t.ProvinceCode).FirstOrDefault();
                    //bind data
                    BDieuChinhPhanHuongUnit.CreateBy = userInfo.Id;
                    BDieuChinhPhanHuongUnit.CreateDate = DateTime.Now;
                    BDieuChinhPhanHuongUnit.ModifyBy = userInfo.Id;
                    BDieuChinhPhanHuongUnit.ModifyDate = DateTime.Now;
                    BDieuChinhPhanHuongUnit.DieuChinhKHXBDetailId = DieuChinhKHXBDetailId;
                    //add action
                    dbDieuChinhPHNC.Add(BDieuChinhPhanHuongUnit, lstUnits);
                    //remap unit lai cho object
                    objUnitNew.UpdateListUnitMap(lstUnits, BDieuChinhPhanHuongUnit.DiemTiepNhanId);
                    Session[Application.Session.UnitModelDieuChinh] = objUnitNew;
                }
                else if (!string.IsNullOrWhiteSpace(typeid))
                {
                    lstQuanHuyen = objUnitNew.getDistrictMap(lstids, typeid);
                    currentprv = lstQuanHuyen.FirstOrDefault().ProvinceCode;
                    BDieuChinhPhanHuongDistrictModel bDieuChinhPhanHuongDistrict = new BDieuChinhPhanHuongDistrictModel();
                    //bind data for district
                    bDieuChinhPhanHuongDistrict.DiemTiepNhanId = BDieuChinhPhanHuongUnit.DiemTiepNhanId;
                    bDieuChinhPhanHuongDistrict.ThongTinBaoId = BDieuChinhPhanHuongUnit.ThongTinBaoId;
                    bDieuChinhPhanHuongDistrict.DieuChinhKHXBDetailId = DieuChinhKHXBDetailId;
                    bDieuChinhPhanHuongDistrict.CreateBy = userInfo.Id;
                    bDieuChinhPhanHuongDistrict.CreateDate = DateTime.Now;
                    bDieuChinhPhanHuongDistrict.ModifyBy = userInfo.Id;
                    bDieuChinhPhanHuongDistrict.ModifyDate = DateTime.Now;
                    //add action
                    dbDieuChinhPHNC.AddDistrict(bDieuChinhPhanHuongDistrict.toBDieuChinhPhanHuongDistrict(), lstQuanHuyen);
                    //map lai list vua tao cho object
                    objUnitNew.UpdateListDistrictMap(lstQuanHuyen, bDieuChinhPhanHuongDistrict.DiemTiepNhanId);
                    Session[Application.Session.UnitModelDieuChinh] = objUnitNew;
                }
                buildMessage("Bạn đã sửa thông tin phân hướng thành công .");
                return RedirectToAction("Edit" + subAction, new { provincecode = currentprv, DieuChinhKHXBDetailId = DieuChinhKHXBDetailId });
            }

            buildMessage("Bạn đã sửa thông tin phân hướng thât bại !");
            return RedirectToAction("Edit" + subAction, new { provincecode = currentprv, DieuChinhKHXBDetailId = DieuChinhKHXBDetailId });
        }