/// <summary>
        /// Xóa
        /// </summary>
        /// <modified>
        /// Author              Date            Comments
        /// TrungNQ             01/09/2017      Tạo mới
        /// </modified>
        /// <param name="id">Id bản ghi</param>
        /// <returns></returns>
        public JsonResult Delete(string id)
        {
            var obj = new tblGate();

            var listPC = _tblPCService.GetAllByGateId(id);

            if (listPC.Any())
            {
                var message = new MessageReport();

                message.isSuccess = false;
                message.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["Message_del_fail_computer"];

                return(Json(message, JsonRequestBehavior.AllowGet));
            }

            var result = _tblGateService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.GateID.ToString(), obj.GateName, "tblGate", ConstField.ParkingCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public MessageReport DeleteById(string id, ref tblGate obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(Guid.Parse(id));
                if (obj != null)
                {
                    _tblGateRepository.Delete(n => n.GateID.ToString() == id);

                    Save();

                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
        public ActionResult Update(tblGate obj, int page = 1, string group = "", string key = "")
        {
            //
            ViewBag.PN         = page;
            ViewBag.groupValue = group;
            ViewBag.keyValue   = key;

            //Kiểm tra
            var oldObj = _tblGateService.GetById(obj.GateID);

            if (oldObj == null)
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                return(View(obj));
            }

            //
            if (string.IsNullOrWhiteSpace(obj.GateName))
            {
                ModelState.AddModelError("GateName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["enter_name"]);
                return(View(oldObj));
            }

            if (!ModelState.IsValid)
            {
                return(View(oldObj));
            }

            var objExisted = _tblGateService.GetByName_Id(obj.GateName, obj.GateID);

            if (objExisted != null)
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_already_exist"];
                return(View(oldObj));
            }

            oldObj.GateName    = obj.GateName;
            oldObj.Description = obj.Description;
            oldObj.Inactive    = obj.Inactive;
            //oldObj.SortOrder = obj.SortOrder;

            //Thực hiện cập nhật
            var result = _tblGateService.Update(oldObj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.GateID.ToString(), obj.GateName, "tblGate", ConstField.ParkingCode, ActionConfigO.Update);

                return(RedirectToAction("Index", new { group = group, key = key, page = page, selectedId = obj.GateID }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }
        public ActionResult Create(tblGate obj, bool SaveAndCountinue = false, string group = "", string key = "")
        {
            ViewBag.groupValue = group;
            ViewBag.keyValue   = key;

            //Kiểm tra
            if (!ModelState.IsValid)
            {
                return(View(obj));
            }

            //
            if (string.IsNullOrWhiteSpace(obj.GateName))
            {
                ModelState.AddModelError("GateName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["enter_name"]);
                return(View(obj));
            }

            //
            var objExisted = _tblGateService.GetByName(obj.GateName);

            if (objExisted != null)
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];;
                return(View(obj));
            }

            //Gán giá trị
            obj.GateID = Guid.NewGuid();

            //Thực hiện thêm mới
            var result = _tblGateService.Create(obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.GateID.ToString(), obj.GateName, "tblGate", ConstField.ParkingCode, ActionConfigO.Create);

                if (SaveAndCountinue)
                {
                    TempData["Success"] = result.Message;
                    return(RedirectToAction("Create", new { group = group, key = key, selectedId = obj.GateID }));
                }

                return(RedirectToAction("Index", new { group = group, key = key, selectedId = obj.GateID }));
            }
            else
            {
                return(View(obj));
            }
        }
示例#5
0
        public MessageReport Create(tblGate obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                _tblGateRepository.Add(obj);

                Save();

                re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["addSuccess"];;
                re.isSuccess = true;
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
 public void AddTotblGates(tblGate tblGate)
 {
     AddObject("tblGates", tblGate);
 }
 public static tblGate CreatetblGate(string gateCode, string branchId)
 {
     tblGate tblGate = new tblGate();
     tblGate.GateCode = gateCode;
     tblGate.BranchId = branchId;
     return tblGate;
 }