private void button1_Click(object sender, EventArgs e) { this.Hide(); var accountTypeId = int.Parse((_accountController.GetAccountId(comboBox2).ToString().Trim())); _reportController.ImportFromExcel(_filename, accountTypeId); _mainform.PopulateTransactionTables(); _mainform.FilterTransactionByAccount(); this.Dispose(); }
public void OpenFileDialog(MainApplication mainForm) { string filename = null; OpenFileDialog openFileDialog = new OpenFileDialog { InitialDirectory = @"..\\Downloads\\", Title = "Browse Text Files", CheckFileExists = true, CheckPathExists = true, DefaultExt = "csv", Filter = "csv files (*.csv)|*.csv", FilterIndex = 2, RestoreDirectory = true, ReadOnlyChecked = true, ShowReadOnly = true }; if (openFileDialog.ShowDialog() == DialogResult.OK) { filename = openFileDialog.FileName; var accountNoString = Path.GetFileName(filename).Split(' ')[0]; //var isSuccessful = Int64.TryParse(accountNoString, out accountNo); var account = _accountController.GetAccount(new GetAccountRequest { AccountNo = accountNoString }); if (account != null) { if (account != null) { MessageBox.Show("Account Type detected as " + account.AccountType, "Account Detection", MessageBoxButtons.OK); ImportFromExcel(filename, account.AccountId); mainForm.PopulateTransactionTables(); mainForm.FilterTransactionByAccount(); } else { new ImportDialog(_transactionController, mainForm, filename).Show(); } } else { new ImportDialog(_transactionController, mainForm, filename).Show(); } } }
public void SaveTransaction() { if (Validator.IsNumber(textBox1.Text) && Validator.IsString(textBox3.Text)) { _transactionController.UpdateTransaction(new UpdateTransactionRequest { TransactionId = _transactionRequest.TransactionId, Amount = decimal.Parse(textBox1.Text.Trim()), Description = textBox3.Text.ToUpper().Trim(), Date = DateTime.Parse(dateTimePicker1.Value.ToString("yyyy-MM-dd")) }); _mainform.FilterTransactionByAccount(); _mainform.PopulateTransactionLabels(); this.Dispose(); } else { MessageBox.Show("Please enter valid description and amount", "Error", MessageBoxButtons.OK); } }
public void SaveTransaction() { if (Validator.IsNumber(textBox1.Text) && Validator.IsString(textBox3.Text)) { _transactionController.SaveTransactionStaging(new SaveTransactionRequest { Amount = decimal.Parse(textBox1.Text.Trim()), AccountTypeId = int.Parse((_AccountController.GetAccountId(comboBox2).ToString().Trim())), TransactionTypeId = _transactionType, Description = textBox3.Text.ToUpper().Trim(), TransactionTimestamp = dateTimePicker1.Value }); _mainform.FilterTransactionByAccount(); _mainform.PopulateTransactionLabels(); this.Dispose(); } else { MessageBox.Show("Please enter valid description and amount", "Error", MessageBoxButtons.OK); } }