Esempio n. 1
0
 public ActionResult AjaxCreate(ContractInfoViewModel model)
 {
     ServiceResult result = new ServiceResult();
     if (!ModelState.IsValid)
     {
         result.Message = "表单输入有误,请仔细填写表单!";
         result.AddServiceError("表单输入有误,请仔细填写表单!");
     }
     else
     {
         try
         {
             var requiremodel = ContactRequireService.Find(model.RequireID);
             var entity = new ContactRequire()
             {
                 ID = requiremodel.ID,
                 Description = requiremodel.Description,
                 AttachmentPath = requiremodel.AttachmentPath,
                 IsRoot = requiremodel.IsRoot,
                 Status = 1,
                 Name = requiremodel.Name
             };
             ContactRequireService.Update(entity);
             ContractInfoService.Create(model);
             result.Message = "处理合同请求成功!";
         }
         catch (Exception ex)
         {
             result.Message = "处理合同请求失败!";
             result.AddServiceError(Utilities.GetInnerMostException(ex));
             LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "处理合同请求失败!", ex);
         }
     }
     return Json(result);
 }
Esempio n. 2
0
 public ActionResult Index(ChangePasswordViewModel model)
 {
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             var memberID = Convert.ToInt32(CookieHelper.UID);
             if (!MemberService.ChangePassword(memberID, model.OldPassword, model.NewPassword))
             {
                 result.Message = "旧密码错误!";
                 result.AddServiceError("旧密码错误");
                 return View(model);
             }
             result.Message = "密码修改成功!";
             return RedirectToAction("index");
         }
         catch (Exception ex)
         {
             result.Message = "密码修改失败!";
             result.AddServiceError(Utilities.GetInnerMostException(ex));
             LogHelper.WriteLog("用户:" + model.MemberID + "密码修改失败!", ex);
         }
     }
     return View(model);
 }
Esempio n. 3
0
        public ActionResult Create(DepartmentViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    Department entity = new Department();
                    entity.Name = model.Name;
                    entity.Description = model.Description;
                    entity.Level = model.Level;
                    entity.PID = model.PID;
                    entity.Code = model.Code;
                    DepartmentService.Create(entity);
                    result.Message = "添加部门成功!";
                    LogHelper.WriteLog("添加部门成功");
                    return RedirectToAction("index");
                }
                catch (DbEntityValidationException ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加部门错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            ViewBag.Data_PID = GetSelectList();
            return View(model);
        }
Esempio n. 4
0
 public ActionResult AjaxCreate(TraceLogViewModel model)
 {
     ServiceResult result = new ServiceResult();
     if (!ModelState.IsValid)
     {
         result.Message = "表单输入有误,请仔细填写表单!";
         result.AddServiceError("表单输入有误,请仔细填写表单!");
     }
     else
     {
         try
         {
             TraceLogService.Create(model);
             //CustomerCompanyService.ChangeRelation(model.CompanyID, model.RelationID);
             result.Message = "添加跟单日志成功!";
         }
         catch (Exception ex)
         {
             result.Message = ex.Message;
             result.AddServiceError(Utilities.GetInnerMostException(ex));
             LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "添加跟单日志失败!", ex);
         }
     }
     ViewBag.Data_RelationID = Utilities.GetSelectListData(RelationCateService.GetALL(), x => x.ID, x => x.CateName, true);
     return Json(result);
 }
Esempio n. 5
0
        public ActionResult Create()
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            try
            {
                DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/" + ConfigSetting.BankupPath));
                if (!di.Exists)
                {
                    di.Create();
                }
                var sql = string.Format("BACKUP DATABASE {0} TO DISK = '{1}'", ConfigSetting.DataBaseName, GetBackName());

                db.SqlQuery<int>(sql).ToList();

                result.Message = "备份成功!";
                LogHelper.WriteLog("备份成功!");

            }
            catch (Exception ex)
            {
                //result.Message = Utilities.GetInnerMostException(ex);
                //result.AddServiceError(result.Message);
                result.Message = "备份成功!";
                LogHelper.WriteLog("备份失败!", ex);
            }
            return RedirectToAction("index");
        }
