日期:2014-05-18  浏览次数:20983 次

当DataSet存入Session之后引发的问题!
DataSet存入Session的函数,在页面A
C# code
string MktLimitDisID = Guid.NewGuid().ToString(); //产生新Guid 

DataSet ds = (DataSet)Session["dsMktSF"];

bool check = true; //日期查核


if(ds!=null)
{
for(int i=0; i <=ds.Tables[0].Rows.Count-1; i++)
{
if(! this.CompareDate(ds.Tables[0].Rows[i]["SDate"].ToString(), ds.Tables[0].Rows[i]["EDate"].ToString(), SDate))
{
check = false;

break;
}

if(! this.CompareDate(ds.Tables[0].Rows[i]["SDate"].ToString(), ds.Tables[0].Rows[i]["EDate"].ToString(), EDate))
{
check = false;

break;
}

if(ds.Tables[0].Rows[i]["SDate"].ToString() == SDate && ds.Tables[0].Rows[i]["EDate"].ToString() == EDate)
{
check = false;

break;
}
}

if(check)
{
DataRow drow;

drow = ds.Tables[0].NewRow();

drow["MktLimitDisID"] = MktLimitDisID;

if(Request.Params["MktID"]==null)
{
drow["MktID"]=DBNull.Value;
}
else
{
drow["MktID"] = Request["MktID"];
}

drow["LimitPrice"] = SFPrice;

drow["SDate"] = " " + SDate;

drow["EDate"] = " " + EDate;

drow["Status"] = "";

if(count==null||count=="")
{
drow["Num"]=DBNull.Value;
}
else
{
drow["Num"]=count;
}

ds.Tables[0].Rows.Add(drow);

Session["dsMktSF"] = ds;

ds.Dispose();

Response.Write("OK");

Response.End();
}
else
{
Session["dsMktSF"] = ds;

ds.Dispose();

Response.Write("日期有重复区间");
DataTable dt=new DataTable();
dt.Columns.Add("Date",typeof(string));
dt.Columns.Add("ID",typeof(Guid));
dt.Columns.Add("No",typeof(string));
for(int i=0; i <=ds.Tables[0].Rows.Count-1; i++)
{

if(! this.CompareDate(ds.Tables[0].Rows[i]["SDate"].ToString(), ds.Tables[0].Rows[i]["EDate"].ToString(), SDate))
{
DataRow row=dt.NewRow();
row["Date"]=ds.Tables[0].Rows[i]["SDate"].ToString().Substring(0,16)+"~"+ds.Tables[0].Rows[i]["EDate"].ToString().Substring(0,16);
row["ID"]= new Guid(ds.Tables[0].Rows[i]["MktID"].ToString());
row["No"]=(GemSTMarket.MarketModify.GetProNo(new Guid(ds.Tables[0].Rows[i]["MktID"].ToString()))).ProNo;
dt.Rows.Add(row);
}

if(! this.CompareDate(ds.Tables[0].Rows[i]["SDate"].ToString(), ds.Tables[0].Rows[i]["EDate"].ToString(), EDate))
{
DataRow row=dt.NewRow();
row["Date"]=ds.Tables[0].Rows[i]["SDate"].ToString().Substring(0,16)+"~"+ds.Tables[0].Rows[i]["EDate"].ToString().Substring(0,16);
row["ID"]= new Guid(ds.Tables[0].Rows[i]["MktID"].ToString());
row["No"]=(GemSTMarket.MarketModify.GetProNo(new Guid(ds.Tables[0