public bool Validation_Returning_User() { if ((txtUserName.Text.Trim() == "")) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", "alert('Please enter valid Username');", true); txtMobile.Focus(); return false; } if ((txtPassword.Text.Trim() == "")) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", "alert('Please enter valid password');", true); txtPassword.Focus(); return false; } if ((txtHouseNo.Text.Trim() == "" || txtLocation.Text.Trim() == "")) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", "alert('Please enter valid Address');", true); txtMobile.Focus(); return false; } csLogin objLogin = new csLogin(); csGlobal globaldata = new csGlobal(); DataTable dt = new DataTable(); dt = objLogin.ExecuteProcedure(txtUserName.Text); if (dt.Rows.Count > 0)//if we get some data in data table then only we will check password { if (txtPassword.Text.Trim() == csLogin.DecodeFrom64(dt.Rows[0]["Pwd"].ToString().Trim())) { Session["user"] = "******"; Session["UserName"] = dt.Rows[0]["UserName"].ToString(); Session["UserType"] = dt.Rows[0]["UserType"].ToString(); Session["UserCategory"] = dt.Rows[0]["UserCategory"].ToString(); Session["UserID"] = dt.Rows[0]["UserID"].ToString(); Session["userEmail"] = dt.Rows[0]["EmailID"].ToString(); globaldata._userID = Convert.ToDecimal(dt.Rows[0]["UserID"]); globaldata.UserTypedata = dt.Rows[0]["UserType"].ToString(); globaldata.UserCategorydata = dt.Rows[0]["UserCategory"].ToString(); return true; } else//In this case we can drop an email to user that some one is trying to access your account without your permission please confirm if you are aware of this login { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage1", "alert('Please check your password and try again!');", true); return false; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage2", "alert('" + txtUserName.Text + " does not exist in our system!');", true); return false; } //string strQurey = "select Customer_ID from tbl_Customer where MobileNo='" + txtMobile.Text + "' and Password='******'"; //CustomerID = Convert.ToInt32(CrystalConnection.SqlScalartoObj(strQurey)); //Session["CustomerID"] = CustomerID; //if (chkPreUser.Checked != true) //{ // if (CustomerID > 0) // { // return false; // } //} }
private void LoginNewUser() { csLogin objLogin = new csLogin(); csGlobal globaldata = new csGlobal(); DataTable dt = new DataTable(); dt = objLogin.ExecuteProcedure(txtUserName.Text); if (dt.Rows.Count > 0)//if we get some data in data table then only we will check password { //if (txtPassword.Text == csLogin.DecodeFrom64(dt.Rows[0]["Pwd"].ToString())) //{ Session["user"] = "******"; Session["UserName"] = dt.Rows[0]["UserName"].ToString(); Session["UserType"] = dt.Rows[0]["UserType"].ToString(); Session["UserCategory"] = dt.Rows[0]["UserCategory"].ToString(); Session["UserID"] = dt.Rows[0]["UserID"].ToString(); Session["userEmail"] = dt.Rows[0]["EmailID"].ToString(); globaldata._userID = Convert.ToDecimal(dt.Rows[0]["UserID"]); globaldata.UserTypedata = dt.Rows[0]["UserType"].ToString(); globaldata.UserCategorydata = dt.Rows[0]["UserCategory"].ToString(); //if (Session["UserType"].ToString() == "Super Admin") //{ // Response.Redirect("~/MasterPages/MenuBoard.aspx"); //} //else if (Session["UserType"].ToString() == "Admin") { Response.Redirect("~/MasterPages/AdminMenuboard.aspx"); } else if (Session["UserType"].ToString() == "Supplier") { Response.Redirect("~/MasterPages/SupplierMenuboard.aspx"); } else if (Session["UserType"].ToString() == "Customer") { Response.Redirect("~/Customer/AddNewCase.aspx"); } else { Response.Redirect("~/login.aspx"); } //} //else//In this case we can drop an email to user that some one is trying to access your account without your permission please confirm if you are aware of this login //{ // ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage1", "alert('Please check your password and try again!');", true); //} } }