Esempio n. 6
0
 public ActionResult Create(RelationCateViewModel model)
 {
     ViewBag.Data_PID = GetSelectList();
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             RelationCate entity = new RelationCate();
             entity.CateName = model.CateName;
             entity.PID = model.PID == 0 ? null : model.PID;
             entity.Level = model.Level;
             entity.OrderIndex = model.OrderIndex;
             entity.Code = model.Code;
             cityService.Create(entity);
             result.Message = "添加城市信息成功!";
             LogHelper.WriteLog("添加城市信息成功");
             return RedirectToAction("index");
         }
         catch (DbEntityValidationException ex)
         {
             result.Message = Utilities.GetInnerMostException(ex);
             result.AddServiceError(result.Message);
             LogHelper.WriteLog("添加城市信息错误", ex);
             return View(model);
         }
     }
     else
     {
         result.Message = "请检查表单是否填写完整!";
         result.AddServiceError("请检查表单是否填写完整!");
         return View(model);
     }
 }
Esempio n. 7
0
        public ActionResult Create(MemberViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    MemberService.Create(model);
                    result.Message = "添加会员信息成功!";
                    LogHelper.WriteLog("添加会员信息成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加会员信息错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            ViewBag.Data_GroupID = Utilities.GetSelectListData(GroupService.GetALL()
              , x => x.ID, x => x.Name, true);
            ViewBag.Data_DepartmentID = Utilities.GetSelectListData(DepartmentService.GetALL()
                , x => x.ID, x => x.Name, true);
            ViewBag.Data_JobTitleID = Utilities.GetSelectListData(
               JobTitleCateService.GetALL()
              , x => x.ID, x => x.CateName, true);
            return View(model);
        }
Esempio n. 8
0
        public ActionResult AjaxCreate(ContactRequireViewModel model)
        {
            ServiceResult result = new ServiceResult();
            if (!ModelState.IsValid)
            {
                result.Message = "表单输入有误,请仔细填写表单!";
                result.AddServiceError("表单输入有误,请仔细填写表单!");
            }
            else
            {
                try
                {
                    ContactRequireService.Create(model);
                    result.Message = "追加回复成功!";
                }
                catch (Exception ex)
                {
                    result.Message = "追加回复失败!";
                    result.AddServiceError(Utilities.GetInnerMostException(ex));
                    LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "追加回复失败!", ex);
                }
            }

            return Json(result);
        }
Esempio n. 9
0
 public ActionResult Delete(int ID)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         var entity = CustomerShareService.Find(ID);
         CustomerShareService.Delete(entity);
         result.Message = "删除共享人员成功!";
     }
     catch (Exception ex)
     {
         result.Message = "删除共享人员失败!";
         result.AddServiceError(Utilities.GetInnerMostException(ex));
         LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "删除共享人员失败!", ex);
     }
     return Json(result);
 }
Esempio n. 10
0
        public ActionResult Delete(string Name)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            try
            {
                var filePath = Name;
                var file = new FileInfo(Name);
                file.Delete();
                result.Message = "删除备份成功!";
                LogHelper.WriteLog("删除备份成功!");

            }
            catch (Exception ex)
            {
                //result.Message = Utilities.GetInnerMostException(ex);
                result.Message = "删除备份失败!";
                result.AddServiceError(result.Message);
                LogHelper.WriteLog("删除备份失败!", ex);
            }
            return RedirectToAction("index");
        }
Esempio n. 11
0
        public ActionResult AjaxAppend(MediaRequireAppendViewModel model)
        {
            ServiceResult result = new ServiceResult();
            if (!ModelState.IsValid)
            {
                result.Message = "表单输入有误,请仔细填写表单!";
                result.AddServiceError("表单输入有误,请仔细填写表单!");
            }
            else
            {
                try
                {
                    var entity = new MediaRequireViewModel()
                    {
                        DepartmentID = model.DepartmentID,
                        AttachmentPath = model.AttachmentPath,
                        CompanyID = model.CompanyID,
                        Description = model.Description,
                        IsRoot = model.IsRoot,
                        ID = model.ID,
                        Name = model.Name,
                        ResolveID = model.ResolveID,
                        PID = model.PID,
                        SenderID = model.SenderID,
                        Status = model.Status

                    };
                    MediaRequireService.Create(entity);
                    result.Message = "追加回复成功!";
                }
                catch (Exception ex)
                {
                    result.Message = "追加回复失败!";
                    result.AddServiceError(Utilities.GetInnerMostException(ex));
                    LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "追加回复失败!", ex);
                }
            }
            return Json(result);
        }
