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

Commit

Permalink
Pages Optimizations and Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxDroid committed Dec 7, 2023
1 parent fe21a34 commit 3d48f9a
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 12 deletions.
11 changes: 8 additions & 3 deletions SubPages/ModBudMan.Designer.cs

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

83 changes: 83 additions & 0 deletions SubPages/ModBudMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ private void clear_Click(object sender, EventArgs e)

private void modifydata_Click(object sender, EventArgs e)
{
string budgetText1 = alloctb.Text.Trim();
string remainingText1 = remtb.Text.Trim();

if (!string.IsNullOrWhiteSpace(budgetText1) && string.IsNullOrWhiteSpace(remainingText1))
{
alloctb.Text = "";
budgetstatuslabel.ForeColor = Color.Maroon;
budgetstatuslabel.Visible = true;
budgetstatuslabel.Enabled = true;
budgetstatuslabel.Text = "If Allocation Amount is provided, Remaining Budget Field must also have input.";
return;
}

if (budmangrid.SelectedRows.Count > 0)
{
string name = nametb.Text.Trim();
Expand Down Expand Up @@ -171,13 +184,15 @@ private void modifydata_Click(object sender, EventArgs e)
budgetstatuslabel.Visible = true;
budgetstatuslabel.ForeColor = Color.DarkGreen;
budgetstatuslabel.Text = "Record updated successfully.";
PopulateDataGridView();
}
else
{
budgetstatuslabel.ForeColor = Color.Maroon;
budgetstatuslabel.Visible = true;
budgetstatuslabel.Enabled = true;
budgetstatuslabel.Text = "Failed to update record.";
PopulateDataGridView();
}
}
}
Expand All @@ -204,6 +219,24 @@ private void NumbersOnly_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}

string newText = remtb.Text + e.KeyChar;

if (!string.IsNullOrEmpty(newText) && decimal.TryParse(newText, out decimal typedAmount))
{
decimal chargeAmount = Convert.ToDecimal(alloctb.Text);

if (typedAmount < 1 && typedAmount == 0)
{
e.Handled = true;
remtb.Text = "1";
}
else if (typedAmount > chargeAmount)
{
e.Handled = true;
remtb.Text = chargeAmount.ToString();
}
}
}

private void SubBudMan_Load(object sender, EventArgs e)
Expand Down Expand Up @@ -335,5 +368,55 @@ private void budmangrid_CellFormatting(object sender, DataGridViewCellFormatting
}
}
}

private void remtb_TextChanged(object sender, EventArgs e)
{
if (int.TryParse(remtb.Text, out int typedAmount))
{
if (typedAmount == 0)
{
remtb.Text = "1";
remtb.SelectionStart = alloctb.Text.Length;
}
}
}

private void remtb_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Back && remtb.Text.Length == 1)
{
remtb.Text = "";
}
}

private void alloctb_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Back && alloctb.Text.Length == 1)
{
alloctb.Text = "";
}
}

private void NumbersOnly2Alloc_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
{
e.Handled = true;
}
}

private void alloctb_TextChanged(object sender, EventArgs e)
{
if (int.TryParse(alloctb.Text, out int typedAmount))
{
if (typedAmount == 0)
{
alloctb.Text = "1";
alloctb.SelectionStart = alloctb.Text.Length;
}
}
remtb.Text = string.Empty;
remtb.Enabled = !string.IsNullOrWhiteSpace(alloctb.Text);
}
}
}
2 changes: 1 addition & 1 deletion SubPages/ModBudMan.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
DgAACw4BQL7hQQAAAZlJREFUSEvtluFtwkAMhRmBERiBETpCN4ANygawAWxAN+kojNAR0u+L3okfISHh
TuJPn2RF9vmeY8fn3GoOuq5bIx/IHjlFvrTFpS0kRn6Q3zyvSAl8iU1or38JSDaIpDfEzNZZGiC+VkJf
X2CTpWVg4zYkZjQa8BHwtxLu3cY0D27Ixs+YFsO94ZgXHEdLVhW0QI5wPS87Tt/IKWo14OqbL+pj4GD3
3qI2AXweQbMe73YWzXYXtRngPCDjWbMoXjsGE4DTrJ0Bw9OBsR8SUZtDbmNEvQOj5bhEbQ64/Yz7qHdg
Expand Down
3 changes: 3 additions & 0 deletions SubPages/ModStudFil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ private void searchtextbox_TextChanged(object sender, EventArgs e)

