Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            shangping s = new shangping();

            s.Show();
            this.Close();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            conn.Open();
            String sql = "insert into commodity(cno,bname,tname,cname,gg,xh,jldw,scj,xsj,cbj,slt,js,kc) values (@cno,@bname,@tname,@cname,@gg,@xh,@jldw,@scj,@xsj,@cbj,@slt,@js,@kc)";

            try
            {
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add(new SqlParameter("@cno", int.Parse(cno.Text)));
                cmd.Parameters.Add(new SqlParameter("@bname", comboBox1.Text));
                cmd.Parameters.Add(new SqlParameter("@tname", comboBox2.Text));
                cmd.Parameters.Add(new SqlParameter("@cname", cname.Text));
                cmd.Parameters.Add(new SqlParameter("@gg", gg.Text));
                cmd.Parameters.Add(new SqlParameter("@xh", xh.Text));
                cmd.Parameters.Add(new SqlParameter("@jldw", jldw.Text));
                cmd.Parameters.Add(new SqlParameter("@scj", scj.Text));
                cmd.Parameters.Add(new SqlParameter("@xsj", xsj.Text));
                cmd.Parameters.Add(new SqlParameter("@cbj", cbj.Text));
                cmd.Parameters.Add(new SqlParameter("@slt", slt.Text));
                cmd.Parameters.Add(new SqlParameter("@js", js.Text));
                cmd.Parameters.Add(new SqlParameter("@kc", kc.Text));
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    MessageBox.Show("信息录入成功");
                    shangping sp = new shangping();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString() + "请检查数据合法性!");
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            String c_no   = cno.Text.Trim();
            String b_name = bname.Text.Trim();
            String t_name = tname.Text.Trim();
            String c_name = cname.Text.Trim();
            String c_js   = js.Text.Trim();
            String c_slt  = slt.Text.Trim();
            String c_gg   = gg.Text.Trim();
            String c_xh   = xh.Text.Trim();
            String c_jldw = jldw.Text.Trim();
            String c_scj  = scj.Text.Trim();
            String c_xsj  = xsj.Text.Trim();
            String c_cbj  = cbj.Text.Trim();
            String c_kc   = kc.Text.Trim();
            String sql    = string.Format("update commodity set bname='{0}',tname='{1}',cname='{2}',gg='{3}',xh='{4}',jldw='{5}',scj='{6}',xsj='{7}',cbj='{8}',slt='{9}',js='{10}',kc='{11}' where cno='{12}'", b_name, t_name, c_name, c_gg, c_xh, c_jldw, c_scj, c_xsj, c_cbj, c_slt, c_js, c_kc, c_no);

            try
            {
                cmd = new SqlCommand(sql, conn);
                int count = cmd.ExecuteNonQuery();
                if (count > 0)
                {
                    MessageBox.Show("信息修改成功");
                    shangping sp = new shangping();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString() + "请检查数据合法性!");
            }
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)

        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                //打开数据库的连接

                String sql = "select * from users where user_id = @user_id and user_psw = @user_psw ";
                //创建数据库的操作字符串

                SqlCommand cmd = new SqlCommand(sql, conn);
                //对指定的对象,操作字符串内容

                cmd.Parameters.Add(new SqlParameter("@user_id", textBox1.Text));
                //用参数代替占位符,线性更安全
                cmd.Parameters.Add(new SqlParameter("@user_psw", textBox2.Text));

                SqlDataReader reader = cmd.ExecuteReader();//操作

                if (reader.Read())
                {
                    //如果查询到内容,跳转到Information界面,同时关闭当前界面
                    shangping sp = new shangping();
                    sp.Show();
                    this.Hide();
                }
                else
                {
                    //MessageBox.Show("请输入正确信息!");
                    //textBox1.Text = "";
                    //textBox2.Text = "";
                    main m = new main();
                    m.Show();
                    this.Hide();
                }
            }
        }