public ScheduleTransactionBinder(SheduledTransactionList transactionEntity, TransactionPartyEntity transactionPartyEntity)
 {
     ReferenceNumber      = transactionEntity.ReferenceNumber;
     TransactionPartyCode = transactionPartyEntity.Code;
     Amount = ((transactionEntity.IsIncome ? 1 : -1) * transactionEntity.Amount).ToString("0.00");
     TransactionDateTime = transactionEntity.NextTransactionDate.ToString("dd-MM-yyyy h:mm tt");
     Type = "Scheduled";
 }
Exemplo n.º 2
0
 public ManageTransactionUserControl(Action <ContentItemEnum> changeContent, TransactionEntity transactionEntity, SheduledTransactionList schtrans) : this(changeContent)
 {
     _transactionEntity = transactionEntity;
     if (schtrans != null)
     {
         _schtransactionEntity = schtrans;
     }
 }
 private void dataGridViewScheduled_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         ScheduleTransactionBinder ScheduleTransactionBinder = _scheduletransactionBinders[e.RowIndex];
         SheduledTransactionList   schtransaction            = _applicationService.SheduledTransactions.First(t => t.ReferenceNumber == ScheduleTransactionBinder.ReferenceNumber);
         _changeContentMainFormAction(ContentItemEnum.ManageTransaction, schtransaction);
     }
 }
Exemplo n.º 4
0
 public ScheduleTransactionBinder(SheduledTransactionList transactionEntity, TransactionPartyEntity transactionPartyEntity)
 {
     ReferenceNumber     = transactionEntity.ReferenceNumber;
     TransactionParty    = transactionPartyEntity.Code;
     Amount              = ((transactionEntity.IsIncome ? 1 : -1) * transactionEntity.Amount).ToString("0.00");
     RepeatType          = transactionEntity.RepeatType;
     NextTransactionDate = transactionEntity.NextTransactionDate;
     Remarks             = transactionEntity.Remarks;
     EndTransactionDate  = transactionEntity.EndDateTime.ToString();
 }
 public ScheduleTransactionBinder(SheduledTransactionList transactionEntity, TransactionPartyEntity transactionPartyEntity)
 {
     ReferenceNumber     = transactionEntity.ReferenceNumber;
     TransactionParty    = transactionPartyEntity.Code;
     Amount              = ((transactionEntity.IsIncome ? 1 : -1) * transactionEntity.Amount).ToString("0.00");
     RepeatType          = transactionEntity.RepeatType;
     NextTransactionDate = transactionEntity.NextTransactionDate;
     Remarks             = transactionEntity.Remarks;
     EndTransactionDate  = transactionEntity.InfiniteSchedule ? "Never" :transactionEntity.EndDateTime.ToString();
     Status              = transactionEntity.IsActive ? "Active" : "Disabled";
 }
Exemplo n.º 6
0
        private void SetScheduleTransactionEntity(SheduledTransactionList transactionEntity = null)
        {
            _schtransactionEntity = transactionEntity ?? new SheduledTransactionList()
            {
                IsIncome           = true,
                Amount             = 0D,
                ReferenceNumber    = "",
                Remarks            = "",
                TransactionPartyId = 0
            };

            if (_schtransactionEntity.Id == 0)
            {
                referenceNumberPanel.Visible           = false;
                transactionPartyComboBox.SelectedIndex = -1;
            }
            else
            {
                comboBoxType.SelectedIndex            = 1;
                comboBoxType.Enabled                  = false;
                referenceNumberPanel.Visible          = true;
                referenceNumberTextBox.Text           = _schtransactionEntity.ReferenceNumber;
                transactionPartyComboBox.SelectedItem = _transactionParties.First(tp => tp.Id == _schtransactionEntity.TransactionPartyId);
            }

            transactionPartErrorLabel.Text = "";

            amountNumericUpDown.Text = _schtransactionEntity.Amount.ToString();
            amountErrorLabel.Text    = "";
            remarksTextBox.Text      = _schtransactionEntity.Remarks;
            remarksErrorLabel.Text   = "";
            incomeCheckBox.Checked   = _schtransactionEntity.IsIncome;

            panel6.Visible  = true;
            panel7.Visible  = true;
            panel8.Visible  = true;
            panel9.Visible  = true;
            panel11.Visible = false;
            DateTime dtTemp = DateTime.Now;

            comboBoxRepeat.SelectedIndex = comboBoxRepeat.FindStringExact(_schtransactionEntity.RepeatType);
            checkBoxNever.Checked        = _schtransactionEntity.InfiniteSchedule;
            checkBoxActive.Checked       = _schtransactionEntity.IsActive;
            dateTimePickerForm.Value     = DateTime.Today.AddDays(1);
            if (checkBoxNever.Checked == true)
            {
                dateTimePickerForm.Value = dtTemp;
            }
            else
            {
                dateTimePickerTo.Value = (DateTime)_schtransactionEntity.EndDateTime;
            }
        }
        public async Task DeleteSheduledTransactionAsync(int id)
        {
            await _transactionModel.DeleteSheduledTransactionAsync(id);

            IList <SheduledTransactionList> transactions       = SheduledTransactions.ToList();
            SheduledTransactionList         deletedTransaction = transactions.First(tp => tp.Id == id);
            UserEntity userEntity = await _userModel.GetUserDetailsAsync();

            deletedTransaction.IsActive = false;
            SheduledTransactions        = transactions;
            CurrentUser = userEntity;
        }
