/// <summary> /// Save /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { EmployeeStandardCostsSetupTDS employeeStandardCostsSetupChanges = (EmployeeStandardCostsSetupTDS)Data.GetChanges(); if (employeeStandardCostsSetupChanges.StandardCostsSetup.Rows.Count > 0) { EmployeeStandardCostsSetupGateway employeeStandardCostsSetupGateway = new EmployeeStandardCostsSetupGateway(employeeStandardCostsSetupChanges); // Update employee foreach (EmployeeStandardCostsSetupTDS.StandardCostsSetupRow standardCostsSetupRow in (EmployeeStandardCostsSetupTDS.StandardCostsSetupDataTable)employeeStandardCostsSetupChanges.StandardCostsSetup) { // Unchanged values int employeeId = standardCostsSetupRow.EmployeeID; int? loginId = null; if(!standardCostsSetupRow.IsLoginIDNull()) loginId = standardCostsSetupRow.LoginID; int? contactsId = null; if (!standardCostsSetupRow.IsContactsIDNull()) contactsId = standardCostsSetupRow.ContactsID; string fullName = standardCostsSetupRow.FullName; string firstName = standardCostsSetupRow.FirstName; string middleInitial = ""; if (!standardCostsSetupRow.IsMiddleInitialNull()) middleInitial = standardCostsSetupRow.MiddleInitial; string lastName = standardCostsSetupRow.LastName; string type = standardCostsSetupRow.Type; string state = standardCostsSetupRow.State; bool isSalessman = standardCostsSetupRow.IsSalesman; bool requestProjectTime = standardCostsSetupRow.RequestProjectTime; bool deleted = standardCostsSetupRow.Deleted; bool salaried = standardCostsSetupRow.Salaried; string eMail = ""; if (!standardCostsSetupRow.IseMailNull()) eMail = standardCostsSetupRow.eMail; bool assignableSrs = standardCostsSetupRow.AssignableSRS; string jobClassType = ""; if (!standardCostsSetupRow.IsJobClassTypeNull()) jobClassType = standardCostsSetupRow.JobClassType; string category = standardCostsSetupRow.Category; string personalAgencyName = ""; if (!standardCostsSetupRow.IsPersonalAgencyNameNull()) personalAgencyName = standardCostsSetupRow.PersonalAgencyName; bool isVacationsManager = standardCostsSetupRow.IsVacationsManager; bool approveTimesheets = standardCostsSetupRow.ApproveTimesheets; // Original values decimal? originalBourdenFactor = employeeStandardCostsSetupGateway.GetBourdenFactorOriginal(employeeId); decimal? originalUSHealthBenefitFactor = employeeStandardCostsSetupGateway.GetUSHealthBenefitFactorOriginal(employeeId); decimal? originalBenefitFactorCad = employeeStandardCostsSetupGateway.GetBenefitFactorCadOriginal(employeeId); decimal? originalBenefitFactorUsd = employeeStandardCostsSetupGateway.GetBenefitFactorUsdOriginal(employeeId); // New variables decimal? newBourdenFactor = employeeStandardCostsSetupGateway.GetBourdenFactor(employeeId); decimal? newUSHealthBenefitFactor = employeeStandardCostsSetupGateway.GetUSHealthBenefitFactor(employeeId); decimal? newBenefitFactorCad = employeeStandardCostsSetupGateway.GetBenefitFactorCad(employeeId); decimal? newBenefitFactorUsd = employeeStandardCostsSetupGateway.GetBenefitFactorUsd(employeeId); string crew = ""; if (!standardCostsSetupRow.IsCrewNull()) crew = standardCostsSetupRow.Crew; // ... Update employee Employee employee = new Employee(null); employee.UpdateDirect(employeeId, loginId, contactsId, fullName, firstName, middleInitial, lastName, type, state, isSalessman, requestProjectTime, deleted, salaried, eMail, assignableSrs, jobClassType, category, personalAgencyName, isVacationsManager, approveTimesheets, originalBourdenFactor, originalUSHealthBenefitFactor, originalBenefitFactorCad, originalBenefitFactorUsd, crew, fullName, firstName, middleInitial, lastName, type, state, isSalessman, requestProjectTime, deleted, salaried, eMail, assignableSrs, jobClassType, category, personalAgencyName, isVacationsManager, approveTimesheets, newBourdenFactor, newUSHealthBenefitFactor, newBenefitFactorCad, newBenefitFactorUsd, crew); // ... Update cost history table // ... ... if there are new values if ((newBourdenFactor.HasValue) && (newUSHealthBenefitFactor.HasValue) && (newBenefitFactorCad.HasValue) && (newBenefitFactorUsd.HasValue)) { // ... ... verify if the new values are different from original if ((originalBourdenFactor.HasValue) && (originalUSHealthBenefitFactor.HasValue) && (originalBenefitFactorCad.HasValue) && (originalBenefitFactorUsd.HasValue)) { if (((decimal)originalBourdenFactor != (decimal)newBourdenFactor) || ((decimal)originalUSHealthBenefitFactor != (decimal)newUSHealthBenefitFactor) || ((decimal)originalBenefitFactorCad != (decimal)newBenefitFactorCad) || ((decimal)originalBenefitFactorUsd != (decimal)newBenefitFactorUsd)) { EmployeeInformationCostInformationGateway employeeInformationCostInformationGateway = new EmployeeInformationCostInformationGateway(); employeeInformationCostInformationGateway.LoadLastCostByEmployeeId(employeeId, companyId); if (employeeInformationCostInformationGateway.Table.Rows.Count > 0) { DateTime date = DateTime.Now; int lastCostId = employeeInformationCostInformationGateway.GetCostId(employeeId); string unitOfMeasurement = employeeInformationCostInformationGateway.GetUnitOfMeasurement(lastCostId, employeeId); decimal payRateCad = employeeInformationCostInformationGateway.GetPayRateCad(lastCostId, employeeId); decimal payRateUsd = employeeInformationCostInformationGateway.GetPayRateUsd(lastCostId, employeeId); decimal benefitFactorUsd = employeeInformationCostInformationGateway.GetBenefitFactorUsd(lastCostId, employeeId); decimal boudenFactor = (decimal)newBourdenFactor / 100; decimal burdenRateCad = Decimal.Round(payRateCad * boudenFactor, 2); decimal totalCostCad = payRateCad + burdenRateCad; totalCostCad = Decimal.Round(totalCostCad, 2); decimal burdenRateUsd = Decimal.Round(payRateUsd * boudenFactor, 2); decimal totalCostUsd = payRateUsd + burdenRateUsd; totalCostUsd = Decimal.Round(totalCostUsd, 2); decimal healthBenefitFactorUsd = (decimal)newUSHealthBenefitFactor / 100; decimal healthBenefitUsd = benefitFactorUsd * healthBenefitFactorUsd; int newCostId = lastCostId + 1; EmployeeCostHistory employeeCostHistory = new EmployeeCostHistory(null); employeeCostHistory.InsertDirect(newCostId, employeeId, date, unitOfMeasurement, payRateCad, burdenRateCad, totalCostCad, payRateUsd, burdenRateUsd, totalCostUsd, false, companyId, (decimal)newBenefitFactorCad, (decimal)newBenefitFactorUsd, healthBenefitUsd); } } } } } } }
protected void Page_PreRender(object sender, EventArgs e) { // Set active toolbar mForm6 master = (mForm6)this.Master; master.ActiveToolbar = "LabourHours"; // ... Labour Hours Mode if ((string)ViewState["LHMode"] == "Full") { EmployeeGateway employeeGateway1 = new EmployeeGateway(new DataSet()); int employeeId = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"])); employeeGateway1.LoadByEmployeeId(employeeId); Employee employee = new Employee(); if (employee.IsValidApproveTimesheetsManager((int)ViewState["employee_id"], employeeId)) { TimesheetNavigator timesheetNavigator = new TimesheetNavigator(timesheetNavigatorTDS); if (timesheetNavigator.Table.Rows.Count > 0) { tkrmTop.Items[1].Visible = true; // Timesheets To Approve } else { tkrmTop.Items[1].Visible = false; // Timesheets To Approve } } else { tkrmTop.Items[1].Visible = false; // Timesheets To Approve } if (!employeeGateway1.GetApproveTimesheets(employeeId)) { tkrpbLeftMenuTools.Items[0].Items[1].Visible = false; ;//tkrpbLeftMenuTools.Items[1].Visible = false; // Approve Project Times } if (Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_VIEW"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { tkrpbLeftMenuOthersTimesheets.Visible = true; tkrpbLeftMenuTools.Items[0].Items[0].Visible = true; //.Items[0].Visible = true; // Add Team Project Time tkrpbLeftMenuTools.Items[0].Items[2].Visible = true; // Missing Project Time // Access control // ... Employees EmployeeListGateway employeeListGateway = new EmployeeListGateway(new DataSet()); if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { employeeListGateway.LoadByRequestProjectTimeWithoutEmployeeId(1, employeeId); } else { employeeListGateway.LoadByRequestProjectTime(1); } DropDownList ddlOthersFor = (DropDownList)tkrpbLeftMenuOthersTimesheets.FindItemByValue("nbOthersTimesheetsDDL").FindControl("ddlOthersFor"); ddlOthersFor.DataSource = employeeListGateway.Table; ddlOthersFor.DataValueField = "EmployeeID"; ddlOthersFor.DataTextField = "FullName"; ddlOthersFor.DataBind(); try { ddlOthersFor.SelectedValue = Session["ddlOthersForSelectedValue"].ToString(); } catch { } ViewState["others"] = "yes"; } else { tkrpbLeftMenuOthersTimesheets.Visible = false; if (!employeeGateway1.GetApproveTimesheets(employeeId)) { tkrpbLeftMenuTools.Visible = false; } tkrpbLeftMenuTools.Items[0].Items[0].Visible = false;//tkrpbLeftMenuTools.Items[0].Visible = false; // Add Team Project Time tkrpbLeftMenuTools.Items[0].Items[2].Visible = false;//tkrpbLeftMenuTools.Items[2].Visible = false; // Missing Project Time } if (!((Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) && (employeeGateway1.GetRequestProjectTime(employeeId)))) { tkrpbLeftMenuMyTimesheets.Visible = false; tkrpbLeftMenuOthersTimesheets.Items[0].Text = "Timesheets"; } if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_REPORTS"])) { // View Reports tkrpbLeftMenuReports.Visible = false; } } } else { // Left menu tkrpbLeftMenuMyTimesheets.Visible = false; tkrpbLeftMenuOthersTimesheets.Items[0].Text = "Timesheets"; tkrpbLeftMenuTools.Items[0].Items[1].Visible = false;//tkrpbLeftMenuTools.Items[1].Visible = false; // Timesheets To Approve // Top menu tkrmTop.Items[0].Visible = true; tkrmTop.Items[1].Visible = false; // Grid options btnEdit.Visible = true; btnDelete.Visible = true; } }
// //////////////////////////////////////////////////////////////////////// // PRIVATE METHODS // /// <summary> /// UpdateForReport /// </summary> private void UpdateForReport() { foreach (PrintUnnapprovedProjectTimesTDS.UnapprovedProjectTimesRow row in (PrintUnnapprovedProjectTimesTDS.UnapprovedProjectTimesDataTable)Table) { Employee employee = new Employee(); string allCategoryManagers = employee.GetAllCategoryManagers(row.Category, row.EmployeeID); if (!String.IsNullOrEmpty(allCategoryManagers)) { row.Manager = allCategoryManagers; } else { row.Manager = ""; } } }
/// <summary> /// Save /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { EmployeeInformationTDS employeeInformationChanges = (EmployeeInformationTDS)Data.GetChanges(); if (employeeInformationChanges.BasicInformation.Rows.Count > 0) { EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway(employeeInformationChanges); // Update employee foreach (EmployeeInformationTDS.BasicInformationRow basicInformationRow in (EmployeeInformationTDS.BasicInformationDataTable)employeeInformationChanges.BasicInformation) { // Unchanged values int employeeId = basicInformationRow.EmployeeID; int? loginId = null; if(!basicInformationRow.IsLoginIDNull()) loginId = basicInformationRow.LoginID; int? contactsId = null; if (!basicInformationRow.IsContactsIDNull()) contactsId = basicInformationRow.ContactsID; string middleInitial = ""; if (!basicInformationRow.IsMiddleInitialNull()) middleInitial = basicInformationRow.MiddleInitial; bool deleted = basicInformationRow.Deleted; decimal? bourdenFactor = null; if (!basicInformationRow.IsBourdenFactorNull()) bourdenFactor = (decimal)basicInformationRow.BourdenFactor; decimal? usHealthBenefitFactor = null; if (!basicInformationRow.IsUSHealthBenefitFactorNull()) usHealthBenefitFactor = (decimal)basicInformationRow.USHealthBenefitFactor; decimal? benefitFactorCad = null; if (!basicInformationRow.IsBenefitFactorCadNull()) benefitFactorCad = (decimal)basicInformationRow.BenefitFactorCad; decimal? benefitFactorUsd = null; if (!basicInformationRow.IsBenefitFactorUsdNull()) benefitFactorUsd = (decimal)basicInformationRow.BenefitFactorUsd; // Original values string originalFirstName = employeeInformationBasicInformationGateway.GetFirstNameOriginal(employeeId); string originalLastName = employeeInformationBasicInformationGateway.GetLastNameOriginal(employeeId); string originalFullName = originalFirstName + ' ' + originalLastName; string originalType = employeeInformationBasicInformationGateway.GetTypeOriginal(employeeId); string originalState = employeeInformationBasicInformationGateway.GetStateOriginal(employeeId); bool originalIsSalessman = employeeInformationBasicInformationGateway.GetIsSalesmanOriginal(employeeId); bool originalRequestProjectTime = employeeInformationBasicInformationGateway.GetRequestProjectTimeOriginal(employeeId); bool originalSalaried = employeeInformationBasicInformationGateway.GetSalariedOriginal(employeeId); string originalEMail = employeeInformationBasicInformationGateway.GeteMailOriginal(employeeId); bool originalAssignableSrs = employeeInformationBasicInformationGateway.GetAssignableSRSOriginal(employeeId); string originalJobClassType = employeeInformationBasicInformationGateway.GetJobClassTypeOriginal(employeeId); string originalCategory = employeeInformationBasicInformationGateway.GetCategoryOriginal(employeeId); string originalPersonalAgencyName = employeeInformationBasicInformationGateway.GetPersonalAgencyNameOriginal(employeeId); bool originalIsVacationsManager = employeeInformationBasicInformationGateway.GetIsVacationsManagerOriginal(employeeId); bool originalApproveTimesheets = employeeInformationBasicInformationGateway.GetApproveTimesheetsOriginal(employeeId); string originalCrew = employeeInformationBasicInformationGateway.GetCrewOriginal(employeeId); // New variables string newFirstName = employeeInformationBasicInformationGateway.GetFirstName(employeeId); string newLastName = employeeInformationBasicInformationGateway.GetLastName(employeeId); string newFullName = newFirstName + ' ' + newLastName; string newType = employeeInformationBasicInformationGateway.GetType(employeeId); string newState = employeeInformationBasicInformationGateway.GetState(employeeId); bool newIsSalessman = employeeInformationBasicInformationGateway.GetIsSalesman(employeeId); bool newRequestProjectTime = employeeInformationBasicInformationGateway.GetRequestProjectTime(employeeId); bool newSalaried = employeeInformationBasicInformationGateway.GetSalaried(employeeId); string newEMail = employeeInformationBasicInformationGateway.GeteMail(employeeId); bool newAssignableSrs = employeeInformationBasicInformationGateway.GetAssignableSRS(employeeId); string newJobClassType = employeeInformationBasicInformationGateway.GetJobClassType(employeeId); string newCategory = employeeInformationBasicInformationGateway.GetCategory(employeeId); string newPersonalAgencyName = employeeInformationBasicInformationGateway.GetPersonalAgencyName(employeeId); bool newIsVacationsManager = employeeInformationBasicInformationGateway.GetIsVacationsManager(employeeId); bool newApproveTimesheets = employeeInformationBasicInformationGateway.GetApproveTimesheets(employeeId); string newCrew = employeeInformationBasicInformationGateway.GetCrew(employeeId); // ... Update Employee employee = new Employee(null); employee.UpdateDirect(employeeId, loginId, contactsId, originalFullName, originalFirstName, middleInitial, originalLastName, originalType, originalState, originalIsSalessman, originalRequestProjectTime, deleted, originalSalaried, originalEMail, originalAssignableSrs, originalJobClassType, originalCategory, originalPersonalAgencyName, originalIsVacationsManager, originalApproveTimesheets, bourdenFactor, usHealthBenefitFactor, benefitFactorCad, benefitFactorUsd, originalCrew, newFullName, newFirstName, middleInitial, newLastName, newType, newState, newIsSalessman, newRequestProjectTime, deleted, newSalaried, newEMail, newAssignableSrs, newJobClassType, newCategory, newPersonalAgencyName, newIsVacationsManager, newApproveTimesheets, bourdenFactor, usHealthBenefitFactor, benefitFactorCad, benefitFactorUsd, newCrew); } } }
public void SendMailFleetManager() { // Get mail information string mailTo = ""; string nameTo = ""; string subject = "Service request has been modified."; string body = ""; // MailtTo, nameTo int companyLevelId = Int32.Parse(hdfCompanyLevel.Value); Employee employees = new Employee(); employees.LoadByFleetManager(companyLevelId); mailTo = employees.GetAllFleetManagersEMails(); nameTo = employees.GetAllFleetManagersNames(); // Mails body body = body + "\nHi " + nameTo + ",\n\nThe following service request has been modified. \n"; body = body + "\n Service Number: " + hdfServiceNumber.Value; body = body + "\n Service Description: " + hdfServiceDescription.Value; // ... Assignation of work // ... ... Deadline date if (hdfDeadlineDate.Value != "") { DateTime deadlineDate = DateTime.Parse(hdfDeadlineDate.Value); string deadlineDateText = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString(); body = body + "\n Deadline date: " + deadlineDateText; } else { body = body + "\n Deadline date: "; } // ... ... Assigned Personal if (hdfAssignToTeamMember.Value == "True") { int employeeId = Int32.Parse(hdfTeamMemberId.Value); EmployeeGateway employeesGateway = new EmployeeGateway(); employeesGateway.LoadForMailsByEmployeeId(employeeId); string assignedTo = ""; if (employeesGateway.Table.Rows.Count > 0) { // Assigned TeamMember assignedTo = employeesGateway.GetFirstName(employeeId) + " " + employeesGateway.GetLastName(employeeId); } body = body + "\n Assigned Team Member: " + assignedTo; } // ... ... Assigned third party vendor if (hdfAssignToThirdPartyVendor.Value == "True") { body = body + "\n Assigned Third Party Vendor: " + hdfThirdPartyVendor.Value; } int registeredByLoginId = Convert.ToInt32(Session["loginID"]); EmployeeGateway employeeGateway = new EmployeeGateway(); employeeGateway.LoadByLoginId(registeredByLoginId); int registeredByEmployeeId = employeeGateway.GetEmployeIdByLoginId(registeredByLoginId); // ... ... Assigned myself if (hdfAssignToMyself.Value == "True") { if (employeeGateway.Table.Rows.Count > 0) { body = body + "\n Assigned to myself: " + employeeGateway.GetFirstName(registeredByEmployeeId) + " " + employeeGateway.GetLastName(registeredByEmployeeId); } } // Registered by if (employeeGateway.Table.Rows.Count > 0) { body = body + "\n Registered By: " + employeeGateway.GetFirstName(registeredByEmployeeId) + " " + employeeGateway.GetLastName(registeredByEmployeeId); } // Service State body = body + "\n\n Service State: " + hdfServiceState.Value; //Send Mail SendMail(mailTo, subject, body); }
private void SendMailFleetManagerAcceptRejectCompleted(string subject, string title) { // Get mail information string mailTo = ""; string nameTo = ""; string body = ""; int serviceId = Int32.Parse(hdfServiceId.Value); int companyId = Int32.Parse(hdfCompanyId.Value); int companyLevel = Int32.Parse(hdfCompanyLevel.Value); // MailtTo, nameTo int companyLevelId = Int32.Parse(hdfCompanyLevel.Value); Employee employees = new Employee(); employees.LoadByFleetManager(companyLevelId); mailTo = employees.GetAllFleetManagersEMails(); nameTo = employees.GetAllFleetManagersNames(); ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS); serviceInformationBasicInformationGateway.LoadByServiceId(serviceId, companyId); // Mails body body = body + "\nHi " + nameTo + ",\n\n" + title + " \n"; body = body + "\n Service: " + serviceInformationBasicInformationGateway.GetServiceNumber(serviceId) + " - " + serviceInformationBasicInformationGateway.GetServiceDescription(serviceId); body = body + "\n Unit: " + serviceInformationBasicInformationGateway.GetUnitCode(serviceId) + " - " + serviceInformationBasicInformationGateway.GetUnitDescription(serviceId); body = body + "\n Fixed Date: "; if (serviceInformationBasicInformationGateway.GetMtoDto(serviceId)) body = body + "Yes "; else body = body + "No "; string unitType = hdfUnitType.Value; if (unitType == "Vehicle") { body = body + "\n Mileage: " + serviceInformationBasicInformationGateway.GetMileage(serviceId) + " " + hdfMileageUnitOfMeasurement.Value; } body = body + "\n Problem Description: " + serviceInformationBasicInformationGateway.GetServiceDescription(serviceId); if (serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId).HasValue) { DateTime deadlineDate = (DateTime)serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId); string deadlineDateText = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString(); body = body + "\n Deadline Date: " + deadlineDateText; } // Asignation if (serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId).HasValue) { int employeeId = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId); EmployeeGateway employeesGateway = new EmployeeGateway(); employeesGateway.LoadByEmployeeId(employeeId); string assignedTo = ""; if (employeesGateway.Table.Rows.Count > 0) { // Assigned TeamMember assignedTo = employeesGateway.GetFirstName(employeeId) + " " + employeesGateway.GetLastName(employeeId); } body = body + "\n Assigned Team Member: " + assignedTo; } // ... Start work information if (serviceInformationBasicInformationGateway.GetStartWorkDateTime(serviceId).HasValue) { DateTime startWorkDate = (DateTime)serviceInformationBasicInformationGateway.GetStartWorkDateTime(serviceId); body = body + "\n Start Work Date & Time: " + startWorkDate; } // ... Complete work information if (serviceInformationBasicInformationGateway.GetCompleteWorkDateTime(serviceId).HasValue) { DateTime completeWorkDate = (DateTime)serviceInformationBasicInformationGateway.GetCompleteWorkDateTime(serviceId); body = body + "\n Complete Work Date & Time: " + completeWorkDate; } //Send Mail SendMail(mailTo, subject, body); }
private void SendMailFleetManager( string subject, string title) { // Get mail information string mailTo = ""; string nameTo = ""; string body = ""; int serviceId = Int32.Parse(hdfServiceId.Value); int companyId = Int32.Parse(hdfCompanyId.Value); int companyLevel = Int32.Parse(hdfCompanyLevel.Value); // MailtTo, nameTo int companyLevelId = Int32.Parse(hdfCompanyLevel.Value); Employee employees = new Employee(); employees.LoadByFleetManager(companyLevelId); mailTo = employees.GetAllFleetManagersEMails(); nameTo = employees.GetAllFleetManagersNames(); ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS); serviceInformationBasicInformationGateway.LoadByServiceId(serviceId, companyId); // Mails body body = body + "\nHi " + nameTo + ",\n\n"+ title + " \n"; body = body + "\n Unit: " + serviceInformationBasicInformationGateway.GetUnitCode(serviceId) + " - " + serviceInformationBasicInformationGateway.GetUnitDescription(serviceId); body = body + "\n Fixed Date: "; if (serviceInformationBasicInformationGateway.GetMtoDto(serviceId)) body = body + "Yes "; else body = body + "No "; string unitType = hdfUnitType.Value; if (unitType == "Vehicle") { body = body + "\n Mileage: " + serviceInformationBasicInformationGateway.GetMileage(serviceId) + " " + hdfMileageUnitOfMeasurement.Value; } body = body + "\n Problem Description: " + serviceInformationBasicInformationGateway.GetServiceDescription(serviceId); if (tkrdpPnlAssignDeadlineDate.SelectedDate.HasValue) { DateTime deadlineDate = tkrdpPnlAssignDeadlineDate.SelectedDate.Value; string deadlineDateText = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString(); body = body + " \n Deadline date: " + deadlineDateText; } else { body = body + " \n Deadline date: "; } if(rbtnPnlAssignToTeamMember.Checked) { int employeeId = Int32.Parse(ddlPnlAssignAssignToTeamMember.SelectedValue); EmployeeGateway employeesGateway = new EmployeeGateway(); employeesGateway.LoadForMailsByEmployeeId(employeeId); string assignedTo = ""; if (employeesGateway.Table.Rows.Count > 0) { // Assigned TeamMember assignedTo = employeesGateway.GetFirstName(employeeId) + " " + employeesGateway.GetLastName(employeeId); } body = body + "\n Assigned Team Member: " + assignedTo; } if (rbtnPnlAssignToThirdPartyVendor.Checked) { body = body + "\n Assigned Third Party Vendor: " + tbxPnlAssignAssignToThirdPartyVendor.Text; } //Send Mail SendMail(mailTo, subject, body); }
/// <summary> /// Save /// </summary> /// <returns>employeeId</returns> public int Save() { EmployeesAddTDS employeeAddChanges = (EmployeesAddTDS)Data.GetChanges(); int employeeId = 0; if (employeeAddChanges != null) { if (employeeAddChanges.EmployeeAdd.Rows.Count > 0) { EmployeeAddGateway employeeNavigatorGateway = new EmployeeAddGateway(employeeAddChanges); // Update employees foreach (EmployeesAddTDS.EmployeeAddRow row in (EmployeesAddTDS.EmployeeAddDataTable)employeeAddChanges.EmployeeAdd) { // Insert new employees if ((!row.Deleted) && (!row.InDatabase)) { Employee employee = new Employee(null); int? loginId = null; if (!row.IsLoginIDNull()) loginId = row.LoginID; int? contactsId = null; if (!row.IsContactsIDNull()) contactsId = row.ContactsID; string middleInitial = ""; if (!row.IsMiddleInitialNull()) middleInitial = row.MiddleInitial; string email = ""; if (!row.IseMailNull()) email = row.eMail; bool assignableSrs = row.AssignableSRS; string jobClass = ""; if (!row.IsJobClassTypeNull()) jobClass = row.JobClassType; string personalAgencyName = ""; if (!row.IsPersonalAgencyNameNull()) personalAgencyName = row.PersonalAgencyName; bool isVacationsManager = row.IsVacationsManager; bool approveTimesheets = row.ApproveTimesheets; decimal? bourdenFactor = null; if (!row.IsBourdenFactorNull()) bourdenFactor = (decimal)row.BourdenFactor; decimal? usHealthBenefitFactor = null; if (!row.IsUSHealthBenefitFactorNull()) usHealthBenefitFactor = (decimal)row.USHealthBenefitFactor; decimal? benefitFactorCad = null; if (!row.IsBenefitFactorCadNull()) benefitFactorCad = (decimal)row.BenefitFactorCad; decimal? benefitFactorUsd = null; if (!row.IsBenefitFactorUsdNull()) benefitFactorUsd = (decimal)row.BenefitFactorUsd; string crew = ""; //TODO CREW employeeId = employee.InsertDirect(loginId, contactsId, row.FullName, row.FirstName, middleInitial, row.LastName, row.Type, row.State, row.IsSalesman, row.RequestProjectTime, row.Deleted, row.Salaried, email, assignableSrs, jobClass, row.Category, personalAgencyName, isVacationsManager, approveTimesheets, bourdenFactor, usHealthBenefitFactor, benefitFactorCad, benefitFactorUsd, crew); // Employee Categories Approve Timesheets EmployeeCategoryApproveTimesheets employeeCategoryApproveTimesheets = new EmployeeCategoryApproveTimesheets(null); employeeCategoryApproveTimesheets.InsertDirect(employeeId, "Field", false, false); employeeCategoryApproveTimesheets.InsertDirect(employeeId, "Field 44", false, false); employeeCategoryApproveTimesheets.InsertDirect(employeeId, "Mechanic/Manufactoring", false, false); employeeCategoryApproveTimesheets.InsertDirect(employeeId, "Office/Admin", false, false); employeeCategoryApproveTimesheets.InsertDirect(employeeId, "Special Forces", false, false); } } } } return employeeId; }
private void UpdateDatabase() { // Get ids int currentEmployeeId = Int32.Parse(hdfCurrentEmployeeId.Value); int companyId = Int32.Parse(hdfCompanyId.Value); // Delete DB.Open(); DB.BeginTransaction(); try { EmployeeTypeHistory employeeTypeHistory = new EmployeeTypeHistory(employeeInformationTDS); employeeTypeHistory.DeleteAllDirect(currentEmployeeId, companyId); Employee employee = new Employee(employeeTDS); employee.DeleteDirect(currentEmployeeId); DB.CommitTransaction(); } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
/// <summary> /// Save /// </summary> public void Save() { EmployeeNavigatorTDS employeeNavigatorChanges = (EmployeeNavigatorTDS)Data.GetChanges(); if (employeeNavigatorChanges != null) { if (employeeNavigatorChanges.EmployeeNavigator.Rows.Count > 0) { EmployeeNavigatorGateway employeeNavigatorGateway = new EmployeeNavigatorGateway(employeeNavigatorChanges); // Update employees foreach (EmployeeNavigatorTDS.EmployeeNavigatorRow row in (EmployeeNavigatorTDS.EmployeeNavigatorDataTable)employeeNavigatorChanges.EmployeeNavigator) { // Insert new employees if ((!row.Deleted) && (!row.InDatabase)) { Employee employee = new Employee(null); int? loginId = null; if (!row.IsLoginIDNull()) loginId = row.LoginID; int? contactsId = null; if (!row.IsContactsIDNull()) contactsId = row.ContactsID; string middleInitial = ""; if (!row.IsMiddleInitialNull()) middleInitial = row.MiddleInitial; string email = ""; if (!row.IseMailNull()) email = row.eMail; bool assignableSrs = row.AssignableSRS; string jobClassType = ""; if (!row.IsJobClassTypeNull()) jobClassType = row.JobClassType; string personalAgencyName = ""; if (!row.IsPersonalAgencyNameNull()) personalAgencyName = row.PersonalAgencyName; decimal? bourdenFactor = null; if (!row.IsBourdenFactorNull()) bourdenFactor = (decimal)row.BourdenFactor; decimal? usHealthBenefitFactor = null; if (!row.IsUSHealthBenefitFactorNull()) usHealthBenefitFactor = (decimal)row.USHealthBenefitFactor; decimal? standardBenefitFactorCad = null; if (!row.IsStandardBenefitFactorCadNull()) standardBenefitFactorCad = (decimal)row.StandardBenefitFactorCad; decimal? standardBenefitFactorUsd = null; if (!row.IsStandardBenefitFactorUsdNull()) standardBenefitFactorUsd = (decimal)row.StandardBenefitFactorUsd; string crew = ""; if (!row.IsCrewNull()) crew = row.Crew; employee.InsertDirect(loginId, contactsId, row.FullName, row.FirstName, middleInitial, row.LastName, row.Type, row.State, row.IsSalesman, row.RequestProjectTime, row.Deleted, row.Salaried, email, assignableSrs, jobClassType, row.Category, personalAgencyName, row.IsVacationsManager, row.ApproveTimesheets, bourdenFactor, usHealthBenefitFactor, standardBenefitFactorCad, standardBenefitFactorUsd, crew); } // Update employees if ((!row.Deleted) && (row.InDatabase)) { // non editable values int employeeId = row.EmployeeID; int? originalLoginId = row.LoginID; int? originalContactsId = row.ContactsID; bool originalDeleted = false; decimal? originalBourdenFactor = null; if (!row.IsBourdenFactorNull()) originalBourdenFactor = (decimal)row.BourdenFactor; decimal? originalUSHealthBenefitFactor = null; if (!row.IsUSHealthBenefitFactorNull()) originalUSHealthBenefitFactor = (decimal)row.USHealthBenefitFactor; decimal? originalStandardBenefitFactorCad = null; if (!row.IsStandardBenefitFactorCadNull()) originalStandardBenefitFactorCad = (decimal)row.StandardBenefitFactorCad; decimal? originalStandardBenefitFactorUsd = null; if (!row.IsStandardBenefitFactorUsdNull()) originalStandardBenefitFactorUsd = (decimal)row.StandardBenefitFactorUsd; // original values string originalFullName = employeeNavigatorGateway.GetFullNameOriginal(employeeId); string originalFirstName = employeeNavigatorGateway.GetFirstNameOriginal(employeeId); string originalMiddleInitial = employeeNavigatorGateway.GetMiddleInitialOriginal(employeeId); string originalLastName = employeeNavigatorGateway.GetLastNameOriginal(employeeId); string originalType = employeeNavigatorGateway.GetTypeOriginal(employeeId); string originalState = employeeNavigatorGateway.GetStateOriginal(employeeId); bool originalIsSalesman = employeeNavigatorGateway.GetIsSalesmanOriginal(employeeId); bool originalRequestProjectTime = employeeNavigatorGateway.GetRequestProjectTimeOriginal(employeeId); bool originalSalaried = employeeNavigatorGateway.GetSalariedOriginal(employeeId); string originalEMail = employeeNavigatorGateway.GetEMailOriginal(employeeId); bool originalAssignableSrs = employeeNavigatorGateway.GetAssignableSRSOriginal(employeeId); string originalJobClassType = employeeNavigatorGateway.GetJobClassTypeOriginal(employeeId); string originalCategory = employeeNavigatorGateway.GetCategoryOriginal(employeeId); string originalPersonalAgencyName = employeeNavigatorGateway.GetPersonalAgencyNameOriginal(employeeId); bool originalIsVacationsManager = employeeNavigatorGateway.GetIsVacationsManagerOriginal(employeeId); bool originalApproveTimesheets = employeeNavigatorGateway.GetApproveTimesheetsOriginal(employeeId); // new values string newFullName = employeeNavigatorGateway.GetFullName(employeeId); string newFirstName = employeeNavigatorGateway.GetFirstName(employeeId); string newMiddleInitial = employeeNavigatorGateway.GetMiddleInitial(employeeId); string newLastName = employeeNavigatorGateway.GetLastName(employeeId); string newType = employeeNavigatorGateway.GetType(employeeId); string newState = employeeNavigatorGateway.GetState(employeeId); bool newIsSalesman = employeeNavigatorGateway.GetIsSalesman(employeeId); bool newRequestProjectTime = employeeNavigatorGateway.GetRequestProjectTime(employeeId); bool newSalaried = employeeNavigatorGateway.GetSalaried(employeeId); string newEMail = employeeNavigatorGateway.GetEMail(employeeId); bool newAssignableSrs = employeeNavigatorGateway.GetAssignableSRS(employeeId); string newJobClassType = employeeNavigatorGateway.GetJobClassType(employeeId); string newCategory = employeeNavigatorGateway.GetCategory(employeeId); string newPersonalAgencyName = employeeNavigatorGateway.GetPersonalAgencyName(employeeId); bool newIsVacationsManager = employeeNavigatorGateway.GetIsVacationsManager(employeeId); bool newApproveTimesheets = employeeNavigatorGateway.GetApproveTimesheets(employeeId); string crew = ""; if (!row.IsCrewNull()) crew = row.Crew;//TODO CREW Employee employee = new Employee(null); employee.UpdateDirect(employeeId, originalLoginId, originalContactsId, originalFullName, originalFirstName, originalMiddleInitial, originalLastName, originalType, originalState, originalIsSalesman, originalRequestProjectTime, originalDeleted, originalSalaried, originalEMail, originalAssignableSrs, originalJobClassType, originalCategory, originalPersonalAgencyName, originalIsVacationsManager, originalApproveTimesheets, originalBourdenFactor, originalUSHealthBenefitFactor, originalStandardBenefitFactorCad, originalStandardBenefitFactorUsd, crew, newFullName, newFirstName, newMiddleInitial, newLastName, newType, newState, newIsSalesman, newRequestProjectTime, originalDeleted, newSalaried, newEMail, newAssignableSrs, newJobClassType, newCategory, newPersonalAgencyName, newIsVacationsManager, newApproveTimesheets, originalBourdenFactor, originalUSHealthBenefitFactor, originalStandardBenefitFactorCad, originalStandardBenefitFactorUsd, crew); } // Deleted employees if ((row.Deleted) && (row.InDatabase)) { Employee employee = new Employee(null); employee.DeleteDirect(row.EmployeeID); } } } } }