/// <summary> /// Call every time when user click on Save Details button. /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs</param> protected void btnSaveDetails_Click(object sender, EventArgs e) { //create Provider Data Access object ProviderDataAccess oProviderDataAccess = new ProviderDataAccess(); //Check for existence for Email address Provider1 oProvider = oProviderDataAccess.GetbyEmail(txtEmail.Text); //now check weather it is in edit provider mode if (Request.QueryString[LACESConstant.QueryString.PROVIDER_ID] != null) { //get the provider id from query string long providerID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.PROVIDER_ID]); //check weather it is the same person if (oProvider != null && oProvider.ID == providerID) { oProvider = null; } } if (oProvider == null) { // The email is not already used, means the current provider can use the email Provider1 currentProvider = new Provider1(); currentProvider.Organization = txtOrganization.Text.Trim(); currentProvider.StreetAddress = txtStreetAddress.Text.Trim(); currentProvider.City = txtCity.Text.Trim(); currentProvider.State = drpState.SelectedValue.Trim(); currentProvider.Zip = txtZip.Text.Trim(); currentProvider.Country = txtCountry.Text.Trim(); currentProvider.Phone = txtPhone.Text.Trim(); currentProvider.Fax = txtFax.Text.Trim(); currentProvider.Website = txtWebsite.Text.Trim(); currentProvider.IndividualsName = txtIndName.Text.Trim(); currentProvider.IndividualsPosition = txtIndPosition.Text.Trim(); currentProvider.IndividualsPhone = txtIndPhone.Text.Trim(); currentProvider.IndividualsFax = txtIndFax.Text.Trim(); currentProvider.IndividualsEmail = txtEmail.Text.Trim(); //set the password fields txtPassword.Attributes.Add("value", txtPassword.Text); txtPasswordConfirm.Attributes.Add("value", txtPasswordConfirm.Text); //Encode the password before saving the provider details information currentProvider.IndividualsPassword = LACESUtilities.Encrypt(txtPassword.Text); //set the provider status currentProvider.Status = radStatus.SelectedValue; //now check weather it is in edit provider mode if (Request.QueryString[LACESConstant.QueryString.PROVIDER_ID] != null) { //get the provider id from query string long providerID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.PROVIDER_ID]); currentProvider.ID = providerID; if (oProviderDataAccess.Update(currentProvider) == null) { lblMsg.Text = "Cannot save data."; lblMsg.ForeColor = System.Drawing.Color.Red; } else { //data saved successfully so prepare and send mail to the respective provider if (SendMailToProvider(true)) { //send mail successfull lblMsg.Text = "Contact information updated successfully and email sent to the contact."; lblMsg.ForeColor = System.Drawing.Color.Green; } else { //send mail error lblMsg.Text = "Contact information updated successfully and email sent to the contact."; lblMsg.ForeColor = System.Drawing.Color.Green; } } } else //it is in add provider mode, so add a new provider { //all thing ok, so store provider into the DB if (oProviderDataAccess.Add(currentProvider) == null) { lblMsg.Text = "Cannot save data."; lblMsg.ForeColor = System.Drawing.Color.Red; } else { //data add successfully so prepare and send mail to the respective provider if (SendMailToProvider(false)) { //send mail successfull lblMsg.Text = "Contact information added successfully and email sent to the contact."; lblMsg.ForeColor = System.Drawing.Color.Green; } else { //send mail error lblMsg.Text = "Contact information added successfully and email sent to the contact."; lblMsg.ForeColor = System.Drawing.Color.Green; } clearForm(); } } } else { //The email is already used, so not allowed lblMsg.Text = "Email already exists. Please provide another email."; lblMsg.ForeColor = System.Drawing.Color.Red; txtEmail.Focus(); } }
/// <summary> /// Call every time when user click on 'Save Details' button. /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs</param> protected void btnSaveDetails_Click(object sender, EventArgs e) { //create Provider Data Access object ProviderDataAccess oProviderDataAccess = new ProviderDataAccess(); //Check for existence for Email address Provider1 oProvider = oProviderDataAccess.GetbyEmail(txtEmail.Text); //now check weather it is in edit provider mode if (Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER] != null) { //get the provider from session Provider1 currentProvider = (Provider1)Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER]; // Get provider information from Session //check weather it is the same person if (oProvider != null && oProvider.ID == currentProvider.ID) { oProvider = null; } } if (oProvider == null) { // The email is not already used, means the current provider can use the email Provider1 currentProvider = new Provider1(); currentProvider.Organization = txtOrganization.Text.Trim(); currentProvider.StreetAddress = txtStreetAddress.Text.Trim(); currentProvider.City = txtCity.Text.Trim(); currentProvider.State = drpState.SelectedValue.Trim(); currentProvider.Zip = txtZip.Text.Trim(); currentProvider.Country = txtCountry.Text.Trim(); currentProvider.Phone = txtPhone.Text.Trim(); currentProvider.Fax = txtFax.Text.Trim(); currentProvider.Website = txtWebsite.Text.Trim(); currentProvider.IndividualsName = txtIndName.Text.Trim(); currentProvider.IndividualsPosition = txtIndPosition.Text.Trim(); currentProvider.IndividualsPhone = txtIndPhone.Text.Trim(); currentProvider.IndividualsFax = txtIndFax.Text.Trim(); currentProvider.IndividualsEmail = txtEmail.Text.Trim(); //set the password fields txtPassword.Attributes.Add("value", txtPassword.Text); txtPasswordConfirm.Attributes.Add("value", txtPasswordConfirm.Text); //Encode the password before saving the provider details information currentProvider.IndividualsPassword = LACESUtilities.Encrypt(txtPassword.Text); //set the provider status //currentProvider.Status = "Y"; //now check session variable if (Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER] != null) { //get the provider id from query string long providerID = ((Provider1)Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER]).ID; currentProvider.ID = providerID; currentProvider = oProviderDataAccess.Update(currentProvider); if (currentProvider == null) { lblMsg.Text = "Cannot save data."; lblMsg.ForeColor = System.Drawing.Color.Red; } else { //send mail successfull lblMsg.Text = "Contact information updated successfully."; lblMsg.ForeColor = System.Drawing.Color.Green; //update the current provider information in the session Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER] = currentProvider; //populate provider updated information from session populateProviderInformation(); } } } else { //The email is already used, so not allowed lblMsg.Text = "Email already exists. Please provide another email."; lblMsg.ForeColor = System.Drawing.Color.Red; txtEmail.Focus(); } }