/// <summary> /// 获得用户名和密码后,点击连接按钮conDB后,查看能否连接数据库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void conDB_Click(object sender, EventArgs e) { Parameters.dbusername = this.tboxname.Text.Trim(); Parameters.dbpassword = this.tboxpw.Text.Trim(); Parameters.user_info = @"Server = localhost;database = User_info;User ID = " + Parameters.dbusername + ";Password = "******";"; Parameters.event_info = @"Server = localhost;database = Event_info;User ID = " + Parameters.dbusername + ";Password = "******";"; Parameters.spatial_info = @"Server = localhost;database = Spatial_info;User ID = " + Parameters.dbusername + ";Password = "******";"; //测试能否连接数据库 DTConnection conn = new DTConnection(); //显示登录情况 if (conn.TestDBConn()) { this.Hide(); MessageBox.Show("数据库连接成功!"); UILogin log = new UILogin();//打开登录界面 log.Show(); } else { MessageBox.Show("数据库连接失败!"); } }
private void Logout_Click(object sender, EventArgs e) { Parameters.settingstate = false; if (Parameters.haslogined&&!Parameters.loginstate) { Parameters.haslogined = false; Parameters.loginstate = true; Parameters.loadPinhu(); UILogin ulg = new UILogin(); ulg.Show(); } this.Close(); }
public void Insert(String name, String password, int sort) { //匹配 corr1.Add("@username"); corr1.Add("@password"); corr2.Add(name); corr2.Add(password); String insertText = null; switch (sort) { case 0: { insertText = "Insert Into StudentInfo(StudentInfo_NickName,StudentInfo_Password) values('" + name + "','" + password + "')"; break; } case 1: { insertText = "Insert Into MerchantInfo(Merchant_Name,Merchant_Password) values('" + name + "','" + password + "')"; break; } case 2: { insertText = "Insert Into AdminInfo(AdminInfo_NickName,AdminInfo_Password) values('" + name + "','" + password + "')"; break; } } String connectionString = Parameters.user_info; DTConnection con = new DTConnection(); string a = "insert into StudentInfo(StudentInfo_NickName,StudentInfo_Password) values('" + name + "','" + password + "')"; //插入信息 int result = con.UpdateCon(insertText, connectionString); if (result == 1) { MessageBox.Show("注册成功!"); } else { MessageBox.Show("注册失败!"); } UILogin r = new UILogin(); r.Show(); }
private void button1_Click(object sender, EventArgs e)//返回首页 { this.Hide(); UILogin hp = new UILogin(); hp.Show(); }
//点击登录,若未登录则登陆,若已登陆则提示 private void btnLogin_Click(object sender, EventArgs e) { if (!Parameters.haslogined) { //未登录 this.Hide(); Parameters.explorestate = false; UILogin r = new UILogin(); r.Show(); } else { MessageBox.Show("您已登陆!"); } }