public static string GetPatientId(int npassedPatientId) { string userid = string.Empty; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); DBHandler dbHandler = new DBHandler(1); SqlParameter dbparamPatientId = new SqlParameter("@PatientId", System.Data.SqlDbType.Int); dbparamPatientId.Value = npassedPatientId; dbParamCollection.Add(dbparamPatientId); //USERDETAILS_SELECT Object objResult = dbHandler.ExecuteScalar(Constants.SP_GET_PATIENT_USERID, dbParamCollection); if (objResult != null) { userid = objResult.ToString(); } } catch (Exception ex) { YelpTrace.Write(ex); } return(userid); }
public static string GetXMLEmailTemplate() { string xmlDataFolder = string.Empty; string emailTeampletFileName = string.Empty; try { xmlDataFolder = ConfigurationManager.AppSettings["XMLDATAFOLDERNAME"]; } catch (Exception ex) { xmlDataFolder = ""; YelpTrace.Write(ex); } try { emailTeampletFileName = ConfigurationManager.AppSettings["XML_EMAIL_TEMPLATE_FILE"]; } catch (Exception ex) { emailTeampletFileName = "EmailTemplates.xml"; YelpTrace.Write(ex); } return(xmlDataFolder + emailTeampletFileName); }
public static DataSet GetRoles() { DataSet resultSet = null; DBHandler dbHandler = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //USERDETAILS_SELECT dbHandler = new DBHandler(1); resultSet = dbHandler.ExecuteReader(Constants.SP_BusinessRole_S, dbParamCollection); } catch (Exception ex) { YelpTrace.Write(ex); } finally { //if (dbHelper != null) // dbHelper.Close(); } return(resultSet); }
private void GetUsers() { try { int businessDetailId; Int32.TryParse(hdnBusinessDetailsID.Value, out businessDetailId); DataTable searchDataTable = Utility.GetUsers(businessDetailId); int recordsFound = 0; if (searchDataTable != null) { recordsFound = searchDataTable.Rows.Count; if (recordsFound >= 3) { btnAddUser.Enabled = false; } gridUserList.DataSource = searchDataTable; gridUserList.DataBind(); gridUserList.Visible = true; } } catch (Exception ex) { YelpTrace.Write(ex); } }
public static string GetImageFolder() { string serverFolderPath = string.Empty; string imageFolderName = string.Empty; try { serverFolderPath = ConfigurationManager.AppSettings["ServerPath"]; } catch (Exception ex) { serverFolderPath = ""; YelpTrace.Write(ex); } try { imageFolderName = ConfigurationManager.AppSettings["ImageFolder"]; } catch (Exception ex) { serverFolderPath = "ClientImages"; YelpTrace.Write(ex); } return(serverFolderPath + imageFolderName); }
public static string GetTTTypeName(short ttTypeid) { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); string treatementName = string.Empty; DBHandler dbHandler = null; try { //Userid SqlParameter dbparamttType = new SqlParameter("@ttType", System.Data.SqlDbType.SmallInt); dbparamttType.Value = ttTypeid; dbParamCollection.Add(dbparamttType); dbHandler = new DBHandler(1); Object objResult = dbHandler.ExecuteScalar(Constants.SP_GET_TREATMENTTYPE_NAME, dbParamCollection); if (objResult != null) { treatementName = objResult.ToString(); } } catch (Exception ex) { YelpTrace.Write(ex); } return(treatementName); }
public static Int32 GetBusinessIdForUser(int userId, int businessRoleId) { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); string businessDetailId; int nbusinessDetailId = 0; DBHandler dbHandler = null; try { //Userid SqlParameter dbparamUserID = new SqlParameter("@UserId", System.Data.SqlDbType.Int); dbparamUserID.Value = userId; dbParamCollection.Add(dbparamUserID); SqlParameter dbparamBusinessRoleId = new SqlParameter("@businessRoleId", System.Data.SqlDbType.Int); dbparamBusinessRoleId.Value = businessRoleId == 0 ? 1 : businessRoleId; //pass admin role id if zero dbParamCollection.Add(dbparamBusinessRoleId); //USERDETAILS_SELECT dbHandler = new DBHandler(1); Object objResult = dbHandler.ExecuteScalar(Constants.SP_BUSINESSID_FROM_USERID_S, dbParamCollection); if (objResult != null) { businessDetailId = objResult.ToString(); Int32.TryParse(businessDetailId, out nbusinessDetailId); } } catch (Exception ex) { YelpTrace.Write(ex); } return(nbusinessDetailId); }
/// <summary> /// Delete record in AccessToken table /// </summary> /// <returns></returns> public static bool DeleteAccessToken(string sitename) { bool bReturn = false; List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //sitename SqlParameter dbparamSitename = new SqlParameter("@sitename", SqlDbType.VarChar, 10); dbparamSitename.Value = sitename; dbParamCollection.Add(dbparamSitename); try { //[[ACCESSTOKEN_INSERT]] DBHandler dbHandler = new DBHandler(1); int rowsAffected = dbHandler.ExecuteNonQuery(Constants.SP_ACCESSTOKEN_DELETE, dbParamCollection); if (rowsAffected < 0) { //errror in query execution bReturn = false; } bReturn = true; } catch (Exception ex) { YelpTrace.Write(ex); } finally { } return(bReturn); }
private void PopulateBusinessTypes() { cmbBusinessType.Items.Clear(); DBHandler dbHandler = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //USERDETAILS_SELECT dbHandler = new DBHandler(1); DataTable dataTable = dbHandler.ExecuteReaderinTable(Constants.SP_BusinessType_S, dbParamCollection); if (dataTable != null) { foreach (DataRow dataRow in dataTable.Rows) { cmbBusinessType.Items.Add(new ListItem(dataRow["BusinessType"].ToString(), dataRow["BusinessTypeId"].ToString())); } } } catch (Exception ex) { YelpTrace.Write("Exception in PopulateBusinessTypes " + ex); } }
protected void Page_Load(object sender, EventArgs e) { string type = string.Empty; string userCode = string.Empty; int userCodeType = -1; if (Request.QueryString["type"] != null) { type = Request.QueryString["type"].ToString(); } if (Request.QueryString["code"] != null) { userCode = Request.QueryString["code"].ToString(); } DBHandler dbHandler = null; if (type == "activation") { userCodeType = 1; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //Term SqlParameter dbparamuserCodeType = new SqlParameter("@userCodeType", SqlDbType.SmallInt); dbparamuserCodeType.Value = userCodeType; dbParamCollection.Add(dbparamuserCodeType); //location SqlParameter dbparamUserCode = new SqlParameter("@code", SqlDbType.VarChar, 50); dbparamUserCode.Value = userCode; dbParamCollection.Add(dbparamUserCode); dbHandler = new DBHandler(1); int rowsAffected = dbHandler.ExecuteNonQuery(Constants.SP_USERDETAILS_USER_ACTIONS, dbParamCollection); if (rowsAffected == 1) { Response.Redirect("/login.aspx?errorMessage=User is activated, please login with your credentials."); } else { lblResponse.Text = "We are not able to find corresponding user for the activation code"; } } catch (Exception ex) { YelpTrace.Write(ex); } } else if (type == "reset") { userCodeType = 2; } }
protected void btnChangePassword_Click(object sender, EventArgs e) { if (ValidateUser()) { #region SQL Express DBHandler dbHandler = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //username SqlParameter dbparamuserId = new SqlParameter("@userId", System.Data.SqlDbType.Int); dbparamuserId.Value = userId; dbParamCollection.Add(dbparamuserId); //Oldpassword SqlParameter dbparamOldPassword = new SqlParameter("@OldPassword", System.Data.SqlDbType.VarChar, 25); dbparamOldPassword.Value = txtOldPassword.Text.Trim(); dbParamCollection.Add(dbparamOldPassword); //Newpassword SqlParameter dbparamNewPassword = new SqlParameter("@NewPassword", System.Data.SqlDbType.VarChar, 25); dbparamNewPassword.Value = txtNewPassword.Text.Trim(); dbParamCollection.Add(dbparamNewPassword); //USERDETAILS_SELECT dbHandler = new DBHandler(1); int nResult = dbHandler.ExecuteNonQuery(Constants.SP_USERDETAILS_CHANGE_PASSWORD, dbParamCollection); if (nResult > 0) { Response.Redirect("/ChangePassword.aspx?errorMessage=Password is changed successfully.."); } else { Response.Redirect("/ChangePassword.aspx?errorMessage=Old password is not correct, password is not changed."); } } catch (Exception ex) { // Add error handling here for debugging. // This error message should not be sent back to the caller. YelpTrace.Write("[ValidateUser] Exception " + ex.Message); YelpTrace.Write(ex); DisplayMessage(MessageType.Success, "Error in change password"); } finally { //if (dbHelper != null) // dbHelper.Close(); } #endregion SQL Express } }
public static int GetTTTypeId(string ttType) { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); int nttTypeId = -1; string strttTypeId = string.Empty; DBHandler dbHandler = null; try { //Userid SqlParameter dbparamttType = new SqlParameter("@ttType", System.Data.SqlDbType.VarChar, 25); dbparamttType.Value = ttType; dbParamCollection.Add(dbparamttType); dbHandler = new DBHandler(1); Object objResult = dbHandler.ExecuteScalar(Constants.SP_GET_TREATMENTTYPEID, dbParamCollection); if (objResult != null) { strttTypeId = objResult.ToString(); Int32.TryParse(strttTypeId, out nttTypeId); } } catch (Exception ex) { YelpTrace.Write(ex); } //switch (ttType) //{ // case "Invisalign" : // { // TtTypeId=1; // break; // } // case "Braces": // { // TtTypeId = 2; // break; // } // case "Both": // { // TtTypeId = 3; // break; // } // default: // { // TtTypeId = -1; // break; // } //} return(nttTypeId); }
protected void btnChangePassword_Click(object sender, EventArgs e) { #region SQL Express DBHandler dbHandler = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //username SqlParameter dbparamEmailId = new SqlParameter("@EmailId", SqlDbType.VarChar, 50); dbparamEmailId.Value = txtEmail.Text.Trim().ToLower(); dbParamCollection.Add(dbparamEmailId); //ActivationCode string strActivationCode = Guid.NewGuid().ToString(); SqlParameter dbparamActivationCode = new SqlParameter("@ActivationCode", SqlDbType.VarChar, 50); dbparamActivationCode.Value = strActivationCode; dbParamCollection.Add(dbparamActivationCode); //USERDETAILS_SELECT dbHandler = new DBHandler(1); int nResult = dbHandler.ExecuteNonQuery(Constants.SP_USERDETAILS_ACTIVATION_INSERT_RESET, dbParamCollection); if (nResult > 0) { SendUserResetPasswordEmail(strActivationCode, txtEmail.Text.Trim()); Response.Redirect("/ResetPassword.aspx?pageMode=0&errorMessage=Email with instructions to Reset password is sent."); } else { Response.Redirect("/ResetPassword.aspx??pageMode=0&errorMessage=Email Id is not registered with us."); } } catch (Exception ex) { // Add error handling here for debugging. // This error message should not be sent back to the caller. YelpTrace.Write("[btnChangePassword_Click] Exception " + ex.Message); YelpTrace.Write(ex); FailureText.Text = "Error in Reset password"; } finally { //if (dbHelper != null) // dbHelper.Close(); } #endregion SQL Express }
private void SendUserRegistrationEmail(string strUserName, string strFirstName, string strEmailId, string strActivationCode) { //read the eamil template.xml file XMLHandler xmlHandler = new XMLHandler("EmailTemplates.xml"); XmlNode xmlNode = xmlHandler.GetXMLNode("UserCreationEmail"); string subject = xmlHandler.GetSubject(xmlNode); string messageBody = xmlHandler.GetMessageBody(xmlNode); string userActivationRawLink = string.Empty; try { userActivationRawLink = ConfigurationManager.AppSettings["BR_USER_ACCOUNT"]; } catch (Exception ex) { userActivationRawLink = "https://www.BusinessRepute.xyz//UsersAccount.aspx&type={0}&code={1}"; YelpTrace.Write(ex); } string userActivationLink = string.Format(userActivationRawLink, "activation", strActivationCode); messageBody = messageBody.Replace("USERNAME", strUserName); messageBody = messageBody.Replace("USERACTIVATIONLINK", userActivationLink); messageBody = "Hello " + strFirstName + "," + Environment.NewLine + messageBody; //get to Email Address try { Exception ex = null; if (Communication.SendMail(strEmailId, string.Empty, subject, messageBody, "Pradip", out ex)) { DisplayMessage(MessageType.Success, "Mail is sent Successfully"); YelpTrace.Write("User registration Email is sent successfully" + ex); } else { DisplayMessage(MessageType.Success, "Issue in sending Email "); YelpTrace.Write("sending user registration Email is failed " + ex); } } catch (Exception ex) { YelpTrace.Write("Exception in user registration Email activation Email sending" + ex); } }
/// <summary> /// Update search Status /// </summary> /// <param name="searchresults"></param> public static int UpdateSearchStatus(int searchId, string strTerm, string strLocation, int searchStatus) { int rowsAffected = -1; DBHandler dbHandler = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //searchId if (searchId > 0) { SqlParameter dbparamSearchId = new SqlParameter("@SearchId", SqlDbType.Int); dbparamSearchId.Value = searchId; dbParamCollection.Add(dbparamSearchId); } //Term SqlParameter dbparamTerm = new SqlParameter("@Term", SqlDbType.VarChar, 50); dbparamTerm.Value = strTerm; dbParamCollection.Add(dbparamTerm); //Location SqlParameter dbparamLocation = new SqlParameter("@Location", SqlDbType.VarChar, 50); dbparamLocation.Value = strLocation; dbParamCollection.Add(dbparamLocation); //SearchFinished SqlParameter dbparamSearchFinished = new SqlParameter("@SearchFinished", SqlDbType.Int); dbparamSearchFinished.Value = searchStatus; dbParamCollection.Add(dbparamSearchFinished); dbHandler = new DBHandler(1); rowsAffected = dbHandler.ExecuteNonQuery(Constants.SP_HouzzMAINSEARCH_SEARCHFINISHED_UPDATE, dbParamCollection); if (rowsAffected < 0) { //errror in query execution } } catch (Exception ex) { YelpTrace.Write("UpdateSearchStatus" + ex); } return(rowsAffected); }
private void SendUserResetPasswordEmail(string strActivationCode, string strEmailID) { string XMLTemplatepath = ConfigurationManager.AppSettings["XML_EMAIL_TEMPLATE_FILE"]; //read the eamil template.xml file XMLHandler xmlHandler = new XMLHandler(XMLTemplatepath); XmlNode xmlNode = xmlHandler.GetXMLNode("ResetPasswordEmail"); string subject = xmlHandler.GetSubject(xmlNode); string messageBody = xmlHandler.GetMessageBody(xmlNode); string passwordResetRawLink = string.Empty; try { passwordResetRawLink = ConfigurationManager.AppSettings["BR_RESET_PASSWORD"]; } catch (Exception ex) { passwordResetRawLink = "https://www.BusinessRepute.xyz/ResetPassword.aspx&pageMode={0}&code={1}"; YelpTrace.Write(ex); } string passwordResetLink = string.Format(passwordResetRawLink, "1", strActivationCode); messageBody = messageBody.Replace("RESETPASSWORDLINK", passwordResetLink); //get to Email Address try { Exception ex = null; if (Communication.SendMail(strEmailID, string.Empty, subject, messageBody, lblClientName.Text, out ex) == true) { DisplayMessage(MessageType.Success, "Instructions to Reset password is sent in registered Email."); YelpTrace.Write("Instructions to Reset password is sent in registered Email."); } else { DisplayMessage(MessageType.Success, "Error in sending Email Reset password instruction, please retry."); } } catch (Exception ex) { YelpTrace.Write("Exception in sending reset password Email" + ex); } }
protected void btnLogin_Click(object sender, EventArgs e) { try { //Login.FailureAction = LoginFailureAction.RedirectToLoginPage; string userName = txtUssername.Text.Trim(); string password = txtPassword.Text.Trim(); bool rememberMe = chkRememberMe.Checked; if (ValidateUser(userName, password)) { FormsAuthentication.SetAuthCookie(userName, chkRememberMe.Checked); if (chkRememberMe.Checked) { HttpCookie cookie = new HttpCookie("BusinessRepute"); cookie.Values.Add("username", txtUssername.Text); cookie.Expires = DateTime.Now.AddDays(15); Response.Cookies.Add(cookie); } string webpath = HttpContext.Current.Request.Url.AbsoluteUri; string webFolderPath = webpath.Substring(0, webpath.LastIndexOf("/")); webFolderPath = webFolderPath.Substring(0, webFolderPath.LastIndexOf("/")); //CtrlLogin.DestinationPageUrl = webFolderPath + "/Home.aspx"; //CtrlLogin.PasswordRecoveryUrl = "manage.aspx"; YelpTrace.Write(webFolderPath + "Main.aspx"); //Response.Redirect(webFolderPath + "QuoteCalc.aspx"); Response.Redirect("Main.aspx"); //Server.Transfer("Home.aspx"); } else { Session["USERID"] = string.Empty; Session["USERNAME"] = string.Empty; //Response.Redirect("/login.aspx?errorMessage=User is not authenticated, please provide correct username and password."); DisplayMessage(MessageType.Error, "User is not authenticated, please provide correct username and password"); } } catch (Exception ex) { YelpTrace.Write("exception in btnLogin_Click " + ex); } }
/// <summary> /// insert record in AccessToken table /// </summary> /// <param name="yelpData"></param> /// <param name="term"></param> /// <param name="location"></param> /// <param name="searchId"></param> /// <returns></returns> public static bool InsertAccessToken(string accessToken, int days, string sitename) { bool bReturn = false; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //accessToken SqlParameter dbparamAccessToken = new SqlParameter("@accessToken", SqlDbType.VarChar, 200); dbparamAccessToken.Value = accessToken; dbParamCollection.Add(dbparamAccessToken); //searchId SqlParameter dbparamDays = new SqlParameter("@days", SqlDbType.Int); dbparamDays.Value = days; dbParamCollection.Add(dbparamDays); //sitename SqlParameter dbparamSitename = new SqlParameter("@sitename", SqlDbType.VarChar, 10); dbparamSitename.Value = sitename; dbParamCollection.Add(dbparamSitename); //[[ACCESSTOKEN_INSERT]] DBHandler dbHandler = new DBHandler(1); int rowsAffected = dbHandler.ExecuteNonQuery(Constants.SP_ACCESSTOKEN_INSERT, dbParamCollection); if (rowsAffected < 0) { //errror in query execution bReturn = false; } bReturn = true; } catch (Exception ex) { YelpTrace.Write(ex); } finally { } return(bReturn); }
private void GetPatients() { gridPatientList.Visible = false; #region SQLExpress try { DBHandler dbHandler = new DBHandler(1); DataTable dataTable = dbHandler.ExecuteReaderinTable(txtSQlQuery.Text.Trim()); int recordsFound = 0; if (dataTable != null) { recordsFound = dataTable.Rows.Count; if (recordsFound > 0) { gridPatientList.DataSource = dataTable; gridPatientList.DataBind(); gridPatientList.Visible = true; } else { DisplayMessage(MessageType.Success, "Zero (0) records found"); } } else { DisplayMessage(MessageType.Error, "Error in SQL Query, please check"); } } catch (Exception ex) { DisplayMessage(MessageType.Exception, "Error in query execution" + ex); YelpTrace.Write(ex); } finally { } #endregion SQLExpress }
public static DataTable GetUsers(int businessDetailId) { DataTable searchDataTable = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); DBHandler dbHandler = new DBHandler(1); SqlParameter dbparamBusinessDetailId = new SqlParameter("@BusinessDetailId", System.Data.SqlDbType.Int); dbparamBusinessDetailId.Value = businessDetailId; dbParamCollection.Add(dbparamBusinessDetailId); //USERDETAILS_SELECT searchDataTable = dbHandler.ExecuteReaderinTable(Constants.SP_BusinessUsers_S, dbParamCollection); } catch (Exception ex) { YelpTrace.Write(ex); } return(searchDataTable); }
private bool IsDuplicateUserName(string userName) { bool bDuplicate = false; #region SQL Express DBHandler dbHandler = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //username SqlParameter dbparamuserName = new SqlParameter("@User_UserName", System.Data.SqlDbType.VarChar, 25); dbparamuserName.Value = userName.Trim(); dbParamCollection.Add(dbparamuserName); //USERDETAILS_SELECT dbHandler = new DBHandler(1); object result = dbHandler.ExecuteScalar(Constants.SP_CHECK_DUPLICATE_USERNAME, dbParamCollection); int userID = 0; if (result != null) { Int32.TryParse(result.ToString(), out userID); //Session["USERID"] = userID.ToString(); bDuplicate = true; } } catch (Exception ex) { bDuplicate = false; YelpTrace.Write(ex); } finally { //if (dbHelper != null) // dbHelper.Close(); } #endregion SQL Express return(bDuplicate); }
protected void btnDelete_Click(object sender, EventArgs e) { try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //Userid SqlParameter dbparamuserid = new SqlParameter("@userId", System.Data.SqlDbType.Int); dbparamuserid.Value = string.IsNullOrEmpty(hdnEditUserID.Value) ? 0 : Int32.Parse(hdnEditUserID.Value); dbParamCollection.Add(dbparamuserid); //USERDETAILS_SELECT DBHandler dbHandler = new DBHandler(1); dbHandler.ExecuteNonQuery(Constants.SP_USER_INFO_D, dbParamCollection); DisplayMessage(MessageType.Information, "User infomration is successfully deleted"); ClearFields(); } catch (Exception ex) { DisplayMessage(MessageType.Exception, ex.Message); YelpTrace.Write(ex); } }
public static DataTable GetBusinessDetails(int userId) { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); DataTable searchDataTable = null; DBHandler dbHandler = null; try { //Userid SqlParameter dbparamUserID = new SqlParameter("@UserId", System.Data.SqlDbType.Int); dbparamUserID.Value = userId; dbParamCollection.Add(dbparamUserID); //USERDETAILS_SELECT dbHandler = new DBHandler(1); searchDataTable = dbHandler.ExecuteReaderinTable(Constants.SP_BUSINESS_DETAILS_S, dbParamCollection); } catch (Exception ex) { YelpTrace.Write(ex); } return(searchDataTable); }
/// <summary> /// to get the accessToken from database /// </summary> /// <returns></returns> public static string GetAccessTokenFromDB(string siteName) { string accessToken = string.Empty; List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //sitename SqlParameter dbparamSitename = new SqlParameter("@sitename", SqlDbType.VarChar, 10); dbparamSitename.Value = siteName; dbParamCollection.Add(dbparamSitename); try { DBHandler dbHandler = new DBHandler(1); Object objResult = dbHandler.ExecuteScalar(Constants.SP_ACCESSTOKEN_SELECT, dbParamCollection); if (objResult != null) { accessToken = objResult.ToString(); } } catch (Exception ex) { YelpTrace.Write(ex); } return(accessToken); }
private void GetBusinessInfo(string userId) { //if (!string.IsNullOrEmpty(userId)) //{ // int nUserID = Convert.ToInt32(userId); // DataTable businessDetailTable = Utility.GetBusinessDetails(nUserID); // //set header // if (businessDetailTable != null) // { // if (businessDetailTable.Rows.Count > 0) // { // lblClientName.Text = (string)businessDetailTable.Rows[0]["businessName"]; // lblHeaderAddress1.Text = (string)businessDetailTable.Rows[0]["businessAddress1"]; // lblHeaderAddress2.Text = (string)businessDetailTable.Rows[0]["businessAddress2"]; // lblHeaderConatct.Text = "Phone: " + (string)businessDetailTable.Rows[0]["businessPhone"] + " Fax: " + (string)businessDetailTable.Rows[0]["businessFax"]; // lblHeaderEmail.Text = "Email: " + (string)businessDetailTable.Rows[0]["businessEmailId"]; // Session["BUSINESSID"] = (businessDetailTable.Rows[0]["BusinessDetailId"]).ToString(); // string logoFileName = (string)businessDetailTable.Rows[0]["logoFileName"]; // try // { // //imgClientLogo.ImageUrl =(Utility.GetImageFolder() + logoFileName); // imgClientLogo.ImageUrl = ("ClientImages\\" + logoFileName); // imgClientLogo1.ImageUrl = ("ClientImages\\" + logoFileName); // } // catch (Exception ex) // { // YelpTrace.Write(ex); // } // } // } //} int nUserId = -1; if (!string.IsNullOrEmpty(userId)) { try { Int32.TryParse(userId, out nUserId); DataTable businessDetailTable = Utility.GetBusinessDetails(nUserId); //set header if (businessDetailTable != null) { if (businessDetailTable.Rows.Count > 0) { lblClientName.Text = (string)businessDetailTable.Rows[0]["businessName"]; lblHeaderAddress1.Text = (string)businessDetailTable.Rows[0]["businessAddress1"]; lblHeaderAddress2.Text = (string)businessDetailTable.Rows[0]["businessAddress2"]; lblHeaderConatct.Text = "Phone: " + (string)businessDetailTable.Rows[0]["businessPhone"]; lblHeaderEmail.Text = "Email: " + (string)businessDetailTable.Rows[0]["businessEmailId"]; Session["BUSINESSID"] = (businessDetailTable.Rows[0]["BusinessDetailId"]).ToString(); string logoFileName = (string)businessDetailTable.Rows[0]["logoFileName"]; try { //imgClientLogo.ImageUrl =(Utility.GetImageFolder() + logoFileName); imgClientLogo.ImageUrl = ("ClientImages\\" + logoFileName); imgClientLogo1.ImageUrl = ("ClientImages\\" + logoFileName); } catch (Exception ex) { YelpTrace.Write(ex); } txtBusinessName.Text = (string)businessDetailTable.Rows[0]["businessName"]; txtBusinessAddress1.Text = (string)businessDetailTable.Rows[0]["businessAddress1"]; txtBusinessAddress2.Text = (string)businessDetailTable.Rows[0]["businessAddress2"]; txtBusinessPhone.Text = (string)businessDetailTable.Rows[0]["businessPhone"]; txtBusinessEmail.Text = (string)businessDetailTable.Rows[0]["businessEmailId"]; txtBussCity.Text = (string)businessDetailTable.Rows[0]["businessCity"]; txtBussState.Text = (string)businessDetailTable.Rows[0]["businessState"]; txtBusinessZip.Text = (string)businessDetailTable.Rows[0]["businesszip"]; hdnBusinessDetailsID.Value = (businessDetailTable.Rows[0]["BusinessDetailId"]).ToString(); cmbBusinessType.SelectedValue = (businessDetailTable.Rows[0]["BusinessTypeId"]).ToString(); //txtSecurityQue1.Text = (string)businessDetailTable.Rows[0]["SecurityQ1"]; //txtSecurityAns1.Text = (string)businessDetailTable.Rows[0]["SecurityA1"]; //txtSecurityQue2.Text = (string)businessDetailTable.Rows[0]["SecurityQ2"]; //txtSecurityAns2.Text = (string)businessDetailTable.Rows[0]["SecurityA2"]; } } } catch (Exception ex) { YelpTrace.Write(ex); } } }
public static bool SendMail(string toEmailId, string filePath, string subject, string messagebody, string bussName, out Exception exOut) { string fromEmailId = string.Empty; string fromPass = string.Empty; string smtpServer = string.Empty; int smtpPortNumber = 0; bool bReturn = true; exOut = null; try { try { fromEmailId = ConfigurationSettings.AppSettings["FROM_EMAIL_ID"]; } catch (Exception ex) { fromEmailId = @"*****@*****.**"; YelpTrace.Write(ex); } try { smtpServer = ConfigurationSettings.AppSettings["SMTPSERVER"]; } catch (Exception ex) { smtpServer = @"smtp.gmail.com"; YelpTrace.Write(ex); } try { string strsmtpPortNumber = ConfigurationSettings.AppSettings["SMTPPORT"]; Int32.TryParse(strsmtpPortNumber, out smtpPortNumber); } catch (Exception ex) { smtpPortNumber = 587; YelpTrace.Write(ex); } try { fromPass = ConfigurationSettings.AppSettings["EMAIL_PASSWORD"]; } catch (Exception ex) { YelpTrace.Write(ex); } string todayDate = DateTime.Now.ToString("yyyy-MM-dd"); MailMessage msg = new MailMessage(); msg.From = new MailAddress(fromEmailId, bussName); msg.To.Add(toEmailId); // Add a new recipient to our msg. msg.Subject = subject; // Assign the subject of our message. msg.Body = messagebody; msg.IsBodyHtml = true; //Add attachments to the mail if (File.Exists(filePath)) { Attachment attachment = new Attachment(filePath); msg.Attachments.Add(attachment); } //create credentials and send mail //if (msg.Attachments.Count > 0) { if (smtpPortNumber > 0) { using (SmtpClient client = new SmtpClient(smtpServer, smtpPortNumber)) { NetworkCredential cred = new NetworkCredential(fromEmailId, fromPass); #if DEBUG //for gmail local client.EnableSsl = true; client.UseDefaultCredentials = false; client.Host = smtpServer; client.Credentials = cred; // Send our account login details to the client. client.Port = 587; //smtpPortNumber; client.DeliveryMethod = SmtpDeliveryMethod.Network; #else //client.EnableSsl = true; //client.UseDefaultCredentials = false; //client.Host = smtpServer; client.Credentials = cred; // Send our account login details to the client. //client.Port = 465;//smtpPortNumber; client.Port = smtpPortNumber; //client.DeliveryMethod = SmtpDeliveryMethod.Network; #endif client.Send(msg); } } else { using (SmtpClient client = new SmtpClient(smtpServer)) { NetworkCredential cred = new NetworkCredential(fromEmailId, fromPass); //client.EnableSsl = true; //client.UseDefaultCredentials = false; //client.Host = smtpServer; client.Credentials = cred; // Send our account login details to the client. //client.Port = 465;//smtpPortNumber; //client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Send(msg); // Send our email. } } } } catch (System.Net.Mail.SmtpException smtpex) { exOut = smtpex; bReturn = false; YelpTrace.Write(smtpex); } catch (Exception ex) { exOut = ex; bReturn = false; //System.Windows.Forms.MessageBox.Show("in SendMail" + ex.Message + ex.InnerException); YelpTrace.Write(ex); } return(bReturn); }
protected void btnResetPassword_Click(object sender, EventArgs e) { string tempCode = string.Empty; if (Request.QueryString["code"] != null) { tempCode = Request.QueryString["code"]; } if (!string.IsNullOrEmpty(tempCode)) { if (ValidatePassword()) { #region SQL Express DBHandler dbHandler = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //code SqlParameter dbparamActivationCode = new SqlParameter("@ActivationCode", System.Data.SqlDbType.VarChar, 50); dbparamActivationCode.Value = tempCode; dbParamCollection.Add(dbparamActivationCode); //code SqlParameter dbparamUserID = new SqlParameter("@userId", System.Data.SqlDbType.Int); dbparamUserID.Value = 0; dbParamCollection.Add(dbparamUserID); //Newpassword SqlParameter dbparamNewPassword = new SqlParameter("@NewPassword", System.Data.SqlDbType.VarChar, 25); dbparamNewPassword.Value = txtNewPassword.Text.Trim(); dbParamCollection.Add(dbparamNewPassword); //USERDETAILS_SELECT dbHandler = new DBHandler(1); int nResult = dbHandler.ExecuteNonQuery(Constants.SP_USERDETAILS_CHANGE_PASSWORD, dbParamCollection); if (nResult > 0) { Response.Redirect("/ResetPassword.aspx?pageMode=1&errorMessage=Password is changed successfully.."); } else { Response.Redirect("/ResetPassword.aspx??pageMode=1&errorMessage=Error in resetting the password, password is not changed."); } } catch (Exception ex) { // Add error handling here for debugging. // This error message should not be sent back to the caller. YelpTrace.Write("[ValidateUser] Exception " + ex.Message); YelpTrace.Write(ex); DisplayMessage(MessageType.Exception, "Error in change password"); } finally { //if (dbHelper != null) // dbHelper.Close(); } } #endregion SQL Express } }
private bool ValidateUser(string userName, string passWord) { bool bReturn = false; if (string.IsNullOrEmpty(userName)) { bReturn = false; } if (string.IsNullOrEmpty(passWord)) { bReturn = false; } #region SQL Express DBHandler dbHandler = null; try { List <SqlParameter> dbParamCollection = new List <SqlParameter>(); //username SqlParameter dbparamuserName = new SqlParameter("@User_UserName", System.Data.SqlDbType.VarChar, 25); dbparamuserName.Value = userName.Trim(); dbParamCollection.Add(dbparamuserName); //password SqlParameter dbparamPassword = new SqlParameter("@Password", System.Data.SqlDbType.VarChar, 25); dbparamPassword.Value = passWord.Trim(); dbParamCollection.Add(dbparamPassword); //USERDETAILS_SELECT dbHandler = new DBHandler(1); DataTable dtResultTable = dbHandler.ExecuteReaderinTable(Constants.SP_USERDETAILS_SELECT, dbParamCollection); if (dtResultTable != null) { if (dtResultTable.Rows.Count > 0) { Session["USERID"] = dtResultTable.Rows[0]["Userid"].ToString(); Session["BUSINESSID"] = dtResultTable.Rows[0]["BusinessDetailId"].ToString(); Session["ROLEID"] = dtResultTable.Rows[0]["BusinessRoleId"].ToString(); Session["USERNAME"] = (string)dtResultTable.Rows[0]["FirstName"]; //ErrorMessage.Visible = false; bReturn = true; } } } catch (Exception ex) { // Add error handling here for debugging. // This error message should not be sent back to the caller. YelpTrace.Write("[ValidateUser] Exception " + ex.Message); bReturn = false; } finally { //if (dbHelper != null) // dbHelper.Close(); } #endregion SQL Express return(bReturn); }
protected void btnSendMessage_Click(object sender, EventArgs e) { //store the details in database and send a mail to client as well as to Admin string name = txtProspectName.Text.Trim(); string email = txtProspectEmail.Text.Trim(); string subject = txtMessageSubject.Text.Trim(); string message = txtMessage.Text.Trim(); string selectedPupose = lstPurpose.SelectedItem.Text; DBHandler dbHandler = null; #region SQLExpress try { List <SqlParameter> sqlParameters = new List <SqlParameter>(); //Name SqlParameter dbparamName = new SqlParameter("@Name", SqlDbType.VarChar, 50); dbparamName.Value = name; sqlParameters.Add(dbparamName); //Email SqlParameter dbparamEmail = new SqlParameter("@Email", SqlDbType.VarChar, 50); dbparamEmail.Value = email; sqlParameters.Add(dbparamEmail); //subject SqlParameter dbparamSubject = new SqlParameter("@subject", SqlDbType.VarChar, 50); dbparamSubject.Value = subject; sqlParameters.Add(dbparamSubject); //Message SqlParameter dbparamMessage = new SqlParameter("@message", SqlDbType.VarChar, 2000); dbparamMessage.Value = message; sqlParameters.Add(dbparamMessage); //Purpose SqlParameter dbparamPurpose = new SqlParameter("@purpose", SqlDbType.VarChar, 100); dbparamPurpose.Value = selectedPupose; sqlParameters.Add(dbparamPurpose); string response = string.Empty; dbHandler = new DBHandler(1); int result = dbHandler.ExecuteNonQuery(Constants.SP_FeedbackDetails_I, sqlParameters); DisplayMessage(MessageType.Information, string.Format(" Thank you for contacting us, we will get back to you immediately.")); //send Email to Admin try { Exception ex = null; if (Communication.SendMail("*****@*****.**", string.Empty, subject, message, "Business Reputation", out ex) == false) { YelpTrace.Write("sending Email to Admin is failed " + ex); } } catch (Exception ex) { YelpTrace.Write("Exception in sending Email to Admin for feedback " + ex); } //send thank you Email to user try { //read the eamil template.xml file XMLHandler xmlHandler = new XMLHandler("EmailTemplates.xml"); XmlNode xmlNode = xmlHandler.GetXMLNode("ThankForFeedback"); string msgSubject = xmlHandler.GetSubject(xmlNode); string messageBody = xmlHandler.GetMessageBody(xmlNode); messageBody = "Hello " + name + "," + Environment.NewLine + messageBody; Exception ex = null; if (Communication.SendMail(email, string.Empty, msgSubject, messageBody, "Business Reputation", out ex) == false) { YelpTrace.Write("sending Email to user for feedback is failed " + ex); } } catch (Exception ex) { YelpTrace.Write("Exception in sending Email to user for feedback " + ex); } //Send Email to Client. ClearFields(); } catch (Exception ex) { DisplayMessage(MessageType.Exception, ex.Message); YelpTrace.Write(ex); } finally { //dbHandler.Close(); } #endregion MSAccess }
protected void Page_Load(object sender, EventArgs e) { string userId = string.Empty; if ((Session["USERID"] == null) || (Session["USERID"] == "")) { //FailureText.Text = " Context.User.Identity.Name " + Context.User.Identity.Name + " Session[USERID] " + Session["USERID"]; string userName = Context.User.Identity.Name; if (string.IsNullOrEmpty(userName)) { Server.Transfer("~/login.aspx", false); } else { userId = Helper.GetUserId(userName); } } else { userId = Session["USERID"].ToString(); } int nUserID = Convert.ToInt32(userId); DataTable businessDetailTable = Utility.GetBusinessDetails(nUserID); //set header if (businessDetailTable != null) { if (businessDetailTable.Rows.Count > 0) { lblClientName.Text = (string)businessDetailTable.Rows[0]["businessName"]; lblHeaderAddress1.Text = (string)businessDetailTable.Rows[0]["businessAddress1"]; lblHeaderAddress2.Text = (string)businessDetailTable.Rows[0]["businessAddress2"]; lblHeaderConatct.Text = "Phone: " + (string)businessDetailTable.Rows[0]["businessPhone"]; // +" Fax: " + (string)businessDetailTable.Rows[0]["businessFax"]; lblHeaderEmail.Text = "Email: " + (string)businessDetailTable.Rows[0]["businessEmailId"]; hdnBusinessDetailsID.Value = (businessDetailTable.Rows[0]["BusinessDetailId"]).ToString(); string logoFileName = (string)businessDetailTable.Rows[0]["logoFileName"]; try { //imgClientLogo.ImageUrl =(Utility.GetImageFolder() + logoFileName); imgClientLogo.ImageUrl = ("ClientImages\\" + logoFileName); imgClientLogo1.ImageUrl = ("ClientImages\\" + logoFileName); } catch (Exception ex) { YelpTrace.Write(ex); } } } if (IsPostBack) { //LoadStatus(); GetUsers(); gridUserList.Visible = true; } else { //LoadStatus(); GetUsers(); } }