Esempio n. 1
0
 private void InitClass() {
     this.DataSetName = "FullDataSet";
     this.Prefix = "";
     this.Namespace = "http://tempuri.org/FullDataSet.xsd";
     this.EnforceConstraints = true;
     this.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
     this.tableProduct = new ProductDataTable();
     base.Tables.Add(this.tableProduct);
     this.tableCountry = new CountryDataTable();
     base.Tables.Add(this.tableCountry);
     this.tableFarmGroup = new FarmGroupDataTable();
     base.Tables.Add(this.tableFarmGroup);
     this.tableFarmGroupLevel2 = new FarmGroupLevel2DataTable(false);
     base.Tables.Add(this.tableFarmGroupLevel2);
     this.tableManufacturer = new ManufacturerDataTable(false);
     base.Tables.Add(this.tableManufacturer);
     this.tablePacking = new PackingDataTable();
     base.Tables.Add(this.tablePacking);
     this.tableStorageCondition = new StorageConditionDataTable();
     base.Tables.Add(this.tableStorageCondition);
     this.tableUnit = new UnitDataTable();
     base.Tables.Add(this.tableUnit);
     this.tableSubstance = new SubstanceDataTable();
     base.Tables.Add(this.tableSubstance);
     this.relationFK_Product_FarmGroupLevel2 = new System.Data.DataRelation("FK_Product_FarmGroupLevel2", new System.Data.DataColumn[] {
                 this.tableFarmGroupLevel2.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.FarmGrouplevel2RefColumn}, false);
     this.Relations.Add(this.relationFK_Product_FarmGroupLevel2);
     this.relationFK_FarmGroupLevel2_FarmGroup = new System.Data.DataRelation("FK_FarmGroupLevel2_FarmGroup", new System.Data.DataColumn[] {
                 this.tableFarmGroup.IDColumn}, new System.Data.DataColumn[] {
                 this.tableFarmGroupLevel2.FarmGroupRefColumn}, false);
     this.Relations.Add(this.relationFK_FarmGroupLevel2_FarmGroup);
     this.relationFK_Manufacturer_Country = new System.Data.DataRelation("FK_Manufacturer_Country", new System.Data.DataColumn[] {
                 this.tableCountry.IDColumn}, new System.Data.DataColumn[] {
                 this.tableManufacturer.CounrtyRefColumn}, false);
     this.Relations.Add(this.relationFK_Manufacturer_Country);
     this.relationFK_Product_Packing = new System.Data.DataRelation("FK_Product_Packing", new System.Data.DataColumn[] {
                 this.tablePacking.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.PackingRefColumn}, false);
     this.Relations.Add(this.relationFK_Product_Packing);
     this.relationFK_Product_StorageCondition = new System.Data.DataRelation("FK_Product_StorageCondition", new System.Data.DataColumn[] {
                 this.tableStorageCondition.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.StorageConditionRefColumn}, false);
     this.Relations.Add(this.relationFK_Product_StorageCondition);
     this.relationFK_Product_Unit = new System.Data.DataRelation("FK_Product_Unit", new System.Data.DataColumn[] {
                 this.tableUnit.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.UnitRefColumn}, false);
     this.Relations.Add(this.relationFK_Product_Unit);
     this.relationFK_Product_Substance = new System.Data.DataRelation("FK_Product_Substance", new System.Data.DataColumn[] {
                 this.tableSubstance.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.SubstanceRefColumn}, false);
     this.Relations.Add(this.relationFK_Product_Substance);
 }
Esempio n. 2
0
 internal UnitRow(System.Data.DataRowBuilder rb) : 
         base(rb) {
     this.tableUnit = ((UnitDataTable)(this.Table));
 }
