private void button6_Click_1(object sender, EventArgs e) { course_info.course_id = textBox5.Text; course_info.course_name = textBox6.Text; course_info.course_type = comboBox2.SelectedItem.ToString(); course_info.Obligatory = radioButton3.Checked ? "必修" : "选修"; course_info.credit = domainUpDown4.Text; course_info.Theoretical_hours = domainUpDown5.Text; course_info.Experimental_hours = domainUpDown6.Text; course_info.id = textBox7.Text; string delsql = "delete from course_information where Course_Id= " + course_info.course_id; //delete from user_information where Id= 266; DBlink db4 = new DBlink(); //创建数据库连接对象 if (db4.DBconn()) { //连接数据库 if (db4.UpdataDeletAdd(delsql)) { MessageBox.Show("删除记录成功!"); this.Close(); } else { MessageBox.Show("删除失败!"); this.Close(); } } db4.DBclose();//关闭数据连接 }
//删除按钮 private void button2_Click(object sender, EventArgs e) { string delsql = "delete from user_information where Id= " + Globel.Id; //delete from user_information where Id= 266; DBlink db4 = new DBlink(); //创建数据库连接对象 if (db4.DBconn()) { //连接数据库 string Str1 = "select Id from login_info WHERE username = '******'"; Globel.Id = db4.Getstringsearch(Str1); string Str2 = "select name from user_information WHERE Id = '" + Globel.Id + "'"; if (db4.Getstringsearch(Str2).Equals(textBox2.Text)) { if (db4.UpdataDeletAdd(delsql) && MaxValue > 0) { MessageBox.Show("删除记录成功!"); this.Close(); } else { MessageBox.Show("删除失败!"); this.Close(); } } else { MessageBox.Show("您不能删除其他用户信息"); this.Close(); } } db4.DBclose();//关闭数据连接 }
private void button5_Click_1(object sender, EventArgs e) { course_info.course_id = textBox5.Text; course_info.course_name = textBox6.Text; course_info.course_type = comboBox2.SelectedItem.ToString(); course_info.Obligatory = radioButton3.Checked ? "必修" : "选修"; course_info.credit = domainUpDown4.Text; course_info.Theoretical_hours = domainUpDown5.Text; course_info.Experimental_hours = domainUpDown6.Text; course_info.id = textBox7.Text; string uptsql; uptsql = "update course_information set course_name='" + course_info.course_name + "', course_type='" + course_info.course_type + "', Obligatory='" + course_info.Obligatory + "', credit='" + course_info.credit + "', Theoretical_hours='" + course_info.Theoretical_hours + "', Experimental_hours ='" + course_info.Experimental_hours + "', Id='" + course_info.id + "'where Course_Id=" + course_info.course_id; DBlink db3 = new DBlink(); //创建数据库连接对象 if (db3.DBconn()) { //连接数据库 if (db3.UpdataDeletAdd(uptsql)) { MessageBox.Show("课程信息更新成功", "更新成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("未更新,请检查!", "无更新", MessageBoxButtons.OK, MessageBoxIcon.Information); } } db3.DBclose();//关闭数据连接 }
//注册事件 private void button1_Click_1(object sender, EventArgs e) { DBlink db = new DBlink(); //创建数据库连接对象 if (db.DBconn()) //连接数据库 { string str = "insert into login_info(Id,username,password,id_tag) values('" + RGnumber.Text + "','" + RGname.Text + "','" + RGpass.Text + "','" + Globel.id_tag + "');"; string info = "注册成功,请等待管理员审核!"; //如果是管理员执行的添加用户时tag直接为1,即不用审核 if (LoginInfo.isadmin) { info = "添加用户成功,该用户可以直接登录!"; str = "insert into login_info(Id,username,password,id_tag,tag) values('" + RGnumber.Text + "','" + RGname.Text + "','" + RGpass.Text + "','" + Globel.id_tag + "','" + 1 + "');"; } if (db.UpdataDeletAdd(str)) { DialogResult dr = MessageBox.Show(info, "标题", MessageBoxButtons.OK, MessageBoxIcon.Question); if (dr == DialogResult.OK) { this.Visible = false;//隐藏当前窗口 } } } db.DBclose();//关闭数据连接 }
public Boolean delete(String id) { String sql = "delete from member where id=" + id; DBlink dBLink = new DBlink(); dBLink.DBconn(); Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean delete(String username) { String sql = "DELETE FROM USER WHERE username='******'"; DBlink dBLink = new DBlink(); dBLink.DBconn(); Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean update(String username, String password) { String sql = "UPDATE `departmental_manage_system`.`user` SET `password`='" + password + "' WHERE (`username`='" + username + "');"; DBlink dBLink = new DBlink(); dBLink.DBconn(); Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean add(String username, String password) { String sql = "INSERT INTO `departmental_manage_system`.`user` (`username`, `password`, `authority`,`activated`) VALUES ('" + username + "', '" + password + "', '1','1');"; DBlink dBLink = new DBlink(); dBLink.DBconn(); Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean deleteAllByDepemtId(int id) { String sql = "delete from member where department_id=" + id; DBlink dBLink = new DBlink(); dBLink.DBconn(); Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean update(int id, String name, String sex, String position, String phone, int depmtId) { String sql = "UPDATE `departmental_manage_system`.`member` SET `name`='" + name + "', `sex`='" + sex + "', `position`='" + position + "', `phone`='" + phone + "', `department_id`='" + depmtId + "' WHERE (`id`='" + id + "');"; DBlink dBLink = new DBlink(); dBLink.DBconn(); Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean active(String Id) { DBlink dBLink = new DBlink(); dBLink.DBconn(); String sql = "UPDATE `departmental_manage_system`.`department` SET `activated`='1' WHERE (`id`='" + Id + "');"; Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
private void button1_Click(object sender, EventArgs e) { ScoreInfo.id = textBox1.Text; ScoreInfo.course_id = textBox2.Text; ScoreInfo.score = textBox3.Text; Boolean DBtag = false; MySqlConnection sqlCnn = new MySqlConnection(); //创建数据库连接对象 MySqlCommand sqlCmd1 = new MySqlCommand(); //创建执行sql的对象 MySqlCommand sqlCmd2 = new MySqlCommand(); //创建执行sql的对象 sqlCnn.ConnectionString = "server = localhost; uid = root; pwd = 052398; database = student_manage_system;"; //连接字符串 string Str1 = "select Course_name from course_information where Course_Id = " + textBox2.Text; string Str2 = "select name from user_information where Id = " + textBox1.Text; try { sqlCnn.Open(); DBtag = true; if (DBtag) { sqlCmd1.Connection = sqlCnn; sqlCmd1.CommandText = Str1; ScoreInfo.course_name = Convert.ToString(sqlCmd1.ExecuteScalar());// 执行查询 sqlCmd2.Connection = sqlCnn; sqlCmd2.CommandText = Str2; ScoreInfo.name = Convert.ToString(sqlCmd2.ExecuteScalar());// 执行查询 } } catch (Exception ex) { MessageBox.Show(ex.Message, "error"); } sqlCnn.Close(); //提交信息 DBlink db = new DBlink(); //创建数据库连接对象 if (db.DBconn()) { //连接数据库 string str1 = "insert into score_info(name,Id,course_name,Course_Id,score) " + "values('" + ScoreInfo.name + "','" + ScoreInfo.id + "','" + ScoreInfo.course_name + "','" + ScoreInfo.course_id + "','" + ScoreInfo.score + "');"; string info = "提交成功!"; if (db.UpdataDeletAdd(str1)) { DialogResult dr = MessageBox.Show(info, "标题", MessageBoxButtons.OK, MessageBoxIcon.Question); if (dr == DialogResult.OK) { this.Visible = false;//隐藏当前窗口 } } } db.DBclose();//关闭数据连接 }
public Boolean delete(String Id) { DBlink dBLink = new DBlink(); dBLink.DBconn(); String sql = "delete from department where id=" + Id + ""; Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean add(String name, String sex, String position, String phone, int depmtId) { String sql = "INSERT INTO `departmental_manage_system`.`member` (`name`, `sex`, `position`, `phone`, `department_id`) " + "VALUES ('" + name + "', '" + sex + "', '" + position + "', '" + phone + "', '" + depmtId + "');"; DBlink dBLink = new DBlink(); dBLink.DBconn(); Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean apply(String Name, String Admin, String adminId) { DBlink dBLink = new DBlink(); dBLink.DBconn(); if (adminId != "NULL") { adminId = "'" + adminId + "'"; } String sql = "INSERT INTO `departmental_manage_system`.`department` (`name`, `admin`,`admin_id`,`activated`) VALUES ('" + Name + "', '" + Admin + "'," + adminId + ",'0');"; Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
public Boolean update(int Id, String Name, String Admin, String adminId) { DBlink dBLink = new DBlink(); dBLink.DBconn(); if (adminId != "NULL") { adminId = "'" + adminId + "'"; } String sql = "UPDATE `departmental_manage_system`.`department` SET `name`='" + Name + "', `admin`='" + Admin + "', `admin_id`=" + adminId + " WHERE (`id`='" + Id + "');"; Boolean res = dBLink.UpdataDeletAdd(sql); dBLink.DBclose(); return(res); }
//确定 private void button3_Click(object sender, EventArgs e) { DBlink db = new DBlink(); //创建数据库连接对象 if (db.DBconn()) { //连接数据库 string str1 = "insert into course_information(Course_Id,course_name,course_type,Obligatory,credit,Theoretical_hours,Experimental_hours,id) " + "values('" + course_info.course_id + "','" + course_info.course_name + "','" + course_info.course_type + "','" + course_info.Obligatory + "','" + course_info.credit + "','" + course_info.Theoretical_hours + "','" + course_info.Experimental_hours + "','" + course_info.id + "');"; string info = "提交成功!"; if (db.UpdataDeletAdd(str1)) { DialogResult dr = MessageBox.Show(info, "标题", MessageBoxButtons.OK, MessageBoxIcon.Question); if (dr == DialogResult.OK) { this.Visible = false;//隐藏当前窗口 } } } db.DBclose();//关闭数据连接 }
private void button3_Click(object sender, EventArgs e) { ScoreInfo.id = textBox1.Text; ScoreInfo.course_id = textBox2.Text; string delsql = "delete from score_info where Id= '" + ScoreInfo.id + "'and Course_Id = '" + ScoreInfo.course_id + "'"; //delete from user_information where Id= 266; DBlink db4 = new DBlink(); //创建数据库连接对象 if (db4.DBconn()) { //连接数据库 if (db4.UpdataDeletAdd(delsql)) { MessageBox.Show("删除记录成功!"); this.Close(); } else { MessageBox.Show("删除失败!"); this.Close(); } } db4.DBclose();//关闭数据连接 }
//更新按钮 private void button1_Click(object sender, EventArgs e) { User_info.name = textBox2.Text; if (radioButton1.Checked) { User_info.sex = radioButton1.Text; } else { User_info.sex = radioButton2.Text; } User_info.birth = dateTimePicker1.Value.Date.ToLongDateString(); User_info.College_Id = comboBox1.SelectedItem.ToString(); User_info.Speciality = textBox3.Text; User_info.Hobby = ""; if (checkBox1.Checked) { User_info.Hobby += checkBox1.Text; } if (checkBox2.Checked) { User_info.Hobby += "、" + checkBox2.Text; } if (checkBox3.Checked) { User_info.Hobby += "、" + checkBox3.Text; } if (checkBox4.Checked) { User_info.Hobby += "、" + checkBox4.Text; } if (checkBox5.Checked) { User_info.Hobby += "、" + checkBox5.Text; } if (checkBox6.Checked) { User_info.Hobby += "、" + checkBox6.Text; } User_info.Political_Outlook = comboBox2.SelectedItem.ToString(); User_info.qualifications = comboBox3.SelectedItem.ToString(); User_info.id_tag = Globel.id_tag; string uptsql; uptsql = "update user_information set name='" + User_info.name + "', sex='" + User_info.sex + "', birth='" + User_info.birth + "', College_Id='" + User_info.College_Id + "', Speciality='" + User_info.Speciality + "', Hobby='" + User_info.Hobby + "', Political_Outlook ='" + User_info.Political_Outlook + "', qualifications='" + User_info.qualifications + "'where Id=" + Globel.Id; DBlink db3 = new DBlink(); //创建数据库连接对象 if (db3.DBconn()) { //连接数据库 string Str1 = "select Id from login_info WHERE username = '******'"; Globel.Id = db3.Getstringsearch(Str1); string Str2 = "select name from user_information WHERE Id = '" + Globel.Id + "'"; if (!db3.Getstringsearch(Str2).Equals(textBox2.Text)) { MessageBox.Show("您不能修改其他用户信息"); this.Close(); } else { if (db3.UpdataDeletAdd(uptsql)) { MessageBox.Show("用户信息更新成功", "更新成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("未更新,请检查!", "无更新", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } db3.DBclose();//关闭数据连接 //showInfo(state); }
//提交用户信息 private void button1_Click(object sender, EventArgs e) { //格式化用户所提交之信息 User_info.id = textBox1.Text; Globel.Id = User_info.id; User_info.name = Textname.Text; if (radioButton1.Checked) { User_info.sex = radioButton1.Text; } else { User_info.sex = radioButton2.Text; } User_info.birth = dateTimePicker1.Value.Date.ToLongDateString(); //MessageBox.Show(DateTime.Now.ToShortDateString().ToString()); User_info.College_Id = chooseCollege.SelectedItem.ToString(); User_info.Speciality = textBox2.Text; User_info.Hobby = ""; if (checkBox1.Checked) { User_info.Hobby += checkBox1.Text; } if (checkBox2.Checked) { User_info.Hobby += "、" + checkBox2.Text; } if (checkBox3.Checked) { User_info.Hobby += "、" + checkBox3.Text; } if (checkBox4.Checked) { User_info.Hobby += "、" + checkBox4.Text; } if (checkBox5.Checked) { User_info.Hobby += "、" + checkBox5.Text; } if (checkBox6.Checked) { User_info.Hobby += "、" + checkBox6.Text; } User_info.Political_Outlook = comboBox2.SelectedItem.ToString(); User_info.qualifications = comboBox3.SelectedItem.ToString(); User_info.id_tag = Globel.id_tag; //满足条件才能提交信息 if (bool1 == true) { DBlink db = new DBlink(); //创建数据库连接对象 if (db.DBconn()) { //连接数据库 string str1 = "insert into user_information(Id,name,sex,birth,College_Id,Speciality,Hobby,Political_Outlook,qualifications,id_tag) " + "values('" + User_info.id + "','" + User_info.name + "','" + User_info.sex + "','" + User_info.birth + "','" + User_info.College_Id + "','" + User_info.Speciality + "','" + User_info.Hobby + "','" + User_info.Political_Outlook + "','" + User_info.qualifications + "','" + User_info.id_tag + "');"; string info = "提交成功!"; if (db.UpdataDeletAdd(str1)) { DialogResult dr = MessageBox.Show(info, "标题", MessageBoxButtons.OK, MessageBoxIcon.Question); if (dr == DialogResult.OK) { this.Visible = false;//隐藏当前窗口 } } } db.DBclose();//关闭数据连接 } else { MessageBox.Show("您的学号输入错误,请核对"); } }