public virtual bool SaveContractTemplate(CasContractTemplateEntity contractTemplateEntity, ref string strError) { contractTemplateEntity.LastModifiedBy = WebCaching.UserAccount; contractTemplateEntity.LastModifiedTime = DateTime.Now; try { var isExist = IsExist(contractTemplateEntity, ref strError); if (isExist) { //更新 if (Update(contractTemplateEntity)) { SaveContractTemplateAttachment(contractTemplateEntity); return(true); } } else { //新增 contractTemplateEntity.ContractTemplateId = Guid.NewGuid().ToString(); contractTemplateEntity.CreatedBy = WebCaching.UserAccount; contractTemplateEntity.CreateTime = DateTime.Now; if (Insert(contractTemplateEntity)) { SaveContractTemplateAttachment(contractTemplateEntity); return(true); } } } catch (Exception exception) { strError = exception.Message; } return(false); }
public virtual bool IsExist(CasContractTemplateEntity contractTemplateEntity, ref string strError) { if (contractTemplateEntity.ContractTemplateId == null) { return(false); } var strsql = new StringBuilder(); strsql.AppendFormat("SELECT 1 FROM CAS_CONTRACT_TEMPLATE WHERE CONTRACT_TEMPLATE_ID = {0}", Utils.ToSQLStr(contractTemplateEntity.ContractTemplateId).Trim()); var val = DataAccess.SelectScalar(strsql.ToString()); if (string.IsNullOrEmpty(val) || val != "1") { return(false); } strError = "该模板合同已经存在"; return(true); }
public ActionResult Edit(CasContractTemplateEntity entity, string id, string type) { if (type == "check") { ViewBag.Type = "3"; } string strError = ""; if (!IsPost) { entity = BusinessDataService.ContractTemplateService.CreateContractTemplateEntity("MDM"); if (!string.IsNullOrEmpty(id)) { entity = BusinessDataService.ContractTemplateService.GetById <CasContractTemplateEntity>(id); //编辑 ViewBag.EditType = "0"; } else { //新增 ViewBag.EditType = "1"; } } else { if (BusinessDataService.ContractTemplateService.SaveContractTemplate(entity, ref strError)) { return(Json(AjaxResult.Success())); } else { strError = "Update failed"; return(Json(AjaxResult.Success(strError))); } } ViewBag.strError = strError; return(View(entity)); }
/// <summary> /// 保存模板合同的附件 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool SaveContractTemplateAttachment(CasContractTemplateEntity entity) { if (!string.IsNullOrWhiteSpace(entity.fileIds)) { string[] filesids = entity.fileIds.ToString().Split(','); string sqlFileids = ""; for (int i = 0; i < filesids.Length; i++) //这个FOR循环就是加单引号 { filesids[i] = "'" + filesids[i] + "'"; sqlFileids = sqlFileids + filesids[i] + ","; } sqlFileids = sqlFileids.Substring(0, sqlFileids.Length - 1); var strsql = new StringBuilder(); strsql.AppendFormat("UPDATE CAS_ATTACHMENT SET SOURCE_ID='{0}' WHERE ATTACHMENT_ID IN ({1})", entity.ContractTemplateId, sqlFileids); var val = DataAccess.ExecuteNoneQuery(strsql.ToString()); if (val <= 0) { return(false); } return(true); } return(false); }
public ActionResult Delet(CasContractTemplateEntity entity, string id) { var a = BusinessDataService.ContractTemplateService.DeletecontractTemplate(id); return(Json(AjaxResult.Success())); }