示例#1
0
        public JsonResult GetPO4Box(string billType, string searchValue, int page, int rows)
        {
            var boxSv = new BoxSv();
            var drSv  = new DRSv();

            List <K3POs4BoxModel> pos;
            string GetPO4Box_param = (string)Session["GetPO4Box_param"];

            if (GetPO4Box_param == null || !GetPO4Box_param.Equals(billType + ":" + searchValue))
            {
                pos = boxSv.GetPos4Box(billType, searchValue, currentUser.userId, currentUser.userName, currentAccount);
                pos = pos.OrderByDescending(p => p.po_date).Take(1000).ToList(); //最多显示1000条记录
                Session["GetPO4Box_param"] = billType + ":" + searchValue;
                Session["GetPO4Box_list"]  = pos;                                //为加快翻页速度,将数据放在session中
            }
            else
            {
                pos = (List <K3POs4BoxModel>)Session["GetPO4Box_list"];
            }
            var result = pos.OrderByDescending(p => p.po_date).Skip((page - 1) * rows).Take(rows).ToList();

            //var noFinishBox = boxSv.GetNotFinishedBoxQty(result.Select(r => new IDModel() { interId = r.po_id, entryId = r.po_entry_id }).ToList());
            foreach (var p in result)
            {
                p.id_field = p.po_id + "-" + p.po_entry_id;
                //2019-10-24 因为TDD送货平台只用来打印标签,不做送货单,所以此规则改为:可做外箱数量=po数量-平台未关联外箱数量(不记k3关联数量)
                //p.can_make_box_qty = p.po_qty - (noFinishBox.Where(f => f.poId == p.po_id && f.poEntryId == p.po_entry_id).Sum(r => r.qty) ?? 0m);
                //p.can_make_box_qty = p.po_qty - p.realte_qty - (noFinishBox.Where(f => f.poId == p.po_id && f.poEntryId == p.po_entry_id).Sum(r => r.qty) ?? 0m);
                //2019-11-19 因为有退补货的存在,所以此规则再次修改为:可做外箱数量=po数量-k3关联数量
                p.can_make_box_qty = p.po_qty - p.realte_qty;
            }

            return(Json(new { suc = true, total = pos.Count(), rows = result }));
        }
示例#2
0
        public JsonResult GetPO4Box(string billType, string searchType, string searchValue, int page, int rows)
        {
            var boxSv = new BoxSv();
            var drSv  = new DRSv();

            List <K3POs4BoxModel> pos;
            string GetPO4Box_param = (string)Session["GetPO4Box_param"];
            string searchInfo      = string.Format("{0};{1}:{2}", billType, searchType, searchValue);

            if (GetPO4Box_param == null || !GetPO4Box_param.Equals(searchInfo))
            {
                pos = boxSv.GetPos4Box(billType, searchType, searchValue, currentUser.userId, currentUser.userName, currentAccount);
                pos = pos.OrderByDescending(p => p.po_date).Take(1000).ToList(); //最多显示1000条记录
                Session["GetPO4Box_param"] = searchInfo;
                Session["GetPO4Box_list"]  = pos;                                //为加快翻页速度,将数据放在session中
            }
            else
            {
                pos = (List <K3POs4BoxModel>)Session["GetPO4Box_list"];
            }
            var result = pos.OrderByDescending(p => p.po_number).ThenBy(p => p.po_entry_id).Skip((page - 1) * rows).Take(rows).ToList();

            var noFinishBox = boxSv.GetNotFinishedBoxQty(result.Select(r => new IDModel()
            {
                interId = r.po_id, entryId = r.po_entry_id
            }).ToList(), currentAccount);

            foreach (var p in result)
            {
                p.id_field         = p.po_id + "-" + p.po_entry_id;
                p.can_make_box_qty = p.po_qty - p.realte_qty - (noFinishBox.Where(f => f.poId == p.po_id && f.poEntryId == p.po_entry_id).Sum(r => r.qty) ?? 0m);
            }

            return(Json(new { suc = true, total = pos.Count(), rows = result }));
        }
