Form2.cs
上传用户:miknos
上传日期:2022-04-30
资源大小:802k
文件大小:7k
源码类别:

百货/超市行业

开发平台:

Visual C++

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using supershop;
  7. namespace supershop2
  8. {
  9. /// <summary>
  10. /// Form2 的摘要说明。
  11. /// </summary>
  12. public class Form2 : System.Windows.Forms.Form
  13. {
  14. private System.Windows.Forms.Label label1;
  15. private System.Windows.Forms.Label label2;
  16. private System.Windows.Forms.TextBox textBox1;
  17. private System.Windows.Forms.TextBox textBox2;
  18. private System.Windows.Forms.Button button1;
  19. private System.Windows.Forms.Button button2;
  20. private System.Data.SqlClient.SqlConnection sqlConnection1;
  21. private System.Data.SqlClient.SqlCommand sqlCommand1;
  22. private System.Windows.Forms.RadioButton radioButton1;
  23. private System.Windows.Forms.RadioButton radioButton2;
  24. //public static string name;
  25. //public static string isman;
  26. /// <summary>
  27. /// 必需的设计器变量。
  28. /// </summary>
  29. private System.ComponentModel.Container components = null;
  30. public Form2()
  31. {
  32. //
  33. // Windows 窗体设计器支持所必需的
  34. //
  35. InitializeComponent();
  36. //
  37. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  38. //
  39. }
  40. /// <summary>
  41. /// 清理所有正在使用的资源。
  42. /// </summary>
  43. protected override void Dispose( bool disposing )
  44. {
  45. if( disposing )
  46. {
  47. if(components != null)
  48. {
  49. components.Dispose();
  50. }
  51. }
  52. base.Dispose( disposing );
  53. }
  54. #region Windows 窗体设计器生成的代码
  55. /// <summary>
  56. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  57. /// 此方法的内容。
  58. /// </summary>
  59. private void InitializeComponent()
  60. {
  61. this.label1 = new System.Windows.Forms.Label();
  62. this.label2 = new System.Windows.Forms.Label();
  63. this.textBox1 = new System.Windows.Forms.TextBox();
  64. this.textBox2 = new System.Windows.Forms.TextBox();
  65. this.button1 = new System.Windows.Forms.Button();
  66. this.button2 = new System.Windows.Forms.Button();
  67. this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
  68. this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
  69. this.radioButton1 = new System.Windows.Forms.RadioButton();
  70. this.radioButton2 = new System.Windows.Forms.RadioButton();
  71. this.SuspendLayout();
  72. // 
  73. // label1
  74. // 
  75. this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
  76. this.label1.Location = new System.Drawing.Point(32, 32);
  77. this.label1.Name = "label1";
  78. this.label1.Size = new System.Drawing.Size(64, 23);
  79. this.label1.TabIndex = 0;
  80. this.label1.Text = "用户名:";
  81. // 
  82. // label2
  83. // 
  84. this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
  85. this.label2.Location = new System.Drawing.Point(32, 72);
  86. this.label2.Name = "label2";
  87. this.label2.Size = new System.Drawing.Size(64, 23);
  88. this.label2.TabIndex = 1;
  89. this.label2.Text = "密 码:";
  90. // 
  91. // textBox1
  92. // 
  93. this.textBox1.Location = new System.Drawing.Point(112, 32);
  94. this.textBox1.Name = "textBox1";
  95. this.textBox1.Size = new System.Drawing.Size(136, 21);
  96. this.textBox1.TabIndex = 2;
  97. this.textBox1.Text = "";
  98. this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
  99. // 
  100. // textBox2
  101. // 
  102. this.textBox2.Location = new System.Drawing.Point(112, 72);
  103. this.textBox2.Name = "textBox2";
  104. this.textBox2.PasswordChar = '*';
  105. this.textBox2.Size = new System.Drawing.Size(136, 21);
  106. this.textBox2.TabIndex = 3;
  107. this.textBox2.Text = "";
  108. // 
  109. // button1
  110. // 
  111. this.button1.Location = new System.Drawing.Point(40, 144);
  112. this.button1.Name = "button1";
  113. this.button1.TabIndex = 4;
  114. this.button1.Text = "确 定";
  115. this.button1.Click += new System.EventHandler(this.button1_Click);
  116. // 
  117. // button2
  118. // 
  119. this.button2.Location = new System.Drawing.Point(152, 144);
  120. this.button2.Name = "button2";
  121. this.button2.TabIndex = 5;
  122. this.button2.Text = "取 消";
  123. this.button2.Click += new System.EventHandler(this.button2_Click);
  124. // 
  125. // sqlConnection1
  126. // 
  127. this.sqlConnection1.ConnectionString = "workstation id=MICROSOFTPANG;packet size=4096;integrated security=SSPI;data sourc" +
  128. "e=MICROSOFTPANG;persist security info=False;initial catalog=supershop";
  129. // 
  130. // radioButton1
  131. // 
  132. this.radioButton1.Checked = true;
  133. this.radioButton1.Location = new System.Drawing.Point(32, 104);
  134. this.radioButton1.Name = "radioButton1";
  135. this.radioButton1.TabIndex = 6;
  136. this.radioButton1.TabStop = true;
  137. this.radioButton1.Text = "销售人员";
  138. // 
  139. // radioButton2
  140. // 
  141. this.radioButton2.Location = new System.Drawing.Point(144, 104);
  142. this.radioButton2.Name = "radioButton2";
  143. this.radioButton2.TabIndex = 7;
  144. this.radioButton2.Text = "管理人员";
  145. // 
  146. // Form2
  147. // 
  148. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  149. this.ClientSize = new System.Drawing.Size(272, 190);
  150. this.ControlBox = false;
  151. this.Controls.Add(this.radioButton2);
  152. this.Controls.Add(this.radioButton1);
  153. this.Controls.Add(this.button2);
  154. this.Controls.Add(this.button1);
  155. this.Controls.Add(this.textBox2);
  156. this.Controls.Add(this.textBox1);
  157. this.Controls.Add(this.label2);
  158. this.Controls.Add(this.label1);
  159. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  160. this.MaximizeBox = false;
  161. this.MinimizeBox = false;
  162. this.Name = "Form2";
  163. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  164. this.Text = "登录";
  165. this.TopMost = true;
  166. this.ResumeLayout(false);
  167. }
  168. #endregion
  169. private void button1_Click(object sender, System.EventArgs e)
  170. {
  171. string uname=textBox1.Text;
  172. string pwd=textBox2.Text;
  173. if(radioButton1.Checked)
  174. {
  175. this.sqlCommand1.CommandText="select * from login where uname = '"+uname+"' and pwd = '"+pwd+"' and ismanage='no'";
  176. }
  177. else if(radioButton2.Checked)
  178. {
  179. this.sqlCommand1.CommandText="select * from login where uname = '"+uname+"' and pwd = '"+pwd+"' and ismanage='yes'";
  180. }
  181. this.sqlCommand1.Connection=this.sqlConnection1;
  182. this.sqlConnection1.Open();
  183. try
  184. {
  185. System.Data.SqlClient.SqlDataReader MyReader = this.sqlCommand1.ExecuteReader();
  186. MyReader.Read();
  187. string name=MyReader.GetValue(1).ToString();
  188. string isman=MyReader.GetValue(3).ToString();
  189. //supershop.Form1.
  190. //string id=flog.ToString();
  191. this.Visible=false;
  192. supershop.Form1.name=name;
  193. supershop.Form1.isman=isman;
  194. //pictureBox1.Visible=true;
  195. //label1.Visible=false;
  196. //label2.Visible=false;
  197. //textBox1.Visible=false;
  198. //textBox2.Visible=false;
  199. //button1.Visible=false;
  200. //button2.Visible=false;
  201. //label3.Visible=true;
  202. //timer1.Enabled=true;
  203. //char ss=(char)flog;
  204. //textBox3.Text=flog;
  205. //textBox3.Text=atoi(flog);
  206. //textBox3.Text=flog.ToString();
  207. //textBox3.Text="no username or passward!";
  208. }
  209. catch(Exception err)
  210. {
  211. this.sqlConnection1.Close();
  212. MessageBox.Show("该用户不存在","信息提示",
  213. MessageBoxButtons.OK,MessageBoxIcon.Information);
  214. return;
  215. }
  216. this.sqlConnection1.Close();
  217. this.Close();
  218. }
  219. private void button2_Click(object sender, System.EventArgs e)
  220. {
  221. Application.Exit();
  222. }
  223. private void textBox1_TextChanged(object sender, System.EventArgs e)
  224. {
  225. }
  226. }
  227. }