public partial class Default6 : System.Web.UI.Page
{
HP hp = new HP();
protected void Page_Load(object sender, EventArgs e)
{
string[] a = new string[8];
string[] b = new string[8];
for (int i = 0; i < 8; i++)
{
a[i] = date(System.DateTime.Now.AddDays(i));
b[i] = dateR(System.DateTime.Now.AddDays(i));
}
DataSet ds = null;
string sql = " select doctorname," + a[1] + "," + a[2] + "," + a[3] + "," + a[4] + "," + a[5] + "," + a[6] + "," + a[7] + " from 医生出诊时间表 ";//sql语句,然后用它自动绑定GridView
ds= hp.ReturnDataSet(sql, "医生出诊时间表");
GridView1.DataSource = ds;
//string[] lic = GridView1.DataKeys;
//string Ywbm = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
// GridView1.Columns[1].HeaderText = b[1] + a[1];
HyperLinkField hypfield1 = new HyperLinkField();
hypfield1.ShowHeader = true;
hypfield1.HeaderText = b[1] + a[1];
hypfield1.DataTextField = a[1];
hypfield1.NavigateUrl = ("CreateUser.aspx?td=" + b[1] + ",id=" + a[2] + "");
GridView1.Columns.Add(hypfield1);
HyperLinkField hypfield2 = new HyperLinkField();
hypfield2.ShowHeader = true;
hypfield2.HeaderText = b[2] + a[2];
hypfield2.DataTextField = a[2];
hypfield2.NavigateUrl = ("CreateUser.aspx?td=" + b[2] + ",id=" + a[2] + "");
GridView1.Columns.Add(hypfield2);
HyperLinkField hypfield3 = new HyperLinkField();
hypfield3.ShowHeader = true;
hypfield3.HeaderText = b[3] + a[3];
hypfield3.DataTextField = a[3];
hypfield3.NavigateUrl = ("CreateUser.aspx?td=" + b[3] + ",id=" + a[2] + "");
GridView1.Columns.Add(hypfield3);
HyperLinkField hypfield4 = new HyperLinkField();
hypfield4.ShowHeader = true;
hypfield4.HeaderText = b[4] + a[4];
hypfield4.DataTextField = a[4];
hypfield4.NavigateUrl = ("CreateUser.aspx?td=" + b[4] + ",id=" + a[2] + "");
GridView1.Columns.Add(hypfield4);
HyperLinkField hypfield5 = new HyperLinkField();
hypfield5.ShowHeader = true;
hypfield5.HeaderText = b[5] + a[5];
hypfield5.DataTextField = a[5];
hypfield5.NavigateUrl = ("CreateUser.aspx?td=" + b[5] + ",id=" + a[2] + "");
GridView1.Columns.Add(hypfield5);
HyperLinkField hypfield6 = new HyperLinkField();
hypfield6.ShowHeader = true;
hypfield6.HeaderText = b[6] + a[6];
hypfield6.DataTextField = a[6];
hypfield6.NavigateUrl = ("CreateUser.aspx?td=" + b[6] + ",id=" + a[2] + "");
GridView1.Columns.Add(hypfield6);
HyperLinkField hypfield7 = new HyperLinkField();
hypfield7.ShowHeader = true;
hypfield7.HeaderText = b[7] + a[7];
hypfield7.DataTextField = a[7];
hypfield7.NavigateUrl = ("CreateUser.aspx?td=" + b[7] + ",id=" + a[2] + "");
GridView1.Columns.Add(hypfield7);
GridView1.DataBind();
}
protected void GridView1_DataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
}
}
private string date(DateTime d)
{
string str = d.DayOfWeek.ToString();
string dates = "";
switch (str)
{
case "Monday": dates = "星期一"; break;
case "Tuesday": dates = "星期二"; break;
case "Wednesday": dates = "星期三"; break;
case "Thursday": dates = "星期四"; break;
case "Friday": dates = "星期五"; break;
case "Saturday": dates = "星期六"; break;
case "Sunday": dates = "星期日"; break;
}
return dates;
}
private string dateR(DateTime r)
{
string str = r.ToLongDateString();
return str;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}