Esempio n. 12
0
        public ActionResult Create(NoticeViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    NoticeService.Create(model);
                    result.Message = "添加部门公告成功!";
                    LogHelper.WriteLog("添加部门公告成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加部门公告错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            var list = DepartmentService.GetALL().Where(x => x.PID.Equals(null));
            var hasPermission = CookieHelper.CheckPermission("boss");
            if (!hasPermission)
            {
                var member = MemberService.Find(CookieHelper.MemberID);
                list = list.Where(x => x.ID == member.DepartmentID);
            }
            ViewBag.Data_DepartmentID = Utilities.GetSelectListData(
                list
                , x => x.ID, x => x.Name, true);

            return View(model);
        }
Esempio n. 13
0
        public ActionResult Create(ArticleViewModel model)
        {
            ViewBag.Data_ArticleCode = GetForeignData();
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    Article article = new Article()
                    {
                        AddTime = DateTime.Now,
                        ArticleCodeValue = model.ArticleCode,
                        Content = model.Content,
                        Name = model.Name,
                        LastTime = DateTime.Now,
                        ArticleCode = Convert.ToInt32(model.ArticleCode.Split(',').Last())
                    };

                    ArticleService.Create(article);
                    result.Message = "添加文章信息成功!";
                    LogHelper.WriteLog("添加文章信息成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加文章信息错误", ex);
                    return View(model);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");
                return View(model);
            }
        }
Esempio n. 14
0
        public ActionResult Create(PunishViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Score == 0)
                    {
                        var rule = RuleCateService.Find(model.RuleID);
                        model.Score = rule.OrderIndex;
                    }
                    PunishService.Create(model);
                    result.Message = "添加行政奖惩成功!";
                    LogHelper.WriteLog("添加行政奖惩告成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加行政奖惩错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }

            ViewBag.Data_RuleID = Utilities.GetSelectListData(
                RuleCateService.GetALL().Where(x => x.PID.Equals(null))
                , x => x.ID, x => x.CateName, true);

            return View(model);
        }
Esempio n. 15
0
 public ActionResult Create(GroupViewModel model)
 {
     var Roles = GetForeignData();
     ViewBag.Data_Roles = Roles;
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             Group entity = new Group();
             entity.Name = model.Name;
             entity.Content = model.Content;
             entity.Description = model.Description;
             var RolesArray = model.Roles.Split(',').Select(x => Convert.ToInt32(x)).ToList();
             var RoleList = RolesService.GetALL().Where(x => RolesArray.Contains(x.ID));
             entity.Roles.AddRange(RoleList);
             GroupService.Create(entity);
             result.Message = "添加群组成功!";
             LogHelper.WriteLog("添加群组成功");
             return RedirectToAction("index");
         }
         catch (DbEntityValidationException ex)
         {
             result.Message = Utilities.GetInnerMostException(ex);
             result.AddServiceError(result.Message);
             LogHelper.WriteLog("添加群组错误", ex);
             return View(model);
         }
     }
     else
     {
         result.Message = "请检查表单是否填写完整!";
         result.AddServiceError("请检查表单是否填写完整!");
         return View(model);
     }
 }
Esempio n. 16
0
 public ActionResult Create(PermissionsViewModel model)
 {
     ViewBag.Data_DepartmentID = GetSelectList();
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             Permissions entity = new Permissions();
             entity.Name = model.Name;
             entity.Description = model.Description;
             entity.Controller = model.Controller;
             entity.Action = model.Action;
             entity.Namespace = model.Namespace;
             entity.DepartmentID = model.DepartmentID;
             PermissionsService.Create(entity);
             result.Message = "添加权限成功!";
             LogHelper.WriteLog("添加权限成功");
             return RedirectToAction("index");
         }
         catch (DbEntityValidationException ex)
         {
             result.Message = Utilities.GetInnerMostException(ex);
             result.AddServiceError(result.Message);
             LogHelper.WriteLog("添加权限错误", ex);
             return View(model);
         }
     }
     else
     {
         result.Message = "请检查表单是否填写完整!";
         result.AddServiceError("请检查表单是否填写完整!");
         return View(model);
     }
 }
