示例#1
0
        /// <summary>
        /// 删除费用单信息
        /// </summary>
        /// <param name="id">费用单id</param>
        /// <returns>删除是否成功</returns>
        public Result Del(int id)
        {
            Result res = new Result()
            {
                Code    = RES.ERROR,
                Message = "删除失败"
            };
            CostApplyDAL apply = new CostApplyDAL();
            //获取该费用单的审批状态
            byte status = apply.QueryMain(new Dictionary <string, object>
            {
                { "id", id }
            }).First().status;

            //如果费用单不是未审批状态,则删除失败
            if (status != 0)
            {
                return(res);
            }
            List <cost_detail>   listDetail   = apply.QueryDetail(id);
            List <cost_approval> ListApproval = apply.QueryApproval(id);

            if (apply.Del(id) == ListApproval.Count + listDetail.Count + 1)
            {
                res.Code    = RES.OK;
                res.Message = "删除成功!";
            }
            return(res);
        }
示例#2
0
        private void CostPlanForm_Load(object sender, EventArgs e)
        {
            List <string> listCostType = new CostApplyDAL().GetCostTypes();

            foreach (string type in listCostType)
            {
                int index = this.DgvAddPlan.Rows.Add();
                this.DgvAddPlan.Rows[index].SetValues(type, 0);
            }
        }
示例#3
0
        public CostApplyForm(int costId)
        {
            this.costId = costId;
            InitializeComponent();
            btnCostApply.Click += new EventHandler(BtnCostApplyUpdate_Click);
            List <cost_detail> listDetail = new CostApplyDAL().QueryDetail(costId);

            foreach (cost_detail detail in listDetail)
            {
                string type = new CostApplyDAL().GetCostTypeById(detail.cost_type_id);
                addDetail(detail.cost_type_id + "." + type, detail.money.ToString());
            }
            CmbApprover.Visible = false;
            LblApprover.Visible = false;
            btnCostApply.Text   = "修改";
        }
示例#4
0
        /// <summary>
        /// 费用单删除
        /// </summary>
        /// <param name="id">费用单id</param>
        /// <returns>删除是否成功</returns>
        public Result Del(int id)
        {
            Result res = new Result
            {
                Code    = RES.ERROR,
                Message = "删除失败"
            };
            cost cost = new CostApprovaDAL().Query(new Dictionary <string, object>
            {
                { "id", id }
            }).First();
            int rightRows = cost.DetailList.Count + cost.ApprovalList.Count + 1;
            int rows      = new CostApplyDAL().Del(id);

            if (rows == rightRows)
            {
                res.Code    = RES.OK;
                res.Message = "删除成功";
            }
            return(res);
        }
        private void CostApprovalForm_Load(object sender, EventArgs e)
        {
            cost cost = new CostApplyBLL().Query(new Dictionary <string, object>
            {
                { "id", costId }
            }).First();
            cost_main    main      = cost.Main;
            view_sys_u2g applicant = new SysUserDAL().SelectById(main.apply_id).First();

            TexApplicant.Text = applicant.name;
            foreach (cost_detail detail in cost.DetailList)
            {
                int index = this.DgvCostDetail.Rows.Add();
                this.DgvCostDetail.Rows[index].SetValues(new CostApplyDAL().GetCostTypeById(detail.cost_type_id), detail.money);
            }
            foreach (cost_approval approval in cost.ApprovalList)
            {
                int    index    = this.DgvApproval.Rows.Add();
                string approver = approval.approval_id + "." + new SysUserDAL().SelectById(approval.approval_id).First().name;
                this.DgvApproval.Rows[index].SetValues(approver, approval.result, approval.time, approval.opinion);
            }
            int           userId       = UserInfoBLL.UserId;
            List <string> approverList = new CostApplyDAL().GetApprovalInfo(userId);

            if (approverList.Count == 0)
            {
                LblNextApprover.Visible = false;
                CmbNextApprover.Visible = false;
                return;
            }
            else
            {
                LblNextApprover.Visible = true;
                CmbNextApprover.Visible = true;
            }
            CmbNextApprover.Items.Clear();
            CmbNextApprover.Items.AddRange(approverList.ToArray());
        }
示例#6
0
        /// <summary>
        /// 更新费用单信息
        /// </summary>
        /// <param name="cost">费用单主表对象 Main:id、apply_money、remark
        /// 费用单审批详情列表 ApprovalList:
        /// 费用详情列表 DetailList:cost_type、cost_type_name、money</param>
        /// <returns>更新是否成功</returns>
        public Result Update(cost cost)
        {
            cost_main          main       = cost.Main;
            List <cost_detail> listDeatil = cost.DetailList;
            Result             res        = new Result()
            {
                Code    = RES.ERROR,
                Message = "更新失败!"
            };

            if (main == null || listDeatil == null || listDeatil.Count == 0)
            {
                return(res);
            }
            CostApplyDAL apply = new CostApplyDAL();
            //获取该费用单的审批状态
            byte status = apply.QueryMain(new Dictionary <string, object>
            {
                { "id", main.id }
            }).First().status;

            //如果费用单不是未审批状态,则更新信息失败
            if (status != 0)
            {
                return(res);
            }
            //先获取未更新时费用详情记录数
            int originDetailCount = apply.QueryDetail(main.id).Count;
            //再更新费用单
            int rows = apply.Update(cost);

            if (rows == 1 + originDetailCount + listDeatil.Count)
            {
                res.Code    = RES.OK;
                res.Message = "更新成功!";
            }
            return(res);
        }
示例#7
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 Result Add(cost cost)
        {
            cost_main          Main       = cost.Main;
            List <cost_detail> DetailList = cost.DetailList;
            Result             res        = new Result()
            {
                Code    = RES.ERROR,
                Message = "添加失败!"
            };

            if (Main == null || DetailList == null || DetailList.Count == 0)
            {
                return(res);
            }
            int rows = new CostApplyDAL().Add(cost);

            if (rows == 2 + DetailList.Count)
            {
                res.Code    = RES.OK;
                res.Message = "添加成功!";
            }
            return(res);
        }