예제 #1
0
        public void UpdateModdedFlag(int index)
        {
            string PartNumber   = MergedInfo[index].PartNumber;
            string SerialNumber = MergedInfo[index].SerialNumber;
            int    SubId        = MergedInfo[index].Index;

            // 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;

                    // TODO: ja - add version check

                    // ja - create insert command with scope identity so we can get the key after the insert
                    //string sqlUpdate = @"Update AssociatedSubAssemblies Set SubSerialNumber = @SubSerialNumber, SubModded = @SubModded
                    //                     where SubPartNumber = " + @"'" + PartNumber + @"'";

                    string sqlUpdate = @"Update AssociatedSubAssemblies Set SubSerialNumber = @SubSerialNumber, SubModded = @SubModded
                                         where SubId = " + @"'" + SubId + @"'";

                    cmd.CommandText = sqlUpdate;

                    bool modded = true;
                    if (string.IsNullOrEmpty(SerialNumber))
                    {
                        modded = false;
                    }

                    // ja - populate the parameters
                    cmd.Parameters.AddWithValue("@SubModded", modded);
                    cmd.Parameters.AddWithValue("@SubSerialNumber", SerialNumber);

                    try
                    {
                        conn.Open();

                        // ja - get the top level key
                        cmd.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        throw;
                    }
                }
            }
        }
예제 #2
0
        private bool OpenConnection()
        {
            TheConnection = new SqlConnection(ConnectonStrings.GetMfgDataConnectionString());


            try
            {
                TheConnection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            return(true);
        }
예제 #3
0
        public void AssociateSubAssembly(int index)
        {
            int nInsertedKey = -1;

            SubAssembliyInfo newItem = MergedInfo[index];

            string SubSerialNumber = newItem.SerialNumber.Trim();
            string SubPartNumber   = newItem.PartNumber.Trim();
            string SubPartVersion  = newItem.Version.Trim();

            // 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 AssociatedSubAssemblies (TopLevelID, SubSerialNumber, SubPartNumber, SubPartVersion, SubModded) 
                                        Values (@TopLevelID, @SubSerialNumber, @SubPartNumber, @SubPartVersion, @SubModded);
                                        SELECT SCOPE_IDENTITY()";
                    cmd.CommandText = sqlInsert;

                    // ja - populate the permaerters
                    cmd.Parameters.AddWithValue("@TopLevelID", TopLevelId);
                    cmd.Parameters.AddWithValue("@SubSerialNumber", SubSerialNumber);
                    cmd.Parameters.AddWithValue("@SubPartNumber", SubPartNumber);
                    cmd.Parameters.AddWithValue("@SubPartVersion", SubPartVersion);
                    cmd.Parameters.AddWithValue("@SubModded", true);

                    try
                    {
                        conn.Open();

                        // ja - get the last key
                        nInsertedKey = Convert.ToInt32(cmd.ExecuteScalar());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        throw;
                    }
                }
            }
        }
예제 #4
0
        public void UpdateAssocatedFlag()
        {
            bool bAssociated = false;

            foreach (var item in MergedInfo)
            {
                if (item.Associated)
                {
                    bAssociated = true;
                    break;
                }
            }

            // 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 sqlUpdate = @"Update AssociatedTopLevelSerialInfo Set Associated = @Associated
                                         where TopLevelId = " + @"'" + TopLevelId + @"'";
                    cmd.CommandText = sqlUpdate;

                    // ja - populate the parameters
                    cmd.Parameters.AddWithValue("@Associated", bAssociated);

                    try
                    {
                        conn.Open();

                        // ja - get the top level key
                        cmd.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        throw;
                    }
                }
            }
        }
예제 #5
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);
                    }
                }
            }
        }
예제 #6
0
        static public void LogLables(List <string> serialsList, bool bIsRma, string sLabelStation, string sLabelType, bool BurstedLabels)
        {
            int nInsertedKey = -1;
            var WorkCode     = serialsList[0].Substring(0, 5);
            var UserName     = Environment.UserName;
            var ComputerName = Environment.MachineName;
            //string SerialData = "[" + string.Join("], [", serialsList) + "]";
            var PrintedLabelsCnt = serialsList.Count;

            // 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 LabelsLog (WorkCode, IsRMA, BurstedLabels, LabelStation, LabelType, ComputerName, UserName, PrintedLabelsCnt) 
                                        Values (@WorkCode, @IsRMA, @BurstedLabels, @LabelStation, @LabelType, @ComputerName, @UserName, @PrintedLabelsCnt);
                                        SELECT SCOPE_IDENTITY()";
                    cmd.CommandText = sqlInsert;

                    // ja - populate the parmaerters
                    cmd.Parameters.AddWithValue("@WorkCode", WorkCode);
                    cmd.Parameters.AddWithValue("@IsRMA", bIsRma);
                    cmd.Parameters.AddWithValue("@BurstedLabels", BurstedLabels);
                    cmd.Parameters.AddWithValue("@LabelStation", sLabelStation);
                    cmd.Parameters.AddWithValue("@LabelType", sLabelType);
                    cmd.Parameters.AddWithValue("@ComputerName", ComputerName);
                    cmd.Parameters.AddWithValue("@UserName", UserName);
                    cmd.Parameters.AddWithValue("@PrintedLabelsCnt", PrintedLabelsCnt);
                    //cmd.Parameters.AddWithValue("@Serials", SerialData);

                    try
                    {
                        conn.Open();

                        // ja - get the last key
                        nInsertedKey = Convert.ToInt32(cmd.ExecuteScalar());

                        cmd.Parameters.Clear();

                        foreach (string sSerial in serialsList)
                        {
                            string sqlSerialInsert = @"Insert Into LabelsLogSerials (SerialNumber, JobId) 
                                        Values (@SerialNumber, @JobId)";

                            cmd.CommandText = sqlSerialInsert;

                            // ja - populate the permaerters
                            cmd.Parameters.AddWithValue("@SerialNumber", sSerial);
                            cmd.Parameters.AddWithValue("@JobId", nInsertedKey);

                            cmd.ExecuteNonQuery();

                            cmd.Parameters.Clear();
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        throw;
                    }
                }
            }
        }