Esempio n. 17
0
 public ActionResult AjaxCreate(TaskViewModel model)
 {
     ServiceResult result = new ServiceResult();
     if (!ModelState.IsValid)
     {
         result.Message = "表单输入有误,请仔细填写表单!";
         result.AddServiceError("表单输入有误,请仔细填写表单!");
     }
     else
     {
         try
         {
             var entity = TaskService.Create(model);
             result.SuccessData = new Task()
             {
                 Start = entity.Start,
                 End = entity.End,
                 ID = entity.ID,
                 StartTimeZone = entity.StartTimeZone,
                 EndTimeZone = entity.EndTimeZone,
                 Description = entity.Description,
                 Title = entity.Title,
                 MemberID = entity.MemberID,
                 IsOtherAdd = entity.MemberID != CookieHelper.MemberID
             };
             result.Message = "添加任务安排成功!";
         }
         catch (Exception ex)
         {
             result.Message = ex.Message;
             result.AddServiceError(Utilities.GetInnerMostException(ex));
             LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "添加任务安排失败!", ex);
         }
     }
     return Json(result);
 }
Esempio n. 18
0
        public ActionResult Create(TcNoticeViewModel model)
        {
            ServiceResult result = new ServiceResult();
            var DepartmentArray = new List<int>();

            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    DepartmentArray = model.DepartmentID.Split(',').Select(x => Convert.ToInt32(x)).ToList();
                    TcNoticeService.Create(model);
                    result.Message = "添加提成公告成功!";
                    LogHelper.WriteLog("添加提成公告成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加提成公告错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            ViewBag.Data_DepartmentID = Utilities.GetSelectListData(
                 DepartmentService.GetALL()
                 .Where(x => x.PID.Equals(null)),
                 x => x.ID, x => x.Name, DepartmentArray, false);

            return View(model);
        }
Esempio n. 19
0
 public ActionResult Delete(int ID)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         var model = TaskService.Find(ID);
         TaskService.Delete(model);
         LogHelper.WriteLog("删除任务安排成功");
         result.Message = "删除任务安排成功!";
     }
     catch (DbEntityValidationException ex)
     {
         result.Message = "删除任务安排错误!";
         result.AddServiceError("删除任务安排错误!");
         LogHelper.WriteLog("删除任务安排错误", ex);
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Esempio n. 20
0
        public ActionResult Create(CustomerCompanyViewModel model)
        {
            ServiceResult result = new ServiceResult();

            TempData["Service_Result"] = result;
            if (!ModelState.IsValid)
            {
                result.Message = "表单输入有误,请仔细填写表单!";
                result.AddServiceError("表单输入有误,请仔细填写表单!");
            }
            else
            {
                try
                {
                    CustomerCompanyService.Create(model);
                    result.Message = "添加客户成功!";
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = "添加客户失败!";
                    result.AddServiceError(Utilities.GetInnerMostException(ex));
                    LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "添加客户失败!", ex);
                }

            }
            ViewBag.Data_RelationID = Utilities.GetSelectListData(RelationCateService.GetALL(), x => x.ID, x => x.CateName, true);
            ViewBag.Data_CustomerCateID = Utilities.GetSelectListData(CustomerCateService.GetALL(), x => x.ID, x => x.CateName, true);
            return View(model);
        }
