Beispiel #1
0
        private void BtnSentSTG_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            DataTable dtSTG = (DataTable)dataGridSTG.DataSource;

            dt = dtSTG.Copy();

            try
            {
                ListToDT.GenerateExcelShipped(dt);

                String            message = @"File exported in Path: C:\STG_Excel_Exports\ShippedData_" + DateTime.Now.ToString("MMddyyyy_HH_mm_ss") + ".xlsx";
                String            caption = "Export Successful";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
            }
            catch (Exception ex)
            {
                String            message = "File Generation failed. Message: " + ex.Message;
                String            caption = "Export Failed";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
            }
        }
Beispiel #2
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 #3
0
        private static bool GenerateCSV(DataTable dt, string csvFileName)
        {
            StringBuilder sb = new StringBuilder();

            dt = ListToDT.ReadyDataTableForExport(dt);

            try
            {
                if (dt != null)
                {
                    IEnumerable <string> columnNames = dt.Columns.Cast <DataColumn>().
                                                       Select(column => column.ColumnName);
                    sb.AppendLine(string.Join(",", columnNames));

                    foreach (DataRow row in dt.Rows)
                    {
                        IEnumerable <string> fields = row.ItemArray.Select(field => field.ToString().Trim());
                        sb.AppendLine(string.Join(",", fields));
                    }

                    File.WriteAllText(@"C:\3PL_Excel_Exports\CSV\" + csvFileName.Trim(), sb.ToString());
                }
                else
                {
                    TextHelper.WriteLine("Empty Table Return from GenerateCSV");
                    return(false);
                }
            } catch (Exception ex)
            {
                TextHelper.WriteLine("CSV generation failed with error : " + ex.Message);
            }

            return(true);
        }
        private void ProcessInputFile(String FileName)
        {
            DataTable dt = ListToDT.CSVtoDatatable(FileName);

            DgImportInbound.DataSource = dt;
            dtImportFile = dt.Copy();
            dt.Dispose();
        }
Beispiel #5
0
        //To process input file
        private void ProcessInputFile(String FileName)
        {
            DataTable dt = ListToDT.CSVtoDatatable(FileName);

            dtImport = dt.Copy();

            //dt = CompareData(dt.Copy());

            //HideUneccessaryColumns(dt);
        }
Beispiel #6
0
        //To process input file
        private void ProcessInputFile(String FileName)
        {
            DataTable dt = ListToDT.CSVtoDatatable(FileName);

            dtImport = dt.Copy();

            DataSet ds = CompareData(dt.Copy());

            if (ds.Tables.Contains("Duplicate") && ds.Tables["Duplicate"].Rows.Count > 0)
            {
                DuplicateData(ds.Tables["Duplicate"]);

                String            message = @"Duplicate Records Found";
                String            caption = "Import Successful";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
            }
            else
            {
                String            message = @"No Duplicate Rows Found";
                String            caption = "Import Successful";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
            }

            if (ds.Tables.Contains("Result") && ds.Tables["Result"].Rows.Count > 0)
            {
                HideUneccessaryColumns(ds.Tables["Result"]);

                var rows        = ds.Tables["Result"].Rows.OfType <DataRow>();
                var columnTotal = rows.Sum(r => Convert.ToInt32((r["Shipped"].ToString() == "") ? 0 : int.Parse(r["Shipped"].ToString())));

                if (columnTotal == 0)
                {
                    String            message = @"No New Records Found";
                    String            caption = "Import Successful";
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show(message, caption, buttons);
                }
                else
                {
                    String            message = @"New Records Found";
                    String            caption = "Import Successful";
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show(message, caption, buttons);
                }
            }
            else
            {
                String            message = @"No Records Found";
                String            caption = "Import Successful";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
            }
        }
Beispiel #7
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;
        }