public List <TaskStage> GetAllTaskStages() { List <TaskStage> elements = new List <TaskStage>(); string sql = "select * from TaskStage"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageTemplateLogic tstl = TaskStageTemplateLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { TaskStageTemplate template = tstl.GetTaskStageTemplate(Convert.ToInt32(dt.Rows[i]["TemplateID"])); string ActualAppr = ""; if (dt.Rows[i]["ActualAppr"] != null && dt.Rows[i]["ActualAppr"] != DBNull.Value) { ActualAppr = dt.Rows[0]["ActualAppr"].ToString(); } string ActualExec = ""; if (dt.Rows[i]["ActualExec"] != null && dt.Rows[i]["ActualExec"] != DBNull.Value) { ActualExec = dt.Rows[0]["ActualExec"].ToString(); } DateTime ApprTime = DateTime.MinValue; if (dt.Rows[i]["ApprTime"] != null && dt.Rows[i]["ApprTime"] != DBNull.Value) { ApprTime = Convert.ToDateTime(dt.Rows[i]["ApprTime"]); } DateTime ExecTime = DateTime.MinValue; if (dt.Rows[i]["ExecTime"] != null && dt.Rows[i]["ExecTime"] != DBNull.Value) { ExecTime = Convert.ToDateTime(dt.Rows[i]["ExecTime"]); } TaskStage element = new TaskStage(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), template, TaskStage.GetTaskStatus(Convert.ToInt32(dt.Rows[i]["TaskStatus"])), ActualExec, ActualAppr, ExecTime, ApprTime, dt.Rows[i]["Remark"].ToString()); elements.Add(element); } } return(elements); }
public TaskStage GetTaskStage(int id) { string sql = "select * from TaskStage where ID=" + id; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageTemplate template = TaskStageTemplateLogic.GetInstance().GetTaskStageTemplate(Convert.ToInt32(dt.Rows[0]["TemplateID"])); string ActualAppr = ""; if (dt.Rows[0]["ActualAppr"] != null && dt.Rows[0]["ActualAppr"] != DBNull.Value) { ActualAppr = dt.Rows[0]["ActualAppr"].ToString(); } string ActualExec = ""; if (dt.Rows[0]["ActualExec"] != null && dt.Rows[0]["ActualExec"] != DBNull.Value) { ActualExec = dt.Rows[0]["ActualExec"].ToString(); } DateTime ApprTime = DateTime.MinValue; if (dt.Rows[0]["ApprTime"] != null && dt.Rows[0]["ApprTime"] != DBNull.Value) { ApprTime = Convert.ToDateTime(dt.Rows[0]["ApprTime"]); } DateTime ExecTime = DateTime.MinValue; if (dt.Rows[0]["ExecTime"] != null && dt.Rows[0]["ExecTime"] != DBNull.Value) { ExecTime = Convert.ToDateTime(dt.Rows[0]["ExecTime"]); } TaskStage element = new TaskStage(Convert.ToInt32(dt.Rows[0]["ID"]), dt.Rows[0]["Name"].ToString(), template, TaskStage.GetTaskStatus(Convert.ToInt32(dt.Rows[0]["TaskStatus"])), ActualExec, ActualAppr, ExecTime, ApprTime, dt.Rows[0]["Remark"].ToString()); return(element); } return(null); }