You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/box/boxReport4.aspx.cs

80 lines
3.7 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using WebSqlHelper;
using System.IO;
namespace DSWeb.box
{
public partial class boxReport4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
createdata();
}
}
protected void createdata()
{
grid.DataSource = retable();
grid.DataBind();
}
protected DataTable retable()
{
DataTable dt = new DataTable();
string rday = "";
try
{
rday = BaseClass.db.GetSqlStrScalar("select deadline2 from sys_remind").ToString();
}
catch { }
if (!string.IsNullOrEmpty(rday) && rday != "0")
{
//dt = BaseClass.db.GetSqlStrTable("select Box_No,max(fobport)fobport,max(Etd)etd,max(position)posion,ReachTime,OperMan,max(opertime)opertime from (select b_id,Box_No,(select port from code_disport where portid=fobport) as fobport,convert(varchar(10),Etd,120) as Etd,(select port from code_disport where portid=position) as position,ReachTime,OperMan,opertime,(case when State=1 then '空箱' when state=2 then '重箱' end) as State from container_business where datediff(dd,opertime,'" + DateTime.Now.ToString() + "')>=" + rday + ")aa group by Box_No");
//dt = BaseClass.db.GetSqlStrTable("select * from (select b.* from (select max(b_id)b_id from container_business group by Box_No) a left join container_business b on a.b_id=b.b_id)cc where datediff(dd,opertime,'" + DateTime.Now.ToString() + "')>=" + rday);
dt = BaseClass.db.GetSqlStrTable("select dd.box_no,e.cntrid,e.cntrno,(select shortname from info_client where codename=e.cntrowner)as cntrowner,e.cntype,e.cnsource,convert(varchar(10),e.buytime,120) as buytime,convert(varchar(10),e.rent_begintime,120) as rent_begintime,convert(varchar(10),e.rent_endtime,120) as rent_endtime,(case when e.status=1 then '可用' when e.status=2 then '已用' when e.status=3 then '维修' when e.status=4 then '停用' end) as status,(select cname from code_disport where portid=e.position) as positionname from container_info e right join (select * from (select b.* from (select max(b_id)b_id from container_business group by Box_No) a left join container_business b on a.b_id=b.b_id)cc where datediff(dd,opertime,'" + DateTime.Now.ToString() + "')>=" + rday + ")dd on e.cntrno=dd.box_no");
}
return dt;
}
protected void ibsave_Click(object sender, ImageClickEventArgs e)
{
grid.DataSource = retable();
grid.DataBind();
if (grid.Rows.Count <= 0)
{
return;
}
grid.Attributes.Add("style", "vnd.ms-excel.numberformat:@");
Response.ClearContent();
Response.Buffer = false;
Response.Charset = "GB2312";
Response.AddHeader("content-disposition", "attachment; filename=excel.xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/excel";
this.EnableViewState = false;
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
grid.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
//base.VerifyRenderingInServerForm(control);
}
}
}