Exemple #1
0
        public ActionResult Update(int id)
        {
            try
            {
                if (id != 0)
                {
                    var userId = User.Identity.GetUserId();

                    var UserInfo = _unitOfWork.User.GetUserByID(userId);
                    if (UserInfo == null)
                    {
                        RedirectToAction("", "");
                    }
                    var Obj             = _unitOfWork.St_SalesManH.GetSt_SalesManHByID(UserInfo.fCompanyId, id);
                    var St_SalesManHObj = new St_SalesManH();
                    St_SalesManHObj.SalesManID  = Obj.SalesManID;
                    St_SalesManHObj.HrID        = Obj.HrID;
                    St_SalesManHObj.ArabicName  = Obj.ArabicName;
                    St_SalesManHObj.EnglishName = Obj.EnglishName;
                    return(PartialView("Update", St_SalesManHObj));
                }
                return(PartialView("Update", new St_SalesManH()));
            }

            catch (Exception ex)
            {
                ViewBag.Error = ex.Message.ToString();
                return(View("Error"));
            }
        }
Exemple #2
0
        public void Delete(St_SalesManH ObjDelete)
        {
            var ObjToDelete = _context.St_SalesManHs.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.SalesManID == ObjDelete.SalesManID);

            if (ObjToDelete != null)
            {
                _context.St_SalesManHs.Remove(ObjToDelete);
            }
        }
Exemple #3
0
        public ActionResult Save()
        {
            var          userId   = User.Identity.GetUserId();
            var          UserInfo = _unitOfWork.User.GetMyInfo(userId);
            St_SalesManH Obj      = new St_SalesManH
            {
                SalesManID = _unitOfWork.St_SalesManH.GetMaxSerial(UserInfo.fCompanyId)
            };

            return(PartialView(Obj));
        }
Exemple #4
0
        public void Update(St_SalesManH ObjUpdate)
        {
            var ObjToUpdate = _context.St_SalesManHs.SingleOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.SalesManID == ObjUpdate.SalesManID);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.ArabicName  = ObjUpdate.ArabicName;
                ObjToUpdate.EnglishName = ObjUpdate.EnglishName;
                ObjToUpdate.HrID        = ObjUpdate.HrID;
                ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime;
                ObjToUpdate.InsUserID   = ObjUpdate.InsUserID;
            }
        }
Exemple #5
0
        public JsonResult SaveSt_SaleManH(St_SalesManH ObjSave)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);
                ObjSave.SalesManID  = _unitOfWork.St_SalesManH.GetMaxSerial(UserInfo.fCompanyId);
                ObjSave.InsDateTime = DateTime.Now;
                ObjSave.InsUserID   = userId;
                ObjSave.CompanyID   = UserInfo.fCompanyId;
                if (String.IsNullOrEmpty(ObjSave.EnglishName))
                {
                    ObjSave.EnglishName = ObjSave.ArabicName;
                }

                if (!ModelState.IsValid)
                {
                    string Err    = " ";
                    var    errors = ModelState.Values.SelectMany(v => v.Errors);
                    foreach (ModelError error in errors)
                    {
                        Err = Err + error.ErrorMessage + " * ";
                    }

                    Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + Err;
                    Msg.Code = 0;
                    return(Json(Msg, JsonRequestBehavior.AllowGet));
                }
                _unitOfWork.St_SalesManH.Add(ObjSave);
                _unitOfWork.Complete();
                Msg.LastID = _unitOfWork.St_FundingAgencyH.GetMaxSerial(UserInfo.fCompanyId).ToString();
                Msg.Code   = 1;
                Msg.Msg    = Resources.Resource.AddedSuccessfully;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString();
                Msg.Code = 0;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #6
0
        public JsonResult DeleteSaleManH(St_SalesManH ObjDelete)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);
                ObjDelete.CompanyID = UserInfo.fCompanyId;
                if (!ModelState.IsValid)
                {
                    string Err    = " ";
                    var    errors = ModelState.Values.SelectMany(v => v.Errors);
                    foreach (ModelError error in errors)
                    {
                        Err = Err + error.ErrorMessage + " * ";
                    }

                    Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + Err;
                    Msg.Code = 0;
                    return(Json(Msg, JsonRequestBehavior.AllowGet));
                }
                _unitOfWork.St_SalesManH.Delete(ObjDelete);
                _unitOfWork.Complete();

                Msg.Code = 1;
                Msg.Msg  = Resources.Resource.DeletedSuccessfully;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString();
                Msg.Code = 0;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #7
0
 public void Add(St_SalesManH ObjSave)
 {
     _context.St_SalesManHs.Add(ObjSave);
 }