ÓÃC#×ö»ð³µ¶©Æ±¹ÜÀíϵͳ¿Î³ÌÉè¼Æ

ÄÚÈÝ·¢²¼¸üÐÂʱ¼ä : 2025/5/3 15:55:22ÐÇÆÚÒ» ÏÂÃæÊÇÎÄÕµÄÈ«²¿ÄÚÈÝÇëÈÏÕæÔĶÁ¡£

reread(); } else {

MessageBox.Show(\ÍËÆ±Ê§°Ü!\ } }

catch (Exception ex) {

MessageBox.Show(ex.Message); } } //¹ÜÀíÔ±Ôö¼Ó³µÆ±

private void btnluru_Click(object sender, EventArgs e) {

if (txtcheci.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÈë³µ´Î £¡MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

if (txtstartzhan.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÈë³ö·¢µØ £¡MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

if (txtsfshijian.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÈë³ö·¢Ê±¼ä£¡MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

if (txtendzhan.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÈëÄ¿µÄµØ £¡MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

if (txtdaodashijian.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÈëµ½´ïʱ¼ä £¡MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

27

\\Information:\\\Information:\

\\Information:\

\\Information:\

\\Information:\

return; }

if (txtyingzuoshu.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÈ복ƱÊýÁ¿ £¡ \\Information:\

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

if (txtyingzuopiaojia.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÈ복Ʊ¼Û¸ñ£¡ \\Information:\

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; } try {

string strSql = \³µÆ±ÐÅÏ¢±í values ('\ + txtcheci.Text + \ + txtstartzhan.Text + \ + txtsfshijian.Text + \ + txtendzhan.Text + \ + txtdaodashijian.Text + \ + txtyingzuoshu.Text + \

+ txtyingzuopiaojia.Text + \ //Á¬½Ó×Ö·û´®

string conn = \Source=2013-20141011IV;Initial Catalog=»ð³µÆ±¹ÜÀíϵͳ;User

ID=sa;Password=123456\

//Ö´ÐÐÓï¾ä

if (ExecuteNonQuery(strSql, conn) > 0) {

MessageBox.Show(\Ìí¼Ó³É¹¦!\ return; } else {

MessageBox.Show(\Ìí¼Óʧ°Ü!\ } }

catch (Exception ex) {

MessageBox.Show(ex.Message); } }

28

//¹«ÓÃÖ´Ðк¯ÊýExecuteNonQuery

public int ExecuteNonQuery(string sql, string conStr) {

using (SqlConnection con = new SqlConnection(conStr)) {

con.Open();

SqlCommand cmd = new SqlCommand(sql, con); return cmd.ExecuteNonQuery(); } } //²é¿´¶©µ¥

private void mytrian_Load(object sender, EventArgs e) {

this.³µÆ±Ô¤¶©±íTableAdapter.Fill(this.»ð³µÆ±¹ÜÀíϵͳDataSet2ÎÒµÄ»ð³µÆ±.³µÆ±Ô¤¶©±í);

SqlConnection conn = new SqlConnection();

conn.ConnectionString = \Source=2013-20141011IV;Initial Catalog=»ð³µÆ±¹ÜÀíϵͳ;User

ID=sa;Password=123456\

conn.Open();

String cmdStr = \³µÆ±Ô¤¶©±í where Óû§ºÅ= '\ SqlCommand sqlCom = new SqlCommand(cmdStr, conn); SqlDataAdapter myadap = new SqlDataAdapter(); myadap.SelectCommand = sqlCom; DataSet myset = new DataSet(); myadap.Fill(myset, \³µÆ±Ô¤¶©±í\

this.dataGridView1.DataSource = myset.Tables[\³µÆ±Ô¤¶©±í\

}

//Óû§ÐÞ¸ÄÃÜÂë

public partial class updatemima : Form {

public updatemima() {

InitializeComponent(); }

private bool check() {

string str = this.txtzhanghao.Text;

SqlConnection conn = new SqlConnection();

conn.ConnectionString = \Source=2013-20141011IV;Initial Catalog=»ð³µÆ±¹ÜÀíϵͳ;User

ID=sa;Password=123456\

conn.Open();

String commstring = \ÃÜÂë from Óû§±í where Óû§ºÅ='\ SqlCommand change_comm = new SqlCommand(commstring, conn); SqlDataReader reader = change_comm.ExecuteReader();

29

if (reader.Read() == true) {

if (reader[\ÃÜÂë\ {

MessageBox.Show(this, \ ÄúÊäÈëµÄÔ­ÃÜÂë²»ÕýÈ· £¡ \\Information:\

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

reader.Close(); conn.Close(); return false; } else {

reader.Close(); conn.Close(); return true; } } else {

MessageBox.Show(this, \ ²»´æÔÚÄúÊäÈëµÄµÇ¼ÕʺŠ£¡ \\Information:\

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

reader.Close(); conn.Close(); return false; } }

private void change_code() {

string str1 = this.txtxinmima.Text;

string connstring1 = \Source=2013-20141011IV;Initial Catalog=»ð³µÆ±¹ÜÀíϵͳ;User

ID=sa;Password=123456\

SqlConnection conn1 = new SqlConnection(connstring1); conn1.Open();

string commstring1 = \Óû§±í set ÃÜÂë='\ SqlCommand comm1 = new SqlCommand(commstring1, conn1); comm1.ExecuteNonQuery(); conn1.Close();

MessageBox.Show(\µÇ¼ÃÜÂëÐ޸ijɹ¦£¡\Ìáʾ\ }

private void btnconfim_Click(object sender, EventArgs e) {

bool str;

if (txtzhanghao.Text == string.Empty)

30

{

MessageBox.Show(this, \ ÇëÊäµÇ¼ÕʺŠ£¡ \\Information:\

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

if (txtyuanmima.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÔ­µÇ¼ÃÜÂë £¡ \\Information:\

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

if (txtxinmima.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÊäÈëеǼÃÜÂë £¡ \\Information:\

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

if (txtxinmimaagain.Text == string.Empty) {

MessageBox.Show(this, \ ÇëÔÙ´ÎÊäÈëеǼÃÜÂë £¡ \\Information:\

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

return; }

str = check(); if (str == false) {

return; } else {

if (this.txtxinmima.Text != this.txtxinmimaagain.Text) {

MessageBox.Show(this, \ ÄúÁ½´ÎÊäÈëµÄÐÄÃÜÂë²»Ò»Ö £¡ \\

Information:\

} else {

change_code(); } } } //²é¿´Óû§ÐÅÏ¢

private void userxinxi_Load(object sender, EventArgs e)

31

ÁªÏµ¿Í·þ£º779662525#qq.com(#Ìæ»»Îª@) ËÕICP±¸20003344ºÅ-4 ceshi