Exemplo n.º 1
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            this.standardImportForm = new StandardImportForm <ShipmentTicketItem>(
                ShipmentTicketItemViewMetaData.KeyNames,
                importItemHandler,
                null,
                "导入发货单条目"
                );

            this.standardImportForm.AddButton("置入套餐", Properties.Resources.check, this.buttonAddCategoryClickedCallback);
            //搜索默认值,首先精确匹配,没有再模糊匹配
            standardImportForm.AddDefaultValue("Unit", string.Format("SELECT DefaultShipmentUnit FROM Supply WHERE [No] = @SupplyNoOrComponentName AND ProjectID = {0} AND WarehouseID = {1} AND IsHistory=0;", this.projectID, this.warehouseID));
            standardImportForm.AddDefaultValue("UnitAmount", string.Format("SELECT DefaultShipmentUnitAmount FROM Supply WHERE [No] = @SupplyNoOrComponentName AND ProjectID = {0} AND WarehouseID = {1} AND IsHistory=0;", this.projectID, this.warehouseID));
            standardImportForm.AddDefaultValue("Unit", string.Format("SELECT DefaultShipmentUnit FROM SupplyView WHERE ComponentName = @SupplyNoOrComponentName AND ProjectID = {0} AND WarehouseID = {1} AND IsHistory=0;", this.projectID, this.warehouseID));
            standardImportForm.AddDefaultValue("UnitAmount", string.Format("SELECT DefaultShipmentUnitAmount FROM SupplyView WHERE ComponentName = @SupplyNoOrComponentName AND ProjectID = {0} AND WarehouseID = {1} AND IsHistory=0;", this.projectID, this.warehouseID));

            standardImportForm.AddDefaultValue("Unit", string.Format("SELECT TOP 2 DefaultShipmentUnit FROM Supply WHERE [No] LIKE '%'+@SupplyNoOrComponentName+'%' AND ProjectID = {0} AND WarehouseID = {1} AND IsHistory=0;", this.projectID, this.warehouseID));
            standardImportForm.AddDefaultValue("UnitAmount", string.Format("SELECT TOP 2 DefaultShipmentUnitAmount FROM Supply WHERE [No] LIKE '%'+@SupplyNoOrComponentName+'%' AND ProjectID = {0} AND WarehouseID = {1} AND IsHistory=0;", this.projectID, this.warehouseID));
            standardImportForm.AddDefaultValue("Unit", string.Format("SELECT TOP 2 DefaultShipmentUnit FROM SupplyView WHERE ComponentName LIKE '%'+@SupplyNoOrComponentName+'%' AND ProjectID = {0} AND WarehouseID = {1} AND IsHistory=0;", this.projectID, this.warehouseID));
            standardImportForm.AddDefaultValue("UnitAmount", string.Format("SELECT TOP 2 DefaultShipmentUnitAmount FROM SupplyView WHERE ComponentName LIKE '%'+@SupplyNoOrComponentName+'%' AND ProjectID = {0} AND WarehouseID = {1} AND IsHistory=0;", this.projectID, this.warehouseID));

            standardImportForm.AddAssociation("SupplyNoOrComponentName", string.Format("SELECT No,SupplierName FROM SupplyView WHERE ProjectID={0} AND WarehouseID = {1} AND IsHistory=0 AND No LIKE '%'+@value+'%'; ", this.projectID, this.warehouseID));
            standardImportForm.AddAssociation("SupplyNoOrComponentName", string.Format("SELECT DISTINCT ComponentName FROM SupplyView WHERE ProjectID={0} AND WarehouseID = {1} AND IsHistory=0 AND ComponentName LIKE '%'+@value+'%'; ", this.projectID, this.warehouseID));
            standardImportForm.AddAssociation("JobPersonName", string.Format("SELECT Name FROM Person WHERE Name LIKE '%'+@value+'%'"));
            standardImportForm.AddAssociation("ConfirmPersonName", string.Format("SELECT Name FROM Person WHERE Name LIKE '%'+@value+'%'"));

            //standardImportForm.AddDefaultValue("ShipmentAmount", "SELECT CASE WHEN @focus = 'ShipmentAmount' THEN NULL WHEN LEN(@UnitAmount)>0 AND LEN(@Unit)>0 THEN CAST(@UnitAmount AS DECIMAL(18,3))*CAST(@Unit AS DECIMAL(18,3)) ELSE NULL END", true, true);
            //standardImportForm.AddDefaultValue("Unit", "SELECT CASE WHEN @focus = 'Unit' THEN NULL WHEN LEN(@ShipmentAmount)>0 AND LEN(@UnitAmount)>0 THEN CAST(@ShipmentAmount AS DECIMAL(18,3))/CAST(@UnitAmount AS DECIMAL(18,3)) ELSE NULL END", true, true);

            standardImportForm.Show();
        }
Exemplo n.º 2
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            //创建导入窗口
            StandardImportForm <DataAccess.Component> formImport =
                new StandardImportForm <DataAccess.Component>
                (
                    //参数1:KeyName
                    ComponenViewMetaData.componenkeyNames,
                    (results, unimportedColumns) => //参数2:导入数据二次处理回调函数
            {
                for (int i = 0; i < results.Count; i++)


                {
                    string componentnameimport;
                    componentnameimport = results[i].Name;
                    //检查导入列表中是否重名
                    for (int j = i + 1; j < results.Count; j++)

                    {
                        if (componentnameimport == results[j].Name)
                        {
                            MessageBox.Show("您输入的零件名" + componentnameimport + "在导入列表中重复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                            return(false);
                        }
                    }

                    //检查数据库中同名
                    try
                    {
                        var sameNameUsers = (from u in wmsEntities.Component
                                             where u.Name == componentnameimport
                                             select u).ToArray();
                        if (sameNameUsers.Length > 0)
                        {
                            MessageBox.Show("导入零件失败,已存在同名零件:" + componentnameimport, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return(false);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                return(true);
            },
                    () => //参数3:导入完成回调函数
            {
                this.searchWidget.Search();
            }
                );

            //显示导入窗口
            formImport.Text = "导入零件信息";
            formImport.Show();
        }
Exemplo n.º 3
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            StandardImportForm <StockInfo> formImport = new StandardImportForm <StockInfo>(
                StockInfoViewMetaData.KeyNames,
                importHandler,
                () =>
            {
                this.searchWidget.Search();
            },
                "导入库存信息");

            formImport.Show();
        }
        private void buttonReturnSupply_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("※重要提示:\n\n批量退件只能将退件作为新的库存批次入库\n此操作会使零件的有效期从本次退回入库日期开始重新计算\n若要退回到原批次中,请在出库单的零件条目中填写退回数\n\n确定使用此功能吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            formImport = new StandardImportForm <ReturnSupply>(returnKeyNames, this.importHandler, null, "批量退件");
            formImport.AddDefaultValue("ReturnQualityAmount", "SELECT 0");
            formImport.AddDefaultValue("ReturnQualityUnit", "SELECT '个'");
            formImport.AddDefaultValue("ReturnQualityUnitAmount", "SELECT 1");
            formImport.AddDefaultValue("ReturnRejectAmount", "SELECT 0");
            formImport.AddDefaultValue("ReturnRejectUnit", "SELECT '个'");
            formImport.AddDefaultValue("ReturnRejectUnitAmount", "SELECT 1");

            formImport.AddAssociation("SupplyNo", string.Format("SELECT No,SupplierName FROM SupplyView WHERE ProjectID={0} AND WarehouseID = {1} AND IsHistory=0 AND No LIKE '%'+@value+'%'; ", this.projectID, this.warehouseID));
            formImport.Show();
        }