Esempio n. 3
0
 private void InitClass() {
     this.DataSetName = "MDataSet";
     this.Prefix = "";
     this.Namespace = "http://tempuri.org/MDataSet.xsd";
     this.EnforceConstraints = true;
     this.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
     this.tableCountry = new CountryDataTable();
     base.Tables.Add(this.tableCountry);
     this.tableDocumentType = new DocumentTypeDataTable();
     base.Tables.Add(this.tableDocumentType);
     this.tableInvoiceDetail = new InvoiceDetailDataTable(false);
     base.Tables.Add(this.tableInvoiceDetail);
     this.tableInvoiceMaster = new InvoiceMasterDataTable(false);
     base.Tables.Add(this.tableInvoiceMaster);
     this.tableOrganization = new OrganizationDataTable(false);
     base.Tables.Add(this.tableOrganization);
     this.tableReceiptRemains = new ReceiptRemainsDataTable();
     base.Tables.Add(this.tableReceiptRemains);
     this.tableStock = new StockDataTable(false);
     base.Tables.Add(this.tableStock);
     this.tableTradePutlet = new TradePutletDataTable();
     base.Tables.Add(this.tableTradePutlet);
     this.tableReceiptMaster = new ReceiptMasterDataTable(false);
     base.Tables.Add(this.tableReceiptMaster);
     this.tableReceiptDetail = new ReceiptDetailDataTable(false);
     base.Tables.Add(this.tableReceiptDetail);
     this.tableStorageCondition = new StorageConditionDataTable(false);
     base.Tables.Add(this.tableStorageCondition);
     this.tableProduct = new ProductDataTable(false);
     base.Tables.Add(this.tableProduct);
     this.tableFarmGroup = new FarmGroupDataTable();
     base.Tables.Add(this.tableFarmGroup);
     this.tablePacking = new PackingDataTable();
     base.Tables.Add(this.tablePacking);
     this.tableSubstance = new SubstanceDataTable();
     base.Tables.Add(this.tableSubstance);
     this.tableUnit = new UnitDataTable();
     base.Tables.Add(this.tableUnit);
     this.tableManufacturer = new ManufacturerDataTable(false);
     base.Tables.Add(this.tableManufacturer);
     this.tableFarmGroupLevel2 = new FarmGroupLevel2DataTable(false);
     base.Tables.Add(this.tableFarmGroupLevel2);
     this.tableOrders = new OrdersDataTable();
     base.Tables.Add(this.tableOrders);
     this.tableRemains = new RemainsDataTable(false);
     base.Tables.Add(this.tableRemains);
     this.tablePricesPurchase = new PricesPurchaseDataTable(false);
     base.Tables.Add(this.tablePricesPurchase);
     this.tablePeriods = new PeriodsDataTable(false);
     base.Tables.Add(this.tablePeriods);
     this.tableLinkedInvoiceDetail = new LinkedInvoiceDetailDataTable();
     base.Tables.Add(this.tableLinkedInvoiceDetail);
     this.tableLinkedInvoiceMaster = new LinkedInvoiceMasterDataTable();
     base.Tables.Add(this.tableLinkedInvoiceMaster);
     this.tableReceiptDetailAdding = new ReceiptDetailAddingDataTable();
     base.Tables.Add(this.tableReceiptDetailAdding);
     System.Data.ForeignKeyConstraint fkc;
     fkc = new System.Data.ForeignKeyConstraint("FK_InvoiceMaster_StockMain", new System.Data.DataColumn[] {
                 this.tableStock.IDColumn}, new System.Data.DataColumn[] {
                 this.tableInvoiceMaster.MainStockRefColumn});
     this.tableInvoiceMaster.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.None;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     fkc = new System.Data.ForeignKeyConstraint("FK_Stock_InvoiceMaster", new System.Data.DataColumn[] {
                 this.tableStock.IDColumn}, new System.Data.DataColumn[] {
                 this.tableInvoiceMaster.RemoteStockRefColumn});
     this.tableInvoiceMaster.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.None;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     fkc = new System.Data.ForeignKeyConstraint("FK_ReceiptRemains_ReceiptDetail", new System.Data.DataColumn[] {
                 this.tableReceiptDetail.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptRemains.ReceiptDetailRefColumn});
     this.tableReceiptRemains.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.None;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     fkc = new System.Data.ForeignKeyConstraint("ReceiptMaster_ReceiptDetail", new System.Data.DataColumn[] {
                 this.tableReceiptMaster.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptDetail.ReceiptMasterRefColumn});
     this.tableReceiptDetail.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.None;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     fkc = new System.Data.ForeignKeyConstraint("FK_Substance_Product", new System.Data.DataColumn[] {
                 this.tableSubstance.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.SubstanceRefColumn});
     this.tableProduct.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.None;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     fkc = new System.Data.ForeignKeyConstraint("FK_Unit_Product", new System.Data.DataColumn[] {
                 this.tableUnit.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.UnitRefColumn});
     this.tableProduct.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.None;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     fkc = new System.Data.ForeignKeyConstraint("FK_FarmGroupLevel2_Product", new System.Data.DataColumn[] {
                 this.tableFarmGroupLevel2.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.FarmGrouplevel2RefColumn});
     this.tableProduct.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.None;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     fkc = new System.Data.ForeignKeyConstraint("FK_FarmGroup_FarmGroupLevel2", new System.Data.DataColumn[] {
                 this.tableFarmGroup.IDColumn}, new System.Data.DataColumn[] {
                 this.tableFarmGroupLevel2.FarmGroupRefColumn});
     this.tableFarmGroupLevel2.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.None;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     fkc = new System.Data.ForeignKeyConstraint("FK_ReceiptDetailAdding_ReceiptDetail", new System.Data.DataColumn[] {
                 this.tableReceiptDetail.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptDetailAdding.ReceiptDetailRefColumn});
     this.tableReceiptDetailAdding.Constraints.Add(fkc);
     fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = System.Data.Rule.Cascade;
     fkc.UpdateRule = System.Data.Rule.Cascade;
     this.relationFK_InvoiceMaster_StockMain = new System.Data.DataRelation("FK_InvoiceMaster_StockMain", new System.Data.DataColumn[] {
                 this.tableStock.IDColumn}, new System.Data.DataColumn[] {
                 this.tableInvoiceMaster.MainStockRefColumn}, false);
     this.Relations.Add(this.relationFK_InvoiceMaster_StockMain);
     this.relationFK_Stock_InvoiceMaster = new System.Data.DataRelation("FK_Stock_InvoiceMaster", new System.Data.DataColumn[] {
                 this.tableStock.IDColumn}, new System.Data.DataColumn[] {
                 this.tableInvoiceMaster.RemoteStockRefColumn}, false);
     this.Relations.Add(this.relationFK_Stock_InvoiceMaster);
     this.relationFK_ReceiptRemains_ReceiptDetail = new System.Data.DataRelation("FK_ReceiptRemains_ReceiptDetail", new System.Data.DataColumn[] {
                 this.tableReceiptDetail.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptRemains.ReceiptDetailRefColumn}, false);
     this.Relations.Add(this.relationFK_ReceiptRemains_ReceiptDetail);
     this.relationReceiptMaster_ReceiptDetail = new System.Data.DataRelation("ReceiptMaster_ReceiptDetail", new System.Data.DataColumn[] {
                 this.tableReceiptMaster.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptDetail.ReceiptMasterRefColumn}, false);
     this.Relations.Add(this.relationReceiptMaster_ReceiptDetail);
     this.relationFK_Substance_Product = new System.Data.DataRelation("FK_Substance_Product", new System.Data.DataColumn[] {
                 this.tableSubstance.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.SubstanceRefColumn}, false);
     this.Relations.Add(this.relationFK_Substance_Product);
     this.relationFK_Unit_Product = new System.Data.DataRelation("FK_Unit_Product", new System.Data.DataColumn[] {
                 this.tableUnit.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.UnitRefColumn}, false);
     this.Relations.Add(this.relationFK_Unit_Product);
     this.relationFK_FarmGroupLevel2_Product = new System.Data.DataRelation("FK_FarmGroupLevel2_Product", new System.Data.DataColumn[] {
                 this.tableFarmGroupLevel2.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.FarmGrouplevel2RefColumn}, false);
     this.Relations.Add(this.relationFK_FarmGroupLevel2_Product);
     this.relationFK_FarmGroup_FarmGroupLevel2 = new System.Data.DataRelation("FK_FarmGroup_FarmGroupLevel2", new System.Data.DataColumn[] {
                 this.tableFarmGroup.IDColumn}, new System.Data.DataColumn[] {
                 this.tableFarmGroupLevel2.FarmGroupRefColumn}, false);
     this.Relations.Add(this.relationFK_FarmGroup_FarmGroupLevel2);
     this.relationFK_ReceiptDetailAdding_ReceiptDetail = new System.Data.DataRelation("FK_ReceiptDetailAdding_ReceiptDetail", new System.Data.DataColumn[] {
                 this.tableReceiptDetail.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptDetailAdding.ReceiptDetailRefColumn}, false);
     this.Relations.Add(this.relationFK_ReceiptDetailAdding_ReceiptDetail);
     this.relationFK_InvoiceDetail_InvoiceMaster = new System.Data.DataRelation("FK_InvoiceDetail_InvoiceMaster", new System.Data.DataColumn[] {
                 this.tableInvoiceMaster.IDColumn}, new System.Data.DataColumn[] {
                 this.tableInvoiceDetail.InvoiceMasterRefColumn}, false);
     this.Relations.Add(this.relationFK_InvoiceDetail_InvoiceMaster);
     this.relationFK_InvoiceMaster_Organization = new System.Data.DataRelation("FK_InvoiceMaster_Organization", new System.Data.DataColumn[] {
                 this.tableOrganization.IDColumn}, new System.Data.DataColumn[] {
                 this.tableInvoiceMaster.OrganisationRefColumn}, false);
     this.Relations.Add(this.relationFK_InvoiceMaster_Organization);
     this.relationFK_ReceiptMaster_DocumentType = new System.Data.DataRelation("FK_ReceiptMaster_DocumentType", new System.Data.DataColumn[] {
                 this.tableDocumentType.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptMaster.DocumentTypeRefColumn}, false);
     this.Relations.Add(this.relationFK_ReceiptMaster_DocumentType);
     this.relationFK_ReceiptMaster_Organization = new System.Data.DataRelation("FK_ReceiptMaster_Organization", new System.Data.DataColumn[] {
                 this.tableOrganization.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptMaster.OrganizationRefColumn}, false);
     this.Relations.Add(this.relationFK_ReceiptMaster_Organization);
     this.relationFK_ReceiptMaster_Stock = new System.Data.DataRelation("FK_ReceiptMaster_Stock", new System.Data.DataColumn[] {
                 this.tableStock.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptMaster.MainStockRefColumn}, false);
     this.Relations.Add(this.relationFK_ReceiptMaster_Stock);
     this.relationStorageCondition_Product = new System.Data.DataRelation("StorageCondition_Product", new System.Data.DataColumn[] {
                 this.tableStorageCondition.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.StorageConditionRefColumn}, false);
     this.Relations.Add(this.relationStorageCondition_Product);
     this.relationFK_Packing_Product = new System.Data.DataRelation("FK_Packing_Product", new System.Data.DataColumn[] {
                 this.tablePacking.IDColumn}, new System.Data.DataColumn[] {
                 this.tableProduct.PackingRefColumn}, false);
     this.Relations.Add(this.relationFK_Packing_Product);
     this.relationReceiptDetail_Orders = new System.Data.DataRelation("ReceiptDetail_Orders", new System.Data.DataColumn[] {
                 this.tableReceiptDetail.ProductRefColumn}, new System.Data.DataColumn[] {
                 this.tableOrders.ProductRefColumn}, false);
     this.Relations.Add(this.relationReceiptDetail_Orders);
     this.relationProduct_Remains = new System.Data.DataRelation("Product_Remains", new System.Data.DataColumn[] {
                 this.tableProduct.IDColumn}, new System.Data.DataColumn[] {
                 this.tableRemains.ProductRefColumn}, false);
     this.Relations.Add(this.relationProduct_Remains);
     this.relationProduct_Orders = new System.Data.DataRelation("Product_Orders", new System.Data.DataColumn[] {
                 this.tableProduct.IDColumn}, new System.Data.DataColumn[] {
                 this.tableOrders.ProductRefColumn}, false);
     this.Relations.Add(this.relationProduct_Orders);
     this.relationTradePutlet_Orders = new System.Data.DataRelation("TradePutlet_Orders", new System.Data.DataColumn[] {
                 this.tableTradePutlet.IDColumn}, new System.Data.DataColumn[] {
                 this.tableOrders.TradePupletRefColumn}, false);
     this.Relations.Add(this.relationTradePutlet_Orders);
     this.relationOrganization_PricesPurchase = new System.Data.DataRelation("Organization_PricesPurchase", new System.Data.DataColumn[] {
                 this.tableOrganization.IDColumn}, new System.Data.DataColumn[] {
                 this.tablePricesPurchase.OrganizationRefColumn}, false);
     this.Relations.Add(this.relationOrganization_PricesPurchase);
     this.relationProduct_PricesPurchase = new System.Data.DataRelation("Product_PricesPurchase", new System.Data.DataColumn[] {
                 this.tableProduct.IDColumn}, new System.Data.DataColumn[] {
                 this.tablePricesPurchase.ProductRefColumn}, false);
     this.Relations.Add(this.relationProduct_PricesPurchase);
     this.relationReceiptDetail_PricesPurchase = new System.Data.DataRelation("ReceiptDetail_PricesPurchase", new System.Data.DataColumn[] {
                 this.tableReceiptDetail.ProductRefColumn}, new System.Data.DataColumn[] {
                 this.tablePricesPurchase.ProductRefColumn}, false);
     this.Relations.Add(this.relationReceiptDetail_PricesPurchase);
     this.relationReceiptDetail_InvoiceDetail = new System.Data.DataRelation("ReceiptDetail_InvoiceDetail", new System.Data.DataColumn[] {
                 this.tableReceiptDetail.IDColumn}, new System.Data.DataColumn[] {
                 this.tableInvoiceDetail.LocalReceiptDetailRefColumn}, false);
     this.Relations.Add(this.relationReceiptDetail_InvoiceDetail);
     this.relationReceiptDetail_Remains = new System.Data.DataRelation("ReceiptDetail_Remains", new System.Data.DataColumn[] {
                 this.tableReceiptDetail.IDColumn}, new System.Data.DataColumn[] {
                 this.tableRemains.ReceiptDetailRefColumn}, false);
     this.Relations.Add(this.relationReceiptDetail_Remains);
     this.relationTradePutlet_Stock = new System.Data.DataRelation("TradePutlet_Stock", new System.Data.DataColumn[] {
                 this.tableTradePutlet.IDColumn}, new System.Data.DataColumn[] {
                 this.tableStock.TradePutletRefColumn}, false);
     this.Relations.Add(this.relationTradePutlet_Stock);
     this.relationProduct_ReceiptDetail = new System.Data.DataRelation("Product_ReceiptDetail", new System.Data.DataColumn[] {
                 this.tableProduct.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptDetail.ProductRefColumn}, false);
     this.Relations.Add(this.relationProduct_ReceiptDetail);
     this.relationFK_Manufacturer_ReceiptDetail = new System.Data.DataRelation("FK_Manufacturer_ReceiptDetail", new System.Data.DataColumn[] {
                 this.tableManufacturer.IDColumn}, new System.Data.DataColumn[] {
                 this.tableReceiptDetail.ManufacturerRefColumn}, false);
     this.Relations.Add(this.relationFK_Manufacturer_ReceiptDetail);
     this.relationLinkedInvoiceMaster_LinkedInvoiceDetail = new System.Data.DataRelation("LinkedInvoiceMaster_LinkedInvoiceDetail", new System.Data.DataColumn[] {
                 this.tableLinkedInvoiceMaster.TradePutletRefColumn,
                 this.tableLinkedInvoiceMaster.IDColumn}, new System.Data.DataColumn[] {
                 this.tableLinkedInvoiceDetail.TradePutletRefColumn,
                 this.tableLinkedInvoiceDetail.InvoiceMasterRefColumn}, false);
     this.Relations.Add(this.relationLinkedInvoiceMaster_LinkedInvoiceDetail);
     this.relationFK_Country_Manufacturer = new System.Data.DataRelation("FK_Country_Manufacturer", new System.Data.DataColumn[] {
                 this.tableCountry.IDColumn}, new System.Data.DataColumn[] {
                 this.tableManufacturer.CounrtyRefColumn}, false);
     this.Relations.Add(this.relationFK_Country_Manufacturer);
     this.relationRemains_InvoiceDetail = new System.Data.DataRelation("Remains_InvoiceDetail", new System.Data.DataColumn[] {
                 this.tableRemains.ReceiptDetailRefColumn}, new System.Data.DataColumn[] {
                 this.tableInvoiceDetail.LocalReceiptDetailRefColumn}, false);
     this.Relations.Add(this.relationRemains_InvoiceDetail);
 }
