protected void btnSubmit_Click(object sender, EventArgs e) { try { Joke joke = JokeFactory.Create(); joke.Title = txtTitle.Text; joke.Teaser = txtTeaser.Text; joke.JokeText = txtJokeText.Text; joke.CategoryId = Convert.ToInt32(ddlCategory.SelectedValue); joke.JokeId = Convert.ToInt16(Request.QueryString["jID"]); joke.TimeStamp = Session["timestamp"]; if (chkFeatured.Checked == true) { joke.IsFeatured = true; } else { joke.IsFeatured = false; } CUDMethods.Update(joke); lblMessage.Text = "Joke has been updated!"; Session["timestamp"] = joke.TimeStamp; //Clear(); } catch (Exception ex) { lblMessage.Text = ex.Message; } }
private void CalculatePayroll_Load(object sender, EventArgs e) { CUDMethods.CalculatePayroll(); sendPayrollEmails(); loadDataGrid(); }
protected void btnDeny_Click(object sender, EventArgs e) { askToClose = true; CUDMethods.ProcessItem(Convert.ToInt32(Session["itemId"].ToString()), Convert.ToByte(3)); LoadItems();; po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue)); foreach (Item item in po.Items) { if (item.ItemStatus == Types.ItemStatus.Pending) { askToClose = false; } else { CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(2)); } } po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue)); lblOrderStatus.Text = po.OrderStatus.ToString(); if (askToClose == true) { btnClose.Visible = true; } }
private void btnCreate_Click(object sender, EventArgs e) { try { btnCreate.Text = "Add Item"; item = ItemFactory.Create(); po = POFactory.Create(); double itemPrice = Convert.ToDouble(txtPrice.Text); orderPrice += itemPrice; item.ItemName = txtName.Text; item.Description = txtDesc.Text; item.Quantity = Convert.ToInt32(txtQty.Text); item.Price = itemPrice; item.Location = txtLocation.Text; item.Justification = txtJustification.Text; po.Items = new List <Types.IItem>(); po.Items.Add(item); po.OrderNumber = Convert.ToInt32(lblOrderNumber.Text); po.EmpId = emp[0].EmpID; int orderNumber = CUDMethods.CreatPO(po); lblSubNum.Text = "$" + (orderPrice).ToString("F"); lblTaxNum.Text = "$" + (orderPrice * 0.15).ToString("F"); lblTotalNum.Text = "$" + (orderPrice * 1.15).ToString("F"); lblOrderNumber.Text = orderNumber.ToString(); lblOrderNumber.Visible = true; lblOrderNumberLabel.Visible = true; if (lstItems.Items.Contains(item.ItemName)) { return; } else { lstItems.Items.Add(item.ItemName); } clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); //errorProvider1.SetError(sender, ex.Message); } }
private void btnEnterPayrollCode_Click(object sender, EventArgs e) { String enteredCode = txtPayrollCode.Text; if (CUDMethods.ValidatePayrollCode(enteredCode)) { DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("Invalid Code."); } }
private void btnApprove_Click(object sender, EventArgs e) { askToClose = true; CUDMethods.ProcessItem(Convert.ToInt32(dgvItems.CurrentRow.Cells[0].Value), Convert.ToByte(2)); LoadItems();; po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue)); foreach (Item item in po.Items) { if (item.ItemStatus == Types.ItemStatus.Pending) { askToClose = false; } else { CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(2)); } } po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue)); lblOrderStatus.Text = po.OrderStatus.ToString(); if (askToClose == true) { DialogResult dialogResult = MessageBox.Show("Do you want to close the order?", "Purchase Order", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(3)); po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue)); LoadItems(); lblOrderNumber.Text = po.OrderNumber.ToString(); lblName.Text = po.EmpId.ToString(); lblDate.Text = po.OrderDate.ToShortDateString(); lblTotal.Text = "$" + po.Total.ToString(); lblOrderStatus.Text = po.OrderStatus.ToString(); sendEmail(); } else if (dialogResult == DialogResult.No) { } } }
protected void btnCreate_Click(object sender, EventArgs e) { try { item = ItemFactory.Create(); po = POFactory.Create(); double itemPrice = Convert.ToDouble(txtPrice.Text); orderPrice += itemPrice; item.ItemName = txtName.Text; item.Description = txtDesc.Text; item.Quantity = Convert.ToInt32(txtQty.Text); item.Price = itemPrice; item.Location = txtLocation.Text; item.Justification = txtJustification.Text; po.Items = new List <Types.IItem>(); po.Items.Add(item); po.OrderNumber = Convert.ToInt32(lblOrderNum.Text); po.EmpId = 10000004; int orderNumber = CUDMethods.CreatPO(po); lblSubNum.Text = "$" + (orderPrice).ToString("F"); lblTaxNum.Text = "$" + (orderPrice * 0.15).ToString("F"); lblTotalNum.Text = "$" + (orderPrice * 1.15).ToString("F"); lblOrderNum.Text = orderNumber.ToString(); lblOrderNum.Visible = true; lblOrder.Visible = true; btnCreate.Text = "Add"; lstItems.Items.Add(item.ItemName); clear(); lblError.InnerText = ""; } catch (Exception ex) { lblError.InnerText = "Please fill all fields correctly!"; } }
protected void btnClose_Click(object sender, EventArgs e) { po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue)); CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(3)); LoadItems(); lblOrderNumber.Text = po.OrderNumber.ToString(); lblDate.Text = po.OrderDate.ToShortDateString(); lblTotal.Text = "$" + po.Total.ToString(); lblOrderStatus.Text = po.OrderStatus.ToString(); btnApprove.Visible = false; btnDeny.Visible = false; btnMod.Visible = false; btnModApprove.Visible = false; btnClose.Visible = false; LoadItems(); sendEmail(); }
private void btnRequestIncrease_Click(object sender, EventArgs e) { try { if (!BusinessLayer.Validate.IsValidPercentageIncreaseRequest(txtPercentageIncreaseRequest.Text)) { MessageBox.Show("Invalid Percentage. Percentage must be a numeric value above 0."); } else { Double perfIncreaseVal = Convert.ToDouble(txtPercentageIncreaseRequest.Text) / 100; if (CUDMethods.CreateCostOfLivingIncrease(perfIncreaseVal, dtpDateOfIncrease.Value)) { MessageBox.Show("Cost-of-living Increase Successful!"); } } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private void btnAddSickDay_Click(object sender, EventArgs e) { try { if (txtSickDayDescription.Text == "") { MessageBox.Show("Error Missing Sick Day Description."); } else if (dtpSickDayDate.Value.Date > DateTime.Now.Date || dtpSickDayEndDate.Value.Date > DateTime.Now.Date) { MessageBox.Show("Error sick date cannot be in the future."); } else if (dtpSickDayDate.Value.Date > dtpSickDayEndDate.Value.Date) { MessageBox.Show("Error sick start date must be before sick end date."); } else { List <SickDays> sickDays = new List <SickDays>(); if (chkRangeOfSickDates.Checked) { //TimeSpan difference = (dtpSickDayEndDate.Value.Date - dtpSickDayDate.Value.Date); DateTime tmpDate = dtpSickDayDate.Value.Date; while (tmpDate.Date <= dtpSickDayEndDate.Value.Date) { SickDays tmpSickDay = SickDaysFactory.SickDaysCreate(); tmpSickDay.empId = emp[listBoxResults.SelectedIndex].EmpID; tmpSickDay.SickDayDate = tmpDate; tmpSickDay.SickDayDescription = txtSickDayDescription.Text; if (cmbLenthOfDay.SelectedValue.ToString() == "Full") { tmpSickDay.SickDayLength = 1; } else { tmpSickDay.SickDayLength = 0.5; } sickDays.Add(tmpSickDay); tmpDate = tmpDate.AddDays(1); } } else { SickDays tmpSickDaySingular = SickDaysFactory.SickDaysCreate(); tmpSickDaySingular.empId = emp[listBoxResults.SelectedIndex].EmpID; tmpSickDaySingular.SickDayDate = dtpSickDayDate.Value; tmpSickDaySingular.SickDayDescription = txtSickDayDescription.Text; if (cmbLenthOfDay.SelectedValue.ToString() == "Full") { tmpSickDaySingular.SickDayLength = 1; } else { tmpSickDaySingular.SickDayLength = 0.5; } sickDays.Add(tmpSickDaySingular); } foreach (SickDays tmpAddSickDay in sickDays) { CUDMethods.CreateNewSickDay(tmpAddSickDay); } MessageBox.Show("Sick Day Added."); RetrieveSickDays(emp[listBoxResults.SelectedIndex].EmpID); clearSickDayInfo(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected void btnModApprove_Click(object sender, EventArgs e) { try { askToClose = true; Item i = ItemFactory.Create(); i.ItemId = Convert.ToInt32(grvItems.SelectedRow.Cells[1].Text); i.ItemName = grvItems.SelectedRow.Cells[2].Text; i.Description = grvItems.SelectedRow.Cells[3].Text; i.Price = Convert.ToDouble(txtModPrice.Text); i.Quantity = Convert.ToInt32(txtModQty.Text); i.Location = txtModLocation.Text; i.Justification = grvItems.SelectedRow.Cells[7].Text; i.OrderNumber = Convert.ToInt32(grvItems.SelectedRow.Cells[9].Text); i.ReasonForMod = txtModReason.Text; if (grvItems.SelectedRow.Cells[8].Text == "Approved") { i.ItemStatus = Types.ItemStatus.Approved; } else if (grvItems.SelectedRow.Cells[8].Text == "Denied") { i.ItemStatus = Types.ItemStatus.Denied; } else if (grvItems.SelectedRow.Cells[8].Text == "Pending") { i.ItemStatus = Types.ItemStatus.Pending; } if (txtModLocation.Text != "" && txtModPrice.Text != "" && txtModQty.Text != "" && txtModReason.Text != "") { CUDMethods.ProcessItem(Convert.ToInt32(Session["itemId"].ToString()), Convert.ToByte(2)); CUDMethods.ModItem(i); } LoadItems(); po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue)); foreach (Item item in po.Items) { if (item.ItemStatus == Types.ItemStatus.Pending) { askToClose = false; } else { CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(2)); } } po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue)); lblOrderStatus.Text = po.OrderStatus.ToString(); if (askToClose == true) { btnClose.Visible = true; } lblModLocation.Visible = false; lblModPrice.Visible = false; lblModQty.Visible = false; lblModReason.Visible = false; txtModLocation.Visible = false; txtModPrice.Visible = false; txtModQty.Visible = false; txtModReason.Visible = false; btnModApprove.Visible = false; lblError.InnerText = ""; } catch (Exception ex) { lblError.InnerText = "Please fill all fields correctly!"; } }
private void btnCreate_Click(object sender, EventArgs e) { try{ String errorMsg = ""; Boolean isValid = true; if (txtSIN.Text.Length <= 0 || txtBiWeeklyPayRate.Text.Length <= 0 || txtCellPhoneNumber.Text.Length <= 0 || txtWorkPhoneNumber.Text.Length <= 0 || txtEmailAddress.Text.Length <= 0 || txtFirstName.Text.Length <= 0 || txtLastName.Text.Length <= 0 || txtStreetAddress.Text.Length <= 0 || txtCity.Text.Length <= 0 || txtPostalCode.Text.Length <= 0) { isValid = false; errorMsg = "Error Missing fields."; } else { if (!BusinessLayer.Validate.IsValidSIN(txtSIN.Text)) { isValid = false; errorMsg += "Invalid SIN. \n"; } if (dtpSeniorityDate.Value.Date > dtpJobStartDate.Value.Date) { isValid = false; errorMsg += "Seniority Date must be sooner than or equal to Job Start Date. \n"; } if (!BusinessLayer.Validate.IsValidBiweeklyPay(txtBiWeeklyPayRate.Text)) { isValid = false; errorMsg += "Bi-Weekly Payrate must be a numeric value greater than 0. \n"; } if (!BusinessLayer.Validate.ValidatePhoneNumber(txtCellPhoneNumber.Text)) { isValid = false; errorMsg += "Invalid Cell Phone Number. \n"; } if (!BusinessLayer.Validate.ValidatePhoneNumber(txtWorkPhoneNumber.Text)) { isValid = false; errorMsg += "Invalid Work Phone Number. \n"; } if (!BusinessLayer.Validate.ValidateEmail(txtEmailAddress.Text)) { isValid = false; errorMsg += "Invalid Email Address. \n"; } if (!BusinessLayer.Validate.ValidateLength(txtFirstName.Text, 20)) { isValid = false; errorMsg += "First Name cannot be longer than 20 characters. \n"; } if (!BusinessLayer.Validate.ValidateLength(txtMiddleInitial.Text, 1)) { isValid = false; errorMsg += "Middle Initial cannot be longer than 1 character. \n"; } if (!BusinessLayer.Validate.ValidateLength(txtLastName.Text, 30)) { isValid = false; errorMsg += "Last Name cannot be longer than 30 characters. \n"; } if (!BusinessLayer.Validate.IsValidPostalCode(txtPostalCode.Text)) { isValid = false; errorMsg += "Invalid Postal Code \n"; } } if (isValid) { Employee emp = EmployeeFactory.CreateEmployee(); emp.FirstName = txtFirstName.Text; emp.MiddleInitial = txtMiddleInitial.Text; emp.LastName = txtLastName.Text; emp.DateOfBirth = dtpDateOfBirth.Value; emp.StreetAddress = txtStreetAddress.Text; emp.City = txtCity.Text; emp.PostalCode = txtPostalCode.Text; emp.SIN = Convert.ToInt32(txtSIN.Text); emp.CellPhoneNumber = txtCellPhoneNumber.Text; emp.WorkPhoneNumber = txtWorkPhoneNumber.Text; emp.EmailAddress = txtEmailAddress.Text; emp.HireDate = dtpSeniorityDate.Value; emp.JobStartDate = dtpJobStartDate.Value; emp.EmailNotification = chkPayrollEmailNotification.Checked; emp.JobID = Convert.ToInt32(cmbJobAssignment.SelectedValue); emp.DepartmentID = Convert.ToInt32(cmbDepartment.SelectedValue); emp.BiWeeklyRate = Convert.ToDouble(txtBiWeeklyPayRate.Text); int newEmpID = CUDMethods.CreateEmp(emp); MessageBox.Show("New Employee Created With ID of: " + newEmpID); //MessageBox.Show("Worked"); } else { MessageBox.Show(errorMsg); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }