Exemple #1
0
        void addToShowBox(int month)
        {
            List <WorkStamp> list = new List <WorkStamp>();

            saveXmlFile();
            DateTime  startDate, finishDate;
            WorkStamp Ws;
            double    hours;

            try
            {
                foreach (XElement item in root.Elements())
                {
                    startDate  = DateTime.Parse(item.Element("StartDate").Value);
                    finishDate = DateTime.Parse(item.Element("FinishDate").Value);
                    hours      = double.Parse(item.Element("Hours").Value);
                    Ws         = new WorkStamp(startDate, finishDate, hours);
                    if (month == 0 || startDate.Month == month)
                    {
                        showTextBox.Items.Add(Ws);
                    }
                }
                //file.WriteLine("Total Hours Overall: " + calcTotal());
                //file.Close()
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemple #2
0
 void initVars()
 {
     Dt  = new WorkStamp();
     nUI = new Thread(new ThreadStart(resetTime));
     nUI.Start();
     //start_stopBtn.FontSize = 15;
     count.Text       = "Stopped";
     count.FontSize   = 15;
     count.Foreground = System.Windows.Media.Brushes.Red;
     FileTB.IsEnabled = false;
 }
Exemple #3
0
        public void addElement(WorkStamp element)
        {
            var Dt = element;

            root.Add(new XElement("Entry",
                                  new XElement("StartDate", Dt.getStart()),
                                  new XElement("FinishDate", Dt.getStop()),
                                  new XElement("Hours", Dt.getTotalHours()
                                               )));
            saveFile();
        }
Exemple #4
0
        public string DatabaseToString(int month)
        {
            saveFile();
            DateTime  startDate, finishDate;
            WorkStamp Ws     = new WorkStamp();
            string    output = "";
            float     hours;

            try
            {
                foreach (var item in root.Elements())
                {
                    startDate  = DateTime.Parse(item.Element("StartDate").Value);
                    finishDate = DateTime.Parse(item.Element("FinishDate").Value);
                    hours      = float.Parse(item.Element("Hours").Value);
                    if (month == 0 || startDate.Month == month)
                    {
                        //file.WriteLine(startDate.ToShortDateString() + "\t" + startDate.ToShortTimeString() + " - " + finishDate.ToShortTimeString() + "\t Total: " + hours + " Hours");
                        //file.Flush();
                        output += startDate.ToShortDateString() + "\t" + startDate.ToShortTimeString() + " - " + finishDate.ToShortTimeString() + "\t Total: " + hours + " Hours";
                        output += Environment.NewLine;
                    }
                }
                //file.WriteLine("Total Hours Overall: " + calcTotal());
                //file.Close();
                if (month == 0)
                {
                    output += "Total Hours Overall: " + calculateTotalHours();
                }
                else
                {
                    output += "Total Hours Overall: " + calculateMonthHours(month);
                }
                output += Environment.NewLine;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(output);
        }
Exemple #5
0
 public void removeElement(WorkStamp element)
 {
     throw new NotImplementedException();
 }
Exemple #6
0
        public void addElement(WorkStamp element)
        {
            string jsonObject = JsonConvert.SerializeObject(element, Formatting.Indented);

            writeToFile(jsonObject);
        }