Esempio n. 4
0
 internal void InitVars(bool initTable) {
     this.tableProduct = ((ProductDataTable)(base.Tables["Product"]));
     if ((initTable == true)) {
         if ((this.tableProduct != null)) {
             this.tableProduct.InitVars();
         }
     }
     this.tableCountry = ((CountryDataTable)(base.Tables["Country"]));
     if ((initTable == true)) {
         if ((this.tableCountry != null)) {
             this.tableCountry.InitVars();
         }
     }
     this.tableFarmGroup = ((FarmGroupDataTable)(base.Tables["FarmGroup"]));
     if ((initTable == true)) {
         if ((this.tableFarmGroup != null)) {
             this.tableFarmGroup.InitVars();
         }
     }
     this.tableFarmGroupLevel2 = ((FarmGroupLevel2DataTable)(base.Tables["FarmGroupLevel2"]));
     if ((initTable == true)) {
         if ((this.tableFarmGroupLevel2 != null)) {
             this.tableFarmGroupLevel2.InitVars();
         }
     }
     this.tableManufacturer = ((ManufacturerDataTable)(base.Tables["Manufacturer"]));
     if ((initTable == true)) {
         if ((this.tableManufacturer != null)) {
             this.tableManufacturer.InitVars();
         }
     }
     this.tablePacking = ((PackingDataTable)(base.Tables["Packing"]));
     if ((initTable == true)) {
         if ((this.tablePacking != null)) {
             this.tablePacking.InitVars();
         }
     }
     this.tableStorageCondition = ((StorageConditionDataTable)(base.Tables["StorageCondition"]));
     if ((initTable == true)) {
         if ((this.tableStorageCondition != null)) {
             this.tableStorageCondition.InitVars();
         }
     }
     this.tableUnit = ((UnitDataTable)(base.Tables["Unit"]));
     if ((initTable == true)) {
         if ((this.tableUnit != null)) {
             this.tableUnit.InitVars();
         }
     }
     this.tableSubstance = ((SubstanceDataTable)(base.Tables["Substance"]));
     if ((initTable == true)) {
         if ((this.tableSubstance != null)) {
             this.tableSubstance.InitVars();
         }
     }
     this.relationFK_Product_FarmGroupLevel2 = this.Relations["FK_Product_FarmGroupLevel2"];
     this.relationFK_FarmGroupLevel2_FarmGroup = this.Relations["FK_FarmGroupLevel2_FarmGroup"];
     this.relationFK_Manufacturer_Country = this.Relations["FK_Manufacturer_Country"];
     this.relationFK_Product_Packing = this.Relations["FK_Product_Packing"];
     this.relationFK_Product_StorageCondition = this.Relations["FK_Product_StorageCondition"];
     this.relationFK_Product_Unit = this.Relations["FK_Product_Unit"];
     this.relationFK_Product_Substance = this.Relations["FK_Product_Substance"];
 }
