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

📄 depotform.cs

📁 主要实现仓库的入库与出库的基本功能
💻 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 Elysian
{
    public partial class depotForm : Form
    {
        SqlConnection sqlconn;
        SqlDataAdapter adapter;
        DataSet ds = new DataSet();
        public depotForm()
        {
            InitializeComponent();
        }

        private static string GetConnectionString()
        {
            return "data source=.;initial catalog=ElysianDB;integrated security=true";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string selectStr = string.Empty;
            selectStr = "select * from 库存表";
            if (textBox1.Text != "")
            {
                selectStr = selectStr + " " + "where 商品编号='" + textBox1.Text + "'";
                if (textBox2.Text != "")
                {
                    selectStr = selectStr + " " + "and 商品名称='" + textBox2.Text + "'";
                }
            }
            else
            {
                if (textBox2.Text != "")
                {
                    selectStr = selectStr + " " + "where 商品名称='" + textBox2.Text + "'";
                }
                else
                {
                    MessageBox.Show("请您输入要查询的信息");
                }
            }
            sqlconn = new SqlConnection(GetConnectionString());
            SqlCommand sqlcomm = new SqlCommand();
            sqlcomm.CommandText = selectStr;
            sqlcomm.Connection = sqlconn;
            sqlconn.Open();
            ds.Clear();
            adapter = new SqlDataAdapter(sqlcomm);
            adapter.Fill(ds, "库存表");
            dataGridView1.DataSource = ds.Tables[0];
            sqlconn.Close();
            textBox1.Text = "";
            textBox2.Text = "";
        }

    }
}

⌨️ 快捷键说明

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