private void button1_Click(object sender, EventArgs e) { String str1 = 注册账号.Text; //form里面有输入账号密码的文本框,这一步是获取其内容; String str2 = 注册密码.Text; String str3 = 族谱号.Text; String str4 = null; if (str3.Length == 0) { str4 = "insert into [User] values('" + str1 + "','" + str2 + "',NULL)"; } else { str4 = "insert into [User] values('" + str1 + "','" + str2 + "','" + str3 + "')"; } gene r2 = new gene(); //用来连接数据库的类gene,所以用其创建对象; int d2 = r2.ExecuteUpdate(str4); //执行后会有返回值,是int类型,如果执行失败会返回0; if (d2 != 0) { MessageBox.Show("注册成功!", "添加结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); Form 登录 = new 登录界面(); //这两行代码是实现界面跳转; Hide(); } else { MessageBox.Show("信息错误,\n请重新输入!", "添加结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } }
private void button6_Click(object sender, EventArgs e) { String str1 = shanchu族谱.Text; String str2 = "DELETE FROM [genealogy] WHERE genealogy_ID = '" + str1 + "'"; gene r2 = new gene(); //用来连接数据库的类gene,所以用其创建对象; int d2 = r2.ExecuteUpdate(str2); //执行后会有返回值,是int类型,如果执行失败会返回0; if (d2 != 0) { MessageBox.Show("确认删除族谱吗?", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); } else { MessageBox.Show("删除错误!\n", "删除结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } }
private void button4_Click(object sender, EventArgs e) { String str1 = addmemID.Text; String str2 = addzupuID.Text; String str3 = add父亲ID.Text; String str4 = memname.Text; String str5 = sex.Text; String str6 = number.Text; String str7 = birthdate.Text; String str8 = deathdate.Text; String str9 = birthplace.Text; String str10 = address.Text; String str11 = spousename.Text; String str12 = spousestate.Text; String str13 = null; if (str11.Length == 0) { str13 = "UPDATE [Member] SET Member_ID='" + str1 + "',Genealogy_ID='" + str2 + "',Father_ID='" + str3 + "',name='" + str4 + "'," + "sex='" + str5 + "' ,number='" + str6 + "',birth='" + str7 + "',death='" + str8 + "',birthplace='" + str9 + "',address='" + str10 + "'," + "spouse_name=NULL,spouse_state=NULL"; //编写sql语句,赋值给一个string变量,然后传给ExecuteQuery来执行; } else { str13 = "UPDATE [Member] SET Member_ID='" + str1 + "',Genealogy_ID='" + str2 + "',Father_ID='" + str3 + "',name='" + str4 + "'," + "sex='" + str5 + "' ,number='" + str6 + "',birth='" + str7 + "',death='" + str8 + "',birthplace='" + str9 + "',address='" + str10 + "'," + "spouse_name='" + str11 + "',spouse_state='" + str12 + "'"; //编写sql语句,赋值给一个string变量,然后传给ExecuteQuery来执行; } gene r2 = new gene(); //用来连接数据库的类gene,所以用其创建对象; int d2 = r2.ExecuteUpdate(str13); //执行后会有返回值,是int类型,如果执行失败会返回0; if (d2 != 0) { MessageBox.Show("修改成功!", "修改结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } else { MessageBox.Show("信息错误,\n请重新输入!", "修改结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } }
private void button4_Click(object sender, EventArgs e) { String str1 = xiugai族谱号.Text; //form里面有输入账号密码的文本框,这一步是获取其内容; String str2 = 家族姓氏.Text; String str3 = 族长.Text; String str4 = 族谱简介.Text; String str5 = "UPDATE [genealogy] SET Last_name='" + str2 + "',patriarch='" + str3 + "',introduction='" + str4 + "' WHERE genealogy_ID='" + str1 + "'"; //编写sql语句,赋值给一个string变量,然后传给ExecuteQuery来执行; gene r2 = new gene(); //用来连接数据库的类gene,所以用其创建对象; int d2 = r2.ExecuteUpdate(str5); //执行后会有返回值,是int类型,如果执行失败会返回0; if (d2 != 0) { MessageBox.Show("修改成功!", "修改结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } else { MessageBox.Show("信息错误,\n请重新输入!", "修改结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } }
private void button1_Click(object sender, EventArgs e) { String str1 = 族谱号.Text; //form里面有输入账号密码的文本框,这一步是获取其内容; String str2 = 家族姓氏.Text; String str3 = 族长.Text; String str4 = 族谱简介.Text; String str5 = "insert into [genealogy] values('" + str1 + "','" + str2 + "','" + str3 + "','" + str4 + "')"; //编写sql语句,赋值给一个string变量,然后传给ExecuteQuery来执行; gene r2 = new gene(); //用来连接数据库的类gene,所以用其创建对象; int d2 = r2.ExecuteUpdate(str5); //执行后会有返回值,是int类型,如果执行失败会返回0; if (d2 != 0) { MessageBox.Show("新建成功!", "新建结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } else { MessageBox.Show("信息错误,\n请重新输入!", "新建结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } }
private void 修改_Click(object sender, EventArgs e) { String str1 = 登录界面.form1.登录账号.Text; //form里面有输入账号密码的文本框,这一步是获取其内容; String str2 = 修改密码.Text; String str3 = 族谱号.Text; String str4 = "UPDATE [User] SET [key]='" + str2 + "',genealogy_ID='" + str3 + "' WHERE User_ID='" + str1 + "'"; //编写sql语句,赋值给一个string变量,然后传给ExecuteQuery来执行; gene r2 = new gene(); //用来连接数据库的类gene,所以用其创建对象; int d2 = r2.ExecuteUpdate(str4); //执行后会有返回值,是int类型,如果执行失败会返回0; if (d2 != 0) { MessageBox.Show("修改成功!", "修改结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); Form 登录 = new 登录界面(); //这两行代码是实现界面跳转; Hide(); } else { MessageBox.Show("信息错误,\n请重新输入!", "修改结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } }
private void button1_Click(object sender, EventArgs e) { String str1 = addmemID.Text; String str2 = addzupuID.Text; String str3 = add父亲ID.Text; String str4 = memname.Text; String str5 = sex.Text; String str6 = number.Text; String str7 = birthdate.Text; String str8 = deathdate.Text; String str9 = birthplace.Text; String str10 = address.Text; String str11 = spousename.Text; String str12 = spousestate.Text; String str13 = null; if (str11.Length == 0) { str13 = "insert into [Member] values('" + str1 + "','" + str3 + "','" + str2 + "','" + str4 + "','" + str5 + "' ,'" + str7 + "','" + str8 + "','" + str9 + "','" + str10 + "', NULL,NULL, '" + str6 + "' ) "; //编写sql语句,赋值给一个string变量,然后传给ExecuteQuery来执行; } else { str13 = "insert into [Member] values('" + str1 + "','" + str3 + "','" + str2 + "','" + str4 + "','" + str5 + "' ,'" + str7 + "','" + str8 + "','" + str9 + "','" + str10 + "','" + str11 + "', '" + str12 + "' , '" + str6 + "' ) "; //编写sql语句,赋值给一个string变量,然后传给ExecuteQuery来执行; } gene r2 = new gene(); //用来连接数据库的类gene,所以用其创建对象; int d2 = r2.ExecuteUpdate(str13); //执行后会有返回值,是int类型,如果执行失败会返回0; if (d2 != 0) { MessageBox.Show("添加成功!", "添加结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } else { MessageBox.Show("保存失败,\n请重新输入!", "添加结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } }