Sunteți pe pagina 1din 3

/*

* Created by SharpDevelop.
* User: User
* Date: 29/01/2019
* Time: 11:08 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace santosjacob_cpe1_2
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms
designer support.
//
InitializeComponent();

//
// TODO: Add constructor code after the InitializeComponent()
call.
//
}
void MainFormLoad(object sender, EventArgs e)
{

}
void ClearClick(object sender, EventArgs e)
{
EmpNameBox.Clear();
EmpNumBox.Clear();
PosCodeBox.Clear();
DaysWorkBox.Clear();
BasicPayBox.Clear();
SSSBox.Clear();
TaxBox.Clear();
NetPayBox.Clear();
Single.Checked=false;
Married.Checked=false;
Widow.Checked=false;
}
void ExitClick(object sender, EventArgs e)
{
this.Close();
}
void ComputeClick(object sender, EventArgs e)
{
if(Single.Checked==false && Married.Checked==false &&
Widow.Checked==false)
{
MessageBox.Show("Error!!! Choose your Civil Status");
}

Double RateDay=0, sssrate=0, taxrate=0, basicPay;


int DaysWorked=Convert.ToInt16(DaysWorkBox.Text);
char PosCode=Convert.ToChar(PosCodeBox.Text);
if(PosCode == 'A' || PosCode == 'a')
{
RateDay = 500.00;

}
else if(PosCode == 'B' || PosCode == 'b')
{
RateDay = 400.00;

}
else if(PosCode == 'C' || PosCode == 'c')
{
RateDay = 300.00;

}
else
{
MessageBox.Show("Invalid Position Code, Choose from A, B,
and C");
}

basicPay = (DaysWorked * RateDay);


if(basicPay >= 10000)
{
sssrate= 0.07;
taxrate= 0.1;
}
else if(basicPay > 5000 && basicPay < 10000)
{
sssrate= 0.05;
taxrate= 0.05;
}
else if(basicPay > 1000 && basicPay < 5000)
{
sssrate= 0.03;
taxrate= 0.05;
}
else
{
sssrate= 0.01;
taxrate= 0.05;
}

BasicPayBox.Text = string.Format("{0:F2}",(basicPay));
SSSBox.Text = string.Format("{0:F2}",(basicPay*sssrate));
TaxBox.Text = string.Format("{0:F2}",(basicPay*taxrate));
NetPayBox.Text = string.Format("{0:F2}",(basicPay -
(basicPay*sssrate) - (basicPay*taxrate)));
}
void EmpNumBoxTextChanged(object sender, EventArgs e)
{
EmpNumBox.MaxLength=6;
int numbox;
if(!int.TryParse(EmpNumBox.Text, out numbox))
{
MessageBox.Show("You have entered an invalid Employee
Number!");
EmpNumBox.Clear();
}
}
void EmpNameBoxTextChanged(object sender, EventArgs e)
{

int namebox;
if(int.TryParse(EmpNameBox.Text, out namebox))
{
MessageBox.Show("You have entered an invalid Employee
Name!");
EmpNameBox.Clear();
}

}
void PosCodeBoxTextChanged(object sender, EventArgs e)
{
PosCodeBox.MaxLength = 1;
if(PosCodeBox.Text == "A" || PosCodeBox.Text == "B" ||
PosCodeBox.Text == "C" || PosCodeBox.Text == "a" || PosCodeBox.Text == "b" ||
PosCodeBox.Text == "c")
{

}
else{
MessageBox.Show("You have entered an invalid Position
Code!");
PosCodeBox.Clear();
}
}
void DaysWorkBoxTextChanged(object sender, EventArgs e)
{
int days;
if(!int.TryParse(DaysWorkBox.Text, out days))
{
MessageBox.Show("You have entered an invalid Number of Days
Worked!");
DaysWorkBox.Clear();
}
}
}
}

S-ar putea să vă placă și