Exemple #1
0
        /// <summary>
        /// Load Excel file from Vendor
        /// </summary>
        public DataSet ParseEngine(string FilePath, string VendorValue, Boolean PalletPartnerChecked, string UserName)
        {
            DataSet   dsVendorData = new DataSet();
            DataTable dtSource     = new DataTable();

            dtSource.Columns.Add("Line", typeof(String));
            dtSource.Columns.Add("Problem", typeof(String));
            dtSource.Columns.Add("OriginalLine", typeof(String));
            string[] delimiter = new string[] { "\t" };
            String   RTSLine;
            String   LineProblems = "";

            PartCol     = -1;
            RTSVendorNo = VendorValue;
            WorkFormsData("ClearVendorRTS", VendorValue, "");
            // Now scan the contents
            using (StreamReader sr = new StreamReader(FilePath))
            {
                while ((RTSLine = sr.ReadLine()) != null)
                {
                    string[] Cols = RTSLine.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                    POValue            = "";
                    PartValue          = "";
                    PalletPartnerValue = "";
                    PalletsValue       = "";
                    CartonsValue       = "";
                    WeightValue        = "";
                    PortOfLadingValue  = "";
                    LocationValue      = "";
                    MfgPlantValue      = "";
                    RecStatus          = "";
                    string[] LineResults = ValidateInputColumns(Cols, PalletPartnerChecked);
                    LineProblems = LineResults[1];
                    RecStatus    = LineResults[0];
                    if (RecStatus != "EM")
                    {
                        try
                        {
                            WorkFormsData("InsertRTS"
                                          , ""
                                          , VendorValue
                                          , POValue
                                          , PartValue
                                          , PalletPartnerValue
                                          , PalletsValue.ToString()
                                          , CartonsValue
                                          , recctr.ToString()
                                          , WeightValue
                                          , PortOfLadingValue
                                          , LocationValue
                                          , MfgPlantValue
                                          , RecStatus
                                          , HoldWeeks.ToString()
                                          , UserName);
                        }
                        catch (Exception ex)
                        {
                            LineProblems += "Write; ";
                            RecStatus     = "99";
                            WorkFormsData("InsertRTS"
                                          , ""
                                          , VendorValue
                                          , ""
                                          , ""
                                          , ""
                                          , "0"
                                          , "0"
                                          , recctr.ToString()
                                          , "0"
                                          , ""
                                          , ""
                                          , ""
                                          , RecStatus
                                          , "0"
                                          , UserName);
                        }
                    }
                    dtSource.Rows.Add(new Object[] { recctr.ToString(), LineProblems, RTSLine.Replace("\"", "      ") });
                    recctr += 1;
                }
            }
            dsVendorData.Tables.Add(dtSource);
            return(dsVendorData);
        }
Exemple #2
0
        /// <summary>
        /// Load Excel file from Vendor
        /// </summary>
        public DataSet ParseEngine(string FilePath, string VendorValue, Boolean PalletPartnerChecked, string UserName)
        {
            DataSet   dsVendorData = new DataSet();
            DataTable dtSource     = new DataTable();

            dtSource.Columns.Add("Line", typeof(String));
            dtSource.Columns.Add("Problem", typeof(String));
            dtSource.Columns.Add("OriginalLine", typeof(String));
            string[] delimiter = new string[] { "\t" };
            String   RTSLine;
            String   LineProblems = "";

            PartCol     = -1;
            RTSVendorNo = VendorValue;
            SqlHelper.ExecuteDataset(connectionString, "[pVMI_Delete]",
                                     new SqlParameter("@tableName", "GERRTS"),
                                     new SqlParameter("@whereClause", "StatusCd >= '01' and VendNo = '" + VendorValue + "'"));
            // Now scan the contents
            using (StreamReader sr = new StreamReader(FilePath))
            {
                while ((RTSLine = sr.ReadLine()) != null)
                {
                    string[] Cols = RTSLine.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                    POValue            = "";
                    PartValue          = "";
                    PalletPartnerValue = "";
                    PalletsValue       = "";
                    CartonsValue       = "";
                    WeightValue        = "";
                    PortOfLadingValue  = "";
                    LocationValue      = "";
                    MfgPlantValue      = "";
                    RecStatus          = "";
                    string[] LineResults = ValidateInputColumns(Cols, PalletPartnerChecked);
                    LineProblems = LineResults[1];
                    RecStatus    = LineResults[0];
                    if (RecStatus != "EM")
                    {
                        insertValues  = "'" + VendorValue + "',";
                        insertValues += "'" + POValue + "',";
                        insertValues += "'" + PartValue + "',";
                        insertValues += "'" + PalletPartnerValue + "',";
                        insertValues += "'" + PalletsValue.ToString() + "',";
                        //insertValues += "'0',";
                        insertValues += CartonsValue + ",";
                        insertValues += recctr.ToString() + ",";
                        insertValues += WeightValue + ",";
                        insertValues += "'" + PortOfLadingValue + "',";
                        insertValues += "'" + LocationValue + "',";
                        insertValues += "'" + MfgPlantValue + "',";
                        insertValues += "'" + UserName + "',";
                        insertValues += "'" + DateTime.Now.ToString() + "',";
                        insertValues += "'" + RecStatus + "'";
                        try
                        {
                            SqlHelper.ExecuteDataset(connectionString, "[ugen_sp_insert]",
                                                     new SqlParameter("@tableName", "GERRTS"),
                                                     new SqlParameter("@columnNames", GERRTSInsertColumns),
                                                     new SqlParameter("@columnValues", insertValues));
                        }
                        catch (Exception ex)
                        {
                            LineProblems += "Write; ";
                            RecStatus     = "99";
                            insertValues  = "'" + VendorValue + "',";
                            insertValues += "'',";
                            insertValues += "'',";
                            insertValues += "'',";
                            insertValues += "'0',";
                            insertValues += "0,";
                            insertValues += recctr.ToString() + ",";
                            insertValues += "0,";
                            insertValues += "'',";
                            insertValues += "'',";
                            insertValues += "'',";
                            insertValues += "'" + UserName + "',";
                            insertValues += "'" + DateTime.Now.ToString() + "',";
                            insertValues += "'" + RecStatus + "'";
                            SqlHelper.ExecuteDataset(connectionString, "[ugen_sp_insert]",
                                                     new SqlParameter("@tableName", "GERRTS"),
                                                     new SqlParameter("@columnNames", GERRTSInsertColumns),
                                                     new SqlParameter("@columnValues", insertValues));
                        }
                    }
                    dtSource.Rows.Add(new Object[] { recctr.ToString(), LineProblems, RTSLine.Replace("\"", "      ") });
                    recctr += 1;
                }
            }
            dsVendorData.Tables.Add(dtSource);
            return(dsVendorData);
        }