public ActionResult Edit(string id) { #region 检查参数 string currentPage = string.IsNullOrWhiteSpace(Request["CurrentPage"]) ? "1" : Request["CurrentPage"]; string backUrl = "/Home/Client/Index?backType=1&CurrentPage=" + currentPage; ViewBag.backUrl = backUrl; if (string.IsNullOrWhiteSpace(id)) { return Redirect(backUrl); } #endregion ViewBag.Country = CommonMethod.GetCountryList(); #region 获取客户信息 ClientModel client = ClientModel.SingleOrDefault(id); if (null == client) { return Redirect(backUrl); } ClientViewModel model = new ClientViewModel(client); return View(model); #endregion }
public string Edit(ClientViewModel model) { if (ModelState.IsValid) { ClientModel client = ClientModel.SingleOrDefault(model.Id); client.Type = model.Type; //客户类别 client.ChName = model.ChName; //中文名称 client.EnName = model.EnName; //英文名称 client.ShortName = model.ShortName; //简称 client.Countryid = model.Countryid.ToInt(); //国家 client.Address = model.Address; //地址 client.Phone = model.Phone; //电话 client.Email = model.Email; //邮箱 client.Linkman = model.Linkman; //联系人 //如果当前的审批状态是“已提交” 则编辑后自动变成“变更待提交” if (model.ApprovalStatus == "3") { client.ApprovalStatus = "2"; #region 同时终止旧的单据审批记录 ApprovalDocumentModel.Update("set Next_RoleID = '-' where Table_Name = 'Sys_Client' and DocID = @0", model.Id); #endregion } //如果当前的审批状态是“已退回” 则编辑后自动变成“待提交” if (model.ApprovalStatus == "5") { client.ApprovalStatus = "1"; } client.Remark = model.Remark; //备注 client.ModifyMan = SysConfig.CurrentUser.Id; //修改人 client.ModifyTime = DateTime.Now; //修改时间 int result = client.Update(); if (result > 0) { //记录操作日志 CommonMethod.Log(SysConfig.CurrentUser.Id, "Update", "Sys_Client"); return "1"; } } return "0"; }
public string Add(ClientViewModel model) { #if DEBUG SysConfig.CurrentUser = UserModel.SingleOrDefault("3"); #endif if (ModelState.IsValid) { ClientModel client = new ClientModel(); client.No = CommonMethod.GetLatestSerialNo(SysConfig.SerialNo.ClientNo); //客户编号 client.Type = model.Type; //客户类别 client.ChName = model.ChName; //中文名称 client.EnName = model.EnName; //英文名称 client.ShortName = model.ShortName; //简称 client.Countryid = model.Countryid.ToInt(); //国家 client.Address = model.Address; //地址 client.Phone = model.Phone; //电话 client.Email = model.Email; //邮箱 client.Linkman = model.Linkman; //联系人 client.Remark = model.Remark; //备注 client.BelongsMan = CommonMethod.GetBelongsMan( //业务员 SysConfig.CurrentUser.Departmentid.ToString()); client.BelongsDepartment = CommonMethod.GetBelongsDepartment( //所属部门 SysConfig.CurrentUser.Departmentid.ToString()); ApprovalRuleModel rule = ApprovalRuleModel.FirstOrDefault(@"where Del_Flag = 0 and Doc_Type = 1 and DepartmentID = @0", client.BelongsDepartment); //如果没有审批规则 则直接生效 if (rule == null) { client.ApprovalStatus = "4"; //审批状态 4:已生效 } //如果有审批规则 则待提交 else { client.ApprovalStatus = "1"; //审批状态 1:待提交 } client.DelFlag = 0; //有效状态 client.CreateMan = SysConfig.CurrentUser.Id; //制单人 client.CreateTime = DateTime.Now; //制单时间 int result = client.Insert().ToInt(); if (result > 0) { //更新客户最大序列号 CommonMethod.UpdateSerialNo(SysConfig.SerialNo.ClientNo); //记录操作日志 CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Client"); CommonMethod.Log(SysConfig.CurrentUser.Id, "Update", "Sys_SerialNo"); return "1"; } } return "0"; }