private void 入库操作ToolStripMenuItem_Click(object sender, EventArgs e) { FormInstock fi = new FormInstock(UserName); fi.MdiParent = this; fi.WindowState = FormWindowState.Maximized; fi.Show(); toolStripStatusLabel2.Text = "当前操作:入库操作"; }
private void Login_Click(object sender, EventArgs e) { string connStr = "Data Source=localhost;Initial Catalog=SuperMarketDB;Integrated Security=True"; //创建连接对象将连接字符串作为构造方法的参数 SqlConnection connection = new SqlConnection(connStr); string sql = string.Format("select count(*) from SIMS_user where userName='******' and userPwd='{1}'", userName.Text, passWord.Text); SqlCommand command = new SqlCommand(sql, connection); try { connection.Open(); int i = (int)command.ExecuteScalar(); if (i > 0) { MessageBox.Show("登录成功!"); string UserName1 = userName.Text; //当前登录人员通过构造函数传值给FormMain和出入库页面 FormMain formMain = new FormMain(UserName1); FormInstock fis = new FormInstock(UserName1); FormOutstock fos = new FormOutstock(UserName1); formMain.Show(); this.Hide(); } else { MessageBox.Show("用户名或者密码错误,请重新输入"); userName.Focus(); } } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { connection.Close(); } }