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

📄 sms_search.cs

📁 库存管理系统,对企业仓库的产品进行管理,使用C#语句 .net 平台开发
💻 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 FORU_SMS_
{
    public partial class SMS_Search : Form
    {
        BaseClass.DataConn Dconn = new FORU_SMS_.BaseClass.DataConn();
        BaseClass.DataClass Dclass = new FORU_SMS_.BaseClass.DataClass();

        public SMS_Search()
        {
            InitializeComponent();
        }

        private void SMS_Search_Load(object sender, EventArgs e)
        {
            dgvGSearch.Controls.Add(hScrollBar1);
        }

        private void dtpEndTime_ValueChanged(object sender, EventArgs e)
        {
            if (this.dtpStartTime.Value > this.dtpEndTime.Value)
            {
                MessageBox.Show("结束日期不能前于开始日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.dtpStartTime.Value = this.dtpEndTime.Value;
            }
        }

        private void dtpStartTime_ValueChanged(object sender, EventArgs e)
        {
            if (this.dtpStartTime.Value > this.dtpEndTime.Value)
            {
                MessageBox.Show("开始日期不能后于结束日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.dtpStartTime.Value = this.dtpEndTime.Value;
            }
        }

        private void btnLook_Click(object sender, EventArgs e)
        {
            string sql = "";
            string tab = "";
            string keyword = "";
            string sqlCondition = "";
            keyword = this.txtLKWord.Text.Trim();
            string strStart = this.dtpStartTime.Value.ToString("yyyy-MM-dd");
            string strEnd = this.dtpEndTime.Value.ToString("yyyy-MM-dd");
            //if (this.txtLKWord.Text.Trim() == "")
            //{
            //    MessageBox.Show("请输入关键字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    this.txtLKWord.Focus();
            //}
            if (this.combGoods.Text.Trim() == "")
            {
                MessageBox.Show("请选择货物类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.combGoods.Focus();
            }
            else if (this.cboxLCondition.Text.Trim() == "")
            {
                MessageBox.Show("请选择查询条件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.cboxLCondition.Focus();
            }
            else
            {
                try
                {
                    switch (this.combGoods.Text.Trim())
                    { 
                        case "入库货物":
                            sql = "SELECT GoodsID AS 货物编号, GoodsName AS 货物名称, SupName AS 仓库名称,StoreName AS 供应商名称, SpecName AS 货物规格,"
                            + "UnitName AS 计量单位,GoodsNum AS 入库数量, GoodsPrice AS 货物单价, GoodsAPrice AS 进货总金额, GoodsTime AS 入库时间,"
                            + "GoodsPeople AS 经手人, GoodsRemarks AS 备注 FROM SMS_Goods";
                            tab = "SMS_Goods";
                            break;
                        case "出库货物":
                            sql = "SELECT GoodsID AS 货物编号, GoodsName AS 货物名称, SupName AS 仓库名称,SpecName AS 货物规格, UnitName AS 计量单位,"
                            + "GoodsNum AS 出库数量, GoodsPrice AS 货物单价, GoodsAPrice AS 总金额,GoodsTime AS 出库日期,GoodsPeople AS 经手人,"
                            + "UpGoodsPeople AS 提货人,GoodsDep As 提货单位, GoodsRemarks AS 备注 FROM SMS_GoodsOut";
                            tab = "SMS_GoodsOut";
                            break;
                        case "借出货物":
                            sql = "SELECT GoodsID AS 货物编号,GoodsName AS 货物名称,SupName AS 仓库名称,SpecName AS 货物规格,GoodsNum AS 出库数量,"
                            + "BorName AS 借货人,GoodsPeople AS 经手人,BorDeparment AS 借货单位,GoodsRemarks AS 备注,GoodsTime AS 借出日期 FROM SMS_Borrow";
                            tab = "SMS_Borrow";
                            break;
                        case "归还货物":
                            sql = "SELECT GoodsID AS 货物编号, GoodsName AS 货物名称, SupName AS 仓库名称,SpecName AS 产品规格,ReturnNum AS 还货数量,"
                            + "NoReturnNum AS 未还数量, ReturnPeople AS 还货人, GoodsPeople AS 经手人, GoodsRemarks AS 备注,GoodsTime AS 归还日期 FROM SMS_Return";
                            tab = "SMS_Return";
                            break;
                    }
                    sql = sql + " WHERE GoodsTime BETWEEN '" + strStart + "' AND '" + strEnd + "'";
                    //sql = sql + " WHERE strStart<=GoodsTime AND strEnd>=GoodsTime ";
                    if (keyword != "")
                    {
                        switch (this.cboxLCondition.Text.Trim())
                        {
                            case "货物编号":
                                sqlCondition = " AND GoodsID='" + keyword + "'";
                                break;
                            case "货物名称":
                                sqlCondition = " AND GoodsName='" + keyword + "'";
                                break;
                            case "仓库名称":
                                sqlCondition = " AND SupName='" + keyword + "'";
                                break;
                        }
                    }
                    DataSet ds = Dclass.GetDataSet(sql + sqlCondition, tab);
                    dgvGSearch.DataSource = ds.Tables[0];
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }

    }
}

⌨️ 快捷键说明

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