using BLL; using FastReport.Editor; using MiniExcelLibs; using Model; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.HJGL.WeldingManage { public partial class WeldMatMatchGet : PageBase { public static List pipelinecode=new List(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var UnitWorkId = Request.Params["UnitWorkId"]; var PipeArea = Request.Params["PipeArea"]; // txtProgressBar.Text = "20"; GetStockNum(UnitWorkId, PipeArea); } } public void GetStockNum(string UnitWorkId,string PipeArea) { var pipeline = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == UnitWorkId && x.PipeArea == PipeArea orderby x.PipelineCode select x).ToList(); List pipelineList = new List(); foreach (var item in pipeline) { bool istrue = BLL.HJGL_MaterialService.isInStockByPipeline(item.PipelineId, this.CurrUser.LoginProjectId); if (istrue) { pipelineList.Add(item.PipelineCode); } } pipelinecode = pipelineList; BindGrid(); } protected void btnOut_Click(object sender, EventArgs e) { string path = Funs.RootPath + @"File\Excel\Temp\weldMatchGet.xlsx"; path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx"); var a = (from x in pipelinecode select new { PipelineCode = x }).ToList(); var b=(from x in Funs.DB .HJGL_Pipeline where pipelinecode.Contains(x.PipelineCode) select new {管线号=x.PipelineCode ,流水段=x.FlowingSection,匹配率="100%",计划安装日期=x.PlanStartDate }).ToList(); MiniExcel.SaveAs(path, b); string fileName = "材料匹配100%管线.xlsx"; FileInfo info = new FileInfo(path); long fileSize = info.Length; System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed"; System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString()); System.Web.HttpContext.Current.Response.TransmitFile(path, 0, fileSize); System.Web.HttpContext.Current.Response.Flush(); System.Web.HttpContext.Current.Response.Close(); File.Delete(path); } void BindGrid() { var a = (from x in pipelinecode select new { PipelineCode = x }).ToList(); var b = (from x in Funs.DB.HJGL_Pipeline where pipelinecode.Contains(x.PipelineCode) select new { PipelineCode = x.PipelineCode, FlowingSection = x.FlowingSection, MatchingRate = "100%", PlanStarDate = x.PlanStartDate }).ToList(); Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); this.Grid1.DataSource = b; this.Grid1.DataBind(); Grid1.RecordCount = a.Count(); } protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { BindGrid(); } } }