/// <summary> /// 将DataRedar转换为List /// </summary> private List <Data.Model.WorkFlowButtons> DataReaderToList(SqlDataReader dataReader) { List <Data.Model.WorkFlowButtons> List = new List <Data.Model.WorkFlowButtons>(); Data.Model.WorkFlowButtons model = null; while (dataReader.Read()) { model = new Data.Model.WorkFlowButtons(); model.ID = dataReader.GetGuid(0); model.Title = dataReader.GetString(1); if (!dataReader.IsDBNull(2)) { model.Ico = dataReader.GetString(2); } if (!dataReader.IsDBNull(3)) { model.Script = dataReader.GetString(3); } if (!dataReader.IsDBNull(4)) { model.Note = dataReader.GetString(4); } model.Sort = dataReader.GetInt32(5); List.Add(model); } return(List); }
public ActionResult Edit(FormCollection collection) { Business.Platform.WorkFlowButtons bworkFlowButtons = new Business.Platform.WorkFlowButtons(); Data.Model.WorkFlowButtons workFlowButton = null; string id = Request.QueryString["id"]; string title = string.Empty; string ico = string.Empty; string script = string.Empty; string note = string.Empty; Guid buttionID; if (id.IsGuid(out buttionID)) { workFlowButton = bworkFlowButtons.Get(buttionID); } string oldXML = workFlowButton.Serialize(); if (collection != null) { title = Request.Form["Title"]; ico = Request.Form["Ico"]; script = Request.Form["Script"]; note = Request.Form["Note"]; bool isAdd = !id.IsGuid(); if (workFlowButton == null) { workFlowButton = new Data.Model.WorkFlowButtons(); workFlowButton.ID = Guid.NewGuid(); workFlowButton.Sort = bworkFlowButtons.GetMaxSort(); } workFlowButton.Ico = ico.IsNullOrEmpty() ? null : ico.Trim(); workFlowButton.Note = note.IsNullOrEmpty() ? null : note.Trim(); workFlowButton.Script = script.IsNullOrEmpty() ? null : script; workFlowButton.Title = title.Trim(); if (isAdd) { bworkFlowButtons.Add(workFlowButton); Business.Platform.Log.Add("添加了流程按钮", workFlowButton.Serialize(), Business.Platform.Log.Types.流程相关); } else { bworkFlowButtons.Update(workFlowButton); Business.Platform.Log.Add("修改了流程按钮", "", Business.Platform.Log.Types.流程相关, oldXML, workFlowButton.Serialize()); } bworkFlowButtons.ClearCache(); ViewBag.Script = "new RoadUI.Window().reloadOpener();alert('保存成功!');new RoadUI.Window().close();"; } return(View(workFlowButton == null ? new Data.Model.WorkFlowButtons() : workFlowButton)); }
/// <summary> /// 更新记录 /// </summary> /// <param name="model">Data.Model.WorkFlowButtons实体类</param> public int Update(Data.Model.WorkFlowButtons model) { string sql = @"UPDATE WorkFlowButtons SET Title=@Title,Ico=@Ico,Script=@Script,Note=@Note,Sort=@Sort WHERE ID=@ID" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Title", SqlDbType.NVarChar, 1000) { Value = model.Title }, model.Ico == null ? new SqlParameter("@Ico", SqlDbType.VarChar, 500) { Value = DBNull.Value } : new SqlParameter("@Ico", SqlDbType.VarChar, 500) { Value = model.Ico }, model.Script == null ? new SqlParameter("@Script", SqlDbType.VarChar, -1) { Value = DBNull.Value } : new SqlParameter("@Script", SqlDbType.VarChar, -1) { Value = model.Script }, model.Note == null ? new SqlParameter("@Note", SqlDbType.VarChar, -1) { Value = DBNull.Value } : new SqlParameter("@Note", SqlDbType.VarChar, -1) { Value = model.Note }, new SqlParameter("@Sort", SqlDbType.Int, -1) { Value = model.Sort }, new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1) { Value = model.ID } }; return(dbHelper.Execute(sql, parameters)); }
/// <summary> /// 添加记录 /// </summary> /// <param name="model">Data.Model.WorkFlowButtons实体类</param> /// <returns>操作所影响的行数</returns> public int Add(Data.Model.WorkFlowButtons model) { string sql = @"INSERT INTO WorkFlowButtons (ID,Title,Ico,Script,Note,Sort) VALUES(@ID,@Title,@Ico,@Script,@Note,@Sort)" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1) { Value = model.ID }, new SqlParameter("@Title", SqlDbType.NVarChar, 1000) { Value = model.Title }, model.Ico == null ? new SqlParameter("@Ico", SqlDbType.VarChar, 500) { Value = DBNull.Value } : new SqlParameter("@Ico", SqlDbType.VarChar, 500) { Value = model.Ico }, model.Script == null ? new SqlParameter("@Script", SqlDbType.VarChar, -1) { Value = DBNull.Value } : new SqlParameter("@Script", SqlDbType.VarChar, -1) { Value = model.Script }, model.Note == null ? new SqlParameter("@Note", SqlDbType.VarChar, -1) { Value = DBNull.Value } : new SqlParameter("@Note", SqlDbType.VarChar, -1) { Value = model.Note }, new SqlParameter("@Sort", SqlDbType.Int, -1) { Value = model.Sort } }; return(dbHelper.Execute(sql, parameters)); }
/// <summary> /// 更新 /// </summary> public int Update(Data.Model.WorkFlowButtons model) { return(dataWorkFlowButtons.Update(model)); }
/// <summary> /// 新增 /// </summary> public int Add(Data.Model.WorkFlowButtons model) { return(dataWorkFlowButtons.Add(model)); }