示例#3
0
        public JsonResult BeforeAddDRApply(string poJson)
        {
            List <K3POs> list = JsonConvert.DeserializeObject <List <K3POs> >(poJson);

            decimal transitQty;

            foreach (var l in list)
            {
                if (l.billType.Equals("普通采购") && (l.poNo.StartsWith("MVAC") || l.poNo.StartsWith("VMAC")))
                {
                    return(Json(new SRM(false, "订单单号是MVAC或者VMAC开头的,订单类型必须是VMI订单而不是普通采购。请联系我司对应采购员修改后再申请。")));
                }
                if (l.billType.Equals("VMI订单") && !l.poNo.StartsWith("MVAC") && !l.poNo.StartsWith("VMAC"))
                {
                    return(Json(new SRM(false, "订单类型是VMI订单的,订单单号必须是MVAC或者VMAC开头,此单的订单类型下错。请联系我司对应采购员修改后再申请。")));
                }
                transitQty = new DRSv().GetPOTransitQty(l.poId, l.poEntryId);
                if (l.orderQty - l.realteQty - transitQty <= 0)
                {
                    return(Json(new SRM(false, string.Format("订单号【{0}】,分录号【{1}】的可申请数量不大于0,不能申请送货", l.poNo, l.poEntryId))));
                }
                l.transitQty = transitQty.ToString();
            }

            try {
                //list.ForEach(l => { l.itemModel = l.itemModel.Replace("\"", "&quot;").Replace("'", "&apos;"); }); //双引号转义
                //验证没问题之后,将获取最新的在途数量的list转化为json后,保存在临时字典表
                var dicId = new ItemSv().SaveTempDic("add_dr_apply", JsonConvert.SerializeObject(list), currentAccount, currentUser.userName);
                return(Json(new SRM(true, "", dicId.ToString())));
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }
        }
示例#4
0
        public ActionResult CheckDRApply(int id)
        {
            //先验证权限
            if (!canCheckAll)
            {
                if (!new UASv().CanCheckTheDRBill(id, currentUser.userName, currentUser.userId))
                {
                    ViewBag.tip = "单据不存在或无权限查看";
                    WLog("查看送货单", "无权访问:" + id.ToString(), "", false);
                    return(View("Error"));
                }
            }

            var sv = new DRSv();
            var dr = sv.GetDRBill(id);

            if (dr == null)
            {
                ViewBag.tip = "申请单不存在,可能已被删除";
                return(View("Error"));
            }

            ViewData["drHead"]    = dr;
            ViewData["drDetails"] = sv.GetDRBillDetails(id);

            WLog("查看申请单", "查看详情", dr == null ? "" : dr.bill_no);
            return(View());
        }
示例#5
0
        public JsonResult TakeBackApply(int billId, string pStatus)
        {
            var dr = new DRSv().GetDRBill(billId);

            if (dr != null)
            {
                if (!dr.mat_order_number.Equals(currentUser.userName))
                {
                    if (!new UASv().hasGotPower(currentUser.userId, "audit_all_bills"))
                    {
                        if (new UASv().GetAuditGroupUsers(currentUser.userId).Where(u => u.user_name == dr.mat_order_number).Count() == 0)
                        {
                            return(Json(new SRM(false, "你没有此单据的反审核权限")));
                        }
                    }
                }
            }

            try {
                new DRSv().UpdatePStatus(billId, currentUser.realName, pStatus, "已提交", "反审核申请单");
                //发送邮件给供应商
                SendNotifyEmail(billId, "反审核");
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }
            return(Json(new SRM()));
        }
示例#6
0
        public ActionResult ConfirmApply(int billId)
        {
            var dr = new DRSv().GetDRBill(billId);

            if (dr == null)
            {
                ViewBag.tip = "单据不存在,可能已被删除";
                return(View("Error"));
            }
            if (!new string[] { "已提交" }.Contains(dr.p_status))
            {
                ViewBag.tip = "只有申请状态是已提交的单据才能处理,当前单据申请状态是:" + dr.p_status;
                return(View("Error"));
            }

            if (!dr.mat_order_number.Equals(currentUser.userName))
            {
                if (!new UASv().hasGotPower(currentUser.userId, "audit_all_bills"))
                {
                    if (new UASv().GetAuditGroupUsers(currentUser.userId).Where(u => u.user_name == dr.mat_order_number).Count() == 0)
                    {
                        ViewBag.tip = "你没有此单据的处理权限";
                        return(View("Error"));
                    }
                }
            }

            ViewData["billId"] = billId;
            ViewData["billNo"] = dr.bill_no;

            return(View());
        }
