Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var copy = Request.QueryString["isCopy"];
                if (!string.IsNullOrEmpty(copy))
                {
                    isCopy = true;
                }

                var thisId = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(thisId))
                {
                    thisReport = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(thisId));
                    if (thisReport != null)
                    {
                        isAdd = isCopy;
                    }
                    if (isCopy)
                    {
                        copyId = thisReport.id;
                    }
                }
            }
            catch (Exception msg)
            {
                Response.Write($"<script>alert('{msg.Message}');window.close();</script>");
            }
        }
Exemple #2
0
 protected List <sdk_expense> expList    = null;   // 报表下的费用
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         var thisId = Request.QueryString["id"];
         if (!string.IsNullOrEmpty(thisId))
         {
             thisReport = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(thisId));
         }
         if (thisReport == null)
         {
             Response.Write("<script>alert('报表已删除');window.close();</script>");
         }
         else if (thisReport.status_id != (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.WAITING_FOR_APPROVAL)
         {
             Response.Write("<script>alert('报表的状态必须是待审批!');window.close();</script>");
         }
         else
         {
             if (thisReport.submit_user_id != null)
             {
                 subRes = new sys_resource_dal().FindNoDeleteById((long)thisReport.submit_user_id);
             }
             expList = new sdk_expense_dal().GetExpByReport(thisReport.id);
         }
     }
     catch (Exception msg)
     {
         Response.Write($"<script>alert('{msg.Message}!');window.close();</script>");
     }
 }
 protected List <sdk_expense> expList    = null;   // 报表下的费用
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         var thisId = Request.QueryString["id"];
         if (!string.IsNullOrEmpty(thisId))
         {
             thisReport = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(thisId));
         }
         if (thisReport == null)
         {
             Response.Write("<script>alert('报表已删除');window.close();</script>");
             return;
         }
         if (thisReport.status_id != (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.REJECTED)
         {
             Response.Write("<script>alert('报表不是拒绝状态,无需查看');window.close();</script>");
             return;
         }
         expList = new sdk_expense_dal().GetExpByReport(thisReport.id);
     }
     catch (Exception msg)
     {
         Response.Write($"<script>alert('{msg.Message}!');window.close();</script>");
     }
 }
