Exemple #1
0
        public override List <object> GetBillList(Models.SalerSearchParamModel pm, int userId)
        {
            bool canCheckAll = new UA(userId).CanCheckAllBill();

            DateTime fd, td;

            if (!DateTime.TryParse(pm.fromDate, out fd))
            {
                fd = DateTime.Parse("2017-01-01");
            }
            if (!DateTime.TryParse(pm.toDate, out td))
            {
                td = DateTime.Parse("2049-09-09");
            }
            td = td.AddDays(1);

            var result = from o in db.Sale_eo_bill
                         join e in db.Sale_eo_bill_detail on o.id equals e.eo_id
                         join a in db.Apply on o.sys_no equals a.sys_no into X
                         from Y in X.DefaultIfEmpty()
                         where (canCheckAll || o.applier_id == userId) &&
                         o.apply_time >= fd &&
                         o.apply_time < td &&
                         (pm.auditResult == 10 || (pm.auditResult == 0 && (Y == null || (Y != null && Y.success == null))) || (pm.auditResult == 1 && Y != null && Y.success == true) || pm.auditResult == -1 && Y != null && Y.success == false)
                         select new EOListModel()
            {
                account      = o.account,
                billId       = o.id,
                auditStatus  = (Y == null ? "未开始申请" : Y.success == true ? "申请成功" : Y.success == false ? "申请失败" : "审批之中"),
                applyDate    = o.apply_time.ToShortDateString(),
                customerName = o.customer_name,
                taxedPrice   = e.tax_price,
                productModel = e.product_model,
                qty          = e.qty,
                productName  = e.product_name,
                sysNo        = o.sys_no
            };

            if (!string.IsNullOrWhiteSpace(pm.searchValue))
            {
                result = result.Where(r => r.sysNo.Contains(pm.searchValue));
            }

            if (!string.IsNullOrWhiteSpace(pm.itemModel))
            {
                result = result.Where(r => r.productModel.Contains(pm.itemModel));
            }

            if (!string.IsNullOrWhiteSpace(pm.customerName))
            {
                result = result.Where(r => r.customerName.Contains(pm.customerName));
            }

            return(result.OrderByDescending(r => r.billId).Take(200).ToList <object>());
        }
