Esempio n. 1
0
        private void ImportMedicament()
        {
            var table = new DS_Medicament.SP_GetMedicamentDataTable();

            table.SetAllowDBNull(true);
            foreach (var row in ds_Import.PurchaseOrderDetail)
            {
                if (row.IsMedicamentNameNull() || row.MedicamentName.Trim().Length == 0)
                {
                    continue;
                }
                //ზედმეტ ასოებს აშორებს.
                row.MedicamentName = row.MedicamentName.Replace("\n", string.Empty).Replace("\t", string.Empty).Trim();

                var newRow = table.NewSP_GetMedicamentRow();
                if (!row.IsMedicamentSubcategoryIDNull())
                {
                    newRow.MedicamentSubcategoryID = row.MedicamentSubcategoryID;
                }
                if (!row.IsMedicamentNameNull())
                {
                    newRow.Name = row.MedicamentName;
                }
                if (!row.IsProductNumberNull())
                {
                    newRow.ProductNumber = row.ProductNumber;
                }
                if (!row.IsMakeFlagNull())
                {
                    newRow.MakeFlag = row.MakeFlag;
                }
                if (!row.IsFinishedGoodsFlagNull())
                {
                    newRow.FinishedGoodsFlag = row.FinishedGoodsFlag;
                }
                if (!row.IsColorNull())
                {
                    newRow.Color = row.Color;
                }
                if (!row.IsSafetyStockLevelNull())
                {
                    newRow.SafetyStockLevel = row.SafetyStockLevel;
                }
                if (!row.IsReorderPointNull())
                {
                    newRow.ReorderPoint = row.ReorderPoint;
                }
                if (!row.IsStandardCostNull())
                {
                    newRow.StandardCost = row.StandardCost;
                }
                if (!row.IsListPriceNull())
                {
                    newRow.ListPrice = row.ListPrice;
                }
                if (!row.IsDealerPriceNull())
                {
                    newRow.DealerPrice = row.DealerPrice;
                }
                if (!row.IsDiscountPctNull())
                {
                    newRow.DiscountPct = row.DiscountPct;
                }
                if (!row.IsTaxRateNull())
                {
                    newRow.TaxRate = row.TaxRate;
                }
                if (!row.IsSizeNull())
                {
                    newRow.Size = row.Size;
                }
                if (!row.IsSizeRangeNull())
                {
                    newRow.SizeRange = row.SizeRange;
                }
                if (!row.IsSizeUnitMeasureCodeNull())
                {
                    newRow.SizeUnitMeasureCode = row.SizeUnitMeasureCode;
                }
                if (!row.IsWeightNull())
                {
                    newRow.Weight = row.Weight;
                }
                if (!row.IsWeightUnitMeasureCodeNull())
                {
                    newRow.WeightUnitMeasureCode = row.WeightUnitMeasureCode;
                }
                if (!row.IsDaysToManufactureNull())
                {
                    newRow.DaysToManufacture = row.DaysToManufacture;
                }
                if (!row.IsProductLineNull())
                {
                    newRow.ProductLine = row.ProductLine;
                }
                if (!row.IsClassNull())
                {
                    newRow.Class = row.Class;
                }
                if (!row.IsStyleNull())
                {
                    newRow.Style = row.Style;
                }
                if (!row.IsProductModelIDNull())
                {
                    newRow.ProductModelID = row.ProductModelID;
                }
                if (!row.IsSellStartDateNull())
                {
                    newRow.SellStartDate = row.SellStartDate;
                }
                if (!row.IsSellEndDateNull())
                {
                    newRow.SellEndDate = row.SellEndDate;
                }
                if (!row.IsDiscontinuedDateNull())
                {
                    newRow.DiscontinuedDate = row.DiscontinuedDate;
                }
                if (!row.IsUnitsInStockNull())
                {
                    newRow.UnitsInStock = row.UnitsInStock;
                }
                //if (!row.IsValidDateNull())
                //    newRow.ValidDate = row.ValidDate;
                //if (!row.IsCountryCodeNull())
                //    newRow.CountryCode = row.CountryCode;
                //if (!row.IsBrandIDNull())
                //    newRow.BrandID = row.BrandID;
                //if (!row.IsSerieNull())
                //    newRow.Serie = row.Serie;

                //newRow.Status = (byte)Statuses.Pending;
                //newRow.ModifiedUserID = GlobalVariable.UserID;
                //newRow.ModifiedDate = GlobalVariable.ServerDateTime;

                table.AddSP_GetMedicamentRow(newRow);
            }


            table.PrimaryKey = null;
            table.RemoveColumns(table.MedicamentIDColumn,
                                //table.StandardCostColumn,
                                //table.ListPriceColumn,
                                //table.DealerPriceColumn,
                                //table.DiscountPctColumn,
                                //table.TaxRateColumn,
                                table.ValidDateColumn,
                                table.CountryCodeColumn,
                                table.BrandIDColumn,
                                table.SerieColumn,
                                table.StatusColumn,
                                table.ModifiedUserIDColumn,
                                table.ModifiedDateColumn,
                                table.ApproverUserIDColumn);

            var newTable = table.SelectDistinct(true, table.Columns, table.NameColumn);
            var xmlTable = newTable.PackAlternationTypedDataTable <DataTable>(dataRowState: DataRowState.Added, addActionColumn: true);

            ImportManager.ImportDataTable(ObjectNames.Medicament, xmlTable);
            ImportManager.InitID(ds_Import.PurchaseOrderDetail, ObjectNames.Medicament, ds_Import.PurchaseOrderDetail.MedicamentIDColumn.ColumnName, false, null, ds_Import.PurchaseOrderDetail.MedicamentNameColumn.ColumnName);
        }
Esempio n. 2
0
 private static void SynchronizeDictionary(DataTable table, ObjectNames objectName, string fieldID, bool chekByID, string fieldParentName, string fieldName)
 {
     ImportManager.SynchronizeDictionary(table, objectName, fieldID, chekByID, fieldParentName, fieldName);
 }