示例#7
0
        public JsonResult GetDROpRecord(string billNo)
        {
            var list = new DRSv().GetOpRecord(billNo);

            if (list.Count() == 0)
            {
                return(Json(new SRM(false, "此申请没有任何操作记录")));
            }
            return(Json(new { suc = true, result = list }));
        }
示例#8
0
 public JsonResult DeleteDR(int billId, bool alsoDeleteBox)
 {
     try {
         var billNo = new DRSv().DeleteDR(billId, alsoDeleteBox, currentUser.userId, currentUser.userName);
         WLog("删除申请单", alsoDeleteBox ? "同时删除关联箱子" : "不删除关联箱子", billNo);
     }
     catch (Exception ex) {
         return(Json(new SRM(ex)));
     }
     return(Json(new SRM()));
 }
示例#9
0
        public JsonResult SearchMyAuditingList(FormCollection fc)
        {
            SearchMyApplyParams p = new SearchMyApplyParams();

            MyUtils.SetFieldValueToModel(fc, p);

            p.account  = currentAccount;
            p.userId   = currentUser.userId;
            p.userName = currentUser.userName;

            var result = new DRSv().SearchMyAuditList(p, canCheckAll);

            return(Json(new { total = result.Count(), rows = result.Skip((p.page - 1) * p.rows).Take(p.rows).ToList() }));
        }
示例#10
0
        public JsonResult SaveApply(string drJson, string detailJson, string boxIdJson, bool aFlag)
        {
            DRBills bill;
            List <DRBillDetails> details;
            List <IDModel>       boxIds;
            var sv = new DRSv();
            int billId;

            try {
                bill    = JsonConvert.DeserializeObject <DRBills>(drJson);
                details = JsonConvert.DeserializeObject <List <DRBillDetails> >(detailJson);
                boxIds  = JsonConvert.DeserializeObject <List <IDModel> >(boxIdJson);

                if (details.Where(d => d.send_qty <= 0).Count() > 0)
                {
                    return(Json(new SRM(false, "存在本次送货数量小于0的分录,保存失败")));
                }

                bill.user_id   = currentUser.userId;
                bill.bill_date = DateTime.Now;
                billId         = sv.SaveApply(bill, details, boxIds);
            }
            catch (Exception ex) {
                return(Json(new SRM(ex))); //保存失败的,suc=false,页面不跳转
            }

            //page为1跳转到修改编辑界面,page为2跳转到只读页面
            if (aFlag)
            {
                try {
                    sv.BeforeApply(bill, details, boxIds, currentAccount);
                    sv.beginApply(billId, currentUser.realName);

                    //发送待处理邮件给订料员
                    SendNotifyEmail(billId, "提交");
                    WLog("提交申请单", "提交成功", bill.bill_no);
                }
                catch (Exception ex) {
                    return(Json(new { suc = true, msg = "保存申请成功,但是提交申请失败。<br/>原因:" + ex.Message, page = 1, id = billId }));
                }

                return(Json(new { suc = true, msg = "已成功保存并提交申请", page = 2, id = billId, bill_no = bill.bill_no }));
            }
            else
            {
                WLog("保存申请单", "保存成功", bill.bill_no);
                return(Json(new { suc = true, msg = "已成功保存申请", page = 1, id = billId }));
            }
        }
