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

Commit

Permalink
Addition of Summaries Labels
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxDroid committed Dec 12, 2023
1 parent e6c0178 commit c58de93
Show file tree
Hide file tree
Showing 10 changed files with 349 additions and 119 deletions.
42 changes: 36 additions & 6 deletions Pages/BudgetManagement.Designer.cs

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

75 changes: 75 additions & 0 deletions Pages/BudgetManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,69 @@ public BudgetManagement()
{
InitializeComponent();
PopulateDataGridView();
UpdateTotalEntriesLabel();
CalculateAndDisplayTotalCharge();
CalculateAndDisplayTotalCharge2();
}

private void CalculateAndDisplayTotalCharge2()
{
int columnIndex = 2;
decimal sum = 0;

if (budmangrid.Rows.Count > 0)
{
foreach (DataGridViewRow row in budmangrid.Rows)
{
if (row.Cells[columnIndex].Value != null && decimal.TryParse(row.Cells[columnIndex].Value.ToString(), out decimal cellValue))
{
sum += cellValue;
}
}
}
else
{
sum = -1;
}

if (sum == -1)
{
TFC2.Text = "Total Alloc Amount: N/A";
}
else
{
TFC2.Text = $"Total Alloc Amount: \r\n{sum:n0}";
}
}

private void CalculateAndDisplayTotalCharge()
{
int columnIndex = 3;
decimal sum = 0;

if (budmangrid.Rows.Count > 0)
{
foreach (DataGridViewRow row in budmangrid.Rows)
{
if (row.Cells[columnIndex].Value != null && decimal.TryParse(row.Cells[columnIndex].Value.ToString(), out decimal cellValue))
{
sum += cellValue;
}
}
}
else
{
sum = -1;
}

if (sum == -1)
{
TFC.Text = "Total Remaining Bud: N/A";
}
else
{
TFC.Text = $"Total Remaining Bud: ₱{sum:n0}";
}
}

private void createbudget_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -94,6 +157,8 @@ private void delete_Click(object sender, EventArgs e)
MessageBox.Show("An error occurred: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
UpdateTotalEntriesLabel();
CalculateAndDisplayTotalCharge();
CalculateAndDisplayTotalCharge2();
}

private void DeleteRecord(int bm_id)
Expand Down Expand Up @@ -159,6 +224,8 @@ private void PopulateDataGridView()
}
}
UpdateTotalEntriesLabel();
CalculateAndDisplayTotalCharge();
CalculateAndDisplayTotalCharge2();
}
catch (Exception ex)
{
Expand All @@ -170,12 +237,16 @@ private void guna2Button1_Click(object sender, EventArgs e)
{
PopulateDataGridView();
UpdateTotalEntriesLabel();
CalculateAndDisplayTotalCharge();
CalculateAndDisplayTotalCharge2();
searchtextbox.Text = string.Empty;
}

private void totalentrieslabel_Click(object sender, EventArgs e)
{
UpdateTotalEntriesLabel();
CalculateAndDisplayTotalCharge();
CalculateAndDisplayTotalCharge2();
}

private void UpdateTotalEntriesLabel()
Expand All @@ -188,6 +259,8 @@ private void searchtextbox_TextChanged(object sender, EventArgs e)
string searchQuery = searchtextbox.Text.Trim();

FilterDataGridView(searchQuery);
CalculateAndDisplayTotalCharge();
CalculateAndDisplayTotalCharge2();
}

private void FilterDataGridView(string searchQuery)
Expand Down Expand Up @@ -223,6 +296,8 @@ private void FilterDataGridView(string searchQuery)

}
UpdateTotalEntriesLabel();
CalculateAndDisplayTotalCharge();
CalculateAndDisplayTotalCharge2();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Pages/BudgetManagement.resx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<data name="searchtextbox.IconRight" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EgAACxIB0t1+/AAAAZlJREFUSEvtluFtwkAMhRmBERiBETpCN4ANygawAWxAN+kojNAR0u+L3okfISHh
EAAACxABrSO9dQAAAZlJREFUSEvtluFtwkAMhRmBERiBETpCN4ANygawAWxAN+kojNAR0u+L3okfISHh
TuJPn2RF9vmeY8fn3GoOuq5bIx/IHjlFvrTFpS0kRn6Q3zyvSAl8iU1or38JSDaIpDfEzNZZGiC+VkJf
X2CTpWVg4zYkZjQa8BHwtxLu3cY0D27Ixs+YFsO94ZgXHEdLVhW0QI5wPS87Tt/IKWo14OqbL+pj4GD3
3qI2AXweQbMe73YWzXYXtRngPCDjWbMoXjsGE4DTrJ0Bw9OBsR8SUZtDbmNEvQOj5bhEbQ64/Yz7qHdg
Expand Down
35 changes: 25 additions & 10 deletions Pages/StudentFile.Designer.cs

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

Loading

0 comments on commit c58de93

Please sign in to comment.