Beispiel #1
0
        /// <summary>
        /// 获取审批流程最新情报并更新到画面
        /// </summary>
        /// <param name="flowTypeID"></param>
        private void refreshApprovalFlowTypeInfo(Guid flowTypeID)
        {
            string message;
            //获取描述信息
            var desp = PharmacyDatabaseService.GetApprovalFlowType(out message, flowTypeID).Decription;

            this.txtDecription.Text = desp;

            //获取节点信息
            var nodelist = PharmacyDatabaseService.AllApprovalFlowNodes(out message).Where(p => p.ApprovalFlowTypeId == flowTypeID).OrderBy(p => p.Order).ToList();

            if (nodelist != null)
            {
                this.dgvApprovalNodeList.AutoGenerateColumns = false;
                this.dgvApprovalNodeList.DataSource          = nodelist;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 保存更改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            //强制表格更新数据。
            this.dgvApprovalNodeList.EndEdit();

            //获取审批流程ID
            var flowTypeID = (Guid)lbApprovalFlowType.SelectedValue;

            var nodelist = this.dgvApprovalNodeList.DataSource as List <ApprovalFlowNode>;

            if (nodelist.Count == 0)
            {
                MessageBox.Show("不能删除所有的节点!");
                return;
            }
            else
            {
                foreach (var node in nodelist)
                {
                    if (string.IsNullOrWhiteSpace(node.Name))
                    {
                        MessageBox.Show("节点名字为必须字段!");
                        return;
                    }
                    if (node.RoleId == Guid.Empty)
                    {
                        MessageBox.Show("节点的权限为必须字段!");
                        return;
                    }
                }
            }

            //删除丢弃的节点信息
            string message;

            foreach (var node in PharmacyDatabaseService.AllApprovalFlowNodes(out message).Where(p => p.ApprovalFlowTypeId == flowTypeID).ToList())
            {
                //已经被删掉了的话,则删除
                if (nodelist.FirstOrDefault(p => p.Id == node.Id) == null)
                {
                    if (!PharmacyDatabaseService.DeleteApprovalFlowNode(out message, node.Id))
                    {
                        MessageBox.Show("保存失败!" + Environment.NewLine + message);
                    }
                    this.PharmacyDatabaseService.WriteLog(AppClientContext.CurrentUser.Id, node.Name + "审批流程删除成功!");
                }
            }

            foreach (var node in nodelist)
            {
                node.UpdateUserId = AppClientContext.CurrentUser.Id;
                node.UpdateTime   = DateTime.Now;
                //说明是新增的数据
                if (node.Id == Guid.Empty)
                {
                    node.Id           = Guid.NewGuid();
                    node.CreateTime   = DateTime.Now;
                    node.CreateUserId = AppClientContext.CurrentUser.Id;
                    if (!PharmacyDatabaseService.AddApprovalFlowNode(out message, node))
                    {
                        MessageBox.Show("保存失败!" + Environment.NewLine + message);
                        return;
                    }
                    this.PharmacyDatabaseService.WriteLog(AppClientContext.CurrentUser.Id, node.Name + "审批流程设置成功!");
                }
                else
                {
                    //更新序号
                    if (!PharmacyDatabaseService.SaveApprovalFlowNode(out message, node))
                    {
                        MessageBox.Show("保存失败!" + Environment.NewLine + message);
                        return;
                    }
                }
            }

            MessageBox.Show("保存成功!");
        }