示例#11
0
        public JsonResult GetPOs(FormCollection fc)
        {
            GetK3POParams p = new GetK3POParams();

            MyUtils.SetFieldValueToModel(fc, p);

            if (p.beginDate == DateTime.MinValue)
            {
                return(Json(new SRM(false, "必须输入正确的开始日期")));
            }
            if (p.endDate == DateTime.MinValue)
            {
                return(Json(new SRM(false, "必须输入正确的结束日期")));
            }
            if (p.beginDate > p.endDate)
            {
                return(Json(new SRM(false, "开始日期不能大于结束日期")));
            }

            p.poNumbers  = p.poNumbers == null ? "" : p.poNumbers.Trim();//去掉前后空格
            p.itemInfo   = p.itemInfo == null ? "" : p.itemInfo.Trim();
            p.account    = currentAccount;
            p.userId     = currentUser.userId;
            p.userNumber = currentUser.userName;
            p.k3HasAudit = true;

            if (p.poNumbers.Length > 800)
            {
                return(Json(new SRM(false, "订单编号字符数不能大于800个")));
            }

            List <K3POs> result;

            try {
                result = new DRSv().GetPOs(p);
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }

            if (result.Count() == 0)
            {
                return(Json(new SRM(false, "查询不到任何符合条件的记录")));
            }

            return(Json(new { suc = true, rows = result.OrderBy(r => r.poDate).ThenBy(r => r.poId).ThenBy(r => r.poEntryId) }));
        }
示例#12
0
        public JsonResult GetBoxNodes(FormCollection fc)
        {
            SearchBoxParams p = new SearchBoxParams();

            MyUtils.SetFieldValueToModel(fc, p);

            p.endDate  = p.endDate.AddDays(1);
            p.account  = currentAccount;
            p.itemInfo = p.itemInfo ?? "";
            p.userName = currentUser.userName;

            BoxSv sv = new BoxSv();

            if (p.id == null)
            {
                //搜索外箱信息
                try {
                    var result = sv.GetOuterBoxes(p, canCheckAll).OrderByDescending(r => r.create_date);
                    if (result.Count() < p.rows && p.page > 1)
                    {
                        p.page = 1;                                                               //应该是当前easyui的bug,翻页后,比如在第二页以后的页码中搜索箱子,结果有1行,但是page还是搜索时候的那个页码,导致页面加载不出箱子,在这里手动将页码调为1
                    }
                    var outerBoxes    = result.Skip((p.page - 1) * p.rows).Take(p.rows).ToList(); //外箱信息
                    var obIds         = outerBoxes.Select(o => o.outer_box_id).ToList();          //所有外箱id
                    var pos           = sv.GetBoxPos(obIds);                                      //po信息
                    var boxIdHasInner = sv.HasGotInnerBox(obIds);                                 //有内箱的外箱id集合
                    var billNoInfo    = new DRSv().GetBillIdAndNo(outerBoxes.Where(o => o.bill_id != null).Select(o => (int)o.bill_id).Distinct().ToList());

                    return(Json(new { suc = true, total = result.Count(), box = outerBoxes, po = pos, boxIdHasInner = boxIdHasInner, billNoInfo = billNoInfo }));
                }
                catch (Exception ex) {
                    return(Json(new SRM(ex)));
                }
            }
            else
            {
                //展开内箱信息
                try {
                    var innerboxes = sv.GetInnerBoxes(p.id);
                    return(Json(new { suc = true, box = innerboxes }));
                }
                catch (Exception ex) {
                    return(Json(new SRM(ex)));
                }
            }
        }
示例#13
0
        public JsonResult GetPOInstockRecord(string billType, int poInterID, int poEntryID, int contractEntryID)
        {
            List <POInstockRecord> result;

            try {
                result = new DRSv().GetInstockRecord(currentAccount, billType, poInterID, poEntryID, contractEntryID);
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }

            if (result.Count() == 0)
            {
                return(Json(new SRM(false, "查询不到入库记录")));
            }
            return(Json(new { suc = true, rows = result }));
        }
示例#14
0
        public JsonResult GetMyAppliesData(FormCollection fc)
        {
            SearchMyApplyParams p = new SearchMyApplyParams();

            MyUtils.SetFieldValueToModel(fc, p);

            p.account  = currentAccount;
            p.userId   = currentUser.userId;
            p.userName = currentUser.userName;

            try {
                var result = new DRSv().SearchMyApplyList(p, canCheckAll);
                return(Json(new { total = result.Count(), rows = result.OrderByDescending(r => r.sendDate).Skip((p.page - 1) * p.rows).Take(p.rows).ToList() }));
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }
        }