Exemple #4
0
 /// <summary>
 /// 费用报表 管理(新增,编辑)
 /// </summary>
 public bool ReportManage(sdk_expense_report report, long userId, bool isCopy = false, long copyId = 0)
 {
     try
     {
         var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
         report.update_user_id = userId;
         report.update_time    = timeNow;
         if (report.id == 0)
         {
             report.id             = _dal.GetNextIdCom();
             report.create_time    = timeNow;
             report.create_user_id = userId;
             report.submit_user_id = userId;
             report.submit_time    = report.create_time;
             _dal.Insert(report);
             OperLogBLL.OperLogAdd <sdk_expense_report>(report, report.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE_REPORT, "新增费用报表");
             // 代表是复制操作
             if (isCopy && copyId != 0)
             {
                 var seDal = new sdk_expense_dal();
                 // 复制时,将原有的费用复制,已经审批提交的只复制相关信息,审批状态不复制
                 var thisExpList = seDal.GetExpByReport(copyId);
                 if (thisExpList != null && thisExpList.Count > 0)
                 {
                     thisExpList.ForEach(_ => {
                         _.id  = seDal.GetNextIdCom();
                         _.oid = 0;
                         _.expense_report_id        = report.id;
                         _.create_time              = timeNow;
                         _.update_time              = timeNow;
                         _.create_user_id           = userId;
                         _.update_user_id           = userId;
                         _.approve_and_post_date    = null;
                         _.approve_and_post_user_id = null;
                         seDal.Insert(_);
                         OperLogBLL.OperLogAdd <sdk_expense>(_, _.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE, "新增费用");
                     });
                 }
             }
         }
         else
         {
             var oldReport = _dal.FindNoDeleteById(report.id);
             if (oldReport != null)
             {
                 _dal.Update(report);
                 OperLogBLL.OperLogUpdate <sdk_expense_report>(report, oldReport, report.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE_REPORT, "修改费用报表");
             }
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemple #5
0
        protected void Save_Close_Click(object sender, EventArgs e)
        {
            if (isAdd)
            {
                thisReport           = new sdk_expense_report();
                thisReport.status_id = (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.HAVE_IN_HAND;
            }
            else
            {
                thisReport = new sdk_expense_report_dal().FindNoDeleteById(thisReport.id);
            }
            thisReport.title = Request.Form["title"];
            var endDate = DateTime.Now;

            if (DateTime.TryParse(Request.Form["end_date"], out endDate))
            {
                thisReport.end_date = endDate;
                var cash_advance_amount = Request.Form["cash_advance_amount"];
                if (!string.IsNullOrEmpty(cash_advance_amount))
                {
                    thisReport.cash_advance_amount = decimal.Parse(cash_advance_amount);
                }
                else
                {
                    thisReport.cash_advance_amount = null;
                }
                var result = new ExpenseBLL().ReportManage(thisReport, LoginUserId, isCopy, copyId);

                if (result)
                {
                    if (!string.IsNullOrEmpty(pageFrom))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存成功!');setTimeout(function () { window.close(); self.opener.location.reload();}, 1000);</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "打开报表", "<script>window.open('../TimeSheet/ExpenseReportDetail.aspx?id=" + thisReport.id + "', '" + (int)OpenWindow.EXPENSE_REPORT_DETAIL + "', 'left=200,top=200,width=900,height=750,resizable=yes', false);</script>");
                        ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存成功!');setTimeout(function () { window.close(); self.opener.location.reload();}, 1000);</script>");
                        //
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存失败!');</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('周期结束日期格式不正确!');</script>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var thisId = Request.QueryString["id"];

            if (!string.IsNullOrEmpty(thisId))
            {
                thisReport = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(thisId));
            }
            if (thisReport == null)
            {
                Response.Write("<script>alert('报表已删除');window.close();</script>");
            }
            else
            {
                defAcc = cBLL.GetDefaultAccount();
                if (thisReport.status_id == (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.REJECTED || thisReport.status_id == (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.HAVE_IN_HAND)
                {
                    isSubmit = true;
                    if (thisReport.status_id == (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.REJECTED)
                    {
                        isRefuse = true;
                    }
                }
                var isAtt = Request.QueryString["ShowAtt"];
                if (!string.IsNullOrEmpty(isAtt))
                {
                    isReport = false;
                }
                var isCk = Request.QueryString["isCheck"];
                if (!string.IsNullOrEmpty(isCk))
                {
                    isCheck = true;
                }
                attList = new com_attachment_dal().GetAttListByOid(thisReport.id);
                expList = new sdk_expense_dal().GetExpByReport(thisReport.id);
            }
        }
Exemple #7
0
        protected bool isFromReport             = false; // 是否从报表页面进行新增操作
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    PageDataBind();
                }
                isShowWorkType = new SysSettingBLL().GetValueById(SysSettingEnum.SDK_EXPENSE_SHOW_WORK_TYPE) == "1";// SDK_EXPENSE_SHOW_WORK_TYPE
                var seDal = new sdk_expense_dal();
                var stDal = new sdk_task_dal();
                var eId   = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(eId))
                {
                    thisExpense = seDal.FindNoDeleteById(long.Parse(eId));
                    if (thisExpense != null)
                    {
                        if (thisExpense.approve_and_post_date != null || thisExpense.approve_and_post_user_id != null)
                        {
                            Response.Write("<script>alert('审批提交的费用不可以更改!')window.close();</script>");
                            Response.End();
                        }
                        if (!new TaskBLL().CanEditExpense(thisExpense.id))
                        {
                            Response.Write("<script>alert('相关报表状态已经更改,不可以进行编辑!');window.close();</script>");
                            Response.End();
                        }

                        isAdd = false;

                        if (!IsPostBack)
                        {
                            if (thisExpense.cost_code_id != null)
                            {
                                cost_code_id.SelectedValue = thisExpense.cost_code_id.ToString();
                            }
                            expense_cost_code_id.SelectedValue = thisExpense.expense_cost_code_id.ToString();
                            RDAddExiRep.Checked           = true;
                            isBillable.Checked            = thisExpense.is_billable == 1;
                            payment_type_id.SelectedValue = thisExpense.payment_type_id.ToString();
                            hasReceipt.Checked            = thisExpense.has_receipt == 1;
                            if (thisExpense.project_id != null)
                            {
                                rbAssProTask.Checked = true;
                            }
                            else
                            {
                                rbAssNone.Checked = true;
                            }
                        }

                        if (thisExpense.project_id != null)
                        {
                            thisProject = new pro_project_dal().FindNoDeleteById((long)thisExpense.project_id);
                        }
                        if (thisExpense.project_id != null && thisExpense.task_id != null)
                        {
                            thisTask = new sdk_task_dal().FindNoDeleteById((long)thisExpense.task_id);
                        }
                        if (thisExpense.project_id == null && thisExpense.task_id != null)
                        {
                            thisTicket = new sdk_task_dal().FindNoDeleteById((long)thisExpense.task_id);
                        }
                        thisAccount = new crm_account_dal().FindNoDeleteById(thisExpense.account_id);
                        thisExpRep  = new sdk_expense_report_dal().FindNoDeleteById(thisExpense.expense_report_id);
                    }
                }
                var task_id = Request.QueryString["task_id"];
                if (!string.IsNullOrEmpty(task_id))
                {
                    thisTask = stDal.FindNoDeleteById(long.Parse(task_id));
                    if (thisTask != null && thisTask.project_id != null)
                    {
                        thisProject = new pro_project_dal().FindNoDeleteById((long)thisTask.project_id);
                        if (thisProject != null)
                        {
                            thisAccount = new crm_account_dal().FindNoDeleteById(thisProject.account_id);
                        }
                    }
                }
                var project_id = Request.QueryString["project_id"];
                if (!string.IsNullOrEmpty(project_id))
                {
                    thisProject = new pro_project_dal().FindNoDeleteById(long.Parse(project_id));
                    if (thisProject != null)
                    {
                        thisAccount = new crm_account_dal().FindNoDeleteById(thisProject.account_id);
                    }
                }

                var report_id = Request.QueryString["report_id"];
                if (!string.IsNullOrEmpty(report_id))
                {
                    thisExpRep = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(report_id));
                    if (thisExpRep != null)
                    {
                        isFromReport = true;
                        thisAccount  = new CompanyBLL().GetDefaultAccount();
                    }
                }

                var ticket_id = Request.QueryString["ticket_id"];
                if (!string.IsNullOrEmpty(ticket_id))
                {
                    thisTicket = new sdk_task_dal().FindNoDeleteById(long.Parse(ticket_id));
                    if (thisTicket != null)
                    {
                        thisAccount = new CompanyBLL().GetCompany(thisTicket.account_id);
                    }
                }
            }
            catch (Exception msg)
            {
                Response.End();
            }
        }
Exemple #8
0
        private ExpenseDto GetParam()
        {
            var param = new ExpenseDto();

            if (RDAddRep.Checked)
            {
                var repTitle   = Request.Form["title"];
                var repEndDate = Request.Form["end_date"];
                var reprAmount = Request.Form["report_amount"];
                if (!string.IsNullOrEmpty(repTitle) && !string.IsNullOrEmpty(repEndDate))
                {
                    var expRep = new sdk_expense_report()
                    {
                        title    = repTitle,
                        end_date = DateTime.Parse(repEndDate),
                    };
                    if (!string.IsNullOrEmpty(reprAmount))
                    {
                        expRep.cash_advance_amount = decimal.Parse(reprAmount);
                    }
                    param.thisExpReport = expRep;
                }
            }
            else if (RDAddExiRep.Checked)
            {
                var expense_report_id = Request.Form["expense_report_id"];
                if (!string.IsNullOrEmpty(expense_report_id))
                {
                    var expRep = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(expense_report_id));
                    if (expRep != null)
                    {
                        param.thisExpReport = expRep;
                    }
                }
            }
            var pageExp = new sdk_expense();

            pageExp.add_date    = DateTime.Parse(Request.Form["add_date"]);
            pageExp.is_billable = (sbyte)(isBillable.Checked?1:0);
            if (isShowWorkType)
            {
                var cost_code_id = Request.Form["cost_code_id"];
                if (!string.IsNullOrEmpty(cost_code_id))
                {
                    pageExp.cost_code_id = long.Parse(cost_code_id);
                }
            }
            pageExp.description = Request.Form["description"];

            pageExp.expense_cost_code_id = int.Parse(Request.Form["expense_cost_code_id"]);
            if (pageExp.expense_cost_code_id == (int)CostCode.ENTERTAINMENT_EXPENSE)
            {
                pageExp.location = Request.Form["location"];
            }
            else if (pageExp.expense_cost_code_id == (int)CostCode.MILEAGE)
            {
                pageExp.from_loc = Request.Form["from_loc"];
                pageExp.to_loc   = Request.Form["to_loc"];
                var odometer_start = Request.Form["odometer_start"];
                if (!string.IsNullOrEmpty(odometer_start))
                {
                    pageExp.odometer_start = decimal.Parse(odometer_start);
                }

                pageExp.odometer_end = decimal.Parse(Request.Form["odometer_end"]);
                var miles = Request.Form["miles"];
                if (!string.IsNullOrEmpty(miles))
                {
                    pageExp.miles = decimal.Parse(miles);
                }
                else
                {
                    pageExp.miles = pageExp.odometer_end - pageExp.odometer_start;
                }
            }
            else
            {
                //var amount = long.Parse(Request.Form["amount"]);
                //var moneyHidden = Request.Form["moneyHidden"];
                //if (!string.IsNullOrEmpty(moneyHidden))
                //{
                //    var money = decimal.Parse(moneyHidden);
                //    if (amount > money)
                //    {
                //        var overdraft_policy_id = Request.Form["overdraft_policy_id"];
                //    }
                //    else
                //    {
                //        pageExp.amount = amount;
                //    }
                //}
                //else
                //{
                //pageExp.amount = amount;
                //}
            }
            pageExp.amount = decimal.Parse(Request.Form["amount"]);
            var esType = new d_cost_code_dal().FindNoDeleteById((long)pageExp.expense_cost_code_id);

            if (esType != null && esType.expense_type_id != null)
            {
                pageExp.type_id = (int)esType.expense_type_id;
            }

            pageExp.payment_type_id = int.Parse(Request.Form["payment_type_id"]);
            var thisPay = new d_general_dal().FindNoDeleteById(pageExp.payment_type_id);

            if (thisPay != null)
            {
            }
            pageExp.has_receipt = (sbyte)(hasReceipt.Checked?1:0);
            pageExp.account_id  = long.Parse(Request.Form["account_id"]);
            if (rbAssTask.Checked)
            {
                var ticket_id = Request.Form["ticket_id"];
                if (!string.IsNullOrEmpty(ticket_id))
                {
                    pageExp.task_id = long.Parse(ticket_id);
                }
            }
            else if (rbAssProTask.Checked)
            {
                pageExp.project_id = long.Parse(Request.Form["project_id"]);

                var task_id = Request.Form["task_id"];
                if (!string.IsNullOrEmpty(task_id))
                {
                    pageExp.task_id = long.Parse(task_id);
                }
            }
            pageExp.purchase_order_no = Request.Form["purchase_order_no"];
            if (!isAdd)
            {
                pageExp.id                       = thisExpense.id;
                pageExp.oid                      = thisExpense.oid;
                pageExp.create_user_id           = thisExpense.create_user_id;
                pageExp.create_time              = thisExpense.create_time;
                pageExp.is_approved              = thisExpense.is_approved;
                pageExp.approve_and_post_user_id = thisExpense.approve_and_post_user_id;
                pageExp.approve_and_post_date    = thisExpense.approve_and_post_date;
                pageExp.amountrate               = thisExpense.amountrate;
                pageExp.purpose                  = thisExpense.purpose;
                pageExp.extacctitemid            = thisExpense.extacctitemid;
                pageExp.web_service_date         = thisExpense.web_service_date;
                pageExp.currency_id              = thisExpense.currency_id;
            }
            param.thisExpense = pageExp;
            return(param);
        }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var eid = Request.QueryString["id"];
                thisReport = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(eid));
                if (thisReport != null)
                {
                    creRes = new sys_resource_dal().FindNoDeleteById(thisReport.create_user_id);
                    if (thisReport.submit_user_id != null)
                    {
                        subRes = new sys_resource_dal().FindNoDeleteById((long)thisReport.submit_user_id);
                    }
                    var chooseDateString = Request.QueryString["startDate"];
                    if (!string.IsNullOrEmpty(chooseDateString))
                    {
                        chooseStartDate = GetMonday(DateTime.Parse(chooseDateString));
                    }
                    var allExpList = new sdk_expense_dal().GetExpByReport(thisReport.id);
                    if (allExpList != null && allExpList.Count > 0)
                    {
                        if (chooseStartDate != null)
                        {
                            expList = allExpList.Where(_ => _.add_date >= chooseStartDate && _.add_date <= ((DateTime)chooseStartDate).AddDays(6)).ToList();
                        }
                    }
                    #region 完善日期下拉框信息
                    GetSelect();  // 获取日期下拉框
                    var choese = dateList.FirstOrDefault(_ => _.select == 1);
                    if (choese == null)
                    {
                        dateList.Add(new DictionaryEntryDto()
                        {
                            select = 1, show = "选择日期", val = ""
                        });
                    }
                    else
                    {
                        dateList.Add(new DictionaryEntryDto()
                        {
                            show = "选择日期", val = ""
                        });
                    }
                    dateList = dateList.OrderBy(_ => _.val).ToList();
                    #endregion

                    if (expList != null && expList.Count > 0)
                    {
                        var dccDal = new d_cost_code_dal();
                        // 获取到招待相关的费用
                        entertainList = expList.Where(_ =>
                        {
                            if (_.cost_code_id != null)
                            {
                                var thisCost = dccDal.FindNoDeleteById((long)_.cost_code_id);
                                if (thisCost != null && thisCost.expense_type_id == (int)DicEnum.EXPENSE_TYPE.ENTERTAINMENT_EXPENSES)
                                {
                                    return(true);
                                }
                            }
                            return(false);
                        }).ToList();

                        if (entertainList != null && entertainList.Count > 0)
                        {
                            noEntertainList = expList.Where(_ => !entertainList.Any(el => el.id == _.id)).ToList();
                        }
                        else
                        {
                            noEntertainList = expList;
                        }
                    }
                }
                else
                {
                    Response.Write($"<script>alerl('未查询到相关报表,请刷新页面后重试!');window.close();</script>");
                }
            }
            catch (Exception msg)
            {
                Response.Write($"<script>alerl('{msg.Message}');</script>");
            }
        }