public void SavePressed()
        {
            if (_edit == false) // new task
            {
                _task.SourceId = string.Format("{0}{1}{2}", DateTime.Now, _task.DateRemainder, _task.Text);
                _task.Save();
            }
            else
            {
                _task.Update();
            }

            TimeEngine.FireTaskChangedEvent(_task);
            _changesMade = true;
            _window.Close();
        }
예제 #2
0
        public void DeleteSelectedTask()
        {
            string message = "Do you realy want to delete this task?";

            if (this.SelectedTasks.Count > 1)
            {
                message = "Do you realy want to delete these tasks?";
            }

            if (MessageBox.Show(message, "Question",
                                MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                // we can't use SelectedTasks, because we are changing selected items by
                // removing them from observable collection
                List <Task> currentSelection = new List <Task>(SelectedTasks);
                for (int i = 0; i < currentSelection.Count; i++)
                {
                    Task task = currentSelection[i];
                    task.Delete();
                    _tasks.Remove(task); // I think it should be slow
                    TimeEngine.FireTaskChangedEvent(task);
                }
            }
        }
예제 #3
0
        /// <summary> Updates the given pObjRecord. </summary>
        /// <remarks> Ranaya, 08/05/2017. </remarks>
        /// <param name="pObjRecord"> The Object record to add. </param>
        /// <returns> An int. </returns>

        public int Update(TimeEngine pObjRecord)
        {
            return(mObjTimeEngineDAO.Update(pObjRecord));
        }
예제 #4
0
파일: ReadCsvTime.cs 프로젝트: xavl369/UGRS
        ///<summary>    Reads time engine. </summary>
        ///<remarks>    Amartinez, 22/05/2017. </remarks>
        ///<param name="pstrPath">  Full pathname of the pstr file. </param>
        public static List <TimeEngine> ReadTimeEngine(string pstrPath)
        {
            string            lStrline;
            List <TimeEngine> lListTimeEngine = new List <TimeEngine>();

            using (var lObjfile = File.OpenRead(pstrPath))
                using (var lObjreader = new StreamReader(lObjfile))
                {
                    lStrline = lObjreader.ReadLine();

                    try
                    {
                        Console.Write("Verificando archivo Horas de motor: " + Path.GetFileName(pstrPath));
                        while (!lObjreader.EndOfStream)
                        {
                            lStrline = lObjreader.ReadLine();
                            TimeEngine lobjTimeEngine = new TimeEngine();
                            var        lArrValues     = lStrline.Split(',');

                            lobjTimeEngine.AccountName   = lArrValues[0];
                            lobjTimeEngine.AccountNumber = Convert.ToInt32(lArrValues[1]);
                            lobjTimeEngine.DateStart     = DateTime.ParseExact(lArrValues[2], "MM/dd/yyyy", CultureInfo.InvariantCulture);
                            lobjTimeEngine.DateEnd       = DateTime.ParseExact(lArrValues[3], "MM/dd/yyyy", CultureInfo.InvariantCulture);
                            //
                            lobjTimeEngine.MachineName  = lArrValues[4];
                            lobjTimeEngine.PinOrVin     = lArrValues[5];
                            lobjTimeEngine.TerminalId   = lArrValues[6];
                            lobjTimeEngine.Brand        = lArrValues[7];
                            lobjTimeEngine.Model        = lArrValues[8];
                            lobjTimeEngine.MachineType  = lArrValues[9];
                            lobjTimeEngine.MachineGroup = lArrValues[10];
                            lobjTimeEngine.OtherOwner   = lArrValues[11];

                            lobjTimeEngine.LastCall     = DateTime.ParseExact(lArrValues[12], "yyyy/MM/dd HH:mm", CultureInfo.InvariantCulture);//verificar si es correcto o yyyy/MM/dd
                            lobjTimeEngine.Location     = lArrValues[13];
                            lobjTimeEngine.AreasControl = lArrValues[14];
                            lobjTimeEngine.Period       = float.Parse(lArrValues[15]);
                            lobjTimeEngine.LastPeriod   = float.Parse(lArrValues[16]);
                            if (lArrValues[17] != "")
                            {
                                lobjTimeEngine.Week1 = float.Parse(lArrValues[17]);
                            }
                            if (lArrValues[18] != "")
                            {
                                lobjTimeEngine.Week2 = float.Parse(lArrValues[18]);
                            }
                            if (lArrValues[19] != "")
                            {
                                lobjTimeEngine.Week3 = float.Parse(lArrValues[19]);
                            }
                            if (lArrValues[20] != "")
                            {
                                lobjTimeEngine.Week4 = float.Parse(lArrValues[20]);
                            }
                            if (lArrValues[21] != "")
                            {
                                lobjTimeEngine.Week5 = float.Parse(lArrValues[21]);
                            }

                            lListTimeEngine.Add(lobjTimeEngine);

                            //Lectura automatica de cualquier csv o clase
                            // faltó la validacion para cada tipo de dato
                            //int i = 0;
                            //foreach (var lpropiedades in lobjTimeEngine.GetType().GetProperties())// revisa las propiedades
                            //{
                            //    lpropiedades.SetValue(lobjTimeEngine,lArrValues[i]);
                            //    i++;
                            //}
                        }
                        Console.WriteLine(" OK ");
                    }
                    catch (Exception e)
                    {
                        LogUtility.Write(e.Message + " En archivo: " + Path.GetFileName(pstrPath));
                        Console.WriteLine(e.Message);
                    }
                    return(lListTimeEngine);
                }
        }
예제 #5
0
        /// <summary> Adds pObjRecord. </summary>
        /// <remarks> Ranaya, 08/05/2017. </remarks>
        /// <param name="pObjRecord"> The Object record to add. </param>
        /// <returns> An int. </returns>

        public int Add(TimeEngine pObjRecord)
        {
            return(mObjTimeEngineDAO.Add(pObjRecord));
        }