private void RemoveNode(TaskStageTemplate selected) { if (nodes.Remove(selected)) { RefreshLayout(); } }
void nc_Selected(object sender, NodeArgs e) { NodeControl nc = sender as NodeControl; TaskStageTemplate tmp = nc.Tag as TaskStageTemplate; bool canceled = false; if (tmp == selected) { canceled = true; selected = null; } else { selected = tmp; } foreach (Control c in panel2.Controls) { if (c is NodeControl) { NodeControl ncc = c as NodeControl; TaskStageTemplate node = ncc.Tag as TaskStageTemplate; if (!canceled && node == selected) { ncc.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; } else { ncc.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; } } } }
public List <FlowTemplate> GetAllFlowTemplates() { List <FlowTemplate> elements = new List <FlowTemplate>(); string sql = "select * from FlowTemplate"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageTemplateLogic tsl = TaskStageTemplateLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { List <TaskStageTemplate> stages = new List <TaskStageTemplate>(); string stageIds = dt.Rows[i]["Stages"].ToString(); List <string> idList = Flow.GetSatges(stageIds); foreach (string id in idList) { TaskStageTemplate stage = tsl.GetTaskStageTemplate(Convert.ToInt32(id)); if (stage != null) { stages.Add(stage); } } FlowTemplate element = new FlowTemplate(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), stages); elements.Add(element); } } return(elements); }
public bool DeleteTaskStageTemplate(TaskStageTemplate element) { string sql = "delete from TaskStageTemplate where ID=" + element.ID; int r = sqlHelper.ExecuteSql(sql); return(r > 0); }
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); }
public bool UpdateTaskStageTemplate(TaskStageTemplate element) { string sql = "update TaskStageTemplate set Name='" + element.Name + "', Executors='" + element.Executors + "', Approvers='" + element.Approvers + "' where ID=" + element.ID; int r = sqlHelper.ExecuteSql(sql); return(r > 0); }
private void UpdateNode(int index, TaskStageTemplate node) { if (index > -1) { nodes[index] = node; RefreshLayout(); } }
private void UpdateNode(int id, TaskStageTemplate node) { int index = nodes.FindIndex(a => a.ID == id); if (index > -1) { nodes[index] = node; RefreshLayout(); } }
private void SetTemplate(TaskStageTemplate value) { if (value != null) { templateId = value.ID; textBox1.Text = value.Name; depUserControlEx1.SelectedUsers = GetUsers(value.Executors); depUserControlEx2.SelectedUsers = GetUsers(value.Approvers); } }
public TaskStageTemplate GetTaskStageTemplate(int id) { string sql = "select * from TaskStageTemplate where ID=" + id; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageTemplate element = new TaskStageTemplate(Convert.ToInt32(dt.Rows[0]["ID"]), dt.Rows[0]["Name"].ToString(), TaskStage.GetUsers(dt.Rows[0]["Executors"].ToString()), TaskStage.GetUsers(dt.Rows[0]["Approvers"].ToString())); return(element); } return(null); }
public int AddTaskStageTemplate(TaskStageTemplate element) { string sql = "insert into TaskStageTemplate (Name, Executors, Approvers) values ('" + element.Name + "', '" + TaskStage.GetUserIds(element.Executors) + "', '" + TaskStage.GetUserIds(element.Approvers) + "'); select SCOPE_IDENTITY()"; object obj = sqlHelper.ExecuteSqlReturn(sql); int R; if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R)) { return(R); } else { return(0); } }
public List <TaskStageTemplate> GetTaskStageTemplatesByApprover(User user) { List <TaskStageTemplate> elements = new List <TaskStageTemplate>(); string sql = "select * from TaskStageTemplate where ','+Approvers+',' like '%," + user.ID + ",%'"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { TaskStageTemplate element = new TaskStageTemplate(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), TaskStage.GetUsers(dt.Rows[i]["Executors"].ToString()), TaskStage.GetUsers(dt.Rows[i]["Approvers"].ToString())); elements.Add(element); } } return(elements); }
private void RefreshLayout() { panel2.SuspendLayout(); panel2.Controls.Clear(); int x = left; int y = top; int offset = 0; int nextPos = left; int nextPosY = 0; for (int i = 0; i < nodes.Count; i++) { TaskStageTemplate node = nodes[i]; LinkControl lc = new LinkControl(); lc.Index = i; NodeControl nc = new NodeControl(); nc.Index = i; nc.NodeName = node.Name; nc.Selected += new EventHandler <NodeArgs>(nc_Selected); offset = nc.Width + lc.Width + interval; int cols = nextPos % this.Width; int rows = (nextPos + offset) / this.Width; if (rows > 0) { nextPosY++; x = left; } else { x = cols; if (cols < offset) { x = left; } } nextPos = x + offset; int maxHeight = Math.Max(nc.Height, lc.Height); y = top + (maxHeight + interval) * nextPosY; lc.Location = new Point(x, y); nc.Location = new Point(x + lc.Width, y); nc.Tag = node; panel2.Controls.Add(lc); panel2.Controls.Add(nc); } panel2.ResumeLayout(true); }
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 List <FlowTemplate> GetFlowTemplates(string name, int stageCount) { List <FlowTemplate> elements = new List <FlowTemplate>(); string where = "where (1=1)"; if (!string.IsNullOrEmpty(name)) { where += " and Name like '%" + name + "%'"; } string sql = "select * from FlowTemplate " + where + " order by ID desc"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageTemplateLogic tsl = TaskStageTemplateLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { List <TaskStageTemplate> stages = new List <TaskStageTemplate>(); string stageIds = dt.Rows[i]["Stages"].ToString(); List <string> idList = Flow.GetSatges(stageIds); if (idList.Count == stageCount) { foreach (string id in idList) { TaskStageTemplate stage = tsl.GetTaskStageTemplate(Convert.ToInt32(id)); if (stage != null) { stages.Add(stage); } } FlowTemplate element = new FlowTemplate(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), stages); elements.Add(element); } } } return(elements); }
public List <FlowTemplate> GetFlowTemplates(string where) { List <FlowTemplate> elements = new List <FlowTemplate>(); if (!string.IsNullOrEmpty(where)) { string w = where.Trim().ToLower(); if (!w.StartsWith("where ")) { w = "where " + w; } string sql = "select * from FlowTemplate " + w + " order by ID desc"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageTemplateLogic tsl = TaskStageTemplateLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { List <TaskStageTemplate> stages = new List <TaskStageTemplate>(); string stageIds = dt.Rows[i]["Stages"].ToString(); List <string> idList = Flow.GetSatges(stageIds); foreach (string id in idList) { TaskStageTemplate stage = tsl.GetTaskStageTemplate(Convert.ToInt32(id)); if (stage != null) { stages.Add(stage); } } FlowTemplate element = new FlowTemplate(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), stages); elements.Add(element); } } } return(elements); }
public FlowTemplate GetFlowTemplate(int id) { string sql = "select * from FlowTemplate where ID=" + id; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageTemplateLogic tsl = TaskStageTemplateLogic.GetInstance(); List <TaskStageTemplate> stages = new List <TaskStageTemplate>(); string stageIds = dt.Rows[0]["Stages"].ToString(); List <string> idList = Flow.GetSatges(stageIds); foreach (string idStr in idList) { TaskStageTemplate stage = tsl.GetTaskStageTemplate(Convert.ToInt32(idStr)); if (stage != null) { stages.Add(stage); } } FlowTemplate element = new FlowTemplate(Convert.ToInt32(dt.Rows[0]["ID"]), dt.Rows[0]["Name"].ToString(), stages); return(element); } return(null); }
private void LoadItems(List <FormItem> items) { if (items != null) { panel2.SuspendLayout(); panel2.Controls.Clear(); for (int i = 0; i < items.Count; i++) { FormItem item = items[i]; if (doc == null) { SystemType type = Commons.GetSystemType(item.ItemType); switch (type) { case SystemType.附件: break; case SystemType.时间: item.ItemValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case SystemType.数字: item.ItemValue = "0.00"; break; case SystemType.字符: item.ItemValue = string.Empty; break; default: break; } } DocEditControl dec = new DocEditControl(); dec.Field = item; dec.Location = new Point(width, height + (height + dec.Height) * i); dec.Width = panel2.Width - width * 2; dec.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; dec.comboBox1.Enabled = (doc == null); if (!dec.comboBox1.Enabled) {//已经存在的文档,限制编辑 bool canEdit = false; bool isAppr; int level; dec.GetExecAppr(out isAppr, out level); TaskInfo task = TaskInfoLogic.GetInstance().GetTaskInfoByEntityId(doc.ID); if (task != null) { TaskStageTemplate stageTemp = task.Flow.Template.Stages[task.Flow.CurrentIndex]; TaskStatus currentStatus = task.Flow.Current.Status; if (level == 0) { if (task.Sponsor == this.User.Username && currentStatus == TaskStatus.Initiative) { canEdit = true;//只有未被接收(即初始化状态)的文档允许文档发起者修改普通字段 } } else//level>0是执行字段和审批字段... { if (isAppr)//审批 { if (stageTemp.Approvers.Contains(this.User.ID.ToString()) && currentStatus == TaskStatus.Processed) { canEdit = true; } } else//执行 { if (stageTemp.Executors.Contains(this.User.ID.ToString()) && currentStatus == TaskStatus.Processing) { canEdit = true; } } } } else { canEdit = true;//没启动流程之前的文档可以修改任何字段 } dec.CanEdit = canEdit; } panel2.Controls.Add(dec); } panel2.ResumeLayout(true); } }
private void AddNode(TaskStageTemplate node) { nodes.Add(node); RefreshLayout(); }