}//end Button_Click #endregion #region "Methods" public void PopulateUserControlsFromSession() { try { //Get installation from session Installation i = WebUtils.GetInstallationObjectFromSession(); //services List<string> servNames = InstallationBLL.GetServiceDetailsFull(i); this.ServiceSelectionUserControl.PopulateServices(servNames); //Staff List<string> staffNames = InstallationBLL.GetStaff1stNameWithTitle(i); this.StaffSelectionUserControl.PopulateStaff(staffNames); //date&time DateTime todaysDate = this.DateSelectionUserControl.GetSelectedDate(); System.Diagnostics.Debug.Print("CALENDAR TIME: " + todaysDate.TimeOfDay.ToString() + "ON todays date: " + todaysDate.ToString()); //ALWAYS pick 1st staff by default EmployeeBLL selStaff = i.Employees[0];//staff can be null PopulateDateAndTimeUserControl(selStaff, todaysDate); //End-user Details //DO nothing start with empty fields //Payment } catch (Exception ex) { System.Diagnostics.Debug.Print("<h2>BookAppt.aspx, PopulateUserControlsFromSession Method</h2>\n" + ex.ToString() + "\n" + ex.InnerException + "\n" + ex.Message); // Log the exception and notify system operators ExceptionUtility.LogException(ex, "BookAppt.aspx, PopulateUserControlsFromSession Method"); ExceptionUtility.NotifySystemOps(ex); }//end catch }//end void
}//end void private void UpdateInstallationObject(bool isService = false, bool isStaff = false, bool isDateAndTime = false, bool isUserInfo = false, bool isPayment = false, bool isConfirmation = false) { try { //get installation and current appt from session Installation i = WebUtils.GetInstallationObjectFromSession(); ApptBLL currAppt = SessionVariables.CURRENT_APPOINTMENT; if (currAppt == null) currAppt = new ApptBLL(); //R SaveInstallationToDB (test installation isnt save to DB) //get selected service details if (isService) {//1 int servSel = this.ServiceSelectionUserControl.GetSelectedServiceIndex(); int? servID = i.Services[servSel].ID; currAppt.serviceID = (int)servID; } //get selected employee details if (isStaff) {//2 int staffSel_index = this.StaffSelectionUserControl.GetSelectedServiceIndex(); string staffSel_1stnameWithTitle = this.StaffSelectionUserControl.GetStaffelected(); EmployeeBLL selStaff = null; //NB index 0 = "No Preference" if (staffSel_index > 0) { selStaff = i.Employees[staffSel_index - 1]; currAppt.provider = staffSel_1stnameWithTitle; //update date&time control == staff calendar PopulateDateAndTimeUserControl(selStaff, this.DateSelectionUserControl.GetSelectedDate()); } else { //ALWAYS pick 1st staff by default selStaff = i.Employees[0];//staff can be null currAppt.provider = selStaff.title + " " + selStaff.firstName; } //update LabelServProvider //-- IMPORTANT LABEL USED ON UPDATE_INSTALLATION() this.LabelServProvider.Text = selStaff.firstName; //R PopulateDateAndTimeUserControl(selStaff, ) }//endif isStaff //get selected Date&Time details if (isDateAndTime) {//3 // get user entries from userControl string userSelDate = this.DateSelectionUserControl.GetSelectedDateStrg(); string userSelTime = this.DateSelectionUserControl.GetSelectedTimeStrg(); //convert entries into correct datat type DateTime userDate = (DateTime)Utils.GetDateFromString(userSelDate); TimeSpan userTime = (TimeSpan)Utils.GetTimeFromString(userSelTime); //assign entries to current appt in the session currAppt.date = userDate; currAppt.time = userTime; System.Diagnostics.Debug.Print(currAppt.provider); } //get entered userInformation details if (isUserInfo) { //get user entries from user control List<string> userPersoDet = this.UserInfoUserControl.GetPersonalDetails(); //NB added programmatically END-USER username is their email address. //add ASP.NETUSER, If it already exists return aspnetID Guid endUserASPUserID = WebUtils.AddEndUserASPNETUser(userPersoDet[2], userPersoDet[1], userPersoDet[3]); //check user exists of DB/session 20/716 revise? int userIndex = i.EndUsers.FindIndex(endUser => endUser.aspnetUserID.ToString().Equals(endUserASPUserID.ToString(), StringComparison.Ordinal)); //create new if (userIndex < 0) { //create new end-user contact Details ContactDetailsBLL newEndUserContact = new ContactDetailsBLL(userPersoDet[5], userPersoDet[6], userPersoDet[7], "UK", null, userPersoDet[4], userPersoDet[3]); //create new end-user EndUserBLL newEndUser = new EndUserBLL(userPersoDet[0], userPersoDet[1], userPersoDet[2], newEndUserContact, endUserASPUserID); //add to installation i.EndUsers.Add(newEndUser); } //add notes to current appt (userID is added on SaveInstallationToDB2) currAppt.notes = userPersoDet[8]; } if (isPayment) { // } if (isConfirmation) { //----- Add appt to installation on session ------ i.Appointments.Add(currAppt); string curSelStaff1stName = this.LabelServProvider.Text; //----- process data and save to database ------ InstallationBLL.SaveInstallationToDB2(ref i, ref currAppt, curSelStaff1stName, SessionVariables.TempStaffFolder, SessionVariables.ISummaryXML); } //save current appt back to session installation and current appt from session SessionVariables.CURRENT_APPOINTMENT = currAppt; //add installation back to session WebUtils.PutInstallationObjectinSession(i); } catch (Exception ex) { System.Diagnostics.Debug.Print("<h2>BookAppt.aspx, UpdateInstallationObject(x6)</h2>\n" + ex.ToString() + "\n" + ex.InnerException + "\n" + ex.Message); // Log the exception and notify system operators ExceptionUtility.LogException(ex, "BookAppt.aspx, UpdateInstallationObject(x6)"); ExceptionUtility.NotifySystemOps(ex); } }//end UpdateInstallationObject(x6)
}//end ResetWarning private void PolulateInstallation(bool isAspNetDet = false, bool isPersDet = false, bool isBusDet = false, bool isBusHrs = false, bool isEmployee = false, bool isService = false, bool isComplete = false) { try { //get isntallation from session Installation i = WebUtils.GetInstallationObjectFromSession(); //udpate Company details if (isBusDet) { var _with2 = i.Company; _with2.domain = this.businessDetails[0]; _with2.industry = this.businessDetails[1]; _with2.natureOfBusiness = (int)Utils.GetNumberInt(this.businessDetails[2]); _with2.businessAddress.landline = this.businessDetails[3]; } //update client details (main company contact CLIENT) if (isPersDet) { var _with1 = i.Company.mainClientContact; _with1.title = this.personalDetails[0]; _with1.firstName = this.personalDetails[1]; _with1.lastName = this.personalDetails[2]; _with1.role = (byte)RolesEnum.CLIENT; } //client ASP.NET USER ID if (isAspNetDet) { var _with21 = i.Company.mainClientContact; _with21.aspnetUserID = this.aspUserID; //client Contact Details var _with11 = _with21.contactDetail; _with11.email = this.email; _with11.dateCreated = i.Timestamp; _with11.dateUpdated = i.Timestamp; } if (isBusHrs) { var _with22 = i.Company; _with22.OpeningTime = this.openHrs; _with22.ClosingTime = this.closeHrs; _with22.OpeningDays = this.openDays; } if (isEmployee) { //Employees Guid tempStaffASPUserID = new Guid(); var _with3 = i.Employees; //loop through all employees added for (int j = 0; j < this.staff1stName.Count; j++) { //add ASP.NET USER and get ASP.NET USER ID tempStaffASPUserID = WebUtils.AddEmployeeASPNETUser(this.staffLastName[j], this.staff1stName[j], this.staffEmail[j]); //add to installation Employee _with3.Add(new EmployeeBLL(this.staffTitles[j], this.staff1stName[j], this.staffLastName[j], this.staffEmail[j], tempStaffASPUserID)); } //add Staff email to Installation ProviderBLL i.ServicesProvidedByStaff.staffEmails = this.staffEmail; }//endif isEmployees if (isService) { //services var _with4 = i.Services; //loop through all employees added for (int k = 0; k < this.serviceName.Count; k++) { //create new service ServicesBLL serv = new ServicesBLL(); serv.name = this.serviceName[k]; serv.duration = (byte)Utils.GetNumberShort(this.serviceDuration[k]); serv.price = (decimal)Utils.GetNumberDouble(this.servicePrice[k]); //add to installation service _with4.Add(serv); } //services Provided By Staff var _with5 = i.ServicesProvidedByStaff; _with5.serviceNames = this.serviceName; _with5.staffPerfServiceNames = this.serviceStaff; } if (!isComplete) //add installation back to session WebUtils.PutInstallationObjectinSession(i); if (isComplete) { //process data and save to database InstallationBLL.SaveInstallationToDB(ref i, SessionVariables.ISummaryXML); SessionVariables.CompanyID = i.Company.ID; } } catch (Exception ex) { System.Diagnostics.Debug.Print("<h2>Register.aspx, PolulateInstallation(x6)</h2>\n" + ex.ToString() + "\n" + ex.InnerException + "\n" + ex.Message); // Log the exception and notify system operators ExceptionUtility.LogException(ex, "Register.aspx, PolulateInstallation(x6)"); ExceptionUtility.NotifySystemOps(ex); } }//end PolulateInstallation(x6)