public bool UpdateTravelAdvanceAmount(int userID, BaseForm webForm) { log.WriteLogEntry("Begin UpdateTravelAuthForm..."); bool result = false; string[,] formFields = new string[0, 0]; string[,] formFilters = new string[0, 0]; if (webForm.GetType() == typeof(TravelAuthForm)) { TravelAuthForm travelForm = (TravelAuthForm)webForm; // Build field and filter list to update SQL try { formFields = new string[, ] { { "advance_amt", travelForm.AdvanceAmount.ToString() }, { "advance_status", Constants.PendingValue.ToString() }, { "advance_date", DateTime.Now.ToString() }, { "close_status", Constants.PendingValue.ToString() }, { "close_date", DateTime.Now.ToString() } }; formFilters = new string[, ] { { "submitter_id", userID.ToString() }, { "form_id", travelForm.FormDataID.ToString() } }; } catch (Exception ex) { log.WriteLogEntry("ERROR building SQL field and filter arrays!\n" + ex.Message); return(result); } log.WriteLogEntry("Starting FormDataHandler..."); FormDataHandler formData = new FormDataHandler(dbServer, dbName); if (formData.UpdateTravelForm(formFields, formFilters) > 0) { result = true; } else { log.WriteLogEntry("FAILED No records updated!"); } } else { log.WriteLogEntry("FAILED submitted form is not a travel authorization form!"); } log.WriteLogEntry("End UpdateTravelAuthForm."); return(result); }
public bool HandleFinanceAction(int commandID, BaseForm webForm) { log.WriteLogEntry("Begin HandleFinanceAction..."); bool result = false; string[,] formFields = new string[0, 0]; string[,] formFilters = new string[0, 0]; if (webForm.GetType() == typeof(TravelAuthForm)) { TravelAuthForm travel = (TravelAuthForm)webForm; switch (commandID) { case 0: // Approve Advance { log.WriteLogEntry("Approve advance."); try { formFields = new string[, ] { { "advance_status", Constants.ApprovedValue.ToString() }, { "advance_date", DateTime.Now.ToString() } }; formFilters = new string[, ] { { "form_id", travel.FormDataID.ToString() } }; } catch (Exception ex) { log.WriteLogEntry("ERROR building SQL field and filter arrays!\n" + ex.Message); return(result); } break; } case 1: // Approve Recap { log.WriteLogEntry("Approve recap."); try { formFields = new string[, ] { { "recap_status", Constants.ApprovedValue.ToString() }, { "recap_date", DateTime.Now.ToString() }, { "close_status", Constants.ApprovedValue.ToString() }, { "close_date", DateTime.Now.ToString() } }; formFilters = new string[, ] { { "form_id", travel.FormDataID.ToString() } }; } catch (Exception ex) { log.WriteLogEntry("ERROR building SQL field and filter arrays!\n" + ex.Message); return(result); } break; } case 2: // Deny Advance { log.WriteLogEntry("Deny advance."); try { formFields = new string[, ] { { "advance_status", Constants.DeniedValue.ToString() }, { "advance_date", DateTime.Now.ToString() } }; formFilters = new string[, ] { { "form_id", travel.FormDataID.ToString() } }; } catch (Exception ex) { log.WriteLogEntry("ERROR building SQL field and filter arrays!\n" + ex.Message); return(result); } break; } case 3: // Deny Recap { log.WriteLogEntry("Deny recap."); try { formFields = new string[, ] { { "recap_status", Constants.DeniedValue.ToString() }, { "recap_date", DateTime.Now.ToString() } }; formFilters = new string[, ] { { "form_id", travel.FormDataID.ToString() } }; } catch (Exception ex) { log.WriteLogEntry("ERROR building SQL field and filter arrays!\n" + ex.Message); return(result); } break; } default: { log.WriteLogEntry("Fell through switch. No action taken."); return(result); } } log.WriteLogEntry("Starting FormDataHandler..."); FormDataHandler formData = new FormDataHandler(dbServer, dbName); if (formData.UpdateTravelForm(formFields, formFilters) > 0) { result = true; } else { log.WriteLogEntry("FAILED No records updated!"); } } else { log.WriteLogEntry("FAILED not a travel form!"); } log.WriteLogEntry("End HandleFinanceAction."); return(result); }
public bool ApproveTravelAuthForm(int userID, BaseForm webForm) { log.WriteLogEntry("Begin ApproveTravelAuthForm..."); bool result = false; string[,] formFields = new string[0, 0]; string[,] formFilters = new string[0, 0]; if (webForm.GetType() == typeof(TravelAuthForm)) { TravelAuthForm travelForm = (TravelAuthForm)webForm; log.WriteLogEntry(string.Format("User {0} is approving form {1}.", userID, travelForm.FormDataID)); if (userID == int.Parse(travelForm.GMID)) { if (travelForm.GMApproval == Constants.DeniedColor) { travelForm.ApprovalStatus = Constants.DeniedColor; } else { travelForm.GMApproval = Constants.ApprovedColor; travelForm.ApprovalStatus = Constants.ApprovedColor; } // Build field and filter list to update SQL try { formFields = new string[, ] { { "manager_approval_date", DateTime.Now.ToString() }, { "manager_approval_status", GetStatusValue(travelForm.GMApproval).ToString() }, { "approval_date", DateTime.Now.ToString() }, { "approval_status", GetStatusValue(travelForm.ApprovalStatus).ToString() } }; formFilters = new string[, ] { { "manager_id", userID.ToString() }, { "form_id", travelForm.FormDataID.ToString() } }; } catch (Exception ex) { log.WriteLogEntry("ERROR building SQL field and filter arrays!\n" + ex.Message); return(result); } } else if (userID == int.Parse(travelForm.DHID)) { if (travelForm.DHApproval == Constants.DeniedColor) { travelForm.ApprovalStatus = Constants.DeniedColor; } else { travelForm.DHApproval = Constants.ApprovedColor; } // Build field and filter list to update SQL try { formFields = new string[, ] { { "supervisor_approval_date", DateTime.Now.ToString() }, { "supervisor_approval_status", GetStatusValue(travelForm.DHApproval).ToString() } }; formFilters = new string[, ] { { "supervisor_id", userID.ToString() }, { "form_id", travelForm.FormDataID.ToString() } }; } catch (Exception ex) { log.WriteLogEntry("ERROR building SQL field and filter arrays!\n" + ex.Message); return(result); } } log.WriteLogEntry("Starting FormDataHandler..."); FormDataHandler formData = new FormDataHandler(dbServer, dbName); if (formData.UpdateTravelForm(formFields, formFilters) > 0) { result = true; } else { log.WriteLogEntry("FAILED No records updated!"); } } else { log.WriteLogEntry("FAILED not a travel form!"); } log.WriteLogEntry("End ApproveTravelAuthForm."); return(result); }
public bool SubmitTravelRecapForm(int userID, BaseForm webForm) { log.WriteLogEntry("Begin SubmitTravelRecapForm..."); bool result = false; if (webForm.GetType() == typeof(TravelAuthForm)) { TravelAuthForm travelForm = (TravelAuthForm)webForm; log.WriteLogEntry(string.Format("User {0} is recapping form {1}.", userID, travelForm.FormDataID)); decimal registrationAmt = 0, airfareAmt = 0, rentalAmt = 0, fuelAmt = 0, parkingAmt = 0, mileageAmt = 0, lodgingAmt = 0, perdiemAmt = 0, miscAmt = 0, totalAmt = 0, reimburseAmt = 0; int miles = 0, travelDays = 0, fullDays = 0; string[,] formFields = new string[0, 0]; string[,] formFilters = new string[0, 0]; // Check field values for correct data type try { log.WriteLogEntry("Registration Cost: " + travelForm.RecapRegistrationCost); registrationAmt = decimal.Parse(travelForm.RecapRegistrationCost); log.WriteLogEntry("Airfare: " + travelForm.RecapAirfare); airfareAmt = decimal.Parse(travelForm.RecapAirfare); log.WriteLogEntry("RentalCar: " + travelForm.RecapRentalCar); rentalAmt = decimal.Parse(travelForm.RecapRentalCar); log.WriteLogEntry("Fuel: " + travelForm.RecapFuel); fuelAmt = decimal.Parse(travelForm.RecapFuel); log.WriteLogEntry("Parking: " + travelForm.RecapParkingTolls); parkingAmt = decimal.Parse(travelForm.RecapParkingTolls); log.WriteLogEntry("Miles Driven: " + travelForm.RecapMileage); miles = int.Parse(travelForm.RecapMileage); log.WriteLogEntry("Mileage Reimbursement: " + travelForm.RecapMileageAmount); mileageAmt = int.Parse(travelForm.RecapMileageAmount); log.WriteLogEntry("Lodging: " + travelForm.RecapLodging); lodgingAmt = decimal.Parse(travelForm.RecapLodging); log.WriteLogEntry("PerDiem: " + travelForm.RecapPerDiem); perdiemAmt = decimal.Parse(travelForm.RecapPerDiem); log.WriteLogEntry("Travel Days: " + travelForm.RecapTravelDays); travelDays = int.Parse(travelForm.RecapTravelDays); log.WriteLogEntry("Full Days: " + travelForm.RecapFullDays); fullDays = int.Parse(travelForm.RecapFullDays); log.WriteLogEntry("Misc: " + travelForm.RecapMisc); miscAmt = decimal.Parse(travelForm.RecapMisc); log.WriteLogEntry("Total Recap: " + travelForm.TotalRecap); totalAmt = decimal.Parse(travelForm.TotalRecap); log.WriteLogEntry("Total Reimbursement: " + travelForm.TotalReimburse); reimburseAmt = decimal.Parse(travelForm.TotalReimburse, System.Globalization.NumberStyles.AllowLeadingSign | System.Globalization.NumberStyles.AllowDecimalPoint); } catch (Exception ex) { log.WriteLogEntry("ERROR in form data conversion!\n" + ex.Message); return(result); } // Build field and filter list to update SQL try { formFields = new string[, ] { { "recap_registration_amt", registrationAmt.ToString() }, { "recap_airfare_amt", airfareAmt.ToString() }, { "recap_rental_amt", rentalAmt.ToString() }, { "recap_fuel_amt", fuelAmt.ToString() }, { "recap_parking_amt", parkingAmt.ToString() }, { "recap_miles", miles.ToString() }, { "recap_mileage_amt", mileageAmt.ToString() }, { "recap_lodging_amt", lodgingAmt.ToString() }, { "recap_perdiem_amt", perdiemAmt.ToString() }, { "recap_travel_days", travelDays.ToString() }, { "recap_full_days", fullDays.ToString() }, { "recap_misc_amt", miscAmt.ToString() }, { "misc_description", travelForm.MiscExplain }, { "recap_total_amt", totalAmt.ToString() }, { "reimburse_amt", reimburseAmt.ToString() }, { "recap_date", DateTime.Now.ToString() }, { "recap_status", Constants.PendingValue.ToString() } }; formFilters = new string[, ] { { "submitter_id", userID.ToString() }, { "form_id", travelForm.FormDataID.ToString() } }; } catch (Exception ex) { log.WriteLogEntry("ERROR building SQL field and filter arrays!\n" + ex.Message); return(result); } log.WriteLogEntry("Starting FormDataHandler..."); FormDataHandler formData = new FormDataHandler(dbServer, dbName); if (formData.UpdateTravelForm(formFields, formFilters) > 0) { result = true; } else { log.WriteLogEntry("FAILED No records updated!"); } } else { log.WriteLogEntry("FAILED submitted form is not a travel authorization form!"); } log.WriteLogEntry("End SubmitTravelRecapForm."); return(result); }