Example #1
0
 private void buttonRemove_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Tray will be removed.\n\nAre You Sure?", "Tray Removal", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         if (Global.Enumerables.Data.Count() <= 1)
         {
             IEnumerable <Tray> selT = from Tray in Global.Enumerables.Data where Tray.InspectionNumber.Equals(SelectedTray.InspectionNumber) && Tray.Area.Equals(SelectedTray.Area) select Tray;
             Global.Enumerables.Data.RemoveAt(Global.Enumerables.Data.IndexOf(selT.ToArray()[0]));
             File.Delete(Global.Strings.CurrentFile);
             DayTotalsFiles.DeleteToday(Global.Other.CurrentDate, Global.Strings.Shift);
             Global.Functions.CalculateTotals();
             ResetForm();
             GetAllTrays();
             CountRejects();
         }
         else
         {
             Global.Functions.Files.LoadData();
             //System.Threading.Thread.Sleep(Global.Ints.RTLoadSeed);
             //Global.Functions.Files.LoadData();
             Global.Functions.Files.LoadMP();
             //Global.Functions.CalculateTotals();
             //UpdateTotalsDisplay();
             IEnumerable <Tray> selT = from Tray in Global.Enumerables.Data where Tray.InspectionNumber.Equals(SelectedTray.InspectionNumber) && Tray.Area.Equals(SelectedTray.Area) select Tray;
             Global.Enumerables.Data.RemoveAt(Global.Enumerables.Data.IndexOf(selT.ToArray()[0]));
             Global.Functions.Files.SaveData();
             Global.Functions.CalculateTotals();
             ResetForm();
             GetAllTrays();
             CountRejects();
         }
     }
 }
Example #2
0
 //save data to xml file
 public static void SaveData()
 {
     if (Enumerables.Data.Count > 0)
     {
         DataTable dt = CreateDataTable(Enumerables.Data);
         dt.TableName = "data";
         dt.WriteXml(Strings.CurrentFile);
         DayTotalsFiles.SaveToday(Other.CurrentDate, Strings.Shift);
     }
 }
Example #3
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            //build day file path
            Global.Functions.Files.BuildDayFile(_DateTime, Shift);
            Global.Dec.CurrentHours  = Convert.ToDecimal(File.ReadAllText(Shift.Equals("Day") ? Global.Strings.TPMFilePathDay : Global.Strings.TPMFilePathSwing).Trim());
            Global.Other.CurrentDate = dateTimePicker1.Value;
            Global.Forms.ClockOut.textBoxHours.Text = Global.Dec.CurrentHours.ToString();
            //check for day file

            if (File.Exists(Global.Strings.CurrentFile))
            {
                if (DevMode)
                {
                    if (MessageBox.Show($"Data for {Shift} on {_DateTime.Date.ToShortDateString()} already exsists do you want to load data?", "Load Data?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Global.Functions.Files.LoadData();
                        Global.Functions.Files.LoadMP();
                        Global.Functions.CalculateTotals();
                        Global.Forms.ClockOut.UpdateTotalsDisplay();
                        Global.Forms.ClockOut.AddRanByAndClockedBy();
                    }
                    else if (MessageBox.Show($"Warning: By pressing yes all data will be deleted for this day.\nAre you sure?", "WARNING!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        File.Delete(Global.Strings.CurrentFile);
                        DayTotalsFiles.DeleteToday(dateTimePicker1.Value, Shift);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    Global.Functions.Files.LoadData();
                    Global.Functions.Files.LoadMP();
                    Global.Functions.CalculateTotals();
                    Global.Forms.ClockOut.UpdateTotalsDisplay();
                    Global.Forms.ClockOut.AddRanByAndClockedBy();
                }
            }
            Global.Forms.ClockOut.date             = dateTimePicker1.Value;
            Global.Forms.ClockOut.Shift            = Shift;
            Properties.Settings.Default.NewVersion = false;
            Properties.Settings.Default.Save();
            //show ClockOut Window
            Global.Forms.ClockOut.Show();
            File.Delete($@"{Global.Strings.ApplicationFilesDirectory}Restart.txt");
            //hide this
            this.Hide();
            //dont show in taskbar
            this.ShowInTaskbar = false;;
        }