/// <summary> /// 将DataRedar转换为List /// </summary> private List <Data.Model.WorkFlowDelegation> DataReaderToList(SqlDataReader dataReader) { List <Data.Model.WorkFlowDelegation> List = new List <Data.Model.WorkFlowDelegation>(); Data.Model.WorkFlowDelegation model = null; while (dataReader.Read()) { model = new Data.Model.WorkFlowDelegation(); model.ID = dataReader.GetGuid(0); model.UserID = dataReader.GetGuid(1); model.StartTime = dataReader.GetDateTime(2); model.EndTime = dataReader.GetDateTime(3); if (!dataReader.IsDBNull(4)) { model.FlowID = dataReader.GetGuid(4); } model.ToUserID = dataReader.GetGuid(5); model.WriteTime = dataReader.GetDateTime(6); if (!dataReader.IsDBNull(7)) { model.Note = dataReader.GetString(7); } List.Add(model); } return(List); }
/// <summary> /// 更新记录 /// </summary> /// <param name="model">Data.Model.WorkFlowDelegation实体类</param> public int Update(Data.Model.WorkFlowDelegation model) { string sql = @"UPDATE WorkFlowDelegation SET UserID=@UserID,StartTime=@StartTime,EndTime=@EndTime,FlowID=@FlowID,ToUserID=@ToUserID,WriteTime=@WriteTime,Note=@Note WHERE ID=@ID" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@UserID", SqlDbType.UniqueIdentifier, -1) { Value = model.UserID }, new SqlParameter("@StartTime", SqlDbType.DateTime, 8) { Value = model.StartTime }, new SqlParameter("@EndTime", SqlDbType.DateTime, 8) { Value = model.EndTime }, model.FlowID == null ? new SqlParameter("@FlowID", SqlDbType.UniqueIdentifier, -1) { Value = DBNull.Value } : new SqlParameter("@FlowID", SqlDbType.UniqueIdentifier, -1) { Value = model.FlowID }, new SqlParameter("@ToUserID", SqlDbType.UniqueIdentifier, -1) { Value = model.ToUserID }, new SqlParameter("@WriteTime", SqlDbType.DateTime, 8) { Value = model.WriteTime }, model.Note == null ? new SqlParameter("@Note", SqlDbType.NVarChar, 8000) { Value = DBNull.Value } : new SqlParameter("@Note", SqlDbType.NVarChar, 8000) { Value = model.Note }, new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1) { Value = model.ID } }; return(dbHelper.Execute(sql, parameters)); }
/// <summary> /// 添加记录 /// </summary> /// <param name="model">Data.Model.WorkFlowDelegation实体类</param> /// <returns>操作所影响的行数</returns> public int Add(Data.Model.WorkFlowDelegation model) { string sql = @"INSERT INTO WorkFlowDelegation (ID,UserID,StartTime,EndTime,FlowID,ToUserID,WriteTime,Note) VALUES(@ID,@UserID,@StartTime,@EndTime,@FlowID,@ToUserID,@WriteTime,@Note)" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1) { Value = model.ID }, new SqlParameter("@UserID", SqlDbType.UniqueIdentifier, -1) { Value = model.UserID }, new SqlParameter("@StartTime", SqlDbType.DateTime, 8) { Value = model.StartTime }, new SqlParameter("@EndTime", SqlDbType.DateTime, 8) { Value = model.EndTime }, model.FlowID == null ? new SqlParameter("@FlowID", SqlDbType.UniqueIdentifier, -1) { Value = DBNull.Value } : new SqlParameter("@FlowID", SqlDbType.UniqueIdentifier, -1) { Value = model.FlowID }, new SqlParameter("@ToUserID", SqlDbType.UniqueIdentifier, -1) { Value = model.ToUserID }, new SqlParameter("@WriteTime", SqlDbType.DateTime, 8) { Value = model.WriteTime }, model.Note == null ? new SqlParameter("@Note", SqlDbType.NVarChar, 8000) { Value = DBNull.Value } : new SqlParameter("@Note", SqlDbType.NVarChar, 8000) { Value = model.Note } }; return(dbHelper.Execute(sql, parameters)); }
/// <summary> /// 更新 /// </summary> public int Update(Data.Model.WorkFlowDelegation model) { return(dataWorkFlowDelegation.Update(model)); }
/// <summary> /// 新增 /// </summary> public int Add(Data.Model.WorkFlowDelegation model) { return(dataWorkFlowDelegation.Add(model)); }
public ActionResult Edit(FormCollection collection) { Business.Platform.WorkFlowDelegation bworkFlowDelegation = new Business.Platform.WorkFlowDelegation(); Data.Model.WorkFlowDelegation workFlowDelegation = null; string id = Request.QueryString["id"]; string UserID = string.Empty; string ToUserID = string.Empty; string StartTime = string.Empty; string EndTime = string.Empty; string FlowID = string.Empty; string Note = string.Empty; bool isOneSelf = "1" == Request.QueryString["isoneself"]; Guid delegationID; if (id.IsGuid(out delegationID)) { workFlowDelegation = bworkFlowDelegation.Get(delegationID); if (workFlowDelegation != null) { FlowID = workFlowDelegation.FlowID.ToString(); } } string oldXML = workFlowDelegation.Serialize(); if (collection != null) { UserID = Request.Form["UserID"]; ToUserID = Request.Form["ToUserID"]; StartTime = Request.Form["StartTime"]; EndTime = Request.Form["EndTime"]; FlowID = Request.Form["FlowID"]; Note = Request.Form["Note"]; bool isAdd = !id.IsGuid(); if (workFlowDelegation == null) { workFlowDelegation = new Data.Model.WorkFlowDelegation(); workFlowDelegation.ID = Guid.NewGuid(); } workFlowDelegation.UserID = isOneSelf ? Business.Platform.Users.CurrentUserID : Business.Platform.Users.RemovePrefix(UserID).ToGuid(); workFlowDelegation.EndTime = EndTime.ToDateTime(); if (FlowID.IsGuid()) { workFlowDelegation.FlowID = FlowID.ToGuid(); } workFlowDelegation.Note = Note.IsNullOrEmpty() ? null : Note; workFlowDelegation.StartTime = StartTime.ToDateTime(); workFlowDelegation.ToUserID = Business.Platform.Users.RemovePrefix(ToUserID).ToGuid(); workFlowDelegation.WriteTime = Utility.DateTimeNew.Now; if (isAdd) { bworkFlowDelegation.Add(workFlowDelegation); Business.Platform.Log.Add("添加了工作委托", workFlowDelegation.Serialize(), Business.Platform.Log.Types.流程相关); } else { bworkFlowDelegation.Update(workFlowDelegation); Business.Platform.Log.Add("修改了工作委托", "", Business.Platform.Log.Types.流程相关, oldXML, workFlowDelegation.Serialize()); } bworkFlowDelegation.RefreshCache(); ViewBag.Script = "alert('保存成功!');new RoadUI.Window().reloadOpener();"; } ViewBag.FlowOptions = new Business.Platform.WorkFlow().GetOptions(FlowID); return(View(workFlowDelegation == null ? new Data.Model.WorkFlowDelegation() { UserID = Business.Platform.Users.CurrentUserID } : workFlowDelegation)); }