private void BtnFailed_Click(object sender, EventArgs e)
        {
            cost_main Main = new cost_main
            {
                id     = costId,
                status = 3
            };
            List <cost_approval> ListApproval = new List <cost_approval>();
            cost_approval        approval     = new cost_approval
            {
                cost_id     = costId,
                approval_id = UserInfoBLL.UserId,
                result      = false,
                time        = DateTime.Now,
                opinion     = TexOpinion.Text
            };

            ListApproval.Add(approval);
            Result res = new CostApprovalBLL().Update(new cost
            {
                Main         = Main,
                ApprovalList = ListApproval
            });

            MessageBox.Show(res.Message, "操作结果提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Example #2
0
        /// <summary>
        /// 添加费用单
        /// </summary>
        /// <param name="cost">费用单主表对象 Main:apply_id、apply_money、status、apply_time、remark
        /// 费用单审批详情列表 ApprovalList:approval_id
        /// 费用详情列表 DetailList:cost_type、money</param>
        /// <returns>数据表受影响的行数</returns>
        public int Add(cost cost)
        {
            cost_main          Main       = cost.Main;
            List <cost_detail> DetailList = cost.DetailList;

            //先构造所有的sql语句
            string[] sqlArray = new string[2 + DetailList.Count];
            //构造插入cost_main、cost_approval表的语句
            int timeStamp = TimeTools.Timestamp();

            Main.id     = timeStamp;//主键(费用单id)是时间戳
            sqlArray[0] = ConditionsToSql <cost_main> .InsertSql(Main);

            //插入cost_approval表时,鉴于审核逻辑的关系,最多一次插入一个
            cost_approval Approval = cost.ApprovalList.First();

            Approval.cost_id = timeStamp;
            sqlArray[1]      = ConditionsToSql <cost_approval> .InsertSql(Approval);

            //构造插入cost_detail表语句
            int count = 1;

            foreach (cost_detail detail in DetailList)
            {
                detail.cost_id      = timeStamp;
                sqlArray[count + 1] = ConditionsToSql <cost_detail> .InsertSql(detail);

                count++;
            }
            //调用方法以事务方式执行sql数组里的语句
            return(sqlArrayToTran.doTran(sqlArray));
        }
        private void BtnPass_Click(object sender, EventArgs e)
        {
            if (CmbNextApprover.Visible && CmbNextApprover.SelectedItem == null)
            {
                MessageBox.Show("请选择一个上级审批人!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            cost_main Main = new cost_main
            {
                id     = costId,
                status = (byte)(CmbNextApprover.Visible ? 1 : 2)
            };

            List <cost_approval> ListApproval = new List <cost_approval>();
            cost_approval        approval     = new cost_approval
            {
                cost_id     = costId,
                approval_id = UserInfoBLL.UserId,
                result      = true,
                time        = DateTime.Now,
                opinion     = TexOpinion.Text
            };

            ListApproval.Add(approval);
            if (CmbNextApprover.Visible)
            {
                ListApproval.Add(new cost_approval
                {
                    cost_id     = costId,
                    approval_id = int.Parse(CmbNextApprover.SelectedItem.ToString().Split('.')[0])
                });
            }
            Result res = new CostApprovalBLL().Update(new cost
            {
                Main         = Main,
                ApprovalList = ListApproval
            });

            MessageBox.Show(res.Message, "操作结果提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Example #4
0
        /// <summary>
        /// 费用审批添加/修改 、审批状态(待审批,通过,驳回)以及审批意见
        /// </summary>
        /// <param name="cost">费用单主表对象Main:id、status
        /// DetailList 费用详情列表:
        /// ApprovalList 费用审批表列表:详见方法体注释</param>
        /// <returns>数据表受影响行数</returns>
        public int Update(cost cost)
        {
            /*
             * ApprovalList最多只有两个元素(前端并不会将已审核通过的cost_approval对象封装到此列表)
             * 第一个元素是正在审批的cost_approval对象:
             * 第二个元素是需要再提交到上级进行审批的cost_approval对象
             */
            string[] sqlArray = new string[1 + cost.ApprovalList.Count];
            sqlArray[0] = "update cost_main set " +
                          nameof(cost_main.status) + "='" + cost.Main.status + "' where id='" + cost.Main.id + "'";
            cost_approval approvalFirst = cost.ApprovalList.First();

            sqlArray[1] = "update cost_approval set result=" + ((bool)approvalFirst.result?1:0) +
                          ",time='" + approvalFirst.time + "',opinion=N'" + approvalFirst.opinion
                          + "' where cost_id='" + approvalFirst.cost_id + "' and approval_id='" + approvalFirst.approval_id + "'";
            if (sqlArray.Length > 2)
            {
                sqlArray[2] = ConditionsToSql <cost_approval> .InsertSql(cost.ApprovalList[1]);
            }
            return(sqlArrayToTran.doTran(sqlArray));
        }
Example #5
0
        /// <summary>
        /// 根据费用单id查询审批详情列表
        /// </summary>
        /// <param name="costId"></param>
        /// <returns></returns>
        public List <cost_approval> QueryApproval(int costId)
        {
            List <cost_approval> ListApproval = new List <cost_approval>();
            string    sql       = "select * from cost_approval where cost_id=" + costId;
            DataTable dataTable = SqlHelper.ExecuteDataset(ConStr, CommandType.Text, sql).Tables[0];

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                DataRow       row      = dataTable.Rows[i];
                cost_approval approval = new cost_approval
                {
                    id          = (int)row["id"],
                    cost_id     = (int)row["cost_id"],
                    approval_id = (int)row["approval_id"]
                };
                approval.result  = (bool?)ConvertTools.DbNullConvert(row["result"]);
                approval.time    = (DateTime?)ConvertTools.DbNullConvert(row["time"]);
                approval.opinion = (string)ConvertTools.DbNullConvert(row["opinion"]);
                ListApproval.Add(approval);
            }
            return(ListApproval);
        }