protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Hospital.Service1SoapClient ss = new Hospital.Service1SoapClient(); string s = ss.GetSQLConnect(); string q = Request.Url.Query; int index = q.IndexOf("index="); string user = q.Substring(6, index - 6); Hospital.DeptEntity[] get = ss.GetUserDept(user); int i = int.Parse(q.Substring(index + 6)); dept = get[i].Name; input.Value = dept; } BindData(); }
protected void userName_input_onclick(object sender, EventArgs e) { Hospital.Service1SoapClient ss = new Hospital.Service1SoapClient(); string s = ss.GetSQLConnect(); Hospital.DeptEntity[] de = ss.GetUserDept(userName_input.Value); if (de.Length == 0) { wrong.Visible = true; dept_ddl.Items.Clear(); } foreach (Hospital.DeptEntity d in de) { ListItem li = new ListItem(d.Name, d.Id.ToString()); dept_ddl.Items.Add(li); wrong.Visible = false; } }
protected void sub_click(object sender, EventArgs e) { string user = userName_input.Value; string pwd = pwd_input.Value; Hospital.Service1SoapClient ss = new Hospital.Service1SoapClient(); string s = ss.GetSQLConnect(); Hospital.Staff2Entity res = ss.UserLogin(user, pwd, int.Parse(dept_ddl.SelectedValue)); if (res.Id != 0) { HttpCookie cookie = new HttpCookie("USER_COOKIE"); if (rmb_pwd.Checked) { cookie.Values.Add("UserName", this.userName_input.Value.Trim()); cookie.Values.Add("UserPassword", this.pwd_input.Value.Trim()); cookie.Values.Add("indx", this.dept_ddl.SelectedIndex.ToString()); //这里是设置Cookie的过期时间,这里设置一个星期的时间,过了一个星期之后状态保持自动清空。 cookie.Expires = System.DateTime.Now.AddDays(7.0); HttpContext.Current.Response.Cookies.Add(cookie); } else { if (cookie != null) { Response.Cookies["USER_COOKIE"].Expires = DateTime.Now; } } _Default a = new _Default(); string url = "http://192.168.1.139:31/Default.aspx?user="******"dept"] = dept_ddl.SelectedItem.Text; url += userName_input.Value; url += "index=" + dept_ddl.SelectedIndex; Response.Redirect(url); } else { wrong.Visible = true; } }
protected void BindData() { selapply.Visible = true; Hospital.Service1SoapClient ss = new Hospital.Service1SoapClient(); string s = ss.GetSQLConnect(); Hospital.VisitEntity[] get = ss.GetVisitData(dept); GridView1.PageSize = int.Parse(pageSize.SelectedItem.Value.ToString()); DataTable dt = new DataTable(); if (get.Length == 0) { return; } ArrayList all = fillValues(get[0]); for (int i = 0; i < attrs.Length; i++) { if (attrs[i].Equals("Age") || attrs[i].Equals("BedCode") || attrs[i].Equals("BedId") || attrs[i].Equals("CaseNo") || all[i].GetType() == typeof(int)) { DataColumn agecol = new DataColumn(attrs[i]); agecol.DataType = typeof(int); dt.Columns.Add(agecol); continue; } else if (attrs[i].Equals("AdmitDit") || attrs[i].Equals("DischargeDt")) { DataColumn datecol = new DataColumn(attrs[i]); datecol.DataType = typeof(DateTime); dt.Columns.Add(datecol); continue; } dt.Columns.Add(attrs[i]); } for (int i = 0; i < get.Length; i++) { ArrayList al = fillValues(get[i]); DataRow dr = dt.NewRow(); for (int j = 0; j < attrs.Length; j++) { dr[attrs[j]] = al[j]; } dt.Rows.Add(dr); } Session["hi"] = dt; DataRow[] sel_drs = dt.Select(seletion()); DataTable sel_tbl = new DataTable(); sel_tbl = dt.Clone(); foreach (DataRow dr in sel_drs) { sel_tbl.Rows.Add(dr.ItemArray); } DataView dv = new DataView(sel_tbl); dv.Sort = sortExpression + sortDirection; if (ward.Items.Count == 1) { DataTable tmp = dv.ToTable(true, "Dept"); foreach (DataRow a in tmp.Columns["Dept"].Table.Rows) { ListItem item = new ListItem(a.ItemArray[0].ToString(), a.ItemArray[0].ToString()); ward.Items.Add(item); } } GridView1.DataSource = dv; GridView1.DataBind(); }