private void Set_Page_FormControls_Values() { // get the user Details int User_Id = int.Parse(this.Request.QueryString["id"]); int user_Id_User_Owner = base.Authenticated_User_ID; TimeLineDashboard.Shared.Models.Users userDetails = Business_Logic_Layer_Facade.Instance.Users_Get_Details_By_User_Id( User_Id, base.Authenticated_User_ID, base.Authenticated_Permission_Type); if (userDetails != null) { this.textbox_Username.Text = userDetails.Username; this.label_Username.Text = userDetails.Username; Common_Tools.Set_ComboBox_Selected_Value_And_Label_Text( userDetails.App_Permission_Type_Id.ToString(), this.dropdown_App_Permission_Type, this.label_App_Permission_Type); this.textbox_First_Name.Text = userDetails.First_Name; this.label_First_Name.Text = userDetails.First_Name; this.textbox_Middle_Name.Text = userDetails.Middle_Name; this.label_Middle_Name.Text = userDetails.Middle_Name; this.textbox_Last_Name.Text = userDetails.Last_Name; this.label_Last_Name.Text = userDetails.Last_Name; this.textbox_Email.Text = userDetails.Email; this.label_Email.Text = userDetails.Email; this.dropdown_Country.SelectedValue = userDetails.Country_Id.ToString(); this.label_Country.Text = Business_Logic_Layer_Facade.Instance.Countries_Get_By_Country_Id(userDetails.Country_Id).Country_English_Name; this.Bind_States_ComboBox(); if (userDetails.State_Id > 0) { dropdown_State.SelectedValue = userDetails.State_Id.ToString(); this.label_State.Text = Business_Logic_Layer_Facade.Instance.States_Get_By_State_Id(userDetails.State_Id).State_Name; } this.textbox_City.Text = userDetails.City; this.label_City.Text = userDetails.City; this.textbox_Address.Text = userDetails.Address; this.label_Address.Text = userDetails.Address; this.textbox_Zipcode.Text = userDetails.ZipCode; this.label_Zipcode.Text = userDetails.ZipCode; if (userDetails.Default_Currency_Id.HasValue) { this.dropdown_Currency.SelectedValue = userDetails.Default_Currency_Id.Value.ToString(); this.label_Currency.Text = Business_Logic_Layer_Facade.Instance.Currencies_Get_By_Id(userDetails.Default_Currency_Id.Value).Formatted_Currency_Display_For_Selection; } this.textbox_Mobile_Phone.Text = userDetails.Mobile_Phone; this.label_Mobile_Phone.Text = userDetails.Mobile_Phone; this.textbox_Additional_Phone_Number.Text = userDetails.Additional_Phone_Number; this.label_Additional_Phone_Number.Text = userDetails.Additional_Phone_Number; Common_Tools.Set_DateTime_To_TextBox_And_Label( userDetails.Birth_Date, this.textbox_Birth_Date, this.label_Birth_Date); Common_Tools.Set_ComboBox_Selected_Value_And_Label_Text( userDetails.Gender.ToString(), this.dropdown_Gender, this.label_Gender); Common_Tools.Set_DateTime_To_ComboBoxes_And_Label( userDetails.Registration_DateTime_UTC, this.textbox_Registration_DateTime, this.label_Registration_DateTime, this.dropdown_Registration_Time_Hours, this.dropdown_Registration_Time_Minutes, this.dropdown_Registration_Time_Seconds, this.label_Registration_Time); this.textbox_Azure_Container_Ref.Text = userDetails.Azure_Container_Ref; this.label_Azure_Container_Ref.Text = userDetails.Azure_Container_Ref; this.textbox_Heard_About_Application_From.Text = userDetails.Heard_About_Application_From; this.label_Heard_About_Application_From.Text = userDetails.Heard_About_Application_From; this.textbox_Our_Administrative_Side_Notes.Text = userDetails.Our_Administrative_Side_Notes; this.label_Our_Administrative_Side_Notes.Text = userDetails.Our_Administrative_Side_Notes; this.checkbox_Is_Active.Checked = userDetails.Is_Active; this.label_Is_Active.Text = userDetails.Is_Active ? "Yes" : "No"; this.label_Record_Created_By_User.Text = userDetails.Record_Created_By_User_Details.FullName_With_Email; this.label_Record_Creation_DateTime_UTC.Text = userDetails.Record_Creation_DateTime_UTC.ToString("dd/MM/yyyy HH:mm:ss UTC"); this.label_Record_Last_Updated_By_User.Text = userDetails.Record_Last_Updated_By_User_Details.FullName_With_Email.ToString(); this.label_Record_Last_Updated_DateTime_UTC.Text = userDetails.Record_Last_Updated_DateTime_UTC.ToString("dd/MM/yyyy HH:mm:ss UTC"); } }
protected void button_Create_User_Click(object sender, EventArgs e) { if (this.Page.IsValid) { bool l_User_Successfully_Created = false; int l_New_User_Id = 0; string exception_During_Process = ""; string exception_During_Process_Extra_Data = ""; string p_Username = this.textbox_Username.Text; string p_Password = this.textbox_Password.Text; byte p_App_Permission_Type_Id = byte.Parse(this.dropdown_App_Permission_Type.SelectedValue); string p_First_Name = this.textbox_First_Name.Text; string p_Middle_Name = this.textbox_Middle_Name.Text; string p_Last_Name = this.textbox_Last_Name.Text; string p_Email = this.textbox_Email_Address.Text; short p_Country_Id = short.Parse(this.dropdown_Country.SelectedValue); short?p_State_Id = new short?(); if (this.dropdown_State.Items.Count > 0) { p_State_Id = short.Parse(this.dropdown_State.SelectedValue); } string p_City = this.textbox_City.Text; string p_Address = this.textbox_Address.Text; string p_ZipCode = this.textbox_Zipcode.Text; byte?p_Default_Currency_Id = new byte?(); if (!string.IsNullOrEmpty(this.dropdown_Currency.SelectedValue)) { p_Default_Currency_Id = byte.Parse(this.dropdown_Currency.SelectedValue); } string p_Mobile_Phone = this.textbox_Mobile_Phone.Text; string p_Additional_Phone_Number = this.textbox_Mobile_Phone.Text; DateTime p_BirthDate; bool BirthDate_Parsed_Successfully = DateTime.TryParseExact(this.textbox_Birth_Date.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out p_BirthDate); if (BirthDate_Parsed_Successfully) { byte p_Gender = byte.Parse(this.dropdown_Gender.SelectedValue); string p_Heard_About_Application_From = this.textbox_Heard_About_Application_From.Text; string p_Our_Administrative_Side_Notes = this.textbox_Administrative_Side_Notes.Text; int p_Logged_In_Authenticated_User_Id = base.Authenticated_User_ID; // ToDo -- Make sure the permission type of the authenticated user that is trying to create a user is appropriate. TimeLineDashboard.Shared.Models.Users new_User_Details = null; try { new_User_Details = Business_Logic_Layer_Facade.Instance.Users_Insert_New_User_Administrative_Registration_Process( p_Username, p_Password, p_App_Permission_Type_Id, p_First_Name, p_Middle_Name, p_Last_Name, p_Email, p_Country_Id, p_State_Id, p_City, p_Address, p_ZipCode, p_Default_Currency_Id, p_Mobile_Phone, p_Additional_Phone_Number, p_BirthDate, p_Gender, p_Heard_About_Application_From, p_Our_Administrative_Side_Notes, p_Logged_In_Authenticated_User_Id ); l_New_User_Id = new_User_Details.User_Id; l_User_Successfully_Created = true; } catch (Exception exc) { exception_During_Process = exc.Message; if (exc.InnerException != null) { exception_During_Process_Extra_Data = exc.InnerException.Message; } } } else { exception_During_Process = "Wrong date format for birth date. Registration process aborted"; } if (l_User_Successfully_Created && l_New_User_Id > 0) { // The user details was successfully created.. // Show success message and redirect the user to view page or back to users page (depends on where the user came from) Response.Redirect("list_Users.aspx"); } else { // show error message to the user for the failed process this.lbl_Insert_Process_Error_Result.Text = exception_During_Process; if (!string.IsNullOrEmpty(exception_During_Process_Extra_Data)) { this.lbl_Insert_Process_Error_Result.Text += " (" + exception_During_Process_Extra_Data + ")"; } } } }