【问题标题】:search a unique code from multiple table c#从多个表c#中搜索唯一代码
【发布时间】:2016-10-08 17:21:40
【问题描述】:

对不起,我的英语不完美...

我正在开发一个实用程序来为超市的管理程序执行产品库存。 软件公司向我提供了开发此工具所需的所有信息,因为它不再支持该程序。 所以我将使用现有的数据和表格。

我有 3 个包含必要数据的表:

  1. ProductList- 包含: 产品代码、描述

  2. 仓库 - 包含: ProductCode、InitialStock、CurrentStock、MinimumStock、ReorderQuantities、修改

  3. RegistryCodesAdditionalArticles - 其中包含: 产品代码、条码

我创建了 7 个文本框,其中包含:

条码, 产品代码, 描述, 初始股, 当前股票, 最低库存, 重新排序数量。

必须通过条形码执行搜索,并使用所需的其他值填充文本框

datagridview 将被隐藏

我使用以下代码加载 3 个 datagridview:

        SqlCommand select1 = new SqlCommand("SELECT ProductCode,Description FROM ProductList ORDER BY ProductList ASC", connav);
        SqlDataAdapter find1 = new SqlDataAdapter(select1);
        DataTable dt1 = new DataTable();
        find1.Fill(dt1);

        BindingSource bs1 = new BindingSource();
        bs1.DataSource = dt1;
        dataGridView1.DataSource = bs1;

等等……

请帮我解决这个问题

【问题讨论】:

  • 你有什么问题?

标签: c# sql database datagridview


【解决方案1】:

您只需要简单的内部连接。为什么您没有在查询中传递条形码?

查询应如下所示:

SELECT RCAA.Barcode,RCAA.ProductCode,PL.Description,W.InitialStock,W.CurrentStock,W.MinimumStock,W.ReorderQuantities
FROM RegistryCodesAdditionalArticles RCAA
JOIN Warehouse W
ON RCAA.ProductCode=W.ProductCode
JOIN ProductList PL
ON RCAA.ProductCode=PL.ProductCode
WHERE RCAA.Barcode = ':BARCODE FROM YOUR CODE'

【讨论】:

    猜你喜欢
    • 2013-01-20
    • 2013-07-24
    • 2010-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-18
    • 1970-01-01
    相关资源
    最近更新 更多