コード例 #1
0
        public async Task <int> InsertTaskAsync(OneTimeTasks task, bool isUserPerformed = false)
        {
            string query = "INSERT INTO `OneTimeTasks`" +
                           "(`Type`,`Comments`,`Duration`,`CreatedUser`,`CreatedDateTime`,`IsDelete`,`Effectivedate`) " +
                           "VALUES (@Type,@Comments,@Duration,@CreatedUser,@CreatedDateTime,@IsDelete,@Effectivedate);";

            IEnumerable <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("@Type", task.Type),
                new KeyValuePair <string, object>("@Comments", task.Comments),
                new KeyValuePair <string, object>("@Duration", task.Duration),
                new KeyValuePair <string, object>("@CreatedUser", task.CreatedUser),
                new KeyValuePair <string, object>("@Effectivedate", TimeConverterMethods.ConvertDateTimeToTimeStamp(task.Effectivedate)),
                new KeyValuePair <string, object>("@CreatedDateTime", TimeConverterMethods.ConvertDateTimeToTimeStamp(task.CreatedDateTime)),
                new KeyValuePair <string, object>("@IsDelete", 0)
            };

            int id = await SqliteConnector.ExecuteInsertQueryAsync(query, parameters, true);

            query = "UPDATE `OneTimeTasks` SET `ReferenceNumber`=@ReferenceNumber WHERE `Id`=@Id";

            parameters = new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("@ReferenceNumber", id.ToString("OTASK000000")),
                new KeyValuePair <string, object>("@Id", id)
            };

            await SqliteConnector.ExecuteNonQueryAsync(query, parameters, true);

            return(id);
        }
コード例 #2
0
        public async Task <OneTimeTasks> InsertTaskAsync(OneTimeTasks task, bool isUserPerformed = false)
        {
            await _insertTaskSemaphoreSlim.WaitAsync();

            try
            {
                UserEntity userEntity = await _userModel.GetUserDetailsAsync();

                task.CreatedUser = userEntity.Id;

                int tId = await _taskModel.InsertTaskAsync(task, isUserPerformed);

                task = await _taskModel.GetTaskByIdAsync(tId);

                IList <OneTimeTasks> tasks = OneTimeTasks.ToList();
                tasks.Add(task);

                OneTimeTasks = tasks;
                CurrentUser  = userEntity;

                return(task);
            }
            catch (Exception k)
            {
                applicationErrorLog.ErrorLog("Task", "Insert one time task", k.ToString());
                return(task);
            }
            finally
            {
                _insertTaskSemaphoreSlim.Release();
            }
        }
コード例 #3
0
 public OneTImeTaskBinder(OneTimeTasks taskEntity)
 {
     ReferenceNumber = taskEntity.ReferenceNumber;
     Comments        = taskEntity.Comments;
     Duration        = taskEntity.Duration.ToString();
     Effectivedate   = taskEntity.Effectivedate;
     Type            = taskEntity.Type == 1 ? ContentTaskTypesEnum.Appointment.ToString() : ContentTaskTypesEnum.Task.ToString();
 }
コード例 #4
0
 public ManageTaskUserControl(Action <ContentItemEnum> changeContent, OneTimeTasks transactionEntity, ScheduledTasks schtrans) : this(changeContent)
 {
     _onetimetaskEntity = transactionEntity;
     if (schtrans != null)
     {
         _schtaskEntity = schtrans;
     }
 }
コード例 #5
0
 private void dataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         OneTImeTaskBinder transactionBinder = _OneTImeTaskBinder[e.RowIndex];
         OneTimeTasks      onetimetasks      = _applicationService.OneTimeTasks.First(t => t.ReferenceNumber == transactionBinder.ReferenceNumber);
         _changeContentMainFormAction(ContentItemEnum.ManageTask, onetimetasks);
     }
 }
コード例 #6
0
        public async Task <OneTimeTasks> UpdateTaskAsync(OneTimeTasks task)
        {
            await _taskModel.UpdateTaskAsync(task);

            UserEntity userEntity = await _userModel.GetUserDetailsAsync();

            IEnumerable <OneTimeTasks> tasks = await _taskModel.GetTaskAsync();

            OneTimeTasks = tasks;
            CurrentUser  = userEntity;

            return(task);
        }
コード例 #7
0
        public async Task DeleteTaskAsync(int id)
        {
            _taskModel.DeleteTaskAsync(id);
            OneTimeTasks task = await _taskModel.GetTaskByIdAsync(id);

            UserEntity userEntity = await _userModel.GetUserDetailsAsync();

            IList <OneTimeTasks> tasks       = OneTimeTasks.ToList();
            OneTimeTasks         deletedTask = tasks.First(tp => tp.Id == id);

            deletedTask.IsDelete = true;

            OneTimeTasks = tasks;
            CurrentUser  = userEntity;
        }
コード例 #8
0
 public ManageTaskUserControl(Action <ContentItemEnum> changeContentMainFormAction)
 {
     _changeContentMainFormAction = changeContentMainFormAction;
     _applicationService          = MyFinance.Entities.MyFinanceApplication.DependancyContainer.GetInstance <IApplicationService>();
     _onetimetaskEntity           = null;
     InitializeComponent();
     comboBoxRepeat.DataSource       = Enum.GetValues(typeof(ContentRepeatItemEnum));
     taskTypeComboBox.SelectedIndex  = 0;
     comboBoxType.SelectedIndex      = 0;
     comboBoxRepeat.SelectedIndex    = 1;
     dateTimePickerTo.MinDate        = DateTime.Today.AddDays(1);
     dateTimePickerForm.MinDate      = DateTime.Today;
     dateTimePickerEffective.MinDate = DateTime.Today.AddDays(1);
     referenceNumberPanel.Visible    = false;
 }
