private void button1_Click(object sender, EventArgs e) { dbConn.GetConnection("server=localhost;database=test;uid=root;pwd=jang7856;"); DatabaseConnection.conn.Open(); MySqlDataReader myRead; string sql = "select bounceball_score from Score where userId='" + UserData.Myid + "'"; impSql.getSql(sql); myRead = impSql.cmd.ExecuteReader(); if (myRead.HasRows) { if (myRead.Read()) { if (Convert.ToInt16(myRead["bounceball_score"]) > point) { MessageBox.Show("이전 기록보다 더 낮습니다."); } else if (Convert.ToInt16(myRead["bounceball_score"]) < point) { myRead.Close(); sql = "update Score set bounceball_score = '" + point + "' where userId ='" + UserData.Myid + "'"; impSql.getSql(sql); impSql.cmd.ExecuteNonQuery(); } } } myRead.Close(); dbConn.disPose(); DatabaseConnection.conn.Close(); Close(); }
private void button2_Click(object sender, EventArgs e) { if (!isChecked) { MessageBox.Show("Check your ID"); } else { dbConn.GetConnection("server=localhost;database=test;uid=root;pwd=jang7856;"); DatabaseConnection.conn.Open(); MySqlDataReader myRead; if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("Fill All Items!"); } else if (textBox2.Text == "admin") { MessageBox.Show("Unusable Id"); } else if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "") { string sql = "select id from UserInfo where id='" + textBox2.Text + "'"; impSql.getSql(sql); myRead = impSql.cmd.ExecuteReader(); if (myRead.HasRows) //하나 이상의 행이 있는지 { if (myRead.Read()) //다음레코드를 이동해서 데이터가 있으면 true, 없으면 false { if (myRead["id"].ToString() == textBox2.Text) { MessageBox.Show("Already Exist"); } } myRead.Close(); } else { impSql.getSql("insert into UserInfo(name,id,password) values " + "('" + textBox1.Text + "', '" + textBox2.Text + "' , '" + textBox3.Text + "')"); myRead.Close(); impSql.cmd.ExecuteNonQuery(); sql = "INSERT INTO Score(userId)Values" + "('" + textBox2.Text + "')"; impSql.getSql(sql); impSql.cmd.ExecuteNonQuery(); MessageBox.Show("Success!"); } } dbConn.disPose(); //데이터베이스 연결 해제 DatabaseConnection.conn.Close(); //데이터베이스 닫음 this.Close(); } }
private void button1_Click(object sender, EventArgs e) { dbConn.GetConnection("server=localhost;database=test;uid=root;pwd=jang7856;"); DatabaseConnection.conn.Open(); MySqlDataReader myRead; string sql = "select id, password from UserInfo where id='" + textBox1.Text + "'"; impSql.getSql(sql); myRead = impSql.cmd.ExecuteReader(); if (textBox1.Text != "" && textBox2.Text != "") { if (myRead.HasRows) { if (myRead.Read()) { if (myRead["password"].ToString() == textBox2.Text) { MessageBox.Show("Welcome " + myRead["id"] + "!"); UserData.Myid = textBox1.Text; this.Close(); new Main2().Show(); } else { MessageBox.Show("Wrong Password"); } } } else if (textBox1.Text == "admin" && textBox2.Text == "1234") { MessageBox.Show("Welcome Admin"); myRead.Close(); DatabaseConnection.conn.Close(); this.Close(); new UserMannegement().Show(); } else { MessageBox.Show("This Id is not exist"); } } else { if (textBox1.Text == "" && textBox2.Text == "") { MessageBox.Show("Input your information"); } else if (textBox2.Text != "") { MessageBox.Show("Input your Id"); } else { MessageBox.Show("Input your password"); } } myRead.Close(); DatabaseConnection.conn.Close(); }
private void label1_MouseEnter(object sender, EventArgs e) { timer1.Enabled = false; MessageBox.Show("Congratulation~!"); dbConn.GetConnection("server=localhost;database=test;uid=root;pwd=cs1234;"); DatabaseConnection.conn.Open(); MySqlDataReader myRead; string sql = "select maze_sec from Score where userId='" + UserData.Myid + "'"; impSql.getSql(sql); myRead = impSql.cmd.ExecuteReader(); if (myRead.HasRows) { if (myRead.Read()) { if (Convert.ToInt16(myRead["maze_sec"]) < count && Convert.ToInt16(myRead["maze_sec"]) != 0) { MessageBox.Show("이전 기록보다 더 늦습니다."); } else if (Convert.ToInt16(myRead["maze_sec"]) == 0) { myRead.Close(); sql = "update Score set maze_sec = '" + count + "' where userId ='" + UserData.Myid + "'"; impSql.getSql(sql); impSql.cmd.ExecuteNonQuery(); } else if (Convert.ToInt16(myRead["maze_sec"]) > count) { myRead.Close(); sql = "update Score set maze_sec = '" + count + "' where userId ='" + UserData.Myid + "'"; impSql.getSql(sql); impSql.cmd.ExecuteNonQuery(); } } } myRead.Close(); dbConn.disPose(); DatabaseConnection.conn.Close(); this.Close(); }