Esempio n. 21
0
 public ActionResult ChangStatus(int ID)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         var model = ContactRequireService.Find(ID);
         var entity = new ContactRequire()
         {
             ID = model.ID,
             Description = model.Description,
             AttachmentPath = model.AttachmentPath,
             IsRoot = model.IsRoot,
             Status = 1,
             Name = model.Name
         };
         ContactRequireService.Update(entity);
         LogHelper.WriteLog("更改合同状态成功");
         result.Message = "更改合同状态成功!";
     }
     catch (DbEntityValidationException ex)
     {
         result.Message = "更改合同状态错误!";
         result.AddServiceError("更改合同状态错误!");
         LogHelper.WriteLog("更改合同状态错误", ex);
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Esempio n. 22
0
 public ActionResult SetDelete(string ids)
 {
     ServiceResult result = new ServiceResult();
     var IdArr = ids.Split(',').Select(x => Convert.ToInt32(x)).ToList();
     try
     {
         for (var i = 0; i < IdArr.Count; i++)
         {
             var model = FileShareService.Find(IdArr[i]);
             FileShareService.Delete(model);
         }
         LogHelper.WriteLog("删除文件共享成功");
         result.Message = "删除文件共享成功!";
     }
     catch (DbEntityValidationException ex)
     {
         result.Message = "删除文件共享错误!";
         result.AddServiceError("删除文件共享错误!");
         LogHelper.WriteLog("删除文件共享错误", ex);
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Esempio n. 23
0
        public ActionResult Edit(FileShareViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {

                    FileShareService.Update(model);
                    result.Message = "编辑文件共享成功!";
                    LogHelper.WriteLog("编辑文件共享成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("编辑文件共享错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            ViewBag.Data_FileCateID = Utilities.GetSelectListData(
               FileCateService.GetALL().Where(x => x.PID.Equals(null))
               , x => x.ID, x => x.CateName, model.FileCateID, true, true);

            var departlist = DepartmentService.GetALL().Where(x => x.PID.Equals(null));

            var hasPermission = CookieHelper.CheckPermission("boss");
            if (!hasPermission)
            {
                var member = MemberService.Find(CookieHelper.MemberID);
                var depart = DepartmentService.Find(member.DepartmentID);
                if (depart.Level == 0)
                {
                    departlist = departlist.Where(x => x.ID == depart.ID);
                }
                else
                {
                    var rootCode = Utilities.GetRootCode(depart.Code, depart.Level);
                    departlist = departlist.Where(x => x.Code == rootCode);
                }
            }
            ViewBag.Data_DepartmentID = Utilities.GetSelectListData(
             departlist
               , x => x.ID, x => x.Name, model.DepartmentID, true, true);
            return View(model);
        }
Esempio n. 24
0
 public ActionResult SetRefresh(string ids)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         CustomerCompanyService.ChangeStatus(ids, CustomerCompanyStatus.Default);
         result.Message = "客户信息恢复成功!";
     }
     catch (Exception ex)
     {
         result.Message = "客户信息恢复失败!";
         result.AddServiceError(Utilities.GetInnerMostException(ex));
         LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "客户信息恢复失败!", ex);
     }
     return Json(result);
 }
Esempio n. 25
0
        public ActionResult Edit(CustomerCompanyViewModel model)
        {
            ServiceResult result = new ServiceResult();

            TempData["Service_Result"] = result;
            if (!ModelState.IsValid)
            {
                result.Message = "表单输入有误,请仔细填写表单!";
                result.AddServiceError("表单输入有误,请仔细填写表单!");
            }
            else
            {
                try
                {
                    CustomerCompanyService.Update(model);
                    //标记为已合作客户
                    if (model.CustomerCateID == 5)
                    {
                        var contact = new ContactRequireViewModel()
                        {
                            CompanyID = model.ID,
                            //财务部
                            DepartmentID = 8,
                            Name = model.Name + "财务合同请求",
                            Description = model.Name + "财务合同请求",
                            SenderID = CookieHelper.MemberID,
                            IsRoot = 1
                        };
                        ContactRequireService.Create(contact);
                    }
                    result.Message = "编辑客户成功!";
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = "编辑客户失败!";
                    result.AddServiceError(Utilities.GetInnerMostException(ex));
                    LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "编辑客户失败!", ex);
                }
            }
            ViewBag.Data_RelationID = Utilities.GetSelectListData(RelationCateService.GetALL(), x => x.ID, x => x.CateName, model.RelationID, true);
            ViewBag.Data_CustomerCateID = Utilities.GetSelectListData(CustomerCateService.GetALL(), x => x.ID, x => x.CateName, model.CustomerCateID, true);
            return View(model);
        }
Esempio n. 26
0
 public ActionResult SetReplace(string ids)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         var idslist = Utilities.GetIdList(ids);
         foreach (var id in idslist)
         {
             CustomerCompanyService.Replace(id, CookieHelper.MemberID);
         }
         result.Message = "客户信息替换成功!";
     }
     catch (Exception ex)
     {
         result.Message = "客户信息替换失败!";
         result.AddServiceError(Utilities.GetInnerMostException(ex));
         LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "客户信息替换失败!", ex);
     }
     return Json(result);
 }
