Exemplo n.º 1
0
        public void SendProductRingEmail(string emailTemplate, List <ProductRingDetailInfo> detailList)
        {
            if (null != detailList && detailList.Count > 0)
            {
                DataTable dtProduct = new DataTable();
                dtProduct.Columns.AddRange(new DataColumn[]
                {
                    new DataColumn("ProductID"),
                    new DataColumn("ProductName"),
                    new DataColumn("BatchNumber"),
                    new DataColumn("ActualQty"),
                    new DataColumn("LeftRingDays"),
                });

                KeyTableVariables keyTablesVariables = new KeyTableVariables();
                KeyValueVariables keyValueVariables  = new KeyValueVariables();

                keyValueVariables.Add("Receiver", detailList[0].Email);

                detailList.ForEach(p =>
                {
                    DataRow dr         = dtProduct.NewRow();
                    dr["ProductID"]    = p.ProductID;
                    dr["ProductName"]  = p.ProductName;
                    dr["BatchNumber"]  = p.BatchNumber;
                    dr["ActualQty"]    = p.ActualQty;
                    dr["LeftRingDays"] = p.LeftRingDays;

                    dtProduct.Rows.Add(dr);
                });

                keyTablesVariables.Add("ProductList", dtProduct);

                ExternalDomainBroker.SendInternalEmail(detailList[0].Email.Trim(), emailTemplate, keyValueVariables, keyTablesVariables);
                //ExternalDomainBroker.SendExternalEmail(detailList[0].Email, emailTemplate, keyValueVariables, keyTablesVariables,"zh-CN");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 发送月底库存邮件
        /// </summary>
        /// <param name="emailList">发送地址列表</param>
        /// <param name="title">标题可以不填</param>
        /// <param name="content">发送内容</param>
        /// <returns>返回成功发送列表</returns>
        public void SendInventoryEmailEndOfMonth(string address, string language, string downloadPath, string savePath)
        {
            DataTable dt = ObjectFactory <IInventoryQueryDA> .Instance.QueryInventoryListEndOfMouth();

            KeyTableVariables keyTablesVariables = new KeyTableVariables();
            KeyValueVariables keyValueVariables  = new KeyValueVariables();
            List <DataTable>  data = new List <DataTable>();

            data.Add(dt);
            //keyTablesVariables.Add("InventoryList", dt);
            List <ColumnData> columndatalist = new List <ColumnData> ();
            ColumnData        columndata     = null;

            columndata = new ColumnData()
            {
                FieldName = "StockName", FooterType = FooterType.None, Width = 30, Title = "渠道仓库"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "ProductID", FooterType = FooterType.None, Width = 30, Title = "商品ID"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "ProductName", FooterType = FooterType.None, Width = 30, Title = "商品名称"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "VendorName", FooterType = FooterType.None, Width = 30, Title = "供应商"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "AccountQty", FooterType = FooterType.None, Width = 30, Title = "财务库存"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "CostAmount", FooterType = FooterType.None, Width = 30, Title = "成本金额"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "AvailableQty", FooterType = FooterType.None, Width = 30, Title = "可用库存"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "AllocatedQty", FooterType = FooterType.None, Width = 30, Title = "被占用库存"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "OrderQty", FooterType = FooterType.None, Width = 30, Title = "被订购数量"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "VirtualQty", FooterType = FooterType.None, Width = 30, Title = "虚库数量"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "ConsignQty", FooterType = FooterType.None, Width = 30, Title = "代销库存"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "PurchaseQty", FooterType = FooterType.None, Width = 30, Title = "采购在途数量"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "ShiftInQty", FooterType = FooterType.None, Width = 30, Title = "移入在途数量"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "ShiftOutQty", FooterType = FooterType.None, Width = 30, Title = "移出在途数量"
            }; columndatalist.Add(columndata);
            columndata = new ColumnData()
            {
                FieldName = "PositionInWarehouse", FooterType = FooterType.None, Width = 30, Title = "库位"
            }; columndatalist.Add(columndata);

            List <List <ColumnData> > columnList = new List <List <ColumnData> >();

            columnList.Add(columndatalist);

            string fileName = "";

            byte[] excelByte = new ExcelFileExporter().CreateFile(data, columnList, null, out fileName, "月底库存报表");

            string     excelName = System.Guid.NewGuid().ToString();
            FileStream fs        = new FileStream(String.Format("{0}//{1}.xls", savePath, excelName), FileMode.Create, FileAccess.Write);

            fs.Write(excelByte, 0, excelByte.Length);
            fs.Close();



            keyValueVariables.Add("Titel", String.Format("月底库存报表,总数{0}条", dt.Rows.Count));
            keyValueVariables.Add("Content", String.Format("库存数据已生成excel文件,请点击<a href=\"{0}/{1}.xls\">下载</a>", downloadPath, excelName));

            ExternalDomainBroker.SendExternalEmail(address, "Inventory_EndOfMonth", keyValueVariables, keyTablesVariables, language);
        }
Exemplo n.º 3
0
        public void ApplyRequestBatch(bool canOperateItemOfLessThanPrice, bool canOperateItemOfSecondHand, List <VirtualRequestInfo> requestList)
        {
            //check less than point price right and second-hand right
            List <int> productSysNoList = new List <int>();

            requestList.ForEach(item =>
            {
                productSysNoList.Add(item.VirtualProduct.SysNo);
            });
            List <ProductInfo> items = ExternalDomainBroker.GetProductInfoListByProductSysNoList(productSysNoList);

            requestList.ForEach(entity =>
            {
                ProductInfo product = items.Find(p => { return(p.SysNo == entity.VirtualProduct.SysNo); });
                if (product == null)
                {
                    throw new BizException(string.Format("操作失败,不能找到编号为{0}的商品的价格信息", entity.VirtualProduct.SysNo));
                }
                if (!canOperateItemOfLessThanPrice)
                {
                    if (product.ProductPriceInfo.UnitCost < 800)
                    {
                        throw new BizException(String.Format("商品编号:{0},错误原因:该商品的单价已经低于了800RMB,您没该商品的虚库操作权限", entity.VirtualProduct.SysNo));
                    }
                }
                if (!canOperateItemOfSecondHand)
                {
                    if (product.ProductBasicInfo.ProductType == ProductType.OpenBox)
                    {
                        throw new BizException(String.Format("商品编号:{0},错误原因:该商品为二手商品,您没该商品的虚库操作权限", entity.VirtualProduct.SysNo));
                    }
                }
            });

            using (TransactionScope scope = new TransactionScope())
            {
                requestList.ForEach(request =>
                {
                    //****************************(2011年6月20日新需求 要求 创建单据时 不关闭之前虚库申请单据************
                    List <VirtualRequestInfo> oldRequestList = virtualRequestDA.ExistNeedCloseRequestByStockAndItem(request.Stock.SysNo.Value, request.VirtualProduct.SysNo, request.CompanyCode);

                    if (oldRequestList != null && oldRequestList.Count > 0)
                    {
                        foreach (VirtualRequestInfo r in oldRequestList)
                        {
                            switch (r.RequestStatus)  //存在 运行中 或 关闭中的单据  需 先进性虚库判断
                            {
                            case VirtualRequestStatus.Origin:
                            case VirtualRequestStatus.Approved:
                            case VirtualRequestStatus.Running:
                            case VirtualRequestStatus.Closing:
                                if (request.ActiveVirtualQuantity > 0 && request.VirtualQuantity < request.ActiveVirtualQuantity)      //调整的虚库数量大于生效的虚库数量 关闭虚库申请单 调整库存 负责无法创建虚库申请单
                                {
                                    throw new BizException("系统编号为" + request.VirtualProduct.SysNo + "的商品设定的虚库数量小于生效虚库数量,无法创建虚库申请单!");
                                }
                                break;
                            }
                        }
                    }
                    request.CreateDate = DateTime.Now;
                    if (!request.StartDate.HasValue)
                    {
                        request.StartDate = request.CreateDate;
                        request.EndDate   = new DateTime(request.StartDate.Value.Year, request.StartDate.Value.Month, request.StartDate.Value.Day).AddDays(4).Subtract(new TimeSpan(0, 0, 1));
                    }
                    request.CreateUser = request.CreateUser == null || request.CreateUser.SysNo == null ? new UserInfo {
                        SysNo = ServiceContext.Current.UserSysNo
                    } : request.CreateUser;
                    request.SysNo = virtualRequestDA.Apply(request);
                });
                scope.Complete();
            }
        }