Esempio n. 5
0
 internal void InitVars(bool initTable) {
     this.tableCountry = ((CountryDataTable)(base.Tables["Country"]));
     if ((initTable == true)) {
         if ((this.tableCountry != null)) {
             this.tableCountry.InitVars();
         }
     }
     this.tableDocumentType = ((DocumentTypeDataTable)(base.Tables["DocumentType"]));
     if ((initTable == true)) {
         if ((this.tableDocumentType != null)) {
             this.tableDocumentType.InitVars();
         }
     }
     this.tableInvoiceDetail = ((InvoiceDetailDataTable)(base.Tables["InvoiceDetail"]));
     if ((initTable == true)) {
         if ((this.tableInvoiceDetail != null)) {
             this.tableInvoiceDetail.InitVars();
         }
     }
     this.tableInvoiceMaster = ((InvoiceMasterDataTable)(base.Tables["InvoiceMaster"]));
     if ((initTable == true)) {
         if ((this.tableInvoiceMaster != null)) {
             this.tableInvoiceMaster.InitVars();
         }
     }
     this.tableOrganization = ((OrganizationDataTable)(base.Tables["Organization"]));
     if ((initTable == true)) {
         if ((this.tableOrganization != null)) {
             this.tableOrganization.InitVars();
         }
     }
     this.tableReceiptRemains = ((ReceiptRemainsDataTable)(base.Tables["ReceiptRemains"]));
     if ((initTable == true)) {
         if ((this.tableReceiptRemains != null)) {
             this.tableReceiptRemains.InitVars();
         }
     }
     this.tableStock = ((StockDataTable)(base.Tables["Stock"]));
     if ((initTable == true)) {
         if ((this.tableStock != null)) {
             this.tableStock.InitVars();
         }
     }
     this.tableTradePutlet = ((TradePutletDataTable)(base.Tables["TradePutlet"]));
     if ((initTable == true)) {
         if ((this.tableTradePutlet != null)) {
             this.tableTradePutlet.InitVars();
         }
     }
     this.tableReceiptMaster = ((ReceiptMasterDataTable)(base.Tables["ReceiptMaster"]));
     if ((initTable == true)) {
         if ((this.tableReceiptMaster != null)) {
             this.tableReceiptMaster.InitVars();
         }
     }
     this.tableReceiptDetail = ((ReceiptDetailDataTable)(base.Tables["ReceiptDetail"]));
     if ((initTable == true)) {
         if ((this.tableReceiptDetail != null)) {
             this.tableReceiptDetail.InitVars();
         }
     }
     this.tableStorageCondition = ((StorageConditionDataTable)(base.Tables["StorageCondition"]));
     if ((initTable == true)) {
         if ((this.tableStorageCondition != null)) {
             this.tableStorageCondition.InitVars();
         }
     }
     this.tableProduct = ((ProductDataTable)(base.Tables["Product"]));
     if ((initTable == true)) {
         if ((this.tableProduct != null)) {
             this.tableProduct.InitVars();
         }
     }
     this.tableFarmGroup = ((FarmGroupDataTable)(base.Tables["FarmGroup"]));
     if ((initTable == true)) {
         if ((this.tableFarmGroup != null)) {
             this.tableFarmGroup.InitVars();
         }
     }
     this.tablePacking = ((PackingDataTable)(base.Tables["Packing"]));
     if ((initTable == true)) {
         if ((this.tablePacking != null)) {
             this.tablePacking.InitVars();
         }
     }
     this.tableSubstance = ((SubstanceDataTable)(base.Tables["Substance"]));
     if ((initTable == true)) {
         if ((this.tableSubstance != null)) {
             this.tableSubstance.InitVars();
         }
     }
     this.tableUnit = ((UnitDataTable)(base.Tables["Unit"]));
     if ((initTable == true)) {
         if ((this.tableUnit != null)) {
             this.tableUnit.InitVars();
         }
     }
     this.tableManufacturer = ((ManufacturerDataTable)(base.Tables["Manufacturer"]));
     if ((initTable == true)) {
         if ((this.tableManufacturer != null)) {
             this.tableManufacturer.InitVars();
         }
     }
     this.tableFarmGroupLevel2 = ((FarmGroupLevel2DataTable)(base.Tables["FarmGroupLevel2"]));
     if ((initTable == true)) {
         if ((this.tableFarmGroupLevel2 != null)) {
             this.tableFarmGroupLevel2.InitVars();
         }
     }
     this.tableOrders = ((OrdersDataTable)(base.Tables["Orders"]));
     if ((initTable == true)) {
         if ((this.tableOrders != null)) {
             this.tableOrders.InitVars();
         }
     }
     this.tableRemains = ((RemainsDataTable)(base.Tables["Remains"]));
     if ((initTable == true)) {
         if ((this.tableRemains != null)) {
             this.tableRemains.InitVars();
         }
     }
     this.tablePricesPurchase = ((PricesPurchaseDataTable)(base.Tables["PricesPurchase"]));
     if ((initTable == true)) {
         if ((this.tablePricesPurchase != null)) {
             this.tablePricesPurchase.InitVars();
         }
     }
     this.tablePeriods = ((PeriodsDataTable)(base.Tables["Periods"]));
     if ((initTable == true)) {
         if ((this.tablePeriods != null)) {
             this.tablePeriods.InitVars();
         }
     }
     this.tableLinkedInvoiceDetail = ((LinkedInvoiceDetailDataTable)(base.Tables["LinkedInvoiceDetail"]));
     if ((initTable == true)) {
         if ((this.tableLinkedInvoiceDetail != null)) {
             this.tableLinkedInvoiceDetail.InitVars();
         }
     }
     this.tableLinkedInvoiceMaster = ((LinkedInvoiceMasterDataTable)(base.Tables["LinkedInvoiceMaster"]));
     if ((initTable == true)) {
         if ((this.tableLinkedInvoiceMaster != null)) {
             this.tableLinkedInvoiceMaster.InitVars();
         }
     }
     this.tableReceiptDetailAdding = ((ReceiptDetailAddingDataTable)(base.Tables["ReceiptDetailAdding"]));
     if ((initTable == true)) {
         if ((this.tableReceiptDetailAdding != null)) {
             this.tableReceiptDetailAdding.InitVars();
         }
     }
     this.relationFK_InvoiceMaster_StockMain = this.Relations["FK_InvoiceMaster_StockMain"];
     this.relationFK_Stock_InvoiceMaster = this.Relations["FK_Stock_InvoiceMaster"];
     this.relationFK_ReceiptRemains_ReceiptDetail = this.Relations["FK_ReceiptRemains_ReceiptDetail"];
     this.relationReceiptMaster_ReceiptDetail = this.Relations["ReceiptMaster_ReceiptDetail"];
     this.relationFK_Substance_Product = this.Relations["FK_Substance_Product"];
     this.relationFK_Unit_Product = this.Relations["FK_Unit_Product"];
     this.relationFK_FarmGroupLevel2_Product = this.Relations["FK_FarmGroupLevel2_Product"];
     this.relationFK_FarmGroup_FarmGroupLevel2 = this.Relations["FK_FarmGroup_FarmGroupLevel2"];
     this.relationFK_ReceiptDetailAdding_ReceiptDetail = this.Relations["FK_ReceiptDetailAdding_ReceiptDetail"];
     this.relationFK_InvoiceDetail_InvoiceMaster = this.Relations["FK_InvoiceDetail_InvoiceMaster"];
     this.relationFK_InvoiceMaster_Organization = this.Relations["FK_InvoiceMaster_Organization"];
     this.relationFK_ReceiptMaster_DocumentType = this.Relations["FK_ReceiptMaster_DocumentType"];
     this.relationFK_ReceiptMaster_Organization = this.Relations["FK_ReceiptMaster_Organization"];
     this.relationFK_ReceiptMaster_Stock = this.Relations["FK_ReceiptMaster_Stock"];
     this.relationStorageCondition_Product = this.Relations["StorageCondition_Product"];
     this.relationFK_Packing_Product = this.Relations["FK_Packing_Product"];
     this.relationReceiptDetail_Orders = this.Relations["ReceiptDetail_Orders"];
     this.relationProduct_Remains = this.Relations["Product_Remains"];
     this.relationProduct_Orders = this.Relations["Product_Orders"];
     this.relationTradePutlet_Orders = this.Relations["TradePutlet_Orders"];
     this.relationOrganization_PricesPurchase = this.Relations["Organization_PricesPurchase"];
     this.relationProduct_PricesPurchase = this.Relations["Product_PricesPurchase"];
     this.relationReceiptDetail_PricesPurchase = this.Relations["ReceiptDetail_PricesPurchase"];
     this.relationReceiptDetail_InvoiceDetail = this.Relations["ReceiptDetail_InvoiceDetail"];
     this.relationReceiptDetail_Remains = this.Relations["ReceiptDetail_Remains"];
     this.relationTradePutlet_Stock = this.Relations["TradePutlet_Stock"];
     this.relationProduct_ReceiptDetail = this.Relations["Product_ReceiptDetail"];
     this.relationFK_Manufacturer_ReceiptDetail = this.Relations["FK_Manufacturer_ReceiptDetail"];
     this.relationLinkedInvoiceMaster_LinkedInvoiceDetail = this.Relations["LinkedInvoiceMaster_LinkedInvoiceDetail"];
     this.relationFK_Country_Manufacturer = this.Relations["FK_Country_Manufacturer"];
     this.relationRemains_InvoiceDetail = this.Relations["Remains_InvoiceDetail"];
 }