Exemple #2
0
        public override List <object> GetBillList(Models.SalerSearchParamModel pm, int userId)
        {
            bool canCheckAll = new UA(userId).CanCheckAllBill();

            pm.searchValue  = pm.searchValue ?? "";
            pm.customerName = pm.customerName ?? "";

            DateTime fd, td;

            if (!DateTime.TryParse(pm.fromDate, out fd))
            {
                fd = DateTime.Parse("2017-01-01");
            }
            if (!DateTime.TryParse(pm.toDate, out td))
            {
                td = DateTime.Parse("2049-09-09");
            }
            td = td.AddDays(1);

            //先检查出货组权限
            List <string> ptypes = GetCHTypes(userId);

            var result = (from o in db.ChBill
                          from d in o.ChBillDetail
                          join a in db.Apply on o.sys_no equals a.sys_no into X
                          from Y in X.DefaultIfEmpty()
                          where (canCheckAll || o.user_id == userId || ptypes.Contains(o.product_type)) &&
                          o.bill_date >= fd &&
                          o.bill_date <= td &&
                          (o.sys_no.Contains(pm.searchValue) || d.item_model.Contains(pm.searchValue)) &&
                          (o.customer_name.Contains(pm.customerName) || o.customer_no.Contains(pm.customerName)) &&
                          (pm.auditResult == 10 || (pm.auditResult == 0 && (Y == null || (Y != null && Y.success == null))) || (pm.auditResult == 1 && Y != null && Y.success == true) || pm.auditResult == -1 && Y != null && Y.success == false)
                          orderby o.bill_date descending
                          select new CHListModel()
            {
                billId = o.id,
                billDate = DateTime.Parse(o.bill_date.ToString()).ToString("yyyy-MM-dd"),
                qty = d.apply_qty.ToString(),
                realQty = d.real_qty.ToString(),
                sysNo = o.sys_no,
                customerName = o.customer_name,
                productModel = d.item_model,
                productName = d.item_name,
                auditStatus = (Y == null ? "未开始申请" : Y.success == true ? "申请成功" : Y.success == false ? "申请失败" : "审批之中"),
                k3AuditDate = o.k3_audit2_date == null ? "未出库" : DateTime.Parse(o.k3_audit2_date.ToString()).ToString("yyyy-MM-dd"),
                orderNo = d.order_no,
                orderEntryNo = d.order_entry_no,
                productType = o.product_type,
                k3StockNo = o.k3_stock_no
            }).Take(200).ToList <object>();

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 营业员导出excel
        /// </summary>
        /// <param name="pm">查询参数模型</param>
        /// <param name="userId">用户id</param>
        public override void ExportSalerExcle(SalerSearchParamModel pm, int userId)
        {
            bool canCheckAll = new UA(userId).CanCheckAllBill();

            DateTime fd, td;

            if (!DateTime.TryParse(pm.fromDate, out fd))
            {
                fd = DateTime.Parse("2017-01-01");
            }
            if (!DateTime.TryParse(pm.toDate, out td))
            {
                td = DateTime.Parse("2049-09-09");
            }
            td = td.AddDays(1);

            var result = from h in db.Sale_eo_bill
                         join e in db.Sale_eo_bill_detail on h.id equals e.eo_id
                         join a in db.Apply on h.sys_no equals a.sys_no into X
                         from Y in X.DefaultIfEmpty()
                         where (canCheckAll || h.applier_id == userId) &&
                         h.apply_time >= fd &&
                         h.apply_time < td &&
                         (pm.auditResult == 10 || (pm.auditResult == 0 && (Y == null || (Y != null && Y.success == null))) || (pm.auditResult == 1 && Y != null && Y.success == true) || pm.auditResult == -1 && Y != null && Y.success == false)
                         select new ExcelData()
            {
                h           = h,
                e           = e,
                auditStatus = (Y == null ? "未开始申请" : Y.success == true ? "申请成功" : Y.success == false ? "申请失败" : "审批之中")
            };

            if (!string.IsNullOrWhiteSpace(pm.searchValue))
            {
                result = result.Where(r => r.h.sys_no.Contains(pm.searchValue));
            }

            if (!string.IsNullOrWhiteSpace(pm.itemModel))
            {
                result = result.Where(r => r.e.product_model.Contains(pm.itemModel));
            }

            if (!string.IsNullOrWhiteSpace(pm.customerName))
            {
                result = result.Where(r => r.h.customer_name.Contains(pm.customerName));
            }

            ExportExcel(result.OrderByDescending(r => r.h.id).Take(200).ToList());
        }
Exemple #4
0
        /// <summary>
        /// 获得单据列表
        /// </summary>
        /// <param name="pm">查询条件模型</param>
        /// <param name="userId">用户id</param>
        /// <returns></returns>
        public override List <object> GetBillList(SalerSearchParamModel pm, int userId)
        {
            bool canCheckAll = new UA(userId).CanCheckAllBill();

            pm.searchValue  = pm.searchValue ?? "";
            pm.customerName = pm.customerName ?? "";

            DateTime fd, td;

            if (!DateTime.TryParse(pm.fromDate, out fd))
            {
                fd = DateTime.Parse("2017-01-01");
            }
            if (!DateTime.TryParse(pm.toDate, out td))
            {
                td = DateTime.Parse("2049-09-09");
            }
            td = td.AddDays(1);

            var result = (from o in db.Order
                          from d in o.OrderDetail
                          join a in db.Apply on o.sys_no equals a.sys_no into X
                          from Y in X.DefaultIfEmpty()
                          where (canCheckAll || o.original_id == userId) &&
                          o.order_date >= fd &&
                          o.order_date <= td &&
                          (o.sys_no.Contains(pm.searchValue) || d.item_model.Contains(pm.searchValue)) &&
                          o.customer_name.Contains(pm.customerName) &&
                          (pm.productType == null || o.product_type_name.Contains(pm.productType)) &&
                          (pm.saleRange == null || (pm.saleRange == "内销" && o.currency_no == "RMB") || (pm.saleRange == "外销" && o.currency_no != "RMB")) &&
                          (pm.auditResult == 10 || (pm.auditResult == 0 && (Y == null || (Y != null && Y.success == null))) || (pm.auditResult == 1 && Y != null && Y.success == true) || pm.auditResult == -1 && Y != null && Y.success == false)
                          orderby o.order_date descending
                          select new SOListModel()
            {
                orderId = o.id,
                orderDate = DateTime.Parse(o.order_date.ToString()).ToString("yyyy-MM-dd"),
                qty = d.qty.ToString(),
                dealPrice = d.deal_price.ToString(),
                sysNo = o.sys_no,
                customerName = o.customer_name,
                productModel = d.item_model,
                productName = d.item_name,
                auditStatus = (Y == null ? "未开始申请" : Y.success == true ? "申请成功" : Y.success == false ? "申请失败" : "审批之中")
            }).Take(200).ToList <object>();

            return(result);
        }
Exemple #5
0
        public override List <object> GetBillList(SalerSearchParamModel pm, int userId)
        {
            bool canCheckAll = new UA(userId).CanCheckAllBill();

            DateTime fd, td;

            if (!DateTime.TryParse(pm.fromDate, out fd))
            {
                fd = DateTime.Parse("2021-01-01");
            }
            if (!DateTime.TryParse(pm.toDate, out td))
            {
                td = DateTime.Parse("2049-09-09");
            }
            td = td.AddDays(1);

            var result = from e in db.Sale_MX
                         join a in db.Apply on e.sys_no equals a.sys_no into X
                         from Y in X.DefaultIfEmpty()
                         where (canCheckAll || e.applier_id == userId) &&
                         e.bill_date >= fd &&
                         e.bill_date < td &&
                         (pm.auditResult == 10 || (pm.auditResult == 0 && (Y == null || (Y != null && Y.success == null))) || (pm.auditResult == 1 && Y != null && Y.success == true) || pm.auditResult == -1 && Y != null && Y.success == false)
                         select new MXListModel()
            {
                billId       = e.id,
                auditStatus  = (Y == null ? "未开始申请" : Y.success == true ? "申请成功" : Y.success == false ? "申请失败" : "审批之中"),
                billDate     = e.bill_date.ToShortDateString(),
                customerName = e.customer_name,
                sysNo        = e.sys_no,
                billNo       = e.bill_no,
                billType     = e.bill_type,
                tranType     = e.tran_type
            };

            if (!string.IsNullOrWhiteSpace(pm.searchValue))
            {
                result = result.Where(r => r.billNo.Contains(pm.searchValue));
            }

            if (!string.IsNullOrWhiteSpace(pm.customerName))
            {
                result = result.Where(r => r.customerName.Contains(pm.customerName));
            }

            return(result.OrderByDescending(r => r.billId).Take(200).ToList <object>());
        }
Exemple #6
0
        /// <summary>
        /// (有参)发送审批通知到下一个审批人
        /// </summary>
        /// <param name="ap"></param>
        /// <param name="nextStep">下一步骤</param>
        /// <returns></returns>
        private bool SendEmailToNextAuditor(int nextStep)
        {
            string emailTemplate    = @"
                <div>你好:</div>
                <div style='margin-left:30px;'>
                    <div>你有一张待审核的流水号为{0}的单据,请尽快处理。</div>
                    <table style='width:400px;font-size:14px;' border='0' cellpadding='0' cellspacing='3'>
                        <tr><td style='width:100px'>公司:</td><td style='width:300px'>{1}</td></tr>
                        <tr><td>申请人:</td><td>{2}</td></tr>
                        <tr><td>办事处:</td><td>{3}</td></tr>
                        <tr><td>单据类型:</td><td>{4}</td></tr>
                        <tr><td>规格型号:</td><td>{5}</td></tr>
                        <tr><td>审核步骤:</td><td>{6}</td></tr>
                    </table>
                    <br />
                    <div>单击以下链接可进入系统审核这张单据。</div>
                    <div><a href='{7}{8}{9}{10}{11}'>内网用户点击此链接</a></div>
                    <div><a href='{12}{8}{9}{10}{11}'>外网用户点击此链接</a></div>
                </div>
            ";
            var    ads              = ap.ApplyDetails.Where(a => a.pass != null);
            var    auditorsEmailArr = ap.ApplyDetails.Where(a => a.step == nextStep).Select(a => a.User.email).ToArray();
            string emailAddrs       = string.Join(",", auditorsEmailArr);
            BillSv bs           = (BillSv) new BillUtils().GetBillSvInstanceBySysNo(ap.sys_no);
            string billType     = bs.GetSpecificBillTypeName();
            string stepName     = ap.ApplyDetails.Where(a => a.step == nextStep).First().step_name;
            string depName      = new UA((int)ap.user_id).GetUserDepartmentName();
            string returnUrl    = SomeUtils.MyUrlEncoder("Audit/BeginAudit?step=" + nextStep + "&applyId=" + ap.id);
            string emailContent = string.Format(
                emailTemplate,
                ap.sys_no,
                COP_NAME,
                ap.User.real_name,
                depName,
                billType,
                ap.p_model,
                stepName,
                WEB_ADDRESS,
                URL_PREFIX,
                returnUrl,
                ACCOUNT_PARAM,
                IS_INNER_FRAME,
                OUT_ADDRESS
                );

            return(new EmailUtil().SendEmail(emailContent, emailAddrs, null, billType + "审批"));
        }
Exemple #7
0
        /// <summary>
        /// 营业员导出excel
        /// </summary>
        /// <param name="pm">查询参数模型</param>
        /// <param name="userId">用户id</param>
        public override void ExportSalerExcle(SalerSearchParamModel pm, int userId)
        {
            bool canCheckAll = new UA(userId).CanCheckAllBill();

            pm.searchValue  = pm.searchValue ?? "";
            pm.customerName = pm.customerName ?? "";
            DateTime fd, td;

            if (!DateTime.TryParse(pm.fromDate, out fd))
            {
                fd = DateTime.Parse("2017-01-01");
            }
            if (!DateTime.TryParse(pm.toDate, out td))
            {
                td = DateTime.Parse("2049-09-09");
            }
            td = td.AddDays(1);

            //先检查出货组权限
            List <string> ptypes = GetCHTypes(userId);

            var result = (from o in db.ChBill
                          from d in o.ChBillDetail
                          join a in db.Apply on o.sys_no equals a.sys_no into X
                          from Y in X.DefaultIfEmpty()
                          where (canCheckAll || o.user_id == userId || ptypes.Contains(o.product_type)) &&
                          o.bill_date >= fd &&
                          o.bill_date <= td &&
                          (o.sys_no.Contains(pm.searchValue) || d.item_model.Contains(pm.searchValue)) &&
                          (o.customer_name.Contains(pm.customerName) || o.customer_no.Contains(pm.customerName)) &&
                          (pm.auditResult == 10 || (pm.auditResult == 0 && (Y == null || (Y != null && Y.success == null))) || (pm.auditResult == 1 && Y != null && Y.success == true) || pm.auditResult == -1 && Y != null && Y.success == false)
                          orderby o.bill_date descending
                          select new ExcelData()
            {
                h = o,
                e = d,
                auditStatus = (Y == null ? "未开始申请" : Y.success == true ? "申请成功" : Y.success == false ? "申请失败" : "审批之中")
            }).Take(200).ToList();

            ExportExcel(result);
        }