/// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); //初始化数据库连接字符串 cnStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]; ///test测试 ///5李丽 11宋述古 1我 Session["User"] = new Dallas.Core.User(11); /// //检查登陆 IsLogin(); user = (Dallas.Core.User)Session["User"]; //检查权限 if (!user.ValidatePermission(Request.FilePath)) { GotoDefault(); } // try // { // // Response.Write(user.ID); // } // catch (NullReferenceException) // { // Response.Redirect("../default.htm"); // } }
private void Start_Click(object sender, System.EventArgs e) { odcn.ConnectionString = @"Provider=Microsoft.Jet.Oledb.4.0;Data Source=D:\Documents and Settings\Administrator\My Documents\名单.xls;Extended Properties=Excel 8.0"; odda = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet3$]", odcn); odda.Fill(dataSet1); dg.DataBind(); Dallas.Core.User user = new Dallas.Core.User(); SqlDataReader sdr; Hashtable newUser, newUserInfo; cn.Open(); foreach (DataRow dr in dataSet1.Tables[0].Rows) { newUser = new Hashtable(); newUserInfo = new Hashtable(); newUser.Add("用户名", dr[1]); newUser.Add("密码", "111111"); cmd.CommandText = "select ID from 科室 where 科室名称='" + dr[3] + "'"; sdr = cmd.ExecuteReader(); if (sdr.Read()) { newUser.Add("科室ID", sdr[0]); } // else // throw new Exception(sdr[0]+":"+dr[0]); sdr.Close(); // newUser.Add("密码问题",PasswordQuestion.Text); // newUser.Add("密码答案",PasswordAnswer.Text); //设置状态为启用 newUser.Add("状态ID", 1); //设置类型为普通用户 newUser.Add("类型ID", 1); newUserInfo.Add("姓名", dr[0]); // newUserInfo.Add("性别",Sex.SelectedValue); // newUserInfo.Add("出生日期",BirthDate.Text); user.Register(newUser, newUserInfo); } cn.Close(); }