示例#15
0
        public ActionResult PrintOuterQrcode(int billId, int numPerPage = 1)
        {
            if (numPerPage < 1)
            {
                numPerPage = 1;
            }

            try {
                var dr     = new DRSv().GetDRBill(billId);
                var result = new ReportSv().GetOuterBoxes4Print(billId);
                ViewData["outerData"]  = result;
                ViewData["numPerPage"] = numPerPage;
                ViewData["billId"]     = billId;
                WLog("打印外箱标签", "打印送货申请关联箱子标签", dr == null ? "" : dr.bill_no);
            }
            catch (Exception ex) {
                ViewBag.tip = ex.Message;
                return(View("Error"));
            }

            return(View());
        }
示例#16
0
        public JsonResult GetPOTransitQty(string interIds, string entryIds)
        {
            string[] interIdArr = interIds.Split(new char[] { ',' });
            string[] entryIdArr = entryIds.Split(new char[] { ',' });

            List <IDModel> poInfo = new List <IDModel>();

            for (var i = 0; i < interIdArr.Length; i++)
            {
                poInfo.Add(new IDModel()
                {
                    interId = Int32.Parse(interIdArr[i]),
                    entryId = Int32.Parse(entryIdArr[i])
                });
            }
            var result       = new DRSv().GetPOTransitQty(poInfo, currentAccount);
            var stringResult = new List <string>();

            foreach (var r in result)
            {
                stringResult.Add(r.ToString("0.##"));
            }
            return(Json(string.Join(",", stringResult)));
        }
示例#17
0
        public ActionResult ModifyDRApply(int id)
        {
            var sv = new DRSv();
            var h  = sv.GetDRBill(id);

            if (h == null)
            {
                ViewBag.tip = "单据不存在,可能已被删除";
                return(View("Error"));
            }

            if (!new string[] { "未提交", "已拒绝" }.Contains(h.p_status))
            {
                ViewBag.tip = "当前申请单状态是:" + h.p_status + ",不能修改";
                return(View("Error"));
            }

            var details = sv.GetDRBillDetails(id);

            //重新再计算一次可申请数量
            decimal stockQty, transitQty;

            foreach (var e in details)
            {
                stockQty       = sv.GetInstockQty(h.account, h.bill_type, (int)e.po_id, (int)e.po_entry_id); // K3已入库数量
                transitQty     = sv.GetPOTransitQty((int)e.po_id, (int)e.po_entry_id, currentAccount);       //在途数量
                e.can_send_qty = e.po_qty - stockQty - transitQty + e.send_qty ?? 0m;                        //可申请数量=订单数量-入库数量-在途数量+本次申请数量
            }

            ViewData["drHead"]    = h;
            ViewData["drDetails"] = details;

            WLog("修改申请单", "进入修改页面", h.bill_no);

            return(View("AddDRApply"));
        }