Exemplo n.º 8
0
        public async Task <int> UpdateScheduledTransactionListAsync(SheduledTransactionList transactionEntity)
        {
            string query = "UPDATE `ScheduledTransaction` " +
                           "SET `TransactionPartyId`=@TransactionPartyId,`Amount`=@Amount,`RepeatType`=@RepeatType,`StartDateTime`=@StartDateTime,`EndDateTime`=@EndDateTime,`InfiniteSchedule`=@InfiniteSchedule,`NextTransactionDate`=@NextTransactionDate,`IsActive`=@IsActive,`Remarks`=@Remarks " +
                           "WHERE `Id` = @Id";

            IEnumerable <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("@TransactionPartyId", transactionEntity.TransactionPartyId),
                new KeyValuePair <string, object>("@Amount", transactionEntity.Amount),
                new KeyValuePair <string, object>("@IsIncome", transactionEntity.IsIncome ? 1 : 0),
                new KeyValuePair <string, object>("@Remarks", transactionEntity.Remarks),
                new KeyValuePair <string, object>("@RepeatType", transactionEntity.RepeatType),
                new KeyValuePair <string, object>("@StartDateTime", TimeConverterMethods.ConvertDateTimeToTimeStamp(transactionEntity.StartDateTime)),
                new KeyValuePair <string, object>("@EndDateTime", TimeConverterMethods.ConvertDateTimeToTimeStamp(transactionEntity.EndDateTime ?? transactionEntity.StartDateTime)),
                new KeyValuePair <string, object>("@NextTransactionDate", TimeConverterMethods.ConvertDateTimeToTimeStamp(transactionEntity.NextTransactionDate)),
                new KeyValuePair <string, object>("@InfiniteSchedule", transactionEntity.InfiniteSchedule ? 1 : 0),
                new KeyValuePair <string, object>("@IsActive", transactionEntity.IsActive),
                new KeyValuePair <string, object>("@Id", transactionEntity.Id),
            };

            return(await SqliteConnector.ExecuteNonQueryAsync(query, parameters, true));
        }
Exemplo n.º 9
0
        public async Task <int> InsertScheduledTransactionListAsync(SheduledTransactionList transactionEntity)
        {
            string query = "INSERT INTO `ScheduledTransaction`" +
                           "(`TransactionPartyId`,`Amount`,`IsIncome`,`RepeatType`,`StartDateTime`,`Remarks`,`CreatedDateTime`,`EndDateTime`,`NextTransactionDate`,`InfiniteSchedule`,`IsDelete`,`CreatedUser`,`IsActive`) " +
                           "VALUES (@TransactionPartyId,@Amount,@IsIncome,@RepeatType,@StartDateTime,@Remarks,@CreatedDateTime,@EndDateTime,@NextTransactionDate,@InfiniteSchedule,@IsDelete,@CreatedUser,@IsActive);";

            IEnumerable <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("@TransactionPartyId", transactionEntity.TransactionPartyId),
                new KeyValuePair <string, object>("@Amount", transactionEntity.Amount),
                new KeyValuePair <string, object>("@IsIncome", transactionEntity.IsIncome ? 1 : 0),
                new KeyValuePair <string, object>("@RepeatType", transactionEntity.RepeatType),
                new KeyValuePair <string, object>("@StartDateTime", TimeConverterMethods.ConvertDateTimeToTimeStamp(transactionEntity.StartDateTime)),
                new KeyValuePair <string, object>("@Remarks", transactionEntity.Remarks),
                new KeyValuePair <string, object>("@CreatedDateTime", TimeConverterMethods.ConvertDateTimeToTimeStamp(transactionEntity.CreatedDateTime)),
                new KeyValuePair <string, object>("@EndDateTime", TimeConverterMethods.ConvertDateTimeToTimeStamp(transactionEntity.EndDateTime ?? transactionEntity.StartDateTime)),
                new KeyValuePair <string, object>("@NextTransactionDate", TimeConverterMethods.ConvertDateTimeToTimeStamp(transactionEntity.NextTransactionDate)),
                new KeyValuePair <string, object>("@InfiniteSchedule", transactionEntity.InfiniteSchedule ? 1 : 0),
                new KeyValuePair <string, object>("@IsDelete", 0),
                new KeyValuePair <string, object>("@CreatedUser", transactionEntity.CreatedUser),
                new KeyValuePair <string, object>("@IsActive", 1)
            };

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

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

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

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

            return(id);
        }
Exemplo n.º 10
0
        private async void actionsUserControl_SaveButtonOnClick(object sender, EventArgs e)
        {
            if (IsFormDataValid())
            {
                tableLayoutPanel.Enabled            = false;
                actionsUserControl.IsEnabledButtons = false;
                int id = 0;

                if (_transactionEntity != null)
                {
                    id = _transactionEntity.Id;
                }
                else if (_schtransactionEntity != null)
                {
                    id = _schtransactionEntity.Id;
                }
                string remarks       = remarksTextBox.Text;
                int    transactionId = comboBoxType.SelectedIndex;
                double amount        = double.Parse(amountNumericUpDown.Text);
                TransactionPartyBinder transactionParty = transactionPartyComboBox.SelectedItem as TransactionPartyBinder;

                if (transactionId == 0)
                {
                    //single time transactions
                    TransactionEntity transactionEntity = new TransactionEntity()
                    {
                        Id                     = id,
                        Amount                 = amount,
                        IsIncome               = incomeCheckBox.Checked,
                        Remarks                = remarks,
                        TransactionPartyId     = transactionParty.Id,
                        IsUserPerformed        = true,
                        ScheduledTransactionId = null,
                        TransactionDateTime    = dateTimePickerOneTimeTransactionDate.Value
                    };

                    if (id == 0)
                    {
                        await _applicationService.InsertTransactionAsync(transactionEntity, true);
                    }
                    else
                    {
                        await _applicationService.UpdateTransactionAsync(transactionEntity);
                    }
                }

                else
                {
                    //Scheduled transactions

                    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);
                    }

                    SheduledTransactionList transactionSheduledEntity = new SheduledTransactionList()
                    {
                        Id = id,
                        TransactionPartyId  = transactionParty.Id,
                        Amount              = amount,
                        RepeatType          = SelectedType,
                        StartDateTime       = dateTimePickerForm.Value,
                        EndDateTime         = dateTimePickerTo.Value,
                        NextTransactionDate = dtNextDate,
                        InfiniteSchedule    = checkBoxNever.Checked,
                        CreatedDateTime     = DateTime.Now,
                        IsIncome            = incomeCheckBox.Checked,
                        Remarks             = remarks,
                        IsDelete            = false,
                        IsActive            = checkBoxActive.Checked,
                    };

                    if (id == 0)
                    {
                        await _applicationService.InsertSheduledTransactionListAsync(transactionSheduledEntity);
                    }
                    else
                    {
                        await _applicationService.UpdateSheduledTransactionListAsync(transactionSheduledEntity);
                    }
                }


                _changeContentMainFormAction(ContentItemEnum.Transaction);
            }
        }
        public async Task <SheduledTransactionList> InsertSheduledTransactionListAsync(SheduledTransactionList transaction)
        {
            await _insertTransactionSemaphoreSlim.WaitAsync();

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

                transaction.CreatedUser = userEntity.Id;
                int tId = await _transactionModel.InsertScheduledTransactionListAsync(transaction);

                transaction = await _transactionModel.GetSheduledTransactionByIdAsync(tId);

                IList <SheduledTransactionList> transactions = SheduledTransactions.ToList();
                transactions.Add(transaction);
                SheduledTransactions = transactions;
                CurrentUser          = userEntity;
                return(transaction);
            }
            catch (Exception k)
            {
                applicationErrorLog.ErrorLog("Transaction", "Insert Sheduled transaction", k.ToString());
                return(transaction);
            }
            finally
            {
                _insertTransactionSemaphoreSlim.Release();
            }
        }
        public async Task <SheduledTransactionList> UpdateSheduledTransactionListAsync(SheduledTransactionList transaction)
        {
            await _transactionModel.UpdateScheduledTransactionListAsync(transaction);

            IEnumerable <SheduledTransactionList> transactions = await _transactionModel.GetSheduledTransactionsAsync();

            UserEntity userEntity = await _userModel.GetUserDetailsAsync();

            SheduledTransactions = transactions;
            CurrentUser          = userEntity;
            return(transaction);
        }