/// <summary> /// 获取日期下拉框 /// </summary> private void GetSelect() { var allExpList = new sdk_expense_dal().GetExpByReport(thisReport.id); if (allExpList != null && allExpList.Count > 0) { #region 获取日期下拉框 var expMinDate = allExpList.Min(_ => _.add_date); expMinDate = GetMonday(expMinDate); var expMaxDate = allExpList.Max(_ => _.add_date); var weeks = GetDateDiffMonth(expMinDate, expMaxDate, "week"); // 获取到两个日期之间相差的周 // 筛选可用的周 for (int i = 0; i < weeks; i++) { var thisWeekExpList = allExpList.Where(_ => _.add_date >= expMinDate.AddDays(i * 7) && _.add_date <= expMinDate.AddDays(i * 7 + 6)).ToList(); if (thisWeekExpList != null && thisWeekExpList.Count > 0) { var thisDto = new DictionaryEntryDto() { val = expMinDate.AddDays(i * 7).ToString("yyyy-MM-dd"), show = expMinDate.AddDays(i * 7).ToString("yyyy-MM-dd") + " - " + expMinDate.AddDays(i * 7 + 6).ToString("yyyy-MM-dd"), }; if (chooseStartDate != null && chooseStartDate >= expMinDate.AddDays(i * 7) && chooseStartDate <= expMinDate.AddDays(i * 7 + 6)) { thisDto.select = 1; } dateList.Add(thisDto); } } #endregion } }
/// <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); }
/// <summary> /// 撤销费用审批 /// </summary> public ERROR_CODE REVOKE_EXPENSE(long user_id, string ids, out string re) { re = ""; if (!string.IsNullOrEmpty(ids)) { var idArr = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var cadDal = new crm_account_deduction_dal(); var seDal = new sdk_expense_dal(); StringBuilder returnvalue = new StringBuilder(); var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); foreach (var accId in idArr) { var thisCad = cadDal.FindNoDeleteById(long.Parse(accId)); if (thisCad != null) { if (thisCad.invoice_id != null) { var ci = new ctt_invoice_dal().FindNoDeleteById((long)thisCad.invoice_id); if (ci != null && ci.is_voided != 1) { returnvalue.Append(accId + "条目已经生成发票(发票ID:" + thisCad.invoice_id + "),请先作废该发票\n"); } } else { #region 除条目信息 // var oldCad = cadDal.FindNoDeleteById(long.Parse(accId)); cadDal.SoftDelete(thisCad, user_id); OperLogBLL.OperLogDelete <crm_account_deduction>(thisCad, thisCad.id, user_id, OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION, "删除审批并提交条目"); #endregion #region 修改费用表 if (thisCad.object_id != null) { var se = seDal.FindNoDeleteById((long)thisCad.object_id); if (se != null) { var oldSe = seDal.FindNoDeleteById((long)thisCad.object_id); se.approve_and_post_date = null; se.approve_and_post_user_id = null; se.amount_deduction = null; se.update_time = timeNow; se.update_user_id = user_id; seDal.Update(se); OperLogBLL.OperLogUpdate <sdk_expense>(se, oldSe, se.id, user_id, OPER_LOG_OBJ_CATE.SDK_EXPENSE, "修改费用"); } } #endregion } } } } return(ERROR_CODE.SUCCESS); }
/// <summary> /// 编辑费用 /// </summary> public void EditExpense(sdk_expense expense, long userId) { var expDal = new sdk_expense_dal(); var oldExpense = expDal.FindNoDeleteById(expense.id); if (oldExpense == null) { return; } expense.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); expense.update_user_id = userId; expDal.Update(expense); OperLogBLL.OperLogUpdate <sdk_expense>(expense, oldExpense, expense.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE, ""); }
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(); } }
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>"); } }