示例#18
0
        public void ExportPOData(string queryJson)
        {
            GetK3POParams p = JsonConvert.DeserializeObject <GetK3POParams>(queryJson);

            p.poNumbers  = p.poNumbers == null ? "" : p.poNumbers.Trim();//去掉前后空格
            p.itemInfo   = p.itemInfo == null ? "" : p.itemInfo.Trim();
            p.account    = currentAccount;
            p.userId     = currentUser.userId;
            p.userNumber = currentUser.userName;
            p.k3HasAudit = true;

            List <K3POs>   result;
            List <decimal> qtyList;

            try {
                result = new DRSv().GetPOs(p).OrderBy(po => po.poDate).Take(1000).ToList();
                //一次性关联1000条到数据库查询会导致内存溢出,所以大于500条的,分2次获取
                var infos = result.Take(500).Select(r => new IDModel()
                {
                    interId = r.poId, entryId = r.poEntryId
                }).ToList();
                qtyList = new DRSv().GetPOTransitQty(infos);
                if (result.Count() > 500)
                {
                    infos = result.Skip(500).Select(r => new IDModel()
                    {
                        interId = r.poId, entryId = r.poEntryId
                    }).ToList();
                    qtyList.AddRange(new DRSv().GetPOTransitQty(infos));
                }
            }
            catch {
                return;
            }

            ushort[] colWidth = new ushort[] { 18, 10, 20, 24, 32, 16,
                                               16, 16, 16, 12, 24, 12, 16,
                                               12, 12, 16, 12, 12, 16 };

            string[] colName = new string[] { "订单编号", "分录号", "PR单号", "物料名称", "规格型号", "订单数量",
                                              "入库数量", "申请数量", "可申请数量", "订料员", "申购部门", "单位", "物料编码",
                                              "订单类型", "采购方式", "订单日期", "贸易类型", "币别", "采购员" };

            //設置excel文件名和sheet名
            XlsDocument xls = new XlsDocument();

            xls.FileName = "订单明细表_" + DateTime.Now.ToString("MMddHHmmss");
            Worksheet sheet = xls.Workbook.Worksheets.Add("订单列表");

            //设置各种样式

            //标题样式
            XF boldXF = xls.NewXF();

            boldXF.HorizontalAlignment = HorizontalAlignments.Centered;
            boldXF.Font.Height         = 12 * 20;
            boldXF.Font.FontName       = "宋体";
            boldXF.Font.Bold           = true;

            //设置列宽
            ColumnInfo col;

            for (ushort i = 0; i < colWidth.Length; i++)
            {
                col = new ColumnInfo(xls, sheet);
                col.ColumnIndexStart = i;
                col.ColumnIndexEnd   = i;
                col.Width            = (ushort)(colWidth[i] * 256);
                sheet.AddColumnInfo(col);
            }

            Cells cells    = sheet.Cells;
            int   rowIndex = 1;
            int   colIndex = 1;

            //设置标题
            foreach (var name in colName)
            {
                cells.Add(rowIndex, colIndex++, name, boldXF);
            }

            for (var i = 0; i < result.Count(); i++)
            {
                var d = result[i];
                var q = qtyList[i];
                colIndex = 1;

                //"订单编号", "分录号", "PR单号", "物料名称", "规格型号", "订单数量",
                //"入库数量", "申请数量", "可申请数量", "订料员", "申购部门","单位","物料编码",
                //"订单类型","采购方式","订单日期","贸易类型","币别","采购员"
                cells.Add(++rowIndex, colIndex, d.poNo);
                cells.Add(rowIndex, ++colIndex, d.poEntryId);
                cells.Add(rowIndex, ++colIndex, d.prNo);
                cells.Add(rowIndex, ++colIndex, d.itemName);
                cells.Add(rowIndex, ++colIndex, d.itemModel);
                cells.Add(rowIndex, ++colIndex, string.Format("{0:0.####}", d.orderQty));

                cells.Add(rowIndex, ++colIndex, string.Format("{0:0.####}", d.realteQty));
                cells.Add(rowIndex, ++colIndex, string.Format("{0:0.####}", q));
                cells.Add(rowIndex, ++colIndex, string.Format("{0:0.####}", d.orderQty - d.realteQty - q));
                cells.Add(rowIndex, ++colIndex, d.matOrderName);
                cells.Add(rowIndex, ++colIndex, d.departmentName);
                cells.Add(rowIndex, ++colIndex, d.unitName);
                cells.Add(rowIndex, ++colIndex, d.itemNumber);

                cells.Add(rowIndex, ++colIndex, d.billType);
                cells.Add(rowIndex, ++colIndex, d.buyType);
                cells.Add(rowIndex, ++colIndex, ((DateTime)d.poDate).ToString("yyyy-MM-dd"));
                cells.Add(rowIndex, ++colIndex, d.tradeTypeName);
                cells.Add(rowIndex, ++colIndex, d.unitName);
                cells.Add(rowIndex, ++colIndex, d.buyerName);
            }

            xls.Send();

            WLog("导出K3订单Excel", "行数:" + result.Count() + ";" + queryJson);

            //return "已成功导出行数:"+result.Count();
        }
