用户资料.cs
上传用户:yan_wy
上传日期:2007-06-09
资源大小:112k
文件大小:10k
源码类别:

ICQ/即时通讯

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.IO;
  8. namespace qq
  9. {
  10. /// <summary>
  11. /// 资料 的摘要说明。
  12. /// </summary>
  13. public class 用户资料 : System.Windows.Forms.Form
  14. {
  15. Form1 form;
  16. private System.Windows.Forms.TextBox textBox1;
  17. private System.Windows.Forms.Label label1;
  18. private System.Windows.Forms.Label label2;
  19. private System.Windows.Forms.TextBox textBox2;
  20. private System.Windows.Forms.Label label3;
  21. private System.Windows.Forms.TextBox textBox3;
  22. private System.Windows.Forms.PictureBox pictureBox1;
  23. private System.Windows.Forms.Button button1;
  24. private System.Windows.Forms.Label label4;
  25. private System.Windows.Forms.RichTextBox richTextBox1;
  26. private System.Windows.Forms.Label label5;
  27. private System.Windows.Forms.TextBox textBox4;
  28. private System.Windows.Forms.Button button2;
  29. private System.Windows.Forms.NumericUpDown numericUpDown1;
  30. /// <summary>
  31. /// 必需的设计器变量。
  32. /// </summary>
  33. private System.ComponentModel.Container components = null;
  34. public 用户资料(Form1 f)
  35. {
  36. //
  37. // Windows 窗体设计器支持所必需的
  38. //
  39.              form=f;
  40. InitializeComponent();
  41. foreach(DataRow dt in this.form.sdata.dataset.Tables["me"].Rows)
  42. {
  43. try
  44. {
  45.  
  46. this.textBox1.Text=form.userid;
  47. this.textBox2.Text=dt[0].ToString();
  48. this.textBox3.Text=dt[2].ToString();
  49. this.textBox4.Text=dt[4].ToString();
  50. this.richTextBox1.Text=dt[5].ToString();
  51. this.pictureBox1.Image=Image.FromFile(form.path+@"newface"+(dt[3].ToString()).Trim()+".bmp");
  52. this.numericUpDown1.Value=int.Parse(dt[3].ToString().Trim());
  53. }
  54. catch(Exception ee)
  55. {
  56. MessageBox.Show(ee.ToString());
  57. }
  58. }
  59. //
  60. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  61. //
  62. }
  63. /// <summary>
  64. /// 清理所有正在使用的资源。
  65. /// </summary>
  66. protected override void Dispose( bool disposing )
  67. {
  68. if( disposing )
  69. {
  70. if(components != null)
  71. {
  72. components.Dispose();
  73. }
  74. }
  75. base.Dispose( disposing );
  76. }
  77. #region Windows 窗体设计器生成的代码
  78. /// <summary>
  79. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  80. /// 此方法的内容。
  81. /// </summary>
  82. private void InitializeComponent()
  83. {
  84. this.textBox1 = new System.Windows.Forms.TextBox();
  85. this.label1 = new System.Windows.Forms.Label();
  86. this.label2 = new System.Windows.Forms.Label();
  87. this.textBox2 = new System.Windows.Forms.TextBox();
  88. this.label3 = new System.Windows.Forms.Label();
  89. this.textBox3 = new System.Windows.Forms.TextBox();
  90. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  91. this.button1 = new System.Windows.Forms.Button();
  92. this.label4 = new System.Windows.Forms.Label();
  93. this.richTextBox1 = new System.Windows.Forms.RichTextBox();
  94. this.label5 = new System.Windows.Forms.Label();
  95. this.textBox4 = new System.Windows.Forms.TextBox();
  96. this.button2 = new System.Windows.Forms.Button();
  97. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  98. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  99. this.SuspendLayout();
  100. // 
  101. // textBox1
  102. // 
  103. this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  104. this.textBox1.Location = new System.Drawing.Point(64, 32);
  105. this.textBox1.Name = "textBox1";
  106. this.textBox1.ReadOnly = true;
  107. this.textBox1.Size = new System.Drawing.Size(64, 21);
  108. this.textBox1.TabIndex = 0;
  109. this.textBox1.Text = "";
  110. // 
  111. // label1
  112. // 
  113. this.label1.Location = new System.Drawing.Point(16, 32);
  114. this.label1.Name = "label1";
  115. this.label1.Size = new System.Drawing.Size(40, 24);
  116. this.label1.TabIndex = 1;
  117. this.label1.Text = "QQ";
  118. // 
  119. // label2
  120. // 
  121. this.label2.Location = new System.Drawing.Point(8, 80);
  122. this.label2.Name = "label2";
  123. this.label2.Size = new System.Drawing.Size(48, 23);
  124. this.label2.TabIndex = 2;
  125. this.label2.Text = "呢称";
  126. // 
  127. // textBox2
  128. // 
  129. this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  130. this.textBox2.Location = new System.Drawing.Point(64, 80);
  131. this.textBox2.Name = "textBox2";
  132. this.textBox2.Size = new System.Drawing.Size(64, 21);
  133. this.textBox2.TabIndex = 3;
  134. this.textBox2.Text = "";
  135. // 
  136. // label3
  137. // 
  138. this.label3.Location = new System.Drawing.Point(0, 128);
  139. this.label3.Name = "label3";
  140. this.label3.Size = new System.Drawing.Size(48, 24);
  141. this.label3.TabIndex = 4;
  142. this.label3.Text = "性别";
  143. this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter;
  144. // 
  145. // textBox3
  146. // 
  147. this.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  148. this.textBox3.Location = new System.Drawing.Point(64, 128);
  149. this.textBox3.Name = "textBox3";
  150. this.textBox3.Size = new System.Drawing.Size(64, 21);
  151. this.textBox3.TabIndex = 4;
  152. this.textBox3.Text = "";
  153. // 
  154. // pictureBox1
  155. // 
  156. this.pictureBox1.Location = new System.Drawing.Point(184, 80);
  157. this.pictureBox1.Name = "pictureBox1";
  158. this.pictureBox1.Size = new System.Drawing.Size(56, 48);
  159. this.pictureBox1.TabIndex = 6;
  160. this.pictureBox1.TabStop = false;
  161. // 
  162. // button1
  163. // 
  164. this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
  165. this.button1.Location = new System.Drawing.Point(168, 272);
  166. this.button1.Name = "button1";
  167. this.button1.Size = new System.Drawing.Size(72, 32);
  168. this.button1.TabIndex = 9;
  169. this.button1.Text = "关闭";
  170. this.button1.Click += new System.EventHandler(this.button1_Click);
  171. // 
  172. // label4
  173. // 
  174. this.label4.Location = new System.Drawing.Point(8, 192);
  175. this.label4.Name = "label4";
  176. this.label4.Size = new System.Drawing.Size(40, 24);
  177. this.label4.TabIndex = 8;
  178. this.label4.Text = "简介";
  179. // 
  180. // richTextBox1
  181. // 
  182. this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  183. this.richTextBox1.Location = new System.Drawing.Point(64, 176);
  184. this.richTextBox1.Name = "richTextBox1";
  185. this.richTextBox1.Size = new System.Drawing.Size(64, 56);
  186. this.richTextBox1.TabIndex = 5;
  187. this.richTextBox1.Text = "";
  188. // 
  189. // label5
  190. // 
  191. this.label5.Location = new System.Drawing.Point(144, 184);
  192. this.label5.Name = "label5";
  193. this.label5.Size = new System.Drawing.Size(32, 16);
  194. this.label5.TabIndex = 10;
  195. this.label5.Text = "年龄";
  196. // 
  197. // textBox4
  198. // 
  199. this.textBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  200. this.textBox4.Location = new System.Drawing.Point(200, 176);
  201. this.textBox4.Name = "textBox4";
  202. this.textBox4.Size = new System.Drawing.Size(56, 21);
  203. this.textBox4.TabIndex = 7;
  204. this.textBox4.Text = "";
  205. // 
  206. // button2
  207. // 
  208. this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
  209. this.button2.Location = new System.Drawing.Point(56, 272);
  210. this.button2.Name = "button2";
  211. this.button2.Size = new System.Drawing.Size(72, 32);
  212. this.button2.TabIndex = 8;
  213. this.button2.Text = "修改";
  214. this.button2.Click += new System.EventHandler(this.button2_Click);
  215. // 
  216. // numericUpDown1
  217. // 
  218. this.numericUpDown1.Location = new System.Drawing.Point(184, 32);
  219. this.numericUpDown1.Maximum = new System.Decimal(new int[] {
  220.    85,
  221.    0,
  222.    0,
  223.    0});
  224. this.numericUpDown1.Minimum = new System.Decimal(new int[] {
  225.    1,
  226.    0,
  227.    0,
  228.    0});
  229. this.numericUpDown1.Name = "numericUpDown1";
  230. this.numericUpDown1.Size = new System.Drawing.Size(56, 21);
  231. this.numericUpDown1.TabIndex = 6;
  232. this.numericUpDown1.Value = new System.Decimal(new int[] {
  233.  1,
  234.  0,
  235.  0,
  236.  0});
  237. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  238. // 
  239. // 用户资料
  240. // 
  241. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  242. this.ClientSize = new System.Drawing.Size(288, 325);
  243. this.Controls.Add(this.numericUpDown1);
  244. this.Controls.Add(this.button2);
  245. this.Controls.Add(this.textBox4);
  246. this.Controls.Add(this.textBox3);
  247. this.Controls.Add(this.textBox2);
  248. this.Controls.Add(this.textBox1);
  249. this.Controls.Add(this.label5);
  250. this.Controls.Add(this.richTextBox1);
  251. this.Controls.Add(this.label4);
  252. this.Controls.Add(this.button1);
  253. this.Controls.Add(this.pictureBox1);
  254. this.Controls.Add(this.label3);
  255. this.Controls.Add(this.label2);
  256. this.Controls.Add(this.label1);
  257. this.MaximizeBox = false;
  258. this.Name = "用户资料";
  259. this.Text = "资料";
  260. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  261. this.ResumeLayout(false);
  262. }
  263. #endregion
  264. private void button1_Click(object sender, System.EventArgs e)
  265. {
  266. this.Close();
  267. }
  268. private void button2_Click(object sender, System.EventArgs e)
  269. {
  270. try
  271. {
  272. System.Data.SqlClient.SqlCommand updata=new System.Data.SqlClient.SqlCommand();
  273. 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; 
  274. updata.Connection=this.form.sdata.sqlConnection1;
  275. this.form.sdata.sqlConnection1.Open();
  276. updata.ExecuteNonQuery();
  277. this.form.sdata.sqlConnection1.Close();
  278. MessageBox.Show("修改成功");
  279. this.form.sdata.yanzhen();
  280. }
  281. catch(Exception ee)
  282. {
  283. MessageBox.Show(ee.ToString());
  284. }
  285. }
  286. private void numericUpDown1_ValueChanged(object sender, System.EventArgs e)
  287. {
  288.    this.pictureBox1.Image=Image.FromFile(form.path+@"newface"+this.numericUpDown1.Value+".bmp");
  289. }
  290. }
  291. }