示例#1
0
        public JsonResult Delete(St_ItemUnitH 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_ItemUnitH.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));
            }
        }
示例#2
0
        public void Delete(St_ItemUnitH ObjDelete)
        {
            var ObjToDelete = _context.St_ItemUnitHs.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.ItemUnitCode == ObjDelete.ItemUnitCode);

            if (ObjToDelete != null)
            {
                _context.St_ItemUnitHs.Remove(ObjToDelete);
            }
        }
示例#3
0
        public ActionResult Add()
        {
            var          userId   = User.Identity.GetUserId();
            var          UserInfo = _unitOfWork.User.GetMyInfo(userId);
            St_ItemUnitH Obj      = new St_ItemUnitH
            {
                ItemUnitCode = _unitOfWork.St_ItemUnitH.GetMaxSerial(UserInfo.fCompanyId)
            };

            return(PartialView(Obj));
        }
示例#4
0
        public void Update(St_ItemUnitH ObjUpdate)
        {
            var ObjToUpdate = _context.St_ItemUnitHs.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.ItemUnitCode == ObjUpdate.ItemUnitCode);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.ArabicName  = ObjUpdate.ArabicName;
                ObjToUpdate.EnglishName = ObjUpdate.EnglishName;
                ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime;
                ObjToUpdate.InsUserID   = ObjUpdate.InsUserID;
            }
        }
示例#5
0
        public JsonResult Save(St_ItemUnitH ObjSave)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);
                ObjSave.ItemUnitCode = _unitOfWork.St_ItemUnitH.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_ItemUnitH.Add(ObjSave);
                _unitOfWork.Complete();
                Msg.LastID = _unitOfWork.St_ItemUnitH.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));
            }
        }
示例#6
0
 public void Add(St_ItemUnitH ObjSave)
 {
     _context.St_ItemUnitHs.Add(ObjSave);
 }