//在Gridview1 做的一个查看
//配货数量大于0 显示 已配货
//处理时间等于今天说明 已处理
private void GetBind()
{
DataTable ds = GetInfo();
GridView1.DataSource = ds;
GridView1.DataBind(); //绑定数据
if (ds != null)//判断信息
{
string oldstr = "";
DateTime oldtime;
DateTime date = new DateTime(); //定义变量
DateTime newtime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
for (int j = 0; j < ds.Rows.Count; j++)
{
int bh = Convert.ToInt32(ds.Rows[j]["补货数量"].ToString());
if (bh == 0)
{
((Label)GridView1.Rows[j].Cells[6].FindControl("sp1")).Attributes.Add("style", "display:none");//查找控件 sp1 使之隐藏
oldstr = ds.Rows[j]["处理时间"].ToString();
if (DateTime.TryParse(oldstr, out date))//判断时间是否匹配
{
oldtime = Convert.ToDateTime(oldstr);
}
else
{
oldtime = Convert.ToDateTime("2012-1-1");//不匹配 赋值 (让下面不出错)
}
if (oldtime == newtime)//两个时间比较
{
((Label)GridView1.Rows[j].Cells[7].FindControl("cl_id1")).Text = "已处理";
}
else
{
((Label)GridView1.Rows[j].Cells[7].FindControl("cl_id1")).Text = "";
}
}
else
{
((Label)GridView1.Rows[j].Cells[6].FindControl("sp2")).Attributes.Add("style", "display:none");
((Label)GridView1.Rows[j].Cells[7].FindControl("cl_id1")).Text = "已配货";
}
}
}