⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storequantity.cs

📁 利用vs2008+sql2000开发的物资管理系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace login
{
    public partial class storequantity : Form
    {
        public storequantity()
        {
            InitializeComponent();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void storequantity_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“wZGL_20052070DataSet.room”中。您可以根据需要移动或移除它。
            this.roomTableAdapter.Fill(this.wZGL_20052070DataSet.room);
            // TODO: 这行代码将数据加载到表“wZGL_20052070_DataDataSet.room”中。您可以根据需要移动或移除它。
            //this.roomTableAdapter.Fill(this.wZGL_20052070_DataDataSet.room);
            // TODO: 这行代码将数据加载到表“wZGL_20052070_DataDataSet.room”中。您可以根据需要移动或移除它。
            //this.roomTableAdapter.Fill(this.wZGL_20052070_DataDataSet.room);

        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=WZGL_20052070;Integrated Security=true;");
            string sqltext = "select pName from room where storaeg=@storaeg";
            SqlCommand storescom= new SqlCommand(sqltext, conn);
            SqlDataAdapter sa = new SqlDataAdapter();
            sa.SelectCommand = storescom;
            DataSet ds = new DataSet();
            sa.Fill(ds);
            comboBox2.DataSource = ds.Tables["room"];

        

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            //MainFrm mainform = new MainFrm();
            //mainform.Show();
            //this.Hide();
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //MainFrm mainform = new MainFrm();
            //mainform.Show();
            //this.Hide();
            this.Close();
        }


        private string strconn;//查询更新数据库字符串。
        private string connstr = "workstation id=localhost;Integrated Security=SSPI;database=WZGL_20052070";
        private SqlDataAdapter sqlda;//查询数据库时使用的适配器。
        private DataSet dset = new DataSet();//保存查询结果的数据集。
        private SqlConnection myconn;//数据库连接。

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            
        }

        private void button3_Click(object sender, EventArgs e)
        {
            strconn = "select *,quantity*qPrice as allqPrice from room";
            myconn = new SqlConnection(connstr);
            sqlda = new SqlDataAdapter(strconn, myconn);
            dset.Clear();
            sqlda.Fill(dset, "room");
            dataGridView1.DataSource = dset.Tables[0];
        }

        private void 查询ToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.roomTableAdapter.查询(this.wZGL_20052070DataSet.room, toolStripComboBox1.Text);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }


        private void comboBox2_SelectedIndexChanged_1(object sender, EventArgs e)
        {


            SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=WZGL_20052070;Integrated Security=sspi;");
            string sqlTextcom = "SELECT str(quantity*qPrice) FROM room where pName=@产品名称";
            conn.Open();
            SqlCommand sqlcmdcom = new SqlCommand(sqlTextcom, conn);
            sqlcmdcom.Parameters.AddWithValue("@产品名称", comboBox2.Text);
            SqlDataReader sqldrcom = sqlcmdcom.ExecuteReader();
            sqldrcom.Read();
            while (sqldrcom.Read())
            {
                textBox3.Text.Equals(sqldrcom.GetValue(0).ToString());
           }
















            
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=WZGL_20052070;Integrated Security=sspi;");
            string sqlTextcom = "SELECT quantity*qPrice FROM room where pName=@产品名称";
            conn.Open();
            SqlCommand sqlcmdcom = new SqlCommand(sqlTextcom, conn);
            sqlcmdcom.Parameters.AddWithValue("@产品名称", comboBox2.Text);
            SqlDataReader sqldrcom = sqlcmdcom.ExecuteReader();
            sqldrcom.Read();
            while (sqldrcom.Read())
            {
                textBox3.Text.Equals(sqldrcom.GetValue(0));
            }
        }

       

       
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -