Beispiel #1
0
        private void listParts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (PinsEdited == true || limitList1.HasEdits() == true || lifetimeLimits1.Edited == true)
            {
                // if (MessageBox.Show("There were changes made to the part.\nWould you like to save these changes to the database?", "Edits detected", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                // {
                SaveChanges();
                //}
            }
            PinsEdited = false;
            limitList1.ClearAllEdits();
            lifetimeLimits1.Edited      = false;
            buttonSaveChanges.IsEnabled = false;

            if (listParts.Items.Count > 0)
            {
                if (listParts.SelectedItem == null)
                {
                    return;
                }
                SelectedPartName        = listParts.SelectedItem.ToString();
                SelectedLifetimeLimitID = GCIDB.GetLifetimeLimitID(SelectedPartName);
                LoadedLimitData         = GCIDB.GetProductionLimits(SelectedPartName);
                lifetimeLimits1.SetEnabled(true);

                if (SelectedLifetimeLimitID > 0)
                {
                    LoadedLifetimeLimitData = GCIDB.GetLifetimeLimits(SelectedPartName);
                    lifetimeLimits1.LCL     = LoadedLifetimeLimitData.LowerRange;
                    lifetimeLimits1.UCL     = LoadedLifetimeLimitData.UpperRange;
                }
                else
                {
                    lifetimeLimits1.LCL = Properties.Settings.Default.LifetimeLimit_DefaultLowerRange;
                    lifetimeLimits1.UCL = Properties.Settings.Default.LifetimeLimit_DefaultUpperRange;
                }

                if (LoadedLimitData.Count > 0)
                {
                    SelectedPartID            = LoadedLimitData[0].PartID;
                    SelectedProductionLimitID = LoadedLimitData[0].ProductionLimitID;
                }
                else
                {
                    SelectedPartID            = GCIDB.GetPartID(SelectedPartName);
                    SelectedProductionLimitID = 0;
                }
                limitList1.ClearLimits();
                foreach (LimitEntity Limit in LoadedLimitData)
                {
                    limitList1.AddLimit(Limit);
                }
                buttonEditTestPins.IsEnabled = true;
                //buttonSaveChanges.IsEnabled = true;
            }
        }