dwinfo.cs
上传用户:toshiba_01
上传日期:2007-06-08
资源大小:306k
文件大小:13k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data ;
using System.Data .SqlClient ;
- namespace RoomManage
- {
- /// <summary>
- /// dwinfo 的摘要说明。
- /// </summary>
- public class dwinfo : System.Windows.Forms.Form
- {
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.TextBox textBox3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.TextBox textBox4;
- private System.Windows.Forms.TextBox textBox5;
- private System.Windows.Forms.TextBox textBox6;
- private System.Windows.Forms.TextBox textBox7;
- private System.Windows.Forms.TextBox textBox8;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.Button button3;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- string opername;//传递操作员姓名
- string[] chushi={"","","","","","","",""};
-
- DataConn dc=new DataConn ();
- public dwinfo(string s)
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- this.opername =s;
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.textBox4 = new System.Windows.Forms.TextBox();
- this.textBox5 = new System.Windows.Forms.TextBox();
- this.textBox6 = new System.Windows.Forms.TextBox();
- this.textBox7 = new System.Windows.Forms.TextBox();
- this.textBox8 = new System.Windows.Forms.TextBox();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(8, 8);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(72, 23);
- this.label1.TabIndex = 0;
- this.label1.Text = "单位名称:";
- this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(8, 32);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(72, 23);
- this.label2.TabIndex = 0;
- this.label2.Text = "地 址:";
- this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(8, 56);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(72, 23);
- this.label3.TabIndex = 0;
- this.label3.Text = "邮政编码:";
- this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(8, 80);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(72, 23);
- this.label5.TabIndex = 0;
- this.label5.Text = "传 真:";
- this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(192, 104);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(72, 23);
- this.label6.TabIndex = 0;
- this.label6.Text = "网 址:";
- this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(8, 104);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(72, 23);
- this.label7.TabIndex = 0;
- this.label7.Text = "电子邮件:";
- this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(192, 80);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(72, 23);
- this.label8.TabIndex = 0;
- this.label8.Text = "财务主管:";
- this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label9
- //
- this.label9.Location = new System.Drawing.Point(192, 144);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(72, 23);
- this.label9.TabIndex = 0;
- this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(80, 9);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(288, 21);
- this.textBox1.TabIndex = 1;
- this.textBox1.Text = "";
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(80, 33);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(288, 21);
- this.textBox2.TabIndex = 1;
- this.textBox2.Text = "";
- //
- // textBox3
- //
- this.textBox3.Location = new System.Drawing.Point(264, 57);
- this.textBox3.Name = "textBox3";
- this.textBox3.TabIndex = 1;
- this.textBox3.Text = "";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(192, 56);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(72, 23);
- this.label4.TabIndex = 0;
- this.label4.Text = "电 话:";
- this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // textBox4
- //
- this.textBox4.Location = new System.Drawing.Point(80, 105);
- this.textBox4.Name = "textBox4";
- this.textBox4.TabIndex = 1;
- this.textBox4.Text = "";
- //
- // textBox5
- //
- this.textBox5.Location = new System.Drawing.Point(80, 81);
- this.textBox5.Name = "textBox5";
- this.textBox5.TabIndex = 1;
- this.textBox5.Text = "";
- //
- // textBox6
- //
- this.textBox6.Location = new System.Drawing.Point(80, 57);
- this.textBox6.Name = "textBox6";
- this.textBox6.TabIndex = 1;
- this.textBox6.Text = "";
- //
- // textBox7
- //
- this.textBox7.Location = new System.Drawing.Point(264, 81);
- this.textBox7.Name = "textBox7";
- this.textBox7.TabIndex = 1;
- this.textBox7.Text = "";
- //
- // textBox8
- //
- this.textBox8.Location = new System.Drawing.Point(264, 105);
- this.textBox8.Name = "textBox8";
- this.textBox8.TabIndex = 1;
- this.textBox8.Text = "";
- //
- // groupBox1
- //
- this.groupBox1.Location = new System.Drawing.Point(0, 136);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(384, 3);
- this.groupBox1.TabIndex = 2;
- this.groupBox1.TabStop = false;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(8, 144);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(48, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "保存";
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(64, 144);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(48, 23);
- this.button2.TabIndex = 1;
- this.button2.Text = "还原";
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(120, 144);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(48, 23);
- this.button3.TabIndex = 2;
- this.button3.Text = "退出";
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // dwinfo
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(376, 173);
- this.ControlBox = false;
- this.Controls.Add(this.button1);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.label6);
- this.Controls.Add(this.label7);
- this.Controls.Add(this.label8);
- this.Controls.Add(this.label9);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox3);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.textBox4);
- this.Controls.Add(this.textBox5);
- this.Controls.Add(this.textBox6);
- this.Controls.Add(this.textBox7);
- this.Controls.Add(this.textBox8);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button3);
- this.MaximizeBox = false;
- this.MaximumSize = new System.Drawing.Size(384, 200);
- this.MinimizeBox = false;
- this.MinimumSize = new System.Drawing.Size(384, 200);
- this.Name = "dwinfo";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "本单位信息维护";
- this.TopMost = true;
- this.Load += new System.EventHandler(this.dwinfo_Load);
- this.ResumeLayout(false);
- }
- #endregion
-
-
- private void dwinfo_Load(object sender, System.EventArgs e)
- {
- this.AcceptButton =this.button1 ;
- this.label9 .Text ="操作员:"+this.opername ;
-
- string str=dc.connstr ;
- SqlConnection conn=new SqlConnection (str);
- string sql="select * from tabbdwdy";
- SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
- DataSet dataset=new DataSet ();
- adapter.Fill (dataset,"tab");
- this.textBox1 .DataBindings.Add (new Binding ("Text",dataset,"tab.单位名称"));
- this.textBox2 .DataBindings.Add (new Binding ("Text",dataset,"tab.地址"));
- this.textBox3 .DataBindings.Add (new Binding ("Text",dataset,"tab.电话"));
- this.textBox4 .DataBindings.Add (new Binding ("Text",dataset,"tab.电子邮件"));
- this.textBox5 .DataBindings.Add (new Binding ("Text",dataset,"tab.传真"));
- this.textBox6 .DataBindings.Add (new Binding ("Text",dataset,"tab.邮政编码"));
- this.textBox7 .DataBindings.Add (new Binding ("Text",dataset,"tab.财务主管"));
- this.textBox8 .DataBindings.Add (new Binding ("Text",dataset,"tab.网址"));
-
- //释放所有绑定
- this.textBox1 .DataBindings .Clear ();
- this.textBox2 .DataBindings .Clear ();
- this.textBox3 .DataBindings .Clear ();
- this.textBox4 .DataBindings .Clear ();
- this.textBox5 .DataBindings .Clear ();
- this.textBox6 .DataBindings .Clear ();
- this.textBox7 .DataBindings .Clear ();
- this.textBox8 .DataBindings .Clear ();
-
- chushi[0]=textBox1.Text ;
- chushi[1]=textBox2.Text ;
- chushi[2]=textBox3.Text ;
- chushi[3]=textBox4.Text ;
- chushi[4]=textBox5.Text ;
- chushi[5]=textBox6.Text ;
- chushi[6]=textBox7.Text ;
- chushi[7]=textBox8.Text ;
- conn.Dispose ();
- adapter.Dispose ();
- dataset.Dispose ();
- }
- private void button1_Click(object sender, System.EventArgs e)
- {
- string str=dc.connstr ;
- SqlConnection conn=new SqlConnection (str);
- string sql="update tabbdwdy set 单位名称='"+this.textBox1 .Text +"',地址='"+this.textBox2 .Text +"',邮政编码='"+this.textBox6.Text +"',电话='"+this.textBox3 .Text +"',传真='"+this.textBox5.Text +"',财务主管='"+this.textBox7.Text +"',电子邮件='"+this.textBox4.Text +"',网址='"+this.textBox8.Text +"'";
- SqlCommand cmd=new SqlCommand (sql,conn);
- conn.Open ();
- try
- {
- cmd.ExecuteNonQuery ();
- MessageBox.Show("保存成功。","恭喜");
- }
- catch(Exception err)
- {
- MessageBox.Show(err.Message,"保存信息出错!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
- }
- finally
- {
- conn.Close ();
- cmd.Dispose ();
- }
- }
- private void button3_Click(object sender, System.EventArgs e)
- {
- if(MessageBox.Show("真的要退出吗?","注意",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
- this.Close ();
- }
- private void button2_Click(object sender, System.EventArgs e)
- {
- textBox1.Text =chushi[0];
- textBox2.Text =chushi[1];
- textBox3.Text =chushi[2];
- textBox4.Text =chushi[3];
- textBox5.Text =chushi[4];
- textBox6.Text =chushi[5];
- textBox7.Text =chushi[6];
- textBox8.Text =chushi[7];
- }
- }
- }