private void button1_Click(object sender, EventArgs e) { if (alert != null) { switch (alert.提醒方式) { case 提醒方式.系统提示: bool f = AlertLogic.GetInstance().SetFlag(alert.ID, 1); if (!f) { MessageBox.Show("已阅置位失败!"); } else { this.Close(); } break; case 提醒方式.执行流程: DocObject doc = DocObjectLogic.GetInstance().GetDocObject(Convert.ToInt32(alert.备注)); if (doc != null) { TaskInfo task = TaskInfoLogic.GetInstance().GetTaskInfoByEntityId(doc.ID); if (task != null) { TaskStageLogic.GetInstance().SetReceiveToExec(task.Flow.Current.ID); } DocEditForm def = new DocEditForm(this.User, this.owner, doc.Form, doc, alert.ID); if (def.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.Close(); } } break; case 提醒方式.审批流程: DocObject doc2 = DocObjectLogic.GetInstance().GetDocObject(Convert.ToInt32(alert.备注)); if (doc2 != null) { TaskInfo task = TaskInfoLogic.GetInstance().GetTaskInfoByEntityId(doc2.ID); if (task != null) { TaskStageLogic.GetInstance().SetReceiveToExec(task.Flow.Current.ID); } DocEditForm def = new DocEditForm(this.User, this.owner, doc2.Form, doc2, alert.ID); if (def.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.Close(); } } break; default: break; } } }
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 button1_Click(object sender, EventArgs e) { DocObjectLogic dol = DocObjectLogic.GetInstance(); if (doc != null) { if (dol.UpdateDocObject(Document, this.User)) { MessageBox.Show("保存文档成功!"); if (appr > 0) { TaskInfo task = TaskInfoLogic.GetInstance().GetTaskInfoByEntityId(doc.ID); if (task != null) { bool flag = false; string err = ""; if (exeORapp == 0) { if (task.Flow.Execute()) { if (FlowLogic.GetInstance().UpdateFlow(task.Flow)) { if (TaskStageLogic.GetInstance().SetActualExec(task.Flow.Current.ID, this.User)) { flag = true; } else { err = "SetActualExec失败"; } } else { err = "UpdateFlow失败"; } } else { err = "Execute失败"; } } else if (exeORapp == 1) { if (task.Flow.Approve()) { if (FlowLogic.GetInstance().UpdateFlow(task.Flow)) { if (TaskStageLogic.GetInstance().SetActualAppr(task.Flow.Current.ID, this.User)) { flag = true; } else { err = "SetActualAppr失败"; } } else { err = "UpdateFlow失败"; } } else { err = "Approve失败"; } } if (flag) { AlertLogic.GetInstance().SetFlag(appr, 1); MessageBox.Show("执行审批成功!"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("执行审批失败。[exeORapp=" + exeORapp + ", err=" + err + "]"); } } else { MessageBox.Show("执行审批失败。"); } } else { this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else { MessageBox.Show("保存文档失败或者您没有权限修改别人的文档!"); } } else { int id = dol.AddDocObject(Document); if (id > 0) { doc.ID = id; MessageBox.Show("新建文档成功!如果需要对该文档做流程,请在右下角点击【设置审批】来生成流程!"); } else { MessageBox.Show("新建文档失败!"); } } }
private void Next() { if (listBox1.SelectedIndex > -1) { FlowTemplate temp = listBox1.SelectedItem as FlowTemplate; if (temp != null) { List <TaskStage> stages = new List <TaskStage>(); foreach (TaskStageTemplate stage in temp.Stages) { TaskStage s = new TaskStage(0, stage.Name, stage, TaskStatus.Initiative, "", "", DateTime.MinValue, DateTime.MinValue, ""); int i = TaskStageLogic.GetInstance().AddTaskStage(s); if (i > 0) { s.ID = i; stages.Add(s); } } string docName = doc.Name; Flow flow = new Flow(0, docName + "(" + temp.Name + ")", temp, -1, "", stages); int r = FlowLogic.GetInstance().AddFlow(flow); if (r > 0) { flow.ID = r; if (FlowLogic.GetInstance().StartFlow(r)) { flow.StartFlow(); TaskInfo task = new TaskInfo(0, doc.ID, flow, this.User.Username, "创建时间:" + DateTime.Now.ToString()); if (TaskInfoLogic.GetInstance().AddTaskInfo(task) > 0) { MessageBox.Show("建立流程任务成功!"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("建立流程任务失败!"); this.DialogResult = System.Windows.Forms.DialogResult.Ignore; } } else { MessageBox.Show("启动流程失败!"); this.DialogResult = System.Windows.Forms.DialogResult.Ignore; } } else { MessageBox.Show("建立流程到数据库失败!"); this.DialogResult = System.Windows.Forms.DialogResult.Ignore; } //this.Close(); } else { MessageBox.Show("您选择的流程模板为空!"); } } else { MessageBox.Show("请先选择一个流程模板!"); } }