protected void btnSubmit_Click(object sender, EventArgs e) { Employee theEmployee = new Employee(); EmployeeTier theTier = new EmployeeTier(); theEmployee.firstName = txtFirstName.Text; theEmployee.lastName = txtLastName.Text; theEmployee.email = txtEmail.Text; theEmployee.address = txtAddress.Text; theEmployee.address2 = txtAddress2.Text; theEmployee.city = txtCity.Text; theEmployee.state = txtState.Text; theEmployee.zip = int.Parse(txtZip.Text); if (calHireDate.SelectedDate != null) { theEmployee.hireDate = calHireDate.SelectedDate; } if (calTermDate.SelectedDate != null) { theEmployee.termDate = calTermDate.SelectedDate; } if (theTier.modifyEmployee(theEmployee)) { Response.Redirect("/SuccessfulSubmission.aspx"); } else { Response.Redirect("/FailedSubmission.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["EmployeeID"] != null) { int id = (int)Session["EmployeeID"]; EmployeeTier theTier = new EmployeeTier(); Employee theEmployee = theTier.getEmployeeByID(id); idLabel.InnerText = "Employee ID: " + theEmployee.empID.ToString(); if (!IsPostBack) { txtFirstName.Text = theEmployee.firstName; txtLastName.Text = theEmployee.lastName; txtEmail.Text = theEmployee.email; txtAddress.Text = theEmployee.address; txtAddress2.Text = theEmployee.address2; txtCity.Text = theEmployee.city; txtState.Text = theEmployee.state; txtZip.Text = theEmployee.zip.ToString(); lblHireDate.Text = theEmployee.hireDate.ToShortDateString(); lblTermDate.Text = theEmployee.termDate.ToShortDateString(); } } else { Response.Redirect("/Admin/EmployeeInfo.aspx"); } }
protected void editClick(object sender, EventArgs e) { Button theButton = (Button)sender; EmployeeTier theTier = new EmployeeTier(); string id = theButton.ID.Remove(theButton.ID.IndexOf("a"), 1); Session["EmployeeID"] = int.Parse(id); Response.Redirect("/Admin/ModifyEmployee.aspx"); }
protected void deleteClick(object sender, EventArgs e) { Button theButton = (Button)sender; EmployeeTier theTier = new EmployeeTier(); int empID = int.Parse(theButton.ID); theTier.deleteEmployee(empID); Response.Redirect("/Admin/EmployeeInfo.aspx"); }
protected void btnOkay_Click(object sender, EventArgs e) { if (Session["theEmployee"] != null) { EmployeeTier theTier = new EmployeeTier(); Employee theEmployee = (Employee)Session["theEmployee"]; if (theTier.insertEmployee(theEmployee)) { Session["theEmployee"] = null; Response.Redirect("/SuccessfulSubmission.aspx"); } else { Response.Redirect("/FailedSubmission.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { EmployeeTier theTier = new EmployeeTier(); List <Employee> theList; Table theTable = new Table(); theTable.CssClass = "table-striped"; theTable.Style.Add("margin", "10px auto 10px auto"); theTable.Style.Add("width", "auto"); TableRow tr = new TableRow(); TableCell td; theList = theTier.getAllEmployees(); Button delete; Button edit; TableHeaderCell th = new TableHeaderCell(); Label theLabel = new Label(); theLabel.Text = "Employee ID"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "First Name"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Last Name"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Email"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Address"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Address 2"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "City"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "State"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Zip"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Hire Date"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Termination Date"; th.Controls.Add(theLabel); tr.Cells.Add(th); theTable.Rows.Add(tr); foreach (Employee emp in theList) { tr = new TableRow(); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.empID.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.firstName.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.lastName.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.email.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.address.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.address2.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.city.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.state.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.zip.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.hireDate.ToShortDateString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = emp.termDate.ToShortDateString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); delete = new Button(); delete.Text = "Delete"; delete.ID = emp.empID.ToString(); delete.Click += deleteClick; td.Controls.Add(delete); edit = new Button(); edit.Text = "Edit"; edit.ID = emp.empID.ToString() + "a"; edit.Click += editClick; td.Controls.Add(edit); tr.Cells.Add(td); theTable.Rows.Add(tr); } pnlOut.Controls.Add(theTable); }