private void btnRemove_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { foreach (DataGridViewRow item in this.dataGridView1.SelectedRows) { double discountRate = Convert.ToDouble(txtDiscount.Text) / 100; int v = int.Parse(item.Cells[4].Value.ToString()); dataGridView1.Rows.RemoveAt(item.Index); TotalAmount -= v; Discount = discountRate * TotalAmount; NetPay = TotalAmount - Discount; lblTotal.Text = TotalAmount.ToString(); lblDiscount.Text = Discount.ToString(); lblNetPay.Text = NetPay.ToString(); } for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { dataGridView1.Rows[i].Cells[0].Value = i + 1; } } else { MessageBox.Show("Please select row to remove!", "Invalid", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); } }
private void button1_Click(object sender, EventArgs e) { String Name = (txtName.Text); int HourlyWage; int SocialSecurtiy; int HoursWorked; double NetPay; double GrossPay; double Federal; double State; double Tax; HourlyWage = Convert.ToInt32(txtPayRate.Text); HoursWorked = Convert.ToInt32(txtHoursWorked.Text); SocialSecurtiy = Convert.ToInt32(txtSocial.Text); GrossPay = HourlyWage * HoursWorked; State = GrossPay / 5; Federal = GrossPay / 15; Tax = State + Federal; NetPay = GrossPay - Tax; lblGrossPay.Text = "" + GrossPay.ToString("C"); lblFederal.Text = "" + Federal.ToString("C"); lblState.Text = "" + State.ToString("C"); lblNet.Text = "" + NetPay.ToString("C"); }
public override string ToString() { return(Id + " " + FirstName + " " + LastName + " " + GrossPay.ToString("C") + " " + FederalTax.ToString("C") + " " + StateTax.ToString("C") + " " + NetPay.ToString("C")); }
private void btnNetPay_Click(object sender, EventArgs e) { double Hours, Rate; double GrossPay, FederalTax, StateTax, NetPay; Hours = Convert.ToDouble(txtAmountWorked.Text); Rate = Convert.ToDouble(txtHourlyDailyMonthlyRate.Text); GrossPay = Hours * Rate; FederalTax = GrossPay * 0.15; StateTax = GrossPay * 5 / 100; NetPay = GrossPay - (FederalTax + StateTax); txtGrossPay.Text = GrossPay.ToString("c"); txtStateTax.Text = StateTax.ToString("c"); txtFederalTax.Text = FederalTax.ToString("c"); txtNetPay.Text = NetPay.ToString("c"); }
private void button1_Click(object sender, EventArgs e) { double hours, rate; double FederalTax, NetPay, StateTax, GrossPay; /* Console.Write("Please Enter the number of hours worked"); * String input = Console.ReadLine(); * double hours = double.Parse */ hours = Convert.ToDouble(textBox_HoursWorked.Text); rate = Convert.ToDouble(textBox_HourlyRate.Text); GrossPay = hours * rate; FederalTax = GrossPay * 0.15; StateTax = GrossPay * 0.05; NetPay = GrossPay - (FederalTax + StateTax); textBoxGrossPay.Text = GrossPay.ToString("C"); textBoxFedTax.Text = FederalTax.ToString("C"); textBoxStateTax.Text = StateTax.ToString("C"); textBoxNetPay.Text = NetPay.ToString("C"); }
private void btnAdd_Click(object sender, EventArgs e) { try { var selectedItem = cmbProduct.SelectedItem as ComboboxItem; ProID = Convert.ToInt32(selectedItem.Value); string cmdtext = "SELECT productName,purchasePrice FROM tblProducts WHERE productID=" + ProID; SqlDataAdapter sda = new SqlDataAdapter(cmdtext, c.con); DataTable dt = new DataTable(); sda.Fill(dt); int pId = ProID; string pName = dt.Rows[0][0].ToString(); int pQuantity = int.Parse(txtQuantity.Text); double unitPrice = Convert.ToDouble(dt.Rows[0][1]); double tamount = unitPrice * pQuantity; double discountRate = Convert.ToDouble(txtDiscount.Text) / 100; dataGridView1.Rows.Add(dataGridView1.Rows.Count, pName, unitPrice, pQuantity, tamount, pId); TotalAmount += tamount; Discount = discountRate * TotalAmount; NetPay = TotalAmount - Discount; lblTotal.Text = TotalAmount.ToString(); lblDiscount.Text = Discount.ToString(); lblNetPay.Text = NetPay.ToString(); ClearFields(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } }
public void ValidateUpdateEmployeeInfo() { AddEmployeeDialogBox addEmp = new AddEmployeeDialogBox(driver); EmployeeBenifitDashboardPage dashboard = new EmployeeBenifitDashboardPage(driver); Actions.LoginToEmployeeBenifitDashboard(Config.Credentials.Valid.Username, Config.Credentials.Valid.Password, driver); //Get count before adding an employee int countOfLastNames = dashboard.LastNameList.Count; int countOfFirstNames = dashboard.FirstNameList.Count; int countOfDependents = dashboard.DependentsList.Count; int i; string UpdateFirstName = "Mike"; string UpdateLastName = "Scott"; string existingFirstName = ""; string existingLastName = ""; string existingDependent = ""; string existingID; string Id; int j; int dependents; decimal BenifitsCost; decimal NetPay; string updatedFirstName = Config.EmployeeInfo.UpdateEmployeeInfo.FirstName; string updatedLastName = Config.EmployeeInfo.UpdateEmployeeInfo.LastName; string updatedDependents = Config.EmployeeInfo.UpdateEmployeeInfo.NumberOfDependents; try { for (i = 0; i <= countOfLastNames; i++) { existingLastName = dashboard.FirstNameList[i].Text; if (existingLastName == UpdateLastName) { existingFirstName = dashboard.LastNameList[i].Text; if (existingFirstName == UpdateFirstName) { existingDependent = dashboard.DependentsList[i].Text; if (existingDependent == "2") { dashboard.EditActionList[i].Click(); Actions.UpdateEmployee(Config.EmployeeInfo.UpdateEmployeeInfo.FirstName, Config.EmployeeInfo.UpdateEmployeeInfo.LastName, Config.EmployeeInfo.UpdateEmployeeInfo.NumberOfDependents, driver); Id = dashboard.IdList[i].Text; for (j = 0; j <= countOfLastNames; j++) { existingLastName = dashboard.FirstNameList[j].Text; if (existingLastName == updatedLastName) { existingFirstName = dashboard.LastNameList[i].Text; if (existingFirstName == updatedFirstName) { existingDependent = dashboard.DependentsList[i].Text; if (existingDependent == updatedDependents) { existingID = dashboard.IdList[i].Text; if (Id == existingID) { Assert.IsTrue(true); dependents = Int32.Parse(updatedDependents); BenifitsCost = Actions.BenifitCalculation(dependents, driver); string CalBenifitCost = BenifitsCost.ToString(); Assert.AreEqual(CalBenifitCost, dashboard.BenefitsCostList[i].Text); NetPay = Actions.NetPayCalcualtion(BenifitsCost, driver); string CalNetPay = NetPay.ToString(); Assert.AreEqual(CalNetPay, dashboard.NetPayList[i].Text); break; } } } } } } } } } } catch (Exception) { dashboard.LogOutLink.Click(); } }
private void btnPayRoll_Click(object sender, EventArgs e) { String Name = (txtName.Text); int Security; int HourlyPay; int HoursWorked; double NetPay; double State; double Federal; double GrossPay; double Tax; HourlyPay = Convert.ToInt32(txtHourlyPay.Text); HoursWorked = Convert.ToInt32(txtHoursWorked.Text); Security = Convert.ToInt32(txtSocialSecurity.Text); GrossPay = HourlyPay * HoursWorked; Federal = GrossPay / 15; State = GrossPay / 5; Tax = Federal + State; NetPay = GrossPay - Tax; lblPayRoll.Text = "Hello " + Name + " Social Security( " + Security + ") , Gross Pay is " + GrossPay.ToString("c") + ". Federal is " + Federal.ToString("c") + " and State is " + State.ToString("c") + ".Your Net Pay is now " + NetPay.ToString("c"); }
public void ValidateAddedValidEmployee() { AddEmployeeDialogBox addEmp = new AddEmployeeDialogBox(driver); EmployeeBenifitDashboardPage dashboard = new EmployeeBenifitDashboardPage(driver); Actions.LoginToEmployeeBenifitDashboard(Config.Credentials.Valid.Username, Config.Credentials.Valid.Password, driver); //Get count before adding an employee int countOfLastNames = dashboard.LastNameList.Count; int countOfFirstNames = dashboard.FirstNameList.Count; int countOfDependents = dashboard.DependentsList.Count; dashboard.AddEmployeeButton.Click(); string fntext = Config.EmployeeInfo.ValidEmployeeInfo.FirstName; string lntext = Config.EmployeeInfo.ValidEmployeeInfo.LastName; string deptext = Config.EmployeeInfo.ValidEmployeeInfo.NumberOfDependents; Actions.AddEmployee(Config.EmployeeInfo.ValidEmployeeInfo.FirstName, Config.EmployeeInfo.ValidEmployeeInfo.LastName, Config.EmployeeInfo.ValidEmployeeInfo.NumberOfDependents, driver); Thread.Sleep(3000); int countofLastNameafterAddition = dashboard.LastNameList.Count; int countOfFirstNameafterAddition = dashboard.FirstNameList.Count; countOfFirstNames = countOfFirstNames + 1; countOfLastNames = countOfLastNames + 1; Assert.AreEqual(countOfFirstNameafterAddition, countOfFirstNames); Assert.AreEqual(countofLastNameafterAddition, countOfLastNames); string addedFirstName = ""; string addedLastName = ""; string addedDependent = ""; int i; int dependents; decimal BenifitsCost; decimal NetPay; for (i = 0; i <= countOfLastNames; i++) { addedFirstName = dashboard.LastNameList[i].Text; if (fntext == addedFirstName) { addedLastName = dashboard.FirstNameList[i].Text; if (lntext == addedLastName) { addedDependent = dashboard.DependentsList[i].Text; if (deptext == addedDependent) { Assert.IsTrue(true); dependents = Int32.Parse(addedDependent); BenifitsCost = Actions.BenifitCalculation(dependents, driver); string CalBenifitCost = BenifitsCost.ToString(); Assert.AreEqual(CalBenifitCost, dashboard.BenefitsCostList[i].Text); NetPay = Actions.NetPayCalcualtion(BenifitsCost, driver); string CalNetPay = NetPay.ToString(); Assert.AreEqual(CalNetPay, dashboard.NetPayList[i].Text); break; } } } } Thread.Sleep(3000); }