Exemple #1
0
        public void ReadSubsFromEpicor()
        {
            EpicorInfo.Clear();

            // ja - local class to wrap Epicor functionality
            EpicorData epicorData = new EpicorData();

            List <string> subs = epicorData.GetSubs(WorkCode);

            foreach (var item in subs)
            {
                string partNumber = null;
                string version    = null;
                epicorData.ExtractPartInfo(item, ref partNumber, ref version);

                SubAssembliyInfo info = new SubAssembliyInfo();

                info.PartNumber = partNumber.Trim();
                info.Version    = version.Trim();
                info.InDatabase = false;
                info.Associated = false;

                EpicorInfo.Add(info);
            }
        }
Exemple #2
0
        public int FindPartNumberMatch(string serialNumber)
        {
            string partNumber   = "";
            string partVersion  = "";
            string tempWorkCode = serialNumber.Substring(0, 5);

            try
            {
                EpicorData ep = new EpicorData();
                ep.GetPartInfo(tempWorkCode, ref partNumber, ref partVersion);

                foreach (var item in MergedInfo)
                {
                    if ((partNumber.Trim() == item.PartNumber) && (partVersion.Trim() == item.Version))
                    {
                        if (!item.Associated)
                        {
                            return(item.Index);
                        }
                    }
                }
            }
            catch (Exception)
            {
                string sMsg = string.Format("WorkCode {0} Not Found in Epicor", tempWorkCode);
                throw new System.InvalidOperationException(sMsg);
                //throw;
            }

            return(-1);
        }
Exemple #3
0
        public void CreateTopLevel()
        {
            string partNumber  = "";
            string partVersion = "";

            EpicorData ep = new EpicorData();

            ep.GetPartInfo(WorkCode, ref partNumber, ref partVersion);

            // ja - open the mfg database and insert the printed label information
            using (SqlConnection conn = new SqlConnection(ConnectonStrings.GetMfgDataConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandType = System.Data.CommandType.Text;

                    // ja - create insert command with scope identity so we can get the key after the insert
                    string sqlInsert = @"Insert Into AssociatedTopLevelSerialInfo (TopLevelSerialNumber, PartNumber, PartVersion) 
                                        Values (@TopLevelSerialNumber, @PartNumber, @PartVersion);
                                        SELECT SCOPE_IDENTITY()";
                    cmd.CommandText = sqlInsert;

                    // ja - populate the parameters
                    cmd.Parameters.AddWithValue("@TopLevelSerialNumber", TopLevelSerial);
                    cmd.Parameters.AddWithValue("@PartNumber", partNumber);
                    cmd.Parameters.AddWithValue("@PartVersion", partVersion);

                    try
                    {
                        conn.Open();

                        // ja - get the top level key
                        TopLevelId = Convert.ToInt32(cmd.ExecuteScalar());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        string sMsg = string.Format("Insert into Database Failed... {0}", ex.Message);
                        throw new System.InvalidOperationException(sMsg);
                    }
                }
            }
        }