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.

79 lines
2.6 KiB
C#

10 months 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 boxReport3 : 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 deadline1 from sys_remind").ToString();
}
catch { }
if (!string.IsNullOrEmpty(rday) && rday != "0")
{
dt = BaseClass.db.GetSqlStrTable("select cntrid,cntrno,(select shortname from info_client where codename=cntrowner)as cntrowner,cntype,cnsource,convert(varchar(10),buytime,120) as buytime,convert(varchar(10),rent_begintime,120) as rent_begintime,convert(varchar(10),rent_endtime,120) as rent_endtime,(case when status=1 then '可用' when status=2 then '已用' when status=3 then '维修' when status=4 then '停用' end) as status,(select cname from code_disport where portid=position) as positionname from container_info where datediff(dd,rent_endtime,'" + DateTime.Now.ToString() + "')<=" + rday);
}
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);
}
}
}