Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Combo Box addition for recent categories added for Budget Management …
Browse files Browse the repository at this point in the history
…and Transaction Logs pages.
  • Loading branch information
VoxDroid committed Dec 11, 2023
1 parent 808f38d commit 6cc687d
Show file tree
Hide file tree
Showing 12 changed files with 459 additions and 45 deletions.
116 changes: 73 additions & 43 deletions SubPages/ModBudMan.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions SubPages/ModBudMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public ModBudMan()
{
InitializeComponent();
PopulateDataGridView();
LoadRecentCategories();
}

private void PopulateDataGridView()
Expand Down Expand Up @@ -87,6 +88,7 @@ private void delete_Click(object sender, EventArgs e)
pagesControl.SelectedIndex = 1;
}
}
LoadRecentCategories();
}
private void clear_Click(object sender, EventArgs e)
{
Expand All @@ -98,6 +100,7 @@ private void clear_Click(object sender, EventArgs e)
budgetstatuslabel.ForeColor = Color.DarkGreen;
budgetstatuslabel.Visible = false;
budgetstatuslabel.Enabled = false;
LoadRecentCategories();
}

private void modifydata_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -185,6 +188,7 @@ private void modifydata_Click(object sender, EventArgs e)
budgetstatuslabel.ForeColor = Color.DarkGreen;
budgetstatuslabel.Text = "Record updated successfully.";
PopulateDataGridView();
LoadRecentCategories();
}
else
{
Expand All @@ -193,6 +197,7 @@ private void modifydata_Click(object sender, EventArgs e)
budgetstatuslabel.Enabled = true;
budgetstatuslabel.Text = "Failed to update record.";
PopulateDataGridView();
LoadRecentCategories();
}
}
}
Expand Down Expand Up @@ -312,6 +317,7 @@ private void searchlabel_Click(object sender, EventArgs e)
private void guna2Button1_Click(object sender, EventArgs e)
{
PopulateDataGridView();
LoadRecentCategories();
}

private void budmangrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
Expand Down Expand Up @@ -418,5 +424,71 @@ private void alloctb_TextChanged(object sender, EventArgs e)
remtb.Text = string.Empty;
remtb.Enabled = !string.IsNullOrWhiteSpace(alloctb.Text);
}

private void recentstudentscb_SelectedIndexChanged(object sender, EventArgs e)
{
if (recentstudentscb.SelectedIndex == 0)
{
categorytb.Text = string.Empty;
}
else
{
categorytb.Text = recentstudentscb.Text;
}
}

private void LoadRecentCategories()
{
try
{
using (MySqlConnection connection = new MySqlConnection(connet))
{
connection.Open();

string sqlQuery = "SELECT DISTINCT category FROM budman ORDER BY bm_id DESC";
using (MySqlCommand command = new MySqlCommand(sqlQuery, connection))
{
using (MySqlDataAdapter adapter = new MySqlDataAdapter(command))
{
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);

recentstudentscb.DataSource = null;
recentstudentscb.Items.Clear();

DataRow initialRow = dataTable.NewRow();
initialRow["category"] = "-- Recent --";
dataTable.Rows.InsertAt(initialRow, 0);

recentstudentscb.DataSource = dataTable;
recentstudentscb.DisplayMember = "category";
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}

private void recentstudentscb_Click(object sender, EventArgs e)
{

LoadRecentCategories();
}

private void categorytb_TextChanged(object sender, EventArgs e)
{
categorytb.Text = categorytb.Text.ToUpper();

categorytb.SelectionStart = categorytb.Text.Length;
categorytb.SelectionLength = 0;
}

private void categorytb_KeyPress(object sender, KeyPressEventArgs e)
{
e.KeyChar = char.ToUpper(e.KeyChar);
}
}
}
Loading

0 comments on commit 6cc687d

Please sign in to comment.