public ContentResult Update() { ResultData <string> rt = new ResultData <string>(); BBusinessPartner bp = GetUpdate <BBusinessPartner>(); //非空验证和属性格式验证 string msg = bpService.CheckBusinessPartner(bp); if (!string.IsNullOrEmpty(msg)) { rt.message = msg; rt.status = -1; return(ReturnResult(rt)); } //验证用户是否存在 if (bpService.IsNotExits(bp, false)) { bp.UpdateDate = DateTime.Now; bp.UpdateBy = this.CurrentUser.ID; bpService.UpdateBusinessPartner(bp); } else { rt.status = -1; rt.message = "业务伙伴编码已经存在."; } return(ReturnResult(rt)); }
public ContentResult Delete() { ResultData <string> rt = new ResultData <string>(); //获取前台传会的删除ID BBusinessPartner bp = GetDelete <BBusinessPartner>(); bpService.RemoveBusinessPartner(bp); rt.message = "删除成功."; return(ReturnResult(rt)); }
/// <summary> /// 检查非空验证 /// </summary> /// <param name="BusinessPartner"></param> public string CheckBusinessPartner(BBusinessPartner bPartner) { string msg = string.Empty; if (string.IsNullOrWhiteSpace(bPartner.BusinessPartnerCode)) { msg = "业务伙伴编码不能为空."; return(msg); } if (string.IsNullOrWhiteSpace(bPartner.BusinessPartnerName)) { msg = "业务伙伴名称不能为空."; return(msg); } if (!string.IsNullOrWhiteSpace(bPartner.Mail)) { if (!ESCRegex.IsEmail(bPartner.Mail)) { msg = "邮箱格式错误."; return(msg); } } if (!string.IsNullOrWhiteSpace(bPartner.Fax)) { if (!ESCRegex.IsFax(bPartner.Fax)) { msg = "传真格式错误."; return(msg); } } if (!string.IsNullOrWhiteSpace(bPartner.Mobile)) { if (!ESCRegex.IsMobile(bPartner.Mobile)) { msg = "电话格式错误."; return(msg); } } return(msg); }
/// <summary> /// 业务伙伴是否存在 /// </summary> /// <param name="bPartner"></param> /// <param name="isAdd"></param> public bool IsNotExits(BBusinessPartner bPartner, bool isAdd) { return(bpRepository.IsNotExits(bPartner, isAdd)); }
/// <summary> /// 更新业务伙伴 /// </summary> /// <param name="bPartner"></param> /// <returns></returns> public bool UpdateBusinessPartner(BBusinessPartner bPartner) { return(bpRepository.Update(bPartner)); }
/// <summary> /// 删除业务伙伴 /// </summary> /// <param name="bPartner"></param> /// <returns></returns> public bool RemoveBusinessPartner(BBusinessPartner bPartner) { //删除业务伙伴 return(bpRepository.Delete(bPartner)); }
/// <summary> /// 插入新业务伙伴 /// </summary> /// <param name="bPartner"></param> /// <returns></returns> public int AddBusinessPartner(BBusinessPartner bPartner) { object result = bpRepository.Insert(bPartner); return(Convert.ToInt32(result)); }