コード例 #1
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);
        }
コード例 #2
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);
                    }
                }
            }
        }