コード例 #1
0
        private static Stream ExportPRByCondition(List <PrManageModel> dataList, string language)
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            ISheet       sheet    = workbook.CreateSheet();
            // 设置字体
            IFont headfont = workbook.CreateFont();

            headfont.FontName = "微软雅黑";

            // 建表头
            IRow row = sheet.CreateRow(0);

            row.CreateCell(0).CellStyle.SetFont(headfont);
            row.CreateCell(0).SetCellValue("编号");
            row.CreateCell(1).SetCellValue("采购内容");
            row.CreateCell(2).SetCellValue("项目名称");
            row.CreateCell(3).SetCellValue("申请时间");
            row.CreateCell(4).SetCellValue("申请人");
            row.CreateCell(5).SetCellValue("需求部门");
            row.CreateCell(6).SetCellValue("预算号");
            row.CreateCell(7).SetCellValue("预算");
            row.CreateCell(8).SetCellValue("采购员");
            row.CreateCell(9).SetCellValue("流程状态");
            //row.CreateCell(7).SetCellValue("供应商");
            //row.CreateCell(8).SetCellValue("合同价格");

            dataList = dataList.OrderByDescending(x => x.b_PrRecordNo).ToList();
            for (var i = 0; i < dataList.Count; i++)
            {
                PrManageModel model   = dataList[i];
                IRow          rowItem = sheet.CreateRow(i + 1);
                rowItem.CreateCell(0).SetCellValue(model.b_PrRecordNo);
                rowItem.CreateCell(1).SetCellValue(model.b_PurchaseContent);
                rowItem.CreateCell(2).SetCellValue(model.b_ProjectName);
                rowItem.CreateCell(3).SetCellValue(model.nb_RaisedDate.ToString("yyyy-MM-dd"));
                rowItem.CreateCell(4).SetCellValue(model.b_Applicant);
                rowItem.CreateCell(5).SetCellValue(model.b_BusinessDepartment);
                rowItem.CreateCell(6).SetCellValue(model.b_BudgetCode);
                rowItem.CreateCell(7).SetCellValue(model.b_Budget.ToString());
                rowItem.CreateCell(8).SetCellValue(model.b_Buyer);
                model.status = Common.GetItemStatus(model.id);
                model.status = Common.GetChineseValueByParam(model.status, "PrManageWorkFlow", "WorkFlow", language);
                rowItem.CreateCell(9).SetCellValue(model.status);

                //rowItem.CreateCell(7).SetCellValue(model.b_SourcedSupplier);
                //rowItem.CreateCell(8).SetCellValue(model.b_ContractPriceStr.ToString());
            }

            MemoryStream ms = new MemoryStream();

            workbook.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(ms);
        }