示例#19
0
        /// <summary>
        /// 导出申请单excel,包括我的申请和我的审批
        /// </summary>
        /// <param name="fc"></param>
        public void ExporDRData(string queryJson, string pageType)
        {
            SearchMyApplyParams p = JsonConvert.DeserializeObject <SearchMyApplyParams>(queryJson);

            p.account  = currentAccount;
            p.userId   = currentUser.userId;
            p.userName = currentUser.userName;

            var    result   = new List <CheckApplyListModel>();
            string fileName = "";

            if (pageType.Equals("apply"))
            {
                fileName = "我的送货申请_";
                result   = new DRSv().SearchMyApplyList(p, canCheckAll).ToList();
            }
            else if (pageType.Equals("audit"))
            {
                fileName = "审核送货申请_";
                result   = new DRSv().SearchMyAuditList(p, canCheckAll).ToList();
            }

            ushort[] colWidth = new ushort[] { 16, 18, 12, 16, 10, 24,
                                               32, 16, 16, 12, 18, 18, 16,
                                               16, 16, 16, 16, 18, 16, 18, 16 };

            string[] colName = new string[] { "发货日期", "送货单号", "申请状态", "订单编号", "分录号", "物料名称",
                                              "规格型号", "订单数量", "申请数量", "单位", "物料编码", "备注", "订单类型",
                                              "采购方式", "订料员", "采购员", "贸易类型", "PR单号", "采购日期", "入库单号", "入库日期" };

            //設置excel文件名和sheet名
            XlsDocument xls = new XlsDocument();

            xls.FileName = fileName + DateTime.Now.ToString("MMddHHmmss");
            Worksheet sheet = xls.Workbook.Worksheets.Add("申请列表");

            //设置各种样式

            //标题样式
            XF boldXF = xls.NewXF();

            boldXF.HorizontalAlignment = HorizontalAlignments.Centered;
            boldXF.Font.Height         = 12 * 20;
            boldXF.Font.FontName       = "宋体";
            boldXF.Font.Bold           = true;

            //设置列宽
            ColumnInfo col;

            for (ushort i = 0; i < colWidth.Length; i++)
            {
                col = new ColumnInfo(xls, sheet);
                col.ColumnIndexStart = i;
                col.ColumnIndexEnd   = i;
                col.Width            = (ushort)(colWidth[i] * 256);
                sheet.AddColumnInfo(col);
            }

            Cells cells    = sheet.Cells;
            int   rowIndex = 1;
            int   colIndex = 1;

            //设置标题
            foreach (var name in colName)
            {
                cells.Add(rowIndex, colIndex++, name, boldXF);
            }

            foreach (var d in result)
            {
                colIndex = 1;

                //"发货日期", "送货单号", "申请状态", "订单编号", "分录号", "物料名称",
                //"规格型号", "订单数量", "申请数量", "单位", "物料编码","订单类型",
                //"采购方式","订料员","采购员","贸易类型","PR单号","采购日期","入库单号","入库日期"
                cells.Add(++rowIndex, colIndex, ((DateTime)d.sendDate).ToString("yyyy-MM-dd"));
                cells.Add(rowIndex, ++colIndex, d.billNo);
                cells.Add(rowIndex, ++colIndex, d.pStatus);
                cells.Add(rowIndex, ++colIndex, d.poNo);
                cells.Add(rowIndex, ++colIndex, d.poEntryId);
                cells.Add(rowIndex, ++colIndex, d.itemName);

                cells.Add(rowIndex, ++colIndex, d.itemModel);
                cells.Add(rowIndex, ++colIndex, string.Format("{0:0.####}", d.poQty));
                cells.Add(rowIndex, ++colIndex, string.Format("{0:0.####}", d.sendQty));
                cells.Add(rowIndex, ++colIndex, d.unitName);
                cells.Add(rowIndex, ++colIndex, d.itemNumber);
                cells.Add(rowIndex, ++colIndex, d.comment);
                cells.Add(rowIndex, ++colIndex, d.billType);

                cells.Add(rowIndex, ++colIndex, d.buyType);
                cells.Add(rowIndex, ++colIndex, d.matOrderName);
                cells.Add(rowIndex, ++colIndex, d.buyerName);
                cells.Add(rowIndex, ++colIndex, d.tradeTypeName);
                cells.Add(rowIndex, ++colIndex, d.prNo);
                cells.Add(rowIndex, ++colIndex, ((DateTime)d.poDate).ToString("yyyy-MM-dd"));
                cells.Add(rowIndex, ++colIndex, d.inStockBillNo);
                cells.Add(rowIndex, ++colIndex, d.inStockBillDate == null?"":((DateTime)d.inStockBillDate).ToString("yyyy-MM-dd"));
            }

            xls.Send();

            WLog("导出申请单Excel", fileName + ":" + queryJson);
        }
