Esempio n. 1
0
 //read data from xml file
 public static void LoadData()
 {
     if (File.Exists(Strings.CurrentFile))
     {
         int lng = File.ReadAllLines(Strings.CurrentFile).Length;
         if (lng >= 5)
         {
             Enumerables.Data.Clear();
             DataSet ds = new DataSet();
             System.Threading.Thread.Sleep(Global.Ints.RTLoadSeed);
             ds.ReadXml(Strings.CurrentFile);
             //DataTable newDataTable = new DataTable();
             //newDataTable.TableName = "data";
             //newDataTable.ReadXml(Strings.CurrentFile);
             for (int i = 0; i < ds.Tables["data"].Rows.Count; i++)
             {
                 Tray t = new Tray();
                 t.InspectionNumber = ds.Tables["data"].Rows[i].ItemArray[0].ToString();
                 t.PartNumber       = ds.Tables["data"].Rows[i].ItemArray[1].ToString();
                 t.GoodParts        = Convert.ToInt32(ds.Tables["data"].Rows[i].ItemArray[3]);
                 t.Area             = ds.Tables["data"].Rows[i].ItemArray[6].ToString();
                 t.RanBy            = ds.Tables["data"].Rows[i].ItemArray[7].ToString();
                 t.InspBy           = ds.Tables["data"].Rows[i].ItemArray[8].ToString();
                 t.Block            = Convert.ToInt32(ds.Tables["data"].Rows[i].ItemArray[9]);
                 t.SecondInspected  = Convert.ToBoolean(ds.Tables["data"].Rows[i].ItemArray[10]);
                 //rejects
                 int            _i    = 0;
                 PropertyInfo[] props = typeof(Rejects).GetProperties();
                 t.Rejects = new Rejects();
                 foreach (PropertyInfo prop in props)
                 {
                     prop.SetValue(t.Rejects, Convert.ToInt32(ds.Tables["Rejects"].Rows[i].ItemArray[_i]));
                     _i++;
                 }
                 t.SetTotalRejects();
                 Enumerables.Data.Add(t);
             }
             //load recent partnumbers
             SetRecentPartNumbers(Enumerables.Data);
         }
     }
 }
Esempio n. 2
0
 private void ListBoxesClick(object sender, EventArgs e)
 {
     if (!(sender as ListBox).SelectedIndex.Equals(-1))
     {
         SelectedIndex                         = (sender as ListBox).SelectedIndex;
         listBoxArea.SelectedIndex             = SelectedIndex;
         listBoxClockedBy.SelectedIndex        = SelectedIndex;
         listBoxGoodParts.SelectedIndex        = SelectedIndex;
         listBoxInspection.SelectedIndex       = SelectedIndex;
         listBoxPartNumber.SelectedIndex       = SelectedIndex;
         listBoxRanBy.SelectedIndex            = SelectedIndex;
         listBoxSecondInspection.SelectedIndex = SelectedIndex;
         listBoxTotalRejects.SelectedIndex     = SelectedIndex;
         btnEdit.Visible                       = true;
         buttonRemove.Visible                  = true;
         SelectedTray = trays.ElementAt(SelectedIndex);
         RejectCount  = new Rejects();
         ResetRejectsDisplay();
         CountRejectsTray(SelectedTray);
     }
 }
Esempio n. 3
0
        public void CountRejectsTray(Tray t)
        {
            Label[]        RejLabels = { LblABRK, LblBINT, LblCA, LblCALL, LblCB, LblCC, LblCCR, LblCD, LblCDMP, LblCHAF, LblCHIP, LblCLOB, LblCLOD, LblCM, LblCON, LblCONT, LblCOSC, LblCOSD, LblCPIT, LblCPOR, LblCPR, LblCRK, LblDEL, LblDPIT, LblDF, LblDID, LblDOA, LblDPOP, LblHCUT, LblHM, LblINFIL, LblINV, lblLAS, LblLCC, LblLDC, LblLip, LblLOST, LblLTD, LblLTS, LblMISC, LblMIX, LblMOLY, LblMOP, LblNCD, LblPARA, LblPERP, LblPLUM, LblPOL, LblRCL, LblRDIC, LblRES, LblRNGC, LblSCR, LblSDC, LblSDIA, LblSHT, LblSPIN, LblTD, LblTEMP, LblTHT, LblTKD, LblWD, LblWP };
            PropertyInfo[] props     = typeof(Rejects).GetProperties();

            foreach (PropertyInfo p in props)
            {
                p.SetValue(RejectCount, Convert.ToInt32(p.GetValue(RejectCount)) + Convert.ToInt32(p.GetValue(t.Rejects)));
            }
            int i = 0;

            foreach (PropertyInfo p in props)
            {
                if (Convert.ToInt32(p.GetValue(RejectCount)) > 0)
                {
                    RejLabels[i].Text    = RejN[i] + " -- " + p.GetValue(RejectCount).ToString();
                    RejLabels[i].Visible = true;
                }
                i++;
            }
        }