Esempio n. 6
0
 private void InitClass()
 {
     this.DataSetName = "THE_Data";
     this.Prefix = "";
     this.Namespace = "http://tempuri.org/THE_Data.xsd";
     this.EnforceConstraints = true;
     this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema;
     this.tableUnits = new UnitsDataTable();
     base.Tables.Add(this.tableUnits);
     this.tableUnit = new UnitDataTable();
     base.Tables.Add(this.tableUnit);
     this.tableSkills = new SkillsDataTable();
     base.Tables.Add(this.tableSkills);
     this.tableSkill = new SkillDataTable();
     base.Tables.Add(this.tableSkill);
     this.tableSpellEffect = new SpellEffectDataTable();
     base.Tables.Add(this.tableSpellEffect);
     this.tableVariableValue = new VariableValueDataTable();
     base.Tables.Add(this.tableVariableValue);
     this.tableSpellEffectBases = new SpellEffectBasesDataTable();
     base.Tables.Add(this.tableSpellEffectBases);
     this.tableSpellEffectBase = new SpellEffectBaseDataTable();
     base.Tables.Add(this.tableSpellEffectBase);
     this.tableVariable = new VariableDataTable();
     base.Tables.Add(this.tableVariable);
     global::System.Data.ForeignKeyConstraint fkc;
     fkc = new global::System.Data.ForeignKeyConstraint("Units_Unit", new global::System.Data.DataColumn[] {
                 this.tableUnits.Units_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableUnit.Units_IdColumn});
     this.tableUnit.Constraints.Add(fkc);
     fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = global::System.Data.Rule.Cascade;
     fkc.UpdateRule = global::System.Data.Rule.Cascade;
     fkc = new global::System.Data.ForeignKeyConstraint("Skills_Skill", new global::System.Data.DataColumn[] {
                 this.tableSkills.Skills_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableSkill.Skills_IdColumn});
     this.tableSkill.Constraints.Add(fkc);
     fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = global::System.Data.Rule.Cascade;
     fkc.UpdateRule = global::System.Data.Rule.Cascade;
     fkc = new global::System.Data.ForeignKeyConstraint("Skill_SpellEffect", new global::System.Data.DataColumn[] {
                 this.tableSkill.Skill_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableSpellEffect.Skill_IdColumn});
     this.tableSpellEffect.Constraints.Add(fkc);
     fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = global::System.Data.Rule.Cascade;
     fkc.UpdateRule = global::System.Data.Rule.Cascade;
     fkc = new global::System.Data.ForeignKeyConstraint("SpellEffect_VariableValue", new global::System.Data.DataColumn[] {
                 this.tableSpellEffect.SpellEffect_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableVariableValue.SpellEffect_IdColumn});
     this.tableVariableValue.Constraints.Add(fkc);
     fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = global::System.Data.Rule.Cascade;
     fkc.UpdateRule = global::System.Data.Rule.Cascade;
     fkc = new global::System.Data.ForeignKeyConstraint("SpellEffectBases_SpellEffectBase", new global::System.Data.DataColumn[] {
                 this.tableSpellEffectBases.SpellEffectBases_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableSpellEffectBase.SpellEffectBases_IdColumn});
     this.tableSpellEffectBase.Constraints.Add(fkc);
     fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = global::System.Data.Rule.Cascade;
     fkc.UpdateRule = global::System.Data.Rule.Cascade;
     fkc = new global::System.Data.ForeignKeyConstraint("SpellEffectBase_Variable", new global::System.Data.DataColumn[] {
                 this.tableSpellEffectBase.SpellEffectBase_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableVariable.SpellEffectBase_IdColumn});
     this.tableVariable.Constraints.Add(fkc);
     fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = global::System.Data.Rule.Cascade;
     fkc.UpdateRule = global::System.Data.Rule.Cascade;
     this.relationUnits_Unit = new global::System.Data.DataRelation("Units_Unit", new global::System.Data.DataColumn[] {
                 this.tableUnits.Units_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableUnit.Units_IdColumn}, false);
     this.relationUnits_Unit.Nested = true;
     this.Relations.Add(this.relationUnits_Unit);
     this.relationSkills_Skill = new global::System.Data.DataRelation("Skills_Skill", new global::System.Data.DataColumn[] {
                 this.tableSkills.Skills_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableSkill.Skills_IdColumn}, false);
     this.relationSkills_Skill.Nested = true;
     this.Relations.Add(this.relationSkills_Skill);
     this.relationSkill_SpellEffect = new global::System.Data.DataRelation("Skill_SpellEffect", new global::System.Data.DataColumn[] {
                 this.tableSkill.Skill_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableSpellEffect.Skill_IdColumn}, false);
     this.relationSkill_SpellEffect.Nested = true;
     this.Relations.Add(this.relationSkill_SpellEffect);
     this.relationSpellEffect_VariableValue = new global::System.Data.DataRelation("SpellEffect_VariableValue", new global::System.Data.DataColumn[] {
                 this.tableSpellEffect.SpellEffect_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableVariableValue.SpellEffect_IdColumn}, false);
     this.relationSpellEffect_VariableValue.Nested = true;
     this.Relations.Add(this.relationSpellEffect_VariableValue);
     this.relationSpellEffectBases_SpellEffectBase = new global::System.Data.DataRelation("SpellEffectBases_SpellEffectBase", new global::System.Data.DataColumn[] {
                 this.tableSpellEffectBases.SpellEffectBases_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableSpellEffectBase.SpellEffectBases_IdColumn}, false);
     this.relationSpellEffectBases_SpellEffectBase.Nested = true;
     this.Relations.Add(this.relationSpellEffectBases_SpellEffectBase);
     this.relationSpellEffectBase_Variable = new global::System.Data.DataRelation("SpellEffectBase_Variable", new global::System.Data.DataColumn[] {
                 this.tableSpellEffectBase.SpellEffectBase_IdColumn}, new global::System.Data.DataColumn[] {
                 this.tableVariable.SpellEffectBase_IdColumn}, false);
     this.relationSpellEffectBase_Variable.Nested = true;
     this.Relations.Add(this.relationSpellEffectBase_Variable);
 }
