用户资料.cs
资源名称:类似QQ聊天程序.rar [点击查看]
上传用户:yan_wy
上传日期:2007-06-09
资源大小:112k
文件大小:10k
源码类别:
ICQ/即时通讯
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.IO;
- namespace qq
- {
- /// <summary>
- /// 资料 的摘要说明。
- /// </summary>
- public class 用户资料 : System.Windows.Forms.Form
- {
- Form1 form;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.TextBox textBox3;
- private System.Windows.Forms.PictureBox pictureBox1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.RichTextBox richTextBox1;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.TextBox textBox4;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.NumericUpDown numericUpDown1;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public 用户资料(Form1 f)
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- form=f;
- InitializeComponent();
- foreach(DataRow dt in this.form.sdata.dataset.Tables["me"].Rows)
- {
- try
- {
- this.textBox1.Text=form.userid;
- this.textBox2.Text=dt[0].ToString();
- this.textBox3.Text=dt[2].ToString();
- this.textBox4.Text=dt[4].ToString();
- this.richTextBox1.Text=dt[5].ToString();
- this.pictureBox1.Image=Image.FromFile(form.path+@"newface"+(dt[3].ToString()).Trim()+".bmp");
- this.numericUpDown1.Value=int.Parse(dt[3].ToString().Trim());
- }
- catch(Exception ee)
- {
- MessageBox.Show(ee.ToString());
- }
- }
- //
- // 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.textBox1 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.button1 = new System.Windows.Forms.Button();
- this.label4 = new System.Windows.Forms.Label();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.textBox4 = new System.Windows.Forms.TextBox();
- this.button2 = new System.Windows.Forms.Button();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- this.SuspendLayout();
- //
- // textBox1
- //
- this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.textBox1.Location = new System.Drawing.Point(64, 32);
- this.textBox1.Name = "textBox1";
- this.textBox1.ReadOnly = true;
- this.textBox1.Size = new System.Drawing.Size(64, 21);
- this.textBox1.TabIndex = 0;
- this.textBox1.Text = "";
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(16, 32);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(40, 24);
- this.label1.TabIndex = 1;
- this.label1.Text = "QQ";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(8, 80);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(48, 23);
- this.label2.TabIndex = 2;
- this.label2.Text = "呢称";
- //
- // textBox2
- //
- this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.textBox2.Location = new System.Drawing.Point(64, 80);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(64, 21);
- this.textBox2.TabIndex = 3;
- this.textBox2.Text = "";
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(0, 128);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(48, 24);
- this.label3.TabIndex = 4;
- this.label3.Text = "性别";
- this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // textBox3
- //
- this.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.textBox3.Location = new System.Drawing.Point(64, 128);
- this.textBox3.Name = "textBox3";
- this.textBox3.Size = new System.Drawing.Size(64, 21);
- this.textBox3.TabIndex = 4;
- this.textBox3.Text = "";
- //
- // pictureBox1
- //
- this.pictureBox1.Location = new System.Drawing.Point(184, 80);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(56, 48);
- this.pictureBox1.TabIndex = 6;
- this.pictureBox1.TabStop = false;
- //
- // button1
- //
- this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
- this.button1.Location = new System.Drawing.Point(168, 272);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(72, 32);
- this.button1.TabIndex = 9;
- this.button1.Text = "关闭";
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(8, 192);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(40, 24);
- this.label4.TabIndex = 8;
- this.label4.Text = "简介";
- //
- // richTextBox1
- //
- this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.richTextBox1.Location = new System.Drawing.Point(64, 176);
- this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.Size = new System.Drawing.Size(64, 56);
- this.richTextBox1.TabIndex = 5;
- this.richTextBox1.Text = "";
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(144, 184);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(32, 16);
- this.label5.TabIndex = 10;
- this.label5.Text = "年龄";
- //
- // textBox4
- //
- this.textBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.textBox4.Location = new System.Drawing.Point(200, 176);
- this.textBox4.Name = "textBox4";
- this.textBox4.Size = new System.Drawing.Size(56, 21);
- this.textBox4.TabIndex = 7;
- this.textBox4.Text = "";
- //
- // button2
- //
- this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
- this.button2.Location = new System.Drawing.Point(56, 272);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(72, 32);
- this.button2.TabIndex = 8;
- this.button2.Text = "修改";
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(184, 32);
- this.numericUpDown1.Maximum = new System.Decimal(new int[] {
- 85,
- 0,
- 0,
- 0});
- this.numericUpDown1.Minimum = new System.Decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(56, 21);
- this.numericUpDown1.TabIndex = 6;
- this.numericUpDown1.Value = new System.Decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- //
- // 用户资料
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(288, 325);
- this.Controls.Add(this.numericUpDown1);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.textBox4);
- this.Controls.Add(this.textBox3);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.richTextBox1);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.pictureBox1);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.MaximizeBox = false;
- this.Name = "用户资料";
- this.Text = "资料";
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- private void button1_Click(object sender, System.EventArgs e)
- {
- this.Close();
- }
- private void button2_Click(object sender, System.EventArgs e)
- {
- try
- {
- System.Data.SqlClient.SqlCommand updata=new System.Data.SqlClient.SqlCommand();
- updata.CommandText= "UPDATE [user] SET name='"+this.textBox2.Text+"',sex='"+this.textBox3.Text+"',age="+this.textBox4.Text+",jianjie='"+this.richTextBox1.Text+"',picture="+this.numericUpDown1.Text+" WHERE id="+form.userid;
- updata.Connection=this.form.sdata.sqlConnection1;
- this.form.sdata.sqlConnection1.Open();
- updata.ExecuteNonQuery();
- this.form.sdata.sqlConnection1.Close();
- MessageBox.Show("修改成功");
- this.form.sdata.yanzhen();
- }
- catch(Exception ee)
- {
- MessageBox.Show(ee.ToString());
- }
- }
- private void numericUpDown1_ValueChanged(object sender, System.EventArgs e)
- {
- this.pictureBox1.Image=Image.FromFile(form.path+@"newface"+this.numericUpDown1.Value+".bmp");
- }
- }
- }