Beispiel #1
0
        private System.Data.DataTable JoinTables(System.Data.DataTable daPH, System.Data.DataTable daGP)
        {
            //System.Data.DataTable daFinal = new System.Data.DataTable();

            var joinResults = (from p in daPH.AsEnumerable()
                               join t in daGP.AsEnumerable()
                               on p.Field <String>("item_id") equals t.Field <String>("ITEMNMBR")
                               select new
            {
                OrderId = p.Field <string>("order_id"),
                ItemNumber = p.Field <string>("item_id"),
                b_company = p.Field <string>("b_company"),
                b_address1 = p.Field <string>("b_address1"),
                b_address2 = p.Field <string>("b_address2"),
                b_address3 = p.Field <string>("b_address3"),
                b_city = p.Field <string>("b_city"),
                b_state = p.Field <string>("b_state"),
                b_zip = p.Field <string>("b_zip"),
                b_country = p.Field <string>("b_country"),
                b_contact = p.Field <string>("b_contact"),
                b_phone = p.Field <string>("b_phone"),
                s_company = p.Field <string>("s_company"),
                po_num = p.Field <string>("po_num"),
                date_ordered = p.Field <string>("date_ordered"),
                cust_id = p.Field <string>("cust_id"),
                //pieces_hard = p.Field<string>("pieces_hard"),
                store_id = p.Field <string>("store_id"),

                ITEMDESC = t.Field <string>("ITEMDESC"),
                ITMSHNAM = t.Field <int>("ITMSHNAM")
            }).ToList();

            return(ListToDT.ToDataTable(joinResults));
        }
Beispiel #2
0
        private void SqlDataLoad_Click(object sender, EventArgs e)
        {
            try
            {
                TextHelper.WriteLine("Log Path : " + TextHelper.GetTempPath());

                dataGridGP.DataSource = null;
                dataGridGP.Update();
                dataGridGP.Refresh();


                DataTable daPowerhouse = new DataTable();
                DataTable daGP         = new DataTable();
                DataTable daSTG        = new DataTable();
                DataTable dafinal      = new DataTable();
                DataTable dtItems      = new DataTable();

                daPowerhouse = BuildPHQuery();

                TextHelper.WriteLine("Data received from Powerhouse");

                //Removed 09/20/21. Bringing data in the original Query.
                //var itemIds = daPowerhouse.AsEnumerable().Select(r => r.Field<String>("StrItemId")).ToList();
                //daGP = BuildGPQuery(itemIds);
                //TextHelper.WriteLine("Data received from GP Inventory");

                List <StgOrdersCSV> ListOfObjects = daPowerhouse.DataTableToList <StgOrdersCSV>();
                //Removed 09/20/21. Bringing data in the original Query.
                //ListOfObjects = ListToDT.AddGPDatatoObjects(ListOfObjects, daGP, "Inventory");

                var ordernNumber = daPowerhouse.AsEnumerable().Select(r => r.Field <String>("StrCustOrdNumber")).ToList();
                daGP = BuildGPSalesQuery(ordernNumber);

                TextHelper.WriteLine("Data received from GP Sales ");

                ListOfObjects = ListToDT.AddGPDatatoObjects(ListOfObjects, daGP, "Order");

                //Add Custom Vendor Numbers============================================================

                STGComm sTGComm = new STGComm();
                dtItems = sTGComm.GetItemsWithVendorNumber();

                ListOfObjects = ListToDT.AddSTGVendorNumberDatatoObjects(ListOfObjects, dtItems, "BBBVendorNumber");
                //End adding custom vendor numbres======================================================


                // START DATA FILTERATION PROCESS BASED ON STG DB
                //Get STG data to filter out old waves

                daSTG = GetSTGQuery(ordernNumber);

                TextHelper.WriteLine("Data received from STG");

                LoadDataTable(daSTG, "Shipped");
                //dataGridSTG.Columns.Clear();
                //dataGridSTG.DataSource = daSTG;

                ListOfObjects = ListToDT.FilterDataFromSTG(ListOfObjects, daSTG);

                // END FILTERATION PROCESS
                TextHelper.WriteLine("Final Table Loaded");
                if (ListOfObjects != null && ListOfObjects.Count > 0)
                {
                    dafinal = ListToDT.ToDataTable <StgOrdersCSV>(ListOfObjects);
                    LoadDataTable(dafinal, "Orders For Ship");

                    String            message = "Data Loading Completed. Showing New Wave Found in PowerHouse";
                    String            caption = "Loading Successfull";
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show(message, caption, buttons);
                }
                else
                {
                    String            message = "No New Waves found in Powerhouse";
                    String            caption = "Loading Successfull";
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show(message, caption, buttons);
                }
            }
            catch (Exception ex)
            {
                String            message = "Error while Getting Data from Powerhouse. Message: " + ex.Message;
                String            caption = "Data Loading Failed";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
            }

            //dataGridGP.Columns.Clear();
            //dataGridGP.DataSource = dafinal;
        }