Esempio n. 7
0
 internal void InitVars(bool initTable)
 {
     this.tableUnits = ((UnitsDataTable)(base.Tables["Units"]));
     if ((initTable == true)) {
         if ((this.tableUnits != null)) {
             this.tableUnits.InitVars();
         }
     }
     this.tableUnit = ((UnitDataTable)(base.Tables["Unit"]));
     if ((initTable == true)) {
         if ((this.tableUnit != null)) {
             this.tableUnit.InitVars();
         }
     }
     this.tableSkills = ((SkillsDataTable)(base.Tables["Skills"]));
     if ((initTable == true)) {
         if ((this.tableSkills != null)) {
             this.tableSkills.InitVars();
         }
     }
     this.tableSkill = ((SkillDataTable)(base.Tables["Skill"]));
     if ((initTable == true)) {
         if ((this.tableSkill != null)) {
             this.tableSkill.InitVars();
         }
     }
     this.tableSpellEffect = ((SpellEffectDataTable)(base.Tables["SpellEffect"]));
     if ((initTable == true)) {
         if ((this.tableSpellEffect != null)) {
             this.tableSpellEffect.InitVars();
         }
     }
     this.tableVariableValue = ((VariableValueDataTable)(base.Tables["VariableValue"]));
     if ((initTable == true)) {
         if ((this.tableVariableValue != null)) {
             this.tableVariableValue.InitVars();
         }
     }
     this.tableSpellEffectBases = ((SpellEffectBasesDataTable)(base.Tables["SpellEffectBases"]));
     if ((initTable == true)) {
         if ((this.tableSpellEffectBases != null)) {
             this.tableSpellEffectBases.InitVars();
         }
     }
     this.tableSpellEffectBase = ((SpellEffectBaseDataTable)(base.Tables["SpellEffectBase"]));
     if ((initTable == true)) {
         if ((this.tableSpellEffectBase != null)) {
             this.tableSpellEffectBase.InitVars();
         }
     }
     this.tableVariable = ((VariableDataTable)(base.Tables["Variable"]));
     if ((initTable == true)) {
         if ((this.tableVariable != null)) {
             this.tableVariable.InitVars();
         }
     }
     this.relationUnits_Unit = this.Relations["Units_Unit"];
     this.relationSkills_Skill = this.Relations["Skills_Skill"];
     this.relationSkill_SpellEffect = this.Relations["Skill_SpellEffect"];
     this.relationSpellEffect_VariableValue = this.Relations["SpellEffect_VariableValue"];
     this.relationSpellEffectBases_SpellEffectBase = this.Relations["SpellEffectBases_SpellEffectBase"];
     this.relationSpellEffectBase_Variable = this.Relations["SpellEffectBase_Variable"];
 }
        public Tuple <MemoryStream, string> GenerateExcel(string filter = "{}")
        {
            Dictionary <string, string> FilterDictionary = new Dictionary <string, string>(JsonConvert.DeserializeObject <Dictionary <string, string> >(filter), StringComparer.OrdinalIgnoreCase);
            var Query      = AcceptedOrderMonitoringLogic.GetQuery(filter);
            var year       = short.Parse(FilterDictionary["year"]);
            var unitFilter = FilterDictionary.ContainsKey("unit") ? FilterDictionary["unit"] : "";
            var weeks      = DbContext.GarmentWeeklyPlans.Include(a => a.Items).Where(a => a.Year == year);
            var data       = Query.ToList();
            var monthTemp  = "";
            int total      = 0;

            if (!string.IsNullOrWhiteSpace(unitFilter))
            {
                weeks = DbContext.GarmentWeeklyPlans.Include(a => a.Items).Where(a => a.Year == year && a.UnitCode == unitFilter);
            }
            DataTable result = new DataTable();

            List <object> rowValuesForEmptyData = new List <object>();
            Dictionary <string, List <UnitDataTable> > rowData = new Dictionary <string, List <UnitDataTable> >();
            Dictionary <string, string> column = new Dictionary <string, string>();

            result.Columns.Add(new DataColumn()
            {
                ColumnName = "Unit", DataType = typeof(string)
            });
            rowValuesForEmptyData.Add("");
            foreach (var d in weeks.OrderByDescending(a => a.UnitCode))
            {
                string unitCol = d.UnitCode;
                if (!column.ContainsKey(d.UnitCode))
                {
                    column.Add(unitCol, unitCol);
                    result.Columns.Add(new DataColumn()
                    {
                        ColumnName = d.UnitCode, DataType = typeof(int)
                    });
                }

                rowValuesForEmptyData.Add(0);

                var month = "";
                monthTemp = "";
                foreach (var item in weeks.FirstOrDefault().Items.OrderBy(a => a.WeekNumber))
                {
                    switch (item.EndDate.Month)
                    {
                    case 1:
                        month = "Januari";
                        break;

                    case 2:
                        month = "Februari";
                        break;

                    case 3:
                        month = "Maret";
                        break;

                    case 4:
                        month = "April";
                        break;

                    case 5:
                        month = "Mei";
                        break;

                    case 6:
                        month = "Juni";
                        break;

                    case 7:
                        month = "Juli";
                        break;

                    case 8:
                        month = "Agustus";
                        break;

                    case 9:
                        month = "September";
                        break;

                    case 10:
                        month = "Oktober";
                        break;

                    case 11:
                        month = "November";
                        break;

                    case 12:
                        month = "Desember";
                        break;

                    default:
                        month = "";
                        break;
                    }

                    string week = string.Concat("W", item.WeekNumber, " - ", month);

                    var dataQty = data.FirstOrDefault(a => a.Unit.Equals(d.UnitCode) && a.WeekNumber.Equals(item.WeekNumber));

                    UnitDataTable unitDataTable = new UnitDataTable
                    {
                        Unit = d.UnitCode,
                        qty  = dataQty == null? 0 : (int)dataQty.Quantity
                    };

                    //disini
                    if (monthTemp == "")
                    {
                        monthTemp = month;
                    }

                    if (monthTemp == month)
                    {
                        total = dataQty == null? 0 + total : (int)dataQty.Quantity + total;
                    }
                    else if (monthTemp != month)
                    {
                        UnitDataTable unitDataTableTotal = new UnitDataTable
                        {
                            Unit = d.UnitCode,
                            qty  = total
                        };
                        string weekTotal = string.Concat("TOTAL ", monthTemp.ToUpper());
                        if (rowData.ContainsKey(weekTotal))
                        {
                            var rowValue = rowData[weekTotal];
                            var unit     = rowValue.FirstOrDefault(a => a.Unit == d.UnitCode);
                            if (unit == null)
                            {
                                rowValue.Add(unitDataTableTotal);
                            }
                        }
                        else
                        {
                            rowData.Add(weekTotal, new List <UnitDataTable> {
                                unitDataTableTotal
                            });
                        }
                        total     = dataQty == null ? 0 : (int)dataQty.Quantity;
                        monthTemp = month;
                    }


                    if (rowData.ContainsKey(week))
                    {
                        var rowValue = rowData[week];
                        var unit     = rowValue.FirstOrDefault(a => a.Unit == d.UnitCode);
                        if (unit == null)
                        {
                            rowValue.Add(unitDataTable);
                        }
                    }
                    else
                    {
                        rowData.Add(week, new List <UnitDataTable> {
                            unitDataTable
                        });
                    }
                }

                UnitDataTable unitDataTableTotal2 = new UnitDataTable
                {
                    Unit = d.UnitCode,
                    qty  = total
                };
                string weekTotal2 = string.Concat("TOTAL ", monthTemp.ToUpper());
                if (rowData.ContainsKey(weekTotal2))
                {
                    var rowValue = rowData[weekTotal2];
                    var unit     = rowValue.FirstOrDefault(a => a.Unit == d.UnitCode);
                    if (unit == null)
                    {
                        rowValue.Add(unitDataTableTotal2);
                    }
                }
                else
                {
                    rowData.Add(weekTotal2, new List <UnitDataTable> {
                        unitDataTableTotal2
                    });
                }
                total = 0;

                var sumQty = data.Where(a => a.Unit == d.UnitCode);
                if (!rowData.ContainsKey("TOTAL"))
                {
                    UnitDataTable unitDataTable1 = new UnitDataTable
                    {
                        Unit = d.UnitCode,
                        qty  = sumQty == null ? 0 : (int)sumQty.Sum(a => a.Quantity)
                    };
                    rowData.Add("TOTAL", new List <UnitDataTable> {
                        unitDataTable1
                    });
                }
                else
                {
                    var           sumData        = rowData["TOTAL"];
                    UnitDataTable unitDataTable2 = new UnitDataTable
                    {
                        Unit = d.UnitCode,
                        qty  = sumQty == null ? 0 : (int)sumQty.Sum(a => a.Quantity)
                    };
                    sumData.Add(unitDataTable2);
                }
            }

            if (data.Count == 0)
            {
                result.Rows.Add(rowValuesForEmptyData.ToArray());
            }
            else
            {
                foreach (var rowValue in rowData)
                {
                    List <object> rowValues = new List <object>();
                    rowValues.Add(rowValue.Key);
                    foreach (var a in rowValue.Value)
                    {
                        rowValues.Add(a.qty);
                    }
                    result.Rows.Add(rowValues.ToArray());
                }
            }

            ExcelPackage package = new ExcelPackage();
            var          sheet   = package.Workbook.Worksheets.Add("Monitoring Order Diterima");

            sheet.Cells["A1"].LoadFromDataTable(result, true, OfficeOpenXml.Table.TableStyles.Light16);

            for (int y = 1; y <= sheet.Dimension.Rows; y++)
            {
                for (int x = 1; x <= sheet.Dimension.Columns; x++)
                {
                    var cell = sheet.Cells[y, x];

                    if (y == 1)
                    {
                        cell.Style.Font.Bold = true;
                    }
                    else
                    {
                        if (sheet.Cells[y, x - x + 1].Value.ToString().Contains("TOTAL"))
                        {
                            cell.Style.Font.Bold = true;
                        }
                        else
                        {
                            cell.Style.Font.Bold = false;
                        }
                    }
                }
            }


            sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
            MemoryStream streamExcel = new MemoryStream();

            package.SaveAs(streamExcel);

            string fileName = string.Concat("Monitoring Order Diterima dan Booking ", FilterDictionary["year"], ".xlsx");

            return(Tuple.Create(streamExcel, fileName));
        }
