Exemplo n.º 1
0
 /// <summary>
 /// 初始化方法
 /// </summary>
 private void Bind()
 {
     try
     {
         //成本中心编号不为空时,成本中心数据
         if (CCID != null)
         {
             //根据成本中心编号获取成本中心信息
             CCDetailDto cc = AutofacConfig.costCenterService.GetCCByID(CCID);
             txtCC_Name.Text    = cc.CC_Name;
             type               = cc.CC_TypeID;
             btnType.Text       = cc.CC_TypeName;
             dpkStartDate.Value = cc.CC_StartDate;
             dpkEndDate.Value   = cc.CC_EndDate;
             txtAmount.Text     = cc.CC_Amount.ToString();
             liableMan          = cc.CC_LiableMan;
             UserDetailDto user = AutofacConfig.userService.GetUserByUserID(cc.CC_LiableMan);
             btnLiableMan.Text = user.U_Name;
             D_ID             = cc.CC_DepartmentID;
             lblDep.Text      = cc.CC_DepName;
             CTempID          = cc.CC_TemplateID;
             btnTemplate.Text = cc.CC_TemplateID;
         }
         else
         {
             DateTime t = DateTime.Now;
             dpkEndDate.Value = t.AddYears(1);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 根据成本中心ID返回成本中心对象
        /// </summary>
        /// <param name="ID">成本中心ID</param>
        public CCDetailDto GetCCByID(string ID)
        {
            CCDetailDto cc = Mapper.Map <CostCenter, CCDetailDto> (_costCenterRepository.GetByID(ID).AsNoTracking().FirstOrDefault());

            if (cc != null)
            {
                if (!string.IsNullOrEmpty(cc.CC_TypeID))
                {
                    CostCenter_Type c = _costCenter_TypeRepository.GetByID(cc.CC_TypeID);
                    if (c != null)
                    {
                        cc.CC_TypeName = c.CC_T_Description;
                    }
                }
                if (!string.IsNullOrEmpty(cc.CC_TemplateID))
                {
                    CC_Type_TemplateDto ctp = Mapper.Map <CC_Type_Template, CC_Type_TemplateDto>(_cc_Type_TemplateRepository.GetByID(cc.CC_TemplateID).AsNoTracking().FirstOrDefault());
                    if (ctp != null)
                    {
                        cc.CC_AEACheckers       = ctp.CC_TT_AEACheckers;
                        cc.CC_FinancialCheckers = ctp.CC_TT_FinancialCheckers;
                    }
                }
                if (!string.IsNullOrEmpty(cc.CC_DepartmentID))
                {
                    DepDetailDto d = Mapper.Map <Department, DepDetailDto>(_departmentRepository.GetByID(cc.CC_DepartmentID).AsNoTracking().FirstOrDefault());
                    if (d != null)
                    {
                        cc.CC_DepName = d.Dep_Name;
                    }
                }
            }
            return(cc);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化数据,将数据显示到页面上
        /// </summary>
        private void Bind()
        {
            try
            {
                //显示报销明细
                List <RB_RowsDto> Rows       = AutofacConfig.rBService.GetRowByRBID(ID);
                List <RB_RowsDto> UnReimRows = AutofacConfig.rBService.GetRowsByCreateUser(Client.Session["U_ID"].ToString());
                this.lblRBNO.Text = ID;                                        //报销编号
                RBDetailDto Reim = AutofacConfig.rBService.GetByID(ID);
                RBCC = Reim.CC_ID;                                             //成本中心编号
                CCDetailDto Cost = AutofacConfig.costCenterService.GetCCByID(Reim.CC_ID);
                this.btnRBCC.Text = Cost.CC_Name;                              //成本中心名称
                this.TxtNote.Text = Reim.RB_Note;                              //备注
                DataTable rowTable = new DataTable();
                rowTable.Columns.Add("ID", typeof(System.Int32));              //消费记录编号
                rowTable.Columns.Add("RBCHECKED", typeof(System.Boolean));     //是否选中
                rowTable.Columns.Add("RB_NO", typeof(System.String));          //报销单编号
                rowTable.Columns.Add("RBROW_DATE", typeof(System.String));     //消费日期
                rowTable.Columns.Add("RBROW_TYPE", typeof(System.String));     //消费类型编号
                rowTable.Columns.Add("RBROW_TYPENAME", typeof(System.String)); //消费类型名称
                rowTable.Columns.Add("RBROW_AMOUNT", typeof(System.Decimal));  //消费金额
                rowTable.Columns.Add("RBROW_NOTE", typeof(System.String));     //消费备注
                foreach (RB_RowsDto Row in Rows)                               //将原报销单中的行项添加到数据源中
                {
                    string TypeName = AutofacConfig.rBService.GetTypeNameByID(Row.R_TypeID);

                    rowTable.Rows.Add(Row.R_ID, true, Row.RB_ID, Row.R_ConsumeDate.ToString("yyyy/MM/dd"), Row.R_TypeID, TypeName, Row.R_Amount, Row.R_Note);
                }
                foreach (RB_RowsDto Row in UnReimRows)          //将当前用户未报销的行项添加到数据源中
                {
                    string TypeName = AutofacConfig.rBService.GetTypeNameByID(Row.R_TypeID);
                    rowTable.Rows.Add(Row.R_ID, false, Row.RB_ID, Row.R_ConsumeDate.ToString("yyyy/MM/dd"), Row.R_TypeID, TypeName, Row.R_Amount, Row.R_Note);
                }
                if (rowTable.Rows.Count > 0)
                {
                    rowTable.Columns.Add("ROW_NOTE", typeof(System.String));
                    rowTable.Columns.Add("ROW_DATE", typeof(System.String));
                    this.listRBRowData.DataSource = rowTable;
                    this.listRBRowData.DataBind();
                    getAmount();
                }
            }
            catch (Exception ex)
            {
                Toast(ex.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化方法
        /// </summary>
        private void Bind()
        {
            try
            {
                //根据成本中心编号获取成本中心数据
                CCDetailDto cc = AutofacConfig.costCenterService.GetCCByID(CCID);
                lblCC_Name.Text   = cc.CC_Name;
                lblType.Text      = cc.CC_TypeName;
                lblStartDate.Text = cc.CC_StartDate.ToString("yyyy/MM/dd");
                lblEndDate.Text   = cc.CC_EndDate.ToString("yyyy/MM/dd");
                lblAmount.Text    = cc.CC_Amount.ToString();
                lblRBAmount.Text  = cc.CC_UsedAmount.ToString();
                UserDetailDto user = AutofacConfig.userService.GetUserByUserID(cc.CC_LiableMan);
                lblLiableMan.Text = user.U_Name;
                lblDep.Text       = cc.CC_DepName;
                lblTemplate.Text  = cc.CC_TemplateID;
                currantSatus      = cc.CC_IsActive;
                switch (cc.CC_IsActive)
                {
                case (int)IsActive.激活:
                    lblActive.Text      = "激活";
                    btnActive.Text      = "冻结";
                    btnActive.BackColor = System.Drawing.Color.FromArgb(97, 121, 138);
                    break;

                case (int)IsActive.冻结:
                    lblActive.Text      = "冻结";
                    btnActive.Text      = "激活";
                    btnActive.BackColor = System.Drawing.Color.FromArgb(229, 96, 79);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        AutofacConfig AutofacConfig = new AutofacConfig(); //调用配置类
        #endregion
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void Bind()
        {
            try
            {
                UserID = Client.Session["U_ID"].ToString();                                                 //当前用户ID
                List <RB_RowsDto> Rows = AutofacConfig.rBService.GetRowByRBID(ID);                          //查找报销单的消费记录信息
                RBDetailDto       Reim = AutofacConfig.rBService.GetByID(ID);                               //查找报销单的相关信息
                Status = (RB_Status)Reim.RB_Status;                                                         //报销订单当前状态
                string[]      ReimAEACheckers       = Reim.RB_AEACheckers.Split(Convert.ToChar(","));       //获取行政审批人员
                string[]      ReimFinancialCheckers = Reim.RB_FinancialCheckers.Split(Convert.ToChar(",")); //获取财务审批人员
                UserDetailDto userInfo = AutofacConfig.userService.GetUserByUserID(Reim.RB_CreateUser);
                title1.TitleText = userInfo.U_Name + "的报销";                                                 //标题
                lblUserName.Text = userInfo.U_Name;                                                         //报销单创建用户
                //当没有设置用户头像时,根据用户性别显示默认头像
                if (string.IsNullOrEmpty(userInfo.U_Portrait) == true)
                {
                    switch (userInfo.U_Sex)
                    {
                    case (int)Sex.男:
                        imgPortrait.ResourceID = "boy";
                        break;

                    case (int)Sex.女:
                        imgPortrait.ResourceID = "girl";
                        break;
                    }
                }
                else
                {
                    imgPortrait.ResourceID = userInfo.U_Portrait;
                }
                //默认状态下,不显示同意,拒绝,编辑按钮
                btnAgreed.Visible = false;
                btnRefuse.Visible = false;
                btnEdit.Visible   = false;
                switch (Status)
                {
                case RB_Status.新建:                            //如果是已创建状态,当前用户为责任人,则显示审批按钮
                    lblRBState.Text = "等待责任人审批";
                    if (UserID == Reim.RB_LiableMan)
                    {
                        btnAgreed.Visible = true;
                        btnRefuse.Visible = true;
                        if (UserID == Reim.RB_CreateUser)
                        {
                            btnEdit.Visible = true;
                            btnAgreed.Width = 85;
                            btnAgreed.Left  = 10;
                            btnRefuse.Width = 85;
                            btnRefuse.Left  = 108;
                            btnEdit.Width   = 85;
                            btnEdit.Left    = 205;
                        }
                        else
                        {
                            btnAgreed.Width = 134;
                            btnAgreed.Left  = 10;
                            btnRefuse.Width = 134;
                            btnRefuse.Left  = 156;
                        }
                    }
                    else
                    {
                        if (UserID == Reim.RB_CreateUser)
                        {
                            btnEdit.Visible = true;
                            btnEdit.Width   = 280;
                            btnEdit.Left    = 10;
                        }
                        else
                        {
                            plButton.Border = new Border(0);
                        }
                    }
                    break;

                case RB_Status.责任人审批:                      //如果是责任人已审批状态,当前用户为行政审批人,则显示审批功能按钮
                    lblRBState.Text = "等待行政审批";
                    foreach (string ReimAEAChecker in ReimAEACheckers)
                    {
                        if (UserID == ReimAEAChecker)
                        {
                            btnAgreed.Visible = true;
                            btnRefuse.Visible = true;
                            btnAgreed.Width   = 134;
                            btnAgreed.Left    = 10;
                            btnRefuse.Width   = 134;
                            btnRefuse.Left    = 156;
                        }
                    }
                    break;

                case RB_Status.行政审批:                    //如果当前行政已审批,当前用户为财务,则显示审批功能按钮
                    lblRBState.Text = "等待财务审批";
                    foreach (string ReimFinancialChecker in ReimFinancialCheckers)
                    {
                        if (UserID == ReimFinancialChecker)
                        {
                            btnAgreed.Visible = true;
                            btnAgreed.Visible = true;
                            btnAgreed.Width   = 134;
                            btnAgreed.Left    = 10;
                            btnRefuse.Width   = 134;
                            btnRefuse.Left    = 156;
                        }
                    }
                    break;

                case RB_Status.财务审批:                         //报销通过,不显示任何按钮
                    lblRBState.Text = "已审批(完成)";
                    plButton.Border = new Border(0);
                    break;

                case RB_Status.已拒绝:                       //报销驳回,如果当前用户为报销单创始人,则显示编辑按钮
                    lblRBState.Text = "已审批(拒绝)";
                    if (UserID == Reim.RB_CreateUser)
                    {
                        btnEdit.Visible = true;
                        btnEdit.Width   = 280;
                        btnEdit.Left    = 10;
                    }
                    else
                    {
                        plButton.Border = new Border(0);
                    }
                    break;
                }
                CCDetailDto Cost = AutofacConfig.costCenterService.GetCCByID(Reim.CC_ID);
                lblRBNO.Text       = Reim.RB_ID;                     //报销单编号
                lblRBCC.Text       = Cost.CC_Name;                   //成本中心名称
                lblAmount.Text     = Reim.RB_TotalAmount.ToString(); //总金额
                lblAmount.Text     = Reim.RB_TotalAmount.ToString(); //报销单总金额
                lblCreateTime.Text = Reim.RB_CreateDate.ToString("yyyy/MM/dd");
                lblnote.Text       = Reim.RB_Note;                   //报销单备注

                if (string.IsNullOrEmpty(Reim.RB_RejectionReason) == true)
                {
                    lblReason.Text               = "";
                    lblReason.Height             = 25;
                    lblReason1.Height            = 25;
                    lblReason.VerticalAlignment  = VerticalAlignment.Center;
                    lblReason1.VerticalAlignment = VerticalAlignment.Center;
                    lblReason.Padding            = new Padding(0, 0, 0, 0);
                    lblReason1.Padding           = new Padding(0, 0, 0, 0);
                }
                else
                {
                    lblReason.Text               = Reim.RB_RejectionReason; //报销单拒绝原因
                    lblReason.Height             = 50;
                    lblReason1.Height            = 50;
                    lblReason.VerticalAlignment  = VerticalAlignment.Top;
                    lblReason1.VerticalAlignment = VerticalAlignment.Top;
                    lblReason.Padding            = new Padding(0, 5, 0, 0);
                    lblReason1.Padding           = new Padding(0, 5, 0, 0);
                }
                listRBRowData.Top = lblReason.Top + lblReason.Height;

                //如果审批已结束,则隐藏按钮所占区域
                if (btnAgreed.Visible == false && btnEdit.Visible == false && btnRefuse.Visible == false)
                {
                    plButton.Visible = false;
                }

                //创建表,将数据进行处理后放入表内,然后显示在页面上
                DataTable rbrowtable = new DataTable();
                rbrowtable.Columns.Add("ID", typeof(System.Int32));              //消费记录编号
                rbrowtable.Columns.Add("RB_NO", typeof(System.String));          //报销单号
                rbrowtable.Columns.Add("RBROW_DATE", typeof(System.String));     //消费日期
                rbrowtable.Columns.Add("RBROW_TYPE", typeof(System.String));     //消费类型ID
                rbrowtable.Columns.Add("RBROW_TYPENAME", typeof(System.String)); //消费类型名称
                rbrowtable.Columns.Add("RBROW_AMOUNT", typeof(System.Decimal));  //消费日期
                rbrowtable.Columns.Add("RBROW_NOTE", typeof(System.String));     //消费记录备注
                foreach (RB_RowsDto Row in Rows)
                {
                    string TypeName = AutofacConfig.rBService.GetTypeNameByID(Row.R_TypeID);
                    rbrowtable.Rows.Add(Row.R_ID, Row.RB_ID, Row.R_ConsumeDate.ToString("yyyy/MM/dd"), Row.R_TypeID, TypeName, Row.R_Amount, Row.R_Note);
                }
                listRBRowData.Rows.Clear();//清空报销单行项列表数据
                if (rbrowtable.Rows.Count > 0)
                {
                    this.listRBRowData.DataSource = rbrowtable;
                    this.listRBRowData.DataBind();
                }
            }
            catch (Exception ex)
            {
                Toast(ex.Message);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 添加报销单
        /// </summary>
        /// <param name="entity">报销单对象</param>
        public ReturnInfo CreateRB(RBInputDto entity)
        {
            ReturnInfo    RInfo = new ReturnInfo();
            StringBuilder sb    = new StringBuilder();
            string        MaxID = _reimbursementRepository.GetMaxID();
            string        NowID = Helper.GenerateID("RB", MaxID);

            entity.RB_ID = NowID;
            string ValidateInfo = Helper.ValidateRBInputDto(entity);

            sb.Append(ValidateInfo);
            if (string.IsNullOrEmpty(ValidateInfo))
            {
                try
                {
                    Reimbursement rb = Mapper.Map <RBInputDto, Reimbursement>(entity);
                    rb.RB_CreateDate   = DateTime.Now;
                    rb.RB_UpdateDate   = DateTime.Now;
                    rb.RB_AEADate      = DateTime.Now;
                    rb.RB_FinDate      = DateTime.Now;
                    rb.RB_LiableDate   = DateTime.Now;
                    rb.RB_Status       = (int)RB_Status.新建;
                    rb.RB_CurrantCheck = "";
                    if (!string.IsNullOrEmpty(entity.CC_ID))
                    {
                        CCDetailDto cc = Mapper.Map <CostCenter, CCDetailDto> (_costCenterRepository.GetByID(entity.CC_ID).AsNoTracking().FirstOrDefault());
                        rb.RB_LiableMan = cc.CC_LiableMan;
                        if (!string.IsNullOrEmpty(cc.CC_TemplateID))
                        {
                            CC_Type_TemplateDto ctp = Mapper.Map <CC_Type_Template, CC_Type_TemplateDto>(_cc_Type_TemplateRepository.GetByID(cc.CC_TemplateID).AsNoTracking().FirstOrDefault());
                            rb.RB_AEACheckers       = ctp.CC_TT_AEACheckers;
                            rb.RB_FinancialCheckers = ctp.CC_TT_FinancialCheckers;
                        }
                    }
                    decimal Total  = 0;
                    string  MaxID2 = _reimbursementRepository.GetMaxID();
                    string  NowID2 = Helper.GenerateID("RB", MaxID2);
                    rb.RB_ID = NowID2;
                    foreach (RB_RowsInputDto row in entity.RB_Rows)
                    {
                        RB_Rows r = _rbrowsRepository.GetByID(row.R_ID).FirstOrDefault();
                        r.RB_ID = NowID2;
                        _unitOfWork.RegisterDirty(r);
                        Total += row.R_Amount;
                    }
                    rb.RB_TotalAmount = Total;
                    _unitOfWork.RegisterNew(rb);
                    bool result = _unitOfWork.Commit();
                    RInfo.IsSuccess = result;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }