SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatchGet.aspx.cs

87 lines
3.7 KiB
C#
Raw Normal View History

2023-02-20 10:49:51 +08:00
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 <string> pipelinecode=new List<string>();
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<string> pipelineList = new List<string>();
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)
2023-02-21 16:36:13 +08:00
select new {线=x.PipelineCode ,=x.FlowingSection,="100%",=x.PlanStartDate }).ToList();
2023-02-20 10:49:51 +08:00
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()
{
2023-02-21 16:36:13 +08:00
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();
2023-02-20 10:49:51 +08:00
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
2023-02-21 16:36:13 +08:00
this.Grid1.DataSource = b;
2023-02-20 10:49:51 +08:00
this.Grid1.DataBind();
Grid1.RecordCount = a.Count();
}
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
BindGrid();
}
}
}