我在我的机器上看一个历史记录。历史记录保存在SQL数据库里,用了一个.NET自带的日历控件来点击查看,点击那一个看那一天的记录。如果只有我一个人看历史记录的话,那么这个时间是没有错误的。如果两个人看历史记录的话,一个是A企业,一个是B企业。这个时候,
A企业那儿就会看到B企业的记录,B企业也可能看到A企业的记录。如果同时只有一个企业在看就没有问题。这是为什么呢?就好像A企业看后保存到缓存了。B企业再取的时候就从缓存里取似的。为什么呀!以下是代码。谢谢!************************************************
DataBase GetData=new DataBase();
protected System.Web.UI.WebControls.PlaceHolder placeLeft;
protected System.Web.UI.WebControls.Label labDay;
protected System.Web.UI.WebControls.DataGrid gridMessage;
protected Wuqi.Webdiyer.AspNetPager pageList;
protected System.Web.UI.HtmlControls.HtmlTable tabDelete;
protected System.Web.UI.WebControls.DropDownList listService;
protected System.Web.UI.WebControls.LinkButton btnDeleteDay;
protected System.Web.UI.WebControls.LinkButton btnDelete;
protected System.Web.UI.WebControls.Calendar calChat;
protected System.Web.UI.WebControls.Label labIntro;

static string strWhere="";

private void Page_Load(object sender, System.EventArgs e)
{
if(IsOnline())
{
//给按纽加上删除确认
btnDelete.Attributes.Add("onclick","return confirm('确认删除吗?');");
btnDeleteDay.Attributes.Add("onclick","return confirm('确认删除吗?');");
//根据权限加载左边的控件
if(Session["DaoGouUserType"].ToString()=="2")
{
Control myCtrl=LoadControl("/UserManage/Left.ascx");
placeLeft.Controls.Add(myCtrl);
}
else
{
Control myCtrl=LoadControl("/ServiceManage/Left.ascx");
placeLeft.Controls.Add(myCtrl);
btnDelete.Visible=false;
btnDeleteDay.Visible=false;
tabDelete.Visible=false;
listService.Visible=false;
labIntro.Visible=false;
}
}
if(!Page.IsPostBack)
{
labDay.Text=DateTime.Now.ToString("D");
calChat.SelectedDate=DateTime.Now.Date;
btnDelete.Text="删除 <font color=red>" + calChat.SelectedDate.Month.ToString() + " </font>月份的洽谈记录!";
btnDeleteDay.Text="删除 <font color=red>" + calChat.SelectedDate.ToShortDateString() + " </font>日的洽谈记录!";
strWhere= " where companyID=" + Session["DaoGouManageCompanyID"].ToString() + " and convert(char(10),AddTime,120) ='" + calChat.SelectedDate.ToString("yyyy-MM-dd") + "'";
if(Session["DaoGouUserType"].ToString()=="2")
{
strWhere= " where companyID=" + Session["DaoGouManageCompanyID"].ToString() + " and convert(char(10),AddTime,120) ='" + calChat.SelectedDate.ToString("yyyy-MM-dd") + "'";
}
else
{
strWhere= " where (FromID=" + Session["DaoGouUserID"].ToString() + " or ToID=" + Session["DaoGouUserID"].ToString() + ")  and convert(char(10),AddTime,120) ='" + calChat.SelectedDate.ToString("yyyy-MM-dd") + "'";
} BindGrid();
BindGridEmployee();
} } //绑定信息
private void BindGrid()
{
string strSQL="Select Count(MessageID) From Message " + strWhere;
pageList.RecordCount=GetData.GetRecordCountByFunction(strSQL); pageList.PageSize=20; //如果是客服,则只显示自己的洽谈记录。
//string aasdfsdf=Session["DaoGouUserType"].ToString();
SqlConnection conn=new SqlConnection(GetData.MyConnectionString);
SqlCommand myCmd=new SqlCommand();
myCmd.CommandType=CommandType.StoredProcedure;
myCmd.CommandText="GetMessage";
myCmd.Parameters.Add("@strWhere",SqlDbType.VarChar,500);
myCmd.Parameters["@strWhere"].Value=strWhere;
myCmd.Connection=conn;
SqlDataAdapter da = new SqlDataAdapter(myCmd); DataSet ds = new DataSet();
da.Fill(ds,pageList.PageSize * (pageList.CurrentPageIndex - 1), pageList.PageSize, "ProductListTable");
gridMessage.DataSource = ds.Tables[0].DefaultView;
gridMessage.DataBind();
}private void calChat_SelectionChanged(object sender, System.EventArgs e)
{
btnDelete.Text="删除 <font color=red>" + calChat.SelectedDate.Month.ToString() + " </font>月份的洽谈记录!";
btnDeleteDay.Text="删除 <font color=red>" + calChat.SelectedDate.ToShortDateString() + " </font>日的洽谈记录!";
labDay.Text=calChat.SelectedDate.ToString("D"); if(Session["DaoGouUserType"].ToString()=="2")
{
strWhere= " where companyID=" + Session["DaoGouManageCompanyID"].ToString() + " and convert(char(10),AddTime,120) ='" + calChat.SelectedDate.ToString("yyyy-MM-dd") + "'";
}
else
{
strWhere= " where (FromID=" + Session["DaoGouUserID"].ToString() + " or ToID=" + Session["DaoGouUserID"].ToString() + ")  and convert(char(10),AddTime,120) ='" + calChat.SelectedDate.ToString("yyyy-MM-dd") + "'";
}
string strSQL="Select Count(MessageID) From Message " + strWhere;
pageList.RecordCount=GetData.GetRecordCountByFunction(strSQL);
pageList.PageSize=20;
pageList.CurrentPageIndex=1; BindGrid();
listService.SelectedIndex=0;
} private void pageList_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
pageList.CurrentPageIndex=e.NewPageIndex;
BindGrid();
}