示例#20
0
        /// <summary>
        /// 发送通知邮件
        /// </summary>
        /// <param name="billId"></param>
        /// <param name="opType"></param>
        private void SendNotifyEmail(int billId, string opType)
        {
            var dr = new DRSv().GetDRBill(billId);

            if (dr == null)
            {
                return;
            }

            string subject, content, emailAddr, accountName;

            //var currentCompany = MyUtils.GetCurrentCompany(dr.account);
            accountName = currentCompany == null ? "" : currentCompany.accountName;
            switch (opType)
            {
            case "提交":
                emailAddr = GetMatOrderEmail(dr);
                subject   = "你有一张待审核的供应商送货申请单";
                content   = "<div style='font-family:Microsoft YaHei'><div>你好:</div>";
                content  += "<div style='margin-left:30px;'>";
                content  += string.Format("你有一张待处理的单号为【{0}】的送货申请单,来自【{3}】,供应商【{1}({2})】。请尽快登录平台处理。", dr.bill_no, dr.supplier_name, dr.supplier_number, accountName);
                content  += "</div>";
                content  += "<div style='clear:both'><br />单击以下链接可进入平台处理这张申请单:</div>";
                content  += string.Format("<div><a href='{0}{1}{2}' style='color:#337ab7;text-decoration:none;'>内网用户请点击此链接</a></div>", innerWebSite, "Delivery/ConfirmApply?billId=", billId);
                content  += string.Format("<div><a href='{0}{1}{2}' style='color:#337ab7;text-decoration:none;'>外网用户请点击此链接</a></div>", outerWebSite, "Delivery/ConfirmApply?billId=", billId);
                content  += "</div>";
                break;

            case "确认":
            case "拒绝":
            case "反审核":
                emailAddr = getSupplierEmail(dr);
                subject   = "你有一张送货申请单已被订料员" + opType;
                content   = "<div style='font-family:Microsoft YaHei'><div>你好:</div>";
                content  += "<div style='margin-left:30px;'>";
                content  += string.Format("你有一张单号为【{0}】的送货申请单已被{1}{2},来自【{3}】", dr.bill_no, dr.mat_order_name, opType, accountName);
                content  += "</div>";
                content  += "<div style='clear:both'><br />单击以下链接可进入平台查看申请单详情:</div>";
                content  += string.Format("<div><a href='{0}{1}{2}' style='color:#337ab7;text-decoration:none;'>请点击此链接查看详情</a></div>", outerWebSite, "Delivery/CheckDRApply?id=", billId);
                content  += "</div>";
                break;

            case "撤销":
                emailAddr = GetMatOrderEmail(dr);
                subject   = "供应商撤销了一张送货申请单";
                content   = "<div style='font-family:Microsoft YaHei'><div>你好:</div>";
                content  += "<div style='margin-left:30px;'>";
                content  += string.Format("单号为【{0}】的送货申请单已被供应商撤销,来自【{3}】,供应商【{1}({2})】。", dr.bill_no, dr.supplier_name, dr.supplier_number, accountName);
                content  += "</div>";
                content  += "<div style='clear:both'><br />单击以下链接可进入平台查看申请单详情:</div>";
                content  += string.Format("<div><a href='{0}{1}{2}' style='color:#337ab7;text-decoration:none;'>内网用户请点击此链接</a></div>", innerWebSite, "Delivery/CheckDRApply?id=", billId);
                content  += string.Format("<div><a href='{0}{1}{2}' style='color:#337ab7;text-decoration:none;'>外网用户请点击此链接</a></div>", outerWebSite, "Delivery/CheckDRApply?id=", billId);
                content  += "</div>";
                break;

            default:
                return;
            }
            WLog("发送通知邮件", opType, dr.bill_no);
            MyEmail.SendEmail(subject, emailAddr, content);
        }