private void chargetb_TextChanged(object sender, EventArgs e)
{
amountptb.Text = string.Empty;
amountptb.Enabled = !string.IsNullOrWhiteSpace(chargetb.Text);
autofillpaid.Enabled = !string.IsNullOrWhiteSpace(chargetb.Text);
UpdatePaymentStatus();
Expand Down Expand Up @@ -359,6 +360,7 @@ private void modifybutton_Click(object sender, EventArgs e)
budgetstatuslabel.Visible = true;
budgetstatuslabel.Enabled = true;
budgetstatuslabel.Text = "Record updated successfully.";
PopulateDataGridView();
amountptb.Clear();
chargetb.Clear();
}
Expand All @@ -368,6 +370,7 @@ private void modifybutton_Click(object sender, EventArgs e)
budgetstatuslabel.Visible = true;
budgetstatuslabel.Enabled = true;
budgetstatuslabel.Text = "Failed to update record.";
PopulateDataGridView();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion SubPages/ModStudFil.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<data name="searchtextbox.IconRight" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DgAACw4BQL7hQQAAAZlJREFUSEvtluFtwkAMhRmBERiBETpCN4ANygawAWxAN+kojNAR0u+L3okfISHh
DAAACwwBP0AiyAAAAZlJREFUSEvtluFtwkAMhRmBERiBETpCN4ANygawAWxAN+kojNAR0u+L3okfISHh
TuJPn2RF9vmeY8fn3GoOuq5bIx/IHjlFvrTFpS0kRn6Q3zyvSAl8iU1or38JSDaIpDfEzNZZGiC+VkJf
X2CTpWVg4zYkZjQa8BHwtxLu3cY0D27Ixs+YFsO94ZgXHEdLVhW0QI5wPS87Tt/IKWo14OqbL+pj4GD3
3qI2AXweQbMe73YWzXYXtRngPCDjWbMoXjsGE4DTrJ0Bw9OBsR8SUZtDbmNEvQOj5bhEbQ64/Yz7qHdg
Expand Down
2 changes: 2 additions & 0 deletions SubPages/ModTranLo.Designer.cs

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

24 changes: 23 additions & 1 deletion SubPages/ModTranLo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private void modifydata_Click(object sender, EventArgs e)
{
command.Parameters.AddWithValue("@name", string.IsNullOrWhiteSpace(name) ? originalName : name);
command.Parameters.AddWithValue("@category", string.IsNullOrWhiteSpace(category) ? originalCategory : category);
command.Parameters.AddWithValue("@description", string.IsNullOrWhiteSpace(budget) ? originalCategory : budget);
command.Parameters.AddWithValue("@description", string.IsNullOrWhiteSpace(budget) ? originalBudget : budget);
command.Parameters.AddWithValue("@amount", remaining);
command.Parameters.AddWithValue("@tl_id", selectedRecordId);

Expand All @@ -170,13 +170,15 @@ private void modifydata_Click(object sender, EventArgs e)
budgetstatuslabel.Visible = true;
budgetstatuslabel.ForeColor = Color.DarkGreen;
budgetstatuslabel.Text = "Record updated successfully.";
PopulateDataGridView();
}
else
{
budgetstatuslabel.ForeColor = Color.Maroon;
budgetstatuslabel.Visible = true;
budgetstatuslabel.Enabled = true;
budgetstatuslabel.Text = "Failed to update record.";
PopulateDataGridView();
}
}
}
Expand Down Expand Up @@ -333,5 +335,25 @@ private void ModTranLo_Load(object sender, EventArgs e)
{

}

private void remtb_TextChanged(object sender, EventArgs e)
{
if (int.TryParse(remtb.Text, out int typedAmount))
{
if (typedAmount == 0)
{
remtb.Text = "1";
remtb.SelectionStart = remtb.Text.Length;
}
}
}

private void remtb_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Back && remtb.Text.Length == 1)
{
remtb.Text = "";
}
}
}
}
2 changes: 1 addition & 1 deletion SubPages/ModTranLo.resx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<data name="searchtextbox.IconRight" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EQAACxEBf2RfkQAAAZlJREFUSEvtluFtwkAMhRmBERiBETpCN4ANygawAWxAN+kojNAR0u+L3okfISHh
EAAACxABrSO9dQAAAZlJREFUSEvtluFtwkAMhRmBERiBETpCN4ANygawAWxAN+kojNAR0u+L3okfISHh
TuJPn2RF9vmeY8fn3GoOuq5bIx/IHjlFvrTFpS0kRn6Q3zyvSAl8iU1or38JSDaIpDfEzNZZGiC+VkJf
X2CTpWVg4zYkZjQa8BHwtxLu3cY0D27Ixs+YFsO94ZgXHEdLVhW0QI5wPS87Tt/IKWo14OqbL+pj4GD3
3qI2AXweQbMe73YWzXYXtRngPCDjWbMoXjsGE4DTrJ0Bw9OBsR8SUZtDbmNEvQOj5bhEbQ64/Yz7qHdg
Expand Down
11 changes: 8 additions & 3 deletions SubPages/SubBudMan.Designer.cs

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

Loading

0 comments on commit 3d48f9a

Please sign in to comment.