Esempio n. 9
0
        public Tuple <MemoryStream, string> GenerateExcel(string filter = "{}")
        {
            var Query = MonitoringRemainingEHLogic.GetQuery(filter);
            var data  = Query.ToList();

            DataTable result = new DataTable();

            List <object> rowValuesForEmptyData = new List <object>();
            Dictionary <string, List <UnitDataTable> > rowData = new Dictionary <string, List <UnitDataTable> >();

            result.Columns.Add(new DataColumn()
            {
                ColumnName = "Unit", DataType = typeof(string)
            });
            rowValuesForEmptyData.Add("");
            foreach (var d in data)
            {
                result.Columns.Add(new DataColumn()
                {
                    ColumnName = d.Unit, DataType = typeof(int)
                });
                rowValuesForEmptyData.Add(0);

                foreach (var item in d.Items)
                {
                    string week   = string.Concat("W", item.WeekNumber);
                    int    opUnit = 0;
                    if (d.Unit != "SK")
                    {
                        opUnit = item.Operator;
                    }
                    UnitDataTable unitDataTable = new UnitDataTable
                    {
                        Unit         = d.Unit,
                        RemainigEH   = item.RemainingEH,
                        Operator     = item.Operator,
                        OperatorUnit = opUnit
                    };

                    if (rowData.ContainsKey(week))
                    {
                        var rowValue = rowData[week];
                        var unit     = rowValue.FirstOrDefault(a => a.Unit == d.Unit);
                        if (unit == null)
                        {
                            rowValue.Add(unitDataTable);
                        }
                    }
                    else
                    {
                        rowData.Add(week, new List <UnitDataTable> {
                            unitDataTable
                        });
                    }
                }
            }
            if (data.Count > 1)
            {
                result.Columns.Add(new DataColumn()
                {
                    ColumnName = "Total Remaining EH", DataType = typeof(string)
                });
                rowValuesForEmptyData.Add("");
            }
            result.Columns.Add(new DataColumn()
            {
                ColumnName = "Head Count Unit", DataType = typeof(string)
            });
            rowValuesForEmptyData.Add("");

            result.Columns.Add(new DataColumn()
            {
                ColumnName = "Head Count Total", DataType = typeof(string)
            });
            rowValuesForEmptyData.Add("");

            if (data.Count == 0)
            {
                result.Rows.Add(rowValuesForEmptyData.ToArray());
            }
            else
            {
                foreach (var rowValue in rowData)
                {
                    List <object> rowValues = new List <object>();
                    rowValues.Add(rowValue.Key);
                    foreach (var d in data)
                    {
                        rowValues.Add(rowValue.Value.Where(w => w.Unit == d.Unit).Select(s => s.RemainigEH).FirstOrDefault());
                    }
                    if (data.Count > 1)
                    {
                        rowValues.Add(rowValue.Value.Sum(s => s.RemainigEH));
                    }
                    rowValues.Add(rowValue.Value.Sum(s => s.OperatorUnit));
                    rowValues.Add(rowValue.Value.Sum(s => s.Operator));
                    result.Rows.Add(rowValues.ToArray());
                }
            }

            ExcelPackage package = new ExcelPackage();
            var          sheet   = package.Workbook.Worksheets.Add("RemainingEH");

            sheet.Cells["A1"].LoadFromDataTable(result, true, OfficeOpenXml.Table.TableStyles.Light16);

            for (int y = 1; y <= sheet.Dimension.Rows; y++)
            {
                for (int x = 1; x <= sheet.Dimension.Columns; x++)
                {
                    var cell = sheet.Cells[y, x];

                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
                    cell.Style.Font.Size        = 12;
                    cell.Style.Fill.PatternType = ExcelFillStyle.Solid;

                    if (y == 1)
                    {
                        cell.Style.Font.Bold = true;
                        cell.Style.Fill.BackgroundColor.SetColor(Color.LightGray);
                    }
                    else
                    {
                        if (x > 1 && x <= (sheet.Dimension.Columns - (data.Count > 1 ? 3 : 2)))
                        {
                            cell.Style.Fill.BackgroundColor.SetColor(
                                (int)cell.Value > 0 ? Color.Yellow :
                                (int)cell.Value < 0 ? Color.Red :
                                Color.Green);
                        }
                        else
                        {
                            cell.Style.Fill.BackgroundColor.SetColor(Color.WhiteSmoke);
                        }
                    }
                }
            }

            sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
            MemoryStream streamExcel = new MemoryStream();

            package.SaveAs(streamExcel);

            Dictionary <string, string> FilterDictionary = new Dictionary <string, string>(JsonConvert.DeserializeObject <Dictionary <string, string> >(filter), StringComparer.OrdinalIgnoreCase);
            string fileName = string.Concat("Remaining EH Report ", FilterDictionary["year"], ".xlsx");

            return(Tuple.Create(streamExcel, fileName));
        }