コード例 #2
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ViewResult Print(string id)
        {
            Item result = PrManageBll.GetPrManageObjById(inn, id);
            //拆解数据
            PrManageModel model = new PrManageModel();

            model.id                   = result.getProperty("id");
            model.b_PrRecordNo         = result.getProperty("b_prrecordno");
            model.b_PrType             = result.getProperty("b_prtype");
            model.b_BusinessDepartment = result.getProperty("b_businessdepartment");
            model.b_Budget             = decimal.Parse(result.getProperty("b_budget"));
            model.b_ApplicantId        = result.getProperty("b_applicantid");
            model.b_Applicant          = result.getProperty("b_applicant");
            model.b_RaisedDate         = DateTime.Parse(result.getProperty("b_raiseddate")).ToString("yyyy-MM-dd");
            model.b_EmailAddress       = result.getProperty("b_emailaddress");
            model.b_PhoneNo            = result.getProperty("b_phoneno");
            model.b_ProjectName        = result.getProperty("b_projectname");
            model.b_BudgetCode         = result.getProperty("b_budgetcode");
            model.b_ProjectLeader      = result.getProperty("b_projectleader");
            model.b_ProjectManager     = result.getProperty("b_projectmanager");
            model.b_ProjectDirector    = result.getProperty("b_projectdirector");
            model.b_BudgetStatus       = result.getProperty("b_budgetstatus");
            model.b_BuyerId            = result.getProperty("b_buyerid");
            model.b_Buyer              = result.getProperty("b_buyer");
            model.b_UrgentPurchase     = result.getProperty("b_urgentpurchase") == "0" ? false : true;
            model.b_RepetitivePurchase = result.getProperty("b_repetitivepurchase") == "0" ? false : true;
            model.b_AuthorizedPurchase = result.getProperty("b_authorizedpurchase") == "0" ? false : true;
            //model.b_SourcedSupplier = result.getProperty("b_sourcedsupplier");
            //model.b_ContractPrice = result.getProperty("b_contractprice");
            //model.b_PoNo = result.getProperty("b_pono");
            //model.b_ContractProperty = result.getProperty("b_contractproperty");
            model.b_PurchaseContent  = result.getProperty("b_purchasecontent");
            model.b_ContractParty    = result.getProperty("b_contractparty");
            model.b_ApplicantAddress = result.getProperty("b_applicantaddress");
            model.b_IsSingleSupplier = result.getProperty("b_issinglesupplier") == "0" ? false : true;
            model.b_ContractType     = result.getProperty("b_contracttype");
            model.b_DeptManager      = result.getProperty("b_deptmanager");
            model.b_DeptDirector     = result.getProperty("b_deptdirector");
            model.b_CostCenter       = result.getProperty("b_costcenter");
            model.b_PurchasingReason = result.getProperty("b_purchasingreason");
            model.b_AdditionalBudget = result.getProperty("b_additionalbudget");
            model.b_DeptVP           = result.getProperty("b_deptvp");
            model.UserName           = Userinfo.UserName;
            model.status             = Common.GetItemStatus(id);
            Item Relation = result.getRelationships("b_RequestInfo");

            if (Relation.getItemCount() > 0)
            {
                model.PrManageItems = new List <PrManageItem>();
                for (int i = 0; i < Relation.getItemCount(); i++)
                {
                    Item         ItemObJ   = Relation.getItemByIndex(i).getRelatedItem();
                    PrManageItem itemModel = new PrManageItem();
                    itemModel.id                      = ItemObJ.getProperty("id");
                    itemModel.b_No                    = ItemObJ.getProperty("b_no");
                    itemModel.b_RequestList           = ItemObJ.getProperty("b_requestlist");
                    itemModel.b_SpecificationQuantity = ItemObJ.getProperty("b_specificationquantity");
                    itemModel.b_ProjectNo             = ItemObJ.getProperty("b_projectno");
                    itemModel.b_TaskNo                = ItemObJ.getProperty("b_taskno");
                    itemModel.b_Qty                   = int.Parse(ItemObJ.getProperty("b_qty"));
                    itemModel.b_Unit                  = ItemObJ.getProperty("b_unit");
                    model.PrManageItems.Add(itemModel);
                }
            }
            List <string> listRoleName = IdentityDA.GetIdentityByUserName(Userinfo.UserName);

            model.IsPurchasingAuth = false;

            if (model.UserName == model.b_Buyer || listRoleName.Contains("采购员") || listRoleName.Contains("采购部接收PR") || listRoleName.Contains("PRReader") || Userinfo.LoginName == "admin")
            {
                model.IsPurchasingAuth = true;
                //询价信息
                Item quotationRelation = result.getRelationships("b_QuotationItem");
                if (quotationRelation.getItemCount() > 0)
                {
                    model.PrQuotationItems = new List <PrQuotationItem>();
                    for (int i = 0; i < quotationRelation.getItemCount(); i++)
                    {
                        Item            itemObj   = quotationRelation.getItemByIndex(i).getRelatedItem();
                        PrQuotationItem itemModel = new PrQuotationItem();
                        itemModel.id          = itemObj.getProperty("id");
                        itemModel.b_Supplier  = itemObj.getProperty("b_supplier");
                        itemModel.b_Quotation = itemObj.getProperty("b_quotation");
                        itemModel.b_Remarks   = itemObj.getProperty("b_remarks");
                        model.PrQuotationItems.Add(itemModel);
                    }
                }

                //获取重复信息
                Item repeatedPurchasing = result.getRelationships("b_RepeatedPurchasing");
                if (repeatedPurchasing.getItemCount() > 0)
                {
                    model.PrRepeateItems = new List <PrRepeateItem>();
                    for (int i = 0; i < repeatedPurchasing.getItemCount(); i++)
                    {
                        Item          itemObj   = repeatedPurchasing.getItemByIndex(i).getRelatedItem();
                        PrRepeateItem itemModel = new PrRepeateItem();
                        itemModel.id                 = itemObj.getProperty("id");
                        itemModel.b_PrRecordNo       = itemObj.getProperty("b_prrecordno");
                        itemModel.b_PreviousSupplier = itemObj.getProperty("b_previoussupplier");
                        itemModel.b_ContractNo       = itemObj.getProperty("b_contractno");
                        //itemModel.b_ContractPrice = itemObj.getProperty("b_contractprice");
                        itemModel.b_PreviousBuyer = itemObj.getProperty("b_previousbuyer");
                        model.PrRepeateItems.Add(itemModel);
                    }
                }

                //获取挑选的供应商
                Item b_ChoiceSuppliers = result.getRelationships("b_ChoiceSuppliers");
                if (b_ChoiceSuppliers.getItemCount() > 0)
                {
                    model.PrChoiceSupplierItems = new List <PrChoiceSupplierItem>();
                    for (int i = 0; i < b_ChoiceSuppliers.getItemCount(); i++)
                    {
                        Item itemObj = b_ChoiceSuppliers.getItemByIndex(i).getRelatedItem();
                        PrChoiceSupplierItem itemModel = new PrChoiceSupplierItem();
                        itemModel.id                 = itemObj.getProperty("id");
                        itemModel.b_Supplier         = itemObj.getProperty("b_supplier");
                        itemModel.b_ContractPrice    = itemObj.getProperty("b_contractprice");
                        itemModel.b_PoNo             = itemObj.getProperty("b_pono");
                        itemModel.b_ContractProperty = itemObj.getProperty("b_contractproperty");
                        itemModel.b_PaymentClause    = itemObj.getProperty("b_paymentclause");
                        model.PrChoiceSupplierItems.Add(itemModel);
                    }
                }
            }
            model.HistoryList = GetPrManageHistoryList(model.id);
            foreach (var item in model.HistoryList)
            {
                item.Created_on = item.Create_onStr.GetValueOrDefault().ToString("yyyy-MM-dd HH:mm:ss");
                item.ItemStatus = Common.GetChineseValueByParam(item.ItemStatus, "PrManageWorkFlow", "WorkFlow", Userinfo.language);
                item.OperateStr = Common.GetChineseValueByParam(item.OperateStr, "PrManageWorkFlow", "WorkFlow", Userinfo.language);
            }
            return(View("~/Views/PrManage/PrintPrManage.cshtml", model));
        }