コード例 #9
0
        public async Task <int> UpdateTaskAsync(OneTimeTasks task)
        {
            string query = "UPDATE `OneTimeTasks` " +
                           "SET `Type`=@Type,`Comments`=@Comments,`Duration`=@Duration,`Effectivedate`=@Effectivedate " +
                           "WHERE `Id` = @Id";

            IEnumerable <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("@Type", task.Type),
                new KeyValuePair <string, object>("@Comments", task.Comments),
                new KeyValuePair <string, object>("@Duration", task.Duration),
                new KeyValuePair <string, object>("@Effectivedate", TimeConverterMethods.ConvertDateTimeToTimeStamp(task.Effectivedate)),
                new KeyValuePair <string, object>("@Id", task.Id),
            };

            return(await SqliteConnector.ExecuteNonQueryAsync(query, parameters, true));
        }
コード例 #10
0
        private void SetTaskEntity(OneTimeTasks onetimetaskEntity = null)
        {
            try
            {
                _onetimetaskEntity = onetimetaskEntity ?? new OneTimeTasks()
                {
                    Duration        = 0D,
                    ReferenceNumber = "",
                    Comments        = "",
                };

                if (_onetimetaskEntity.Id == 0)
                {
                    referenceNumberPanel.Visible = false;
                }
                else
                {
                    referenceNumberPanel.Visible = true;
                    referenceNumberTextBox.Text  = _onetimetaskEntity.ReferenceNumber;
                }

                durationErrorLabel.Text        = "";
                amountNumericUpDown.Text       = _onetimetaskEntity.Duration.ToString();
                taskTypeComboBox.SelectedIndex = _onetimetaskEntity.Type;
                remarksTextBox.Text            = _onetimetaskEntity.Comments;
                dateTimePickerEffective.Value  = _onetimetaskEntity.Effectivedate;
                remarksTextBox.Text            = _onetimetaskEntity.Comments;
                remarksErrorLabel.Text         = "";
                comboBoxType.Enabled           = false;
                dateTimePickerForm.Enabled     = true;
            }
            catch (Exception k)
            {
                applicationErrorLog.ErrorLog("Task", "setting one time tasks to UI", k.ToString());
            }
        }
コード例 #11
0
        private async void actionsUserControl_SaveButtonOnClick(object sender, EventArgs e)
        {
            if (IsFormDataValid())
            {
                tableLayoutPanel.Enabled            = false;
                actionsUserControl.IsEnabledButtons = false;
                int id = 0;

                if (_onetimetaskEntity != null)
                {
                    id = _onetimetaskEntity.Id;
                }
                else if (_schtaskEntity != null)
                {
                    id = _schtaskEntity.Id;
                }
                string   remarks       = remarksTextBox.Text;
                int      taskId        = comboBoxType.SelectedIndex;
                double   duration      = double.Parse(amountNumericUpDown.Text);
                DateTime Effectivedate = dateTimePickerEffective.Value;

                if (taskId == 0)
                {
                    //single time tasks
                    OneTimeTasks taskEntity = new OneTimeTasks()
                    {
                        Id              = id,
                        Duration        = duration,
                        Comments        = remarks,
                        Effectivedate   = Effectivedate,
                        IsDelete        = false,
                        Type            = taskTypeComboBox.SelectedIndex,
                        CreatedDateTime = DateTime.Now
                    };

                    if (id == 0)
                    {
                        await _applicationService.InsertTaskAsync(taskEntity, true);
                    }
                    else
                    {
                        await _applicationService.UpdateTaskAsync(taskEntity);
                    }
                }

                else
                {
                    //Scheduled tasks

                    DateTime dtNextDate   = DateTime.Now;
                    string   SelectedType = this.comboBoxRepeat.GetItemText(this.comboBoxRepeat.SelectedItem).Trim();

                    if (SelectedType == ContentRepeatItemEnum.Daily.ToString())
                    {
                        dtNextDate = dateTimePickerForm.Value.AddDays(1);
                    }
                    else if (SelectedType == ContentRepeatItemEnum.Weekly.ToString())
                    {
                        dtNextDate = dateTimePickerForm.Value.AddDays(7);
                    }
                    else if (SelectedType == ContentRepeatItemEnum.Monthly.ToString())
                    {
                        dtNextDate = dateTimePickerForm.Value.AddDays(30);
                    }
                    else
                    {
                        dtNextDate = dateTimePickerForm.Value.AddYears(1);
                    }

                    ScheduledTasks taskSheduledEntity = new ScheduledTasks()
                    {
                        Id              = id,
                        Duration        = duration,
                        Comments        = remarks,
                        Effectivedate   = Effectivedate,
                        IsDelete        = false,
                        Type            = comboBoxType.SelectedIndex,
                        CreatedDateTime = DateTime.Now,
                        RepeatType      = SelectedType,
                        StartDateTime   = dateTimePickerForm.Value,
                        EndDateTime     = dateTimePickerTo.Value,
                        IsActive        = checkBoxActive.Checked,
                    };

                    if (id == 0)
                    {
                        await _applicationService.InsertSheduledTasktAsync(taskSheduledEntity);
                    }
                    else
                    {
                        await _applicationService.UpdateSheduledTaskListAsync(taskSheduledEntity);
                    }
                }


                _changeContentMainFormAction(ContentItemEnum.Task);
            }
        }