首页 新闻 会员 周边 捐助

页面刷新,但是列表里面的数据不改变。

0
悬赏园豆:20 [已关闭问题] 关闭于 2011-08-21 14:55

页面刷新,但是列表里面的数据不改变。好像方法调用的数据是存在缓存里的数据。但我不知道怎么去除缓存里的数据...   求大哥们解救我吧...

private readonly CastleAccess acc = new CastleAccess();
readonly SqlHelper _sqlHlp = new SqlHelper();
public string url = "";
private string sql =
@"select c.Id,left(Convert(varchar(20),c.IntoDate,25),10) '日期','' as '发票(收据)号码',c.InOrderId as '订单号码',
c.OrderId as '引用单号'
,c.Customer as '供应商',
(case when SUBSTRING(c.MaterielId,1,2)='FL' then '辅料'
when SUBSTRING(c.MaterielId,1,2)='YJ' then '硬件'
when SUBSTRING(c.MaterielId,1,2)='LB' then '标签'
when SUBSTRING(c.MaterielId,1,2)='PP' then '原材料'
when SUBSTRING(c.MaterielId,1,2)='RB' then '碳带'
when SUBSTRING(c.MaterielId,1,2)='RJ' then '软件'
else '其它' end) as '类别',c.MaterielId as '产品编号',c.MaterielName as '产品名称',c.Spaces as '规格',c.Model as '型号',c.Uint as '单位'
,c.Num as '数量'
,c.Price as '成本单价',c.SumPrice as '成本金额',c.Demo as '备注' from CGDetails c
";

private const string QUERYSTRING = "QueryString";

public CreateReportHelper oclsReport
{
get
{
object obj = Session["ReportHelper"];
if (obj != null && obj is CreateReportHelper)
return ((CreateReportHelper)obj);
else
{
return new CreateReportHelper(Page);
}
}

set { Session["ReportHelper"] = value; }
}

protected void Page_Load(object sender, EventArgs e)
{

ListGridInfo.DataSourceDelegate
= new PaginationGrid.GridDataSourceDelegate(BindList);
if (!IsPostBack)
{
QueryString
= " where left(Convert(varchar(20),c.IntoDate,25),7)=left('" +
TextBox_Date.Text
+ "',7)";
ListGridInfo.BindGrid();
}
}

private object BindList()
{
if (QueryString.Trim().Length > 0)
sql
+= QueryString;
DataTable dt
= acc.GetDataTableBySql(sql);
if (dt != null && dt.Rows.Count > 0)
{
btnExcl.Enabled
= true;
}
return dt;
}

/// <summary>
/// 获取或设置查询条件
/// </summary>
private string QueryString
{
get
{
if (ViewState[QUERYSTRING] == null)
return "";
return ViewState[QUERYSTRING].ToString();
}
set
{
ViewState[QUERYSTRING]
= value;
}
}

/// <summary>
/// 获得Excel路径
/// </summary>
/// <param name="m_ExcelNo">Excel名</param>
/// <returns></returns>
private string GetExcelPath(string m_ExcelNo)
{
string savePath = "";
savePath
= Server.MapPath("/Sala/") + "Worksheet";
savePath
= "" + savePath + "\\" + m_ExcelNo;
return savePath;
}

protected void btnExcl_Click(object sender, EventArgs e)
{
string strDate = Convert.ToDateTime(TextBox_Date.Text).ToString("yyyy-MM-dd");
var oclsMonthTicketReport
= new StockIncss(oclsReport);
var m_ExcelNo
= oclsReport.CreateExeclFileName("StockIn");
DataTable dt
= (DataTable)BindList();
if (dt.Rows.Count > 0)
{
var intResult
= oclsMonthTicketReport.DrowExcel(GetExcelPath(m_ExcelNo), strDate);
switch (intResult)
{
case 1:
Alert.MessageBox(
"当前月份未有报表数据,请检测");
break;
default:
break;
}
if (intResult == 0)
{
string path = Server.MapPath("/Sala/") + "Worksheet" + @"\" + m_ExcelNo;
oclsReport.SetFileSavePath(
"StockIn", path);
}
}
else
{
Alert.MessageBox(
"您查询的该月份没有入库记录!");
return;
}
}

protected void btnQuery_Click1(object sender, EventArgs e)
{
btnExcl.Enabled
= true;

if (txtValue.Text != "")
{
if (rbtAmount.Checked)
{
QueryString
= " where left(Convert(varchar(20),c.IntoDate,25),7)=left('" +
TextBox_Date.Text
+ "',7) and " + ddlCondition.SelectedItem.Value + " = '" +
txtValue.Text
+
"' ";
}
else
{
QueryString
= " where left(Convert(varchar(20),c.IntoDate,25),7)=left('" +
TextBox_Date.Text
+ "',7) and " + ddlCondition.SelectedItem.Value + " like '%" +
txtValue.Text
+ "%' ";
}
}
else
{
QueryString
= " where left(Convert(varchar(20),c.IntoDate,25),7)=left('" +
TextBox_Date.Text
+ "',7)";
}

ListGridInfo.BindGrid();
}

protected void ListGridInfo_OnGridItemSelect1(object sender, PaginationGridItemSelectArgs e)
{
string val = e.SelectedDataKeyValue;
var win
= new Window(Page, "单价修改")
{
Height
= 280,
Width
= 520,
Scrollbars
= true,
Status
= true,
Name
= "单价修改"
};
win.ShowModalDialog(
"EditStockInPrice.aspx?&Id=" + val, new[] { "hdCheckInfo" });
}

protected void Button1_Click(object sender, EventArgs e)
{
string sql = "select * from CGDetails";
DataTable dt
= _sqlHlp.ExecuteDataSet(acc.Session, sql).Tables[0];
if (dt.Rows.Count != 0)
{
PanCheck.Visible
= false;
PanMain.Visible
= true;
lblCheck.Visible
= true;
if (TextBox_Date.Text.Trim().Length > 0)
{
QueryString
= " where left(Convert(varchar(20),c.IntoDate,25),7)=left('" +
TextBox_Date.Text
+ "',7)";
}
else
{
Alert.MessageBox(
"温馨提示:请填写在文本框里面填写你要查询的月份!谢谢!");
}
var report
= new MonthReprot();
report.SaveObjectCg(Convert.ToDateTime(TextBox_Date.Text).ToString(
"yyyy-MM-dd"));
report.SaveObjectXs(Convert.ToDateTime(TextBox_Date.Text).ToString(
"yyyy-MM-dd"));
report.SaveObjectItD(Convert.ToDateTime(TextBox_Date.Text).ToString(
"yyyy-MM-dd"));
ListGridInfo.BindGrid();
}
}

protected void btnBackDate_Click(object sender, EventArgs e)
{
PanCheck.Visible
= true;
PanMain.Visible
= false;
lblCheck.Visible
= false;
}
Elliot.XiaHou的主页 Elliot.XiaHou | 初学一级 | 园豆:80
提问于:2011-06-25 11:04
< >
分享
所有回答(1)
0

应该是没有绑定新的数据,这里没有缓存数据啊,我建议试试将ListGridInfo.DataSourceDelegate = new PaginationGrid.GridDataSourceDelegate放到if(!IsPostBack)里面试试

加百力 | 园豆:533 (小虾三级) | 2011-06-27 00:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册