Esempio n. 27
0
        public ActionResult refresh(string Name)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            try
            {
                var filePath = Name;
                string sql = string.Format(

                    "use master restore database {0} from disk='{1}'"

                    , ConfigSetting.DataBaseName, filePath);
                db.SqlQuery<int>(sql).ToList();
                result.Message = "还原成功!";
                LogHelper.WriteLog("还原成功!");

            }
            catch (Exception ex)
            {
                //result.Message = Utilities.GetInnerMostException(ex);
                //result.AddServiceError(result.Message);
                result.Message = "还原成功!";
                LogHelper.WriteLog("还原失败!", ex);
            }
            return RedirectToAction("index");
        }
Esempio n. 28
0
 public ActionResult Edit(RolesViewModel model)
 {
     var permissionsArray = model.Permissions.Split(',').Select(x => Convert.ToInt32(x)).ToList();
     var permissions = GetGroupForeignData(permissionsArray);
     ViewBag.Data_Permissions = permissions;
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             Roles entity = new Roles();
             entity.ID = model.ID;
             entity.Name = model.Name;
             entity.Description = model.Description;
             var PermissionList = PermissionsService.GetALL().Where(x => permissionsArray.Contains(x.ID)).ToList();
             entity.Permissions = PermissionList;
             RolesService.Update(entity);
             result.Message = "编辑角色成功!";
             LogHelper.WriteLog("编辑角色成功");
             return RedirectToAction("index");
         }
         catch (DbEntityValidationException ex)
         {
             result.Message = Utilities.GetInnerMostException(ex);
             result.AddServiceError(result.Message);
             LogHelper.WriteLog("添加角色错误", ex);
             return View(model);
         }
     }
     else
     {
         result.Message = "请检查表单是否填写完整!";
         result.AddServiceError("请检查表单是否填写完整!");
         return View(model);
     }
 }
Esempio n. 29
0
        public ActionResult Edit(CustomerViewModel model)
        {
            ServiceResult result = new ServiceResult();

            TempData["Service_Result"] = result;
            if (!ModelState.IsValid)
            {
                result.Message = "表单输入有误,请仔细填写表单!";
                result.AddServiceError("表单输入有误,请仔细填写表单!");
            }
            else
            {
                try
                {
                    CustomerService.Update(model);
                    result.Message = "编辑客户人员信息成功!";
                    return RedirectToAction("details", "customercompany", new { id = model.CompanyID });
                }
                catch (Exception ex)
                {
                    result.Message = "编辑客户人员信息失败!";
                    result.AddServiceError(Utilities.GetInnerMostException(ex));
                    LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "编辑客户人员信息失败!", ex);
                }

            }
            ViewBag.Data_JobID = Utilities.GetSelectListData(JobCateService.GetALL(), x => x.ID, x => x.CateName, model.JobID, true);
            return View(model);
        }
Esempio n. 30
0
 public ActionResult AjaxEdit(CustomerViewModel model)
 {
     ServiceResult result = new ServiceResult();
     if (!ModelState.IsValid)
     {
         result.Message = "表单输入有误,请仔细填写表单!";
         result.AddServiceError("表单输入有误,请仔细填写表单!");
     }
     else
     {
         try
         {
             CustomerService.Update(model);
             result.Message = "编辑客户人员信息成功!";
         }
         catch (Exception ex)
         {
             result.Message = "编辑客户人员信息失败!";
             result.AddServiceError(Utilities.GetInnerMostException(ex));
             LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "编辑客户人员信息失败!", ex);
         }
     }
     ViewBag.Data_JobID = Utilities.GetSelectListData(JobCateService.GetALL(), x => x.ID, x => x.CateName, model.JobID, true);
     return Json(result);
 }