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

📄 formjhcx1.cs

📁 超市进销存管理系统 Visual Studio 2005+SQL Sever2005
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _10901BS
{
    public partial class formJhcx : Form
    {
        SqlConnection con = new SqlConnection();//全局连接对象
        SqlCommand com = new SqlCommand();//全局的命令对象
        SqlDataAdapter da;  //全局的数据适配器  
        SqlDataReader dr; 
        DataSet ds = new DataSet();//全局的数据集<在客户端>
        DataSet ds1 = new DataSet();//全局的数据集<在客户端>
        public formJhcx()
        {
            InitializeComponent();
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.ConnectionString = "server=.;database=110901DB;Integrated Security=True";
                con.Open();
             
            }

            da = new SqlDataAdapter("select jhDjID  '进货单据编号' from jhzBiao", con);
            ds.Clear();
            da.Fill(ds);
            this.cboJHDJBH.Items.Clear();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                this.cboJHDJBH.Items.Add(row.ItemArray[0]);
            }
            da = new SqlDataAdapter("select jhDjID '进货单据编号',jhSpZsl '进货商品总数量', jhZje '进货总金额',jhRq '进货日期',jhjsr '经手人' from  jhzBiao  where 1=2", con);
            ds.Clear();
            da.Fill(ds);
            this.dataGridView1.DataSource = ds.Tables[0];
            this.dataGridView1.Columns[0].Width = 200;
            this.dataGridView1.Columns[1].Width = 200;
            this.dataGridView1.Columns[2].Width = 200;

            da = new SqlDataAdapter("select jhID '进货编号',jhDjID '进货单据编号',gysID '供应商编号', spID '商品编号', jhSl '进货数量', jhDjia '进货单价', jhZje '进货总金额', beiZhu '备注' from jhxqBiao where 1=2", con);
            ds1.Clear();
            da.Fill(ds1);
            this.dataGridView2.DataSource = ds1.Tables[0];
            this.dataGridView2.Columns[0].Visible = false;
            this.dataGridView2.Columns[1].Width = 200;
            this.dataGridView2.Columns[2].Width = 120;
            this.dataGridView2.Columns[6].Width = 120;
        }

     


        //-------------------------刷新--------------------------//
        private void btnChuaXin_Click(object sender, EventArgs e)
        {
            Form3_Load(sender, e);
            this.btnChaXun.Enabled = true;
        }
        //---------------------退出------------------------//
        private void btnTuiChu_Click_1(object sender, EventArgs e)
        {
            DialogResult dlg = MessageBox.Show("您确实要退出当前应用程序吗?", "退出", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dlg == DialogResult.Yes)
            {
                this.Close();
            }
        }
        //------------------------查询-------------------//
        private void btnChaXun_Click_1(object sender, EventArgs e)
        {
            if (this.cboJHDJBH.Text != "")
            {
                com.Connection = con;
                com.CommandText = "select  jhDjID '进货单据编号',jhSpZsl '进货商品总数量', jhZje '进货总金额',jhRq '进货日期',jhjsr '经手人' from  jhzBiao   where jhDjID like '%" + this.cboJHDJBH.Text + "%'";
                da.SelectCommand = com;
                ds.Clear();
                da.Fill(ds);
                this.dataGridView1.DataSource = ds.Tables[0];

         com.Connection = con;
               com.CommandText = "select jhID '进货编号', jhDjID '进货单据编号', gysID '供应商编号', spID '商品编号', jhSl '进货数量', jhDjia '进货单价', jhZje '进货总金额', beiZhu '备注' from jhxqBiao  where jhDjID like '%" + this.cboJHDJBH.Text.Trim () + "%' ";
                da.SelectCommand = com;
                ds1.Clear();
                da.Fill(ds1);
                this.dataGridView2.DataSource = ds1.Tables[0];
             
                }        

            }

        private void cboJHDJBH_Leave(object sender, EventArgs e)
        {
            com.Connection = con;
            com.CommandText = "select jhDjID from jhzBiao where jhDjID='" + cboJHDJBH.Text + "'";
            dr = com.ExecuteReader();
            if (dr.Read())
            {
                dr.Close();

            }
            else
            {

                dr.Close();
                MessageBox.Show("对不起您输入的单据编号不存在。");
                ds.Clear();
                this.cboJHDJBH.Text = "";
                cboJHDJBH.Focus();
            }
        }      
        }

    }

      

   

⌨️ 快捷键说明

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