Esempio n. 4
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            //load file data
            if (File.Exists(Global.Strings.CurrentFile))
            {
                Global.Functions.Files.LoadData();
                //System.Threading.Thread.Sleep(Global.Ints.RTLoadSeed);
                //Global.Functions.Files.LoadData();
                Global.Functions.Files.LoadMP();
                //Global.Functions.CalculateTotals();
                //UpdateTotalsDisplay();
            }
            if (EditMode)
            {
                Global.Enumerables.Data.RemoveAt(Global.Enumerables.Data.IndexOf(EditTray.ToArray()[0]));
            }

            //check for missing information.
            if (CheckForMissingData())
            {
                return;
            }
            //check if anca and radius selected.
            //adding later update
            //check for duplicates.
            Tray[] _t = (from Tray in Global.Enumerables.Data where Tray.InspectionNumber == textBoxInspection.Text && Tray.Area == comboBoxAreaSelection.Text select Tray).ToArray();
            if (_t.Length > 0)
            {
                if (MessageBox.Show($"Inspection {_t[0].InspectionNumber} is already clocked for {_t[0].Area}.\nDo you want to replace tray?", "Tray Already Clocked", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Global.Enumerables.Data.RemoveAt(Global.Enumerables.Data.IndexOf(_t[0]));
                }
                else
                {
                    checkBoxOverrideTrayQuantity.Checked    = false;
                    comboBoxRecentPartNumbers.SelectedIndex = -1;
                    textBoxInspection.Text = string.Empty;
                    textBoxPartNumber.Text = string.Empty;
                    textBoxGoodParts.Text  = string.Empty;
                    if (!checkBoxFreezeArea.Checked)
                    {
                        comboBoxAreaSelection.SelectedIndex = -1;
                        comboBoxAreaSelection.Text          = string.Empty;
                    }
                    comboBoxInspBy.SelectedIndex      = -1; comboBoxInspBy.Text = string.Empty;
                    comboBoxRanBy.SelectedIndex       = -1; comboBoxRanBy.Text = string.Empty;
                    comboBoxRecentPartNumbers.Visible = false;
                    listBoxReject.Items.Clear();
                    listBoxRCount.Items.Clear();
                    checkBoxSecondInspected.Checked = false;
                    RejectCount = 0;
                    //update totals display
                    UpdateTotalsDisplay();
                    AcceptButton = btn;
                    textBoxInspection.Select();
                    //save file data
                    Global.Functions.Files.SaveData();
                    EditMode = false;
                    return;
                }
            }
            //create a new tray instance
            Tray t = new Tray();

            //set tray values
            t.InspectionNumber = textBoxInspection.Text;
            t.PartNumber       = textBoxPartNumber.Text;
            t.GoodParts        = int.Parse(textBoxGoodParts.Text);
            t.Block            = CurrentSelectedBlock;
            t.Area             = comboBoxAreaSelection.Text.ToUpper();
            t.RanBy            = comboBoxRanBy.Text.ToUpper();
            t.InspBy           = comboBoxInspBy.Text.ToUpper();
            t.SecondInspected  = checkBoxSecondInspected.Checked;
            //traverse rejects and add to tray
            foreach (object item in listBoxReject.Items)
            {
                t.Rejects.SetRejectValueByCode(item.ToString(), Convert.ToInt32(listBoxRCount.Items[listBoxReject.Items.IndexOf(item)]));

                // removed due to indexer not working with reflection
                //t.Rejects[item.ToString()] = int.Parse(listBoxRCount.Items[listBoxReject.Items.IndexOf(item)].ToString());
            }
            //calculate total rejects for the tray
            t.SetTotalRejects();
            // add to tray list
            Global.Enumerables.Data.Add(t);
            // calculate totals
            Global.Functions.CalculateTotals();

            //add history
            LastPartNumber = textBoxPartNumber.Text;
            if (comboBoxRecentPartNumbers.Items.IndexOf(LastPartNumber) == -1)
            {
                comboBoxRecentPartNumbers.Items.Add(LastPartNumber); //recent part numbers add
            }
            if (comboBoxInspBy.Items.IndexOf(comboBoxInspBy.Text.ToUpper()) == -1)
            {
                comboBoxInspBy.Items.Add(comboBoxInspBy.Text.ToUpper()); //initials inspby add
            }
            if (comboBoxRanBy.Items.IndexOf(comboBoxRanBy.Text.ToUpper()) == -1)
            {
                comboBoxRanBy.Items.Add(comboBoxRanBy.Text.ToUpper()); //initials ranby add
            }
            //reset form
            checkBoxOverrideTrayQuantity.Checked    = false;
            comboBoxRecentPartNumbers.SelectedIndex = -1;
            textBoxInspection.Text = string.Empty;
            textBoxPartNumber.Text = string.Empty;
            textBoxGoodParts.Text  = string.Empty;
            if (!checkBoxFreezeArea.Checked)
            {
                comboBoxAreaSelection.SelectedIndex = -1;
                comboBoxAreaSelection.Text          = string.Empty;
            }
            comboBoxInspBy.SelectedIndex      = -1; comboBoxInspBy.Text = string.Empty;
            comboBoxRanBy.SelectedIndex       = -1; comboBoxRanBy.Text = string.Empty;
            comboBoxRecentPartNumbers.Visible = false;
            listBoxReject.Items.Clear();
            listBoxRCount.Items.Clear();
            checkBoxSecondInspected.Checked = false;
            RejectCount = 0;
            //update totals display
            UpdateTotalsDisplay();
            AcceptButton = btn;
            textBoxInspection.Select();
            //save file data
            Global.Functions.Files.SaveData();
            EditMode = false;
        }