protected void BtnAdd_Click(object sender, EventArgs e) { DBManager dm = new DBManager(); EncryptionManager em = new EncryptionManager(); string pass = em.EncryptMyData(Txtp.Text); string npass = em.EncryptMyData(Txtn.Text); string cpass = em.EncryptMyData(Txtc.Text); if (npass == cpass) { string cmd = "update tbl_login set passwd='" + npass + "' where user_id='" + Session["aid"] + "'"; if (dm.ExecuteInsertUpdateOrDelete(cmd)) { Response.Write("<script>alert('Password Change Successfully..');window.location.href='../Login.aspx';</script>"); } else { Response.Write("<script>alert('UserId or Password in Not Match..');</script>"); } } else { Response.Write("<script>alert('Please Confirm Password..')</script>"); } }
protected void BtnLogin_Click(object sender, EventArgs e) { DatabaseManager dm = new DatabaseManager(); string epass = EncryptionManager.EncryptMyData(TxtPassword.Text); string mycmd = "select usertype from login where userid='" + TxtUserId.Text + "' and passwd='" + epass + "'"; DataTable dt = new DataTable(); dt = dm.ExecuteSelect(mycmd); if (dt.Rows.Count > 0) { mycmd = "update Login set lcount=lcount+1,lastlogin='******' where userid='" + TxtUserId.Text + "' and passwd='" + epass + "'"; dm.ExecuteInsertUpdateDelete(mycmd); string usertype = dt.Rows[0][0].ToString(); if (usertype == "user") { Session["userid"] = TxtUserId.Text; Response.Redirect("ConsumerZone/Home.aspx"); } else if (usertype == "admin") { Session["adminid"] = TxtUserId.Text; Response.Redirect("AdminZone/Home.aspx"); } } else { Response.Write("<script>alert('Invalid User!')</script>"); } }
protected void BtnSubmit_Click(object sender, EventArgs e) { DatabaseManager dm = new DatabaseManager(); string oldpassword = EncryptionManager.EncryptMyData(TxtOldPassword.Text); string newpassword = EncryptionManager.EncryptMyData(TxtNewPassword.Text); string Query = "update Login set passwd='" + newpassword + "' where userid='" + Session["userid"] + "' and passwd='" + oldpassword + "'"; string Query2 = "update Registration set passwd='" + newpassword + "' where emailid='" + Session["userid"] + "' and passwd='" + oldpassword + "'"; bool x = dm.ExecuteInsertUpdateDelete(Query); if (x == true) { if (dm.ExecuteInsertUpdateDelete(Query2) == true) { Response.Write("<script>alert('Password Changed Successfully')</script>"); } else { Response.Write("<script>alert('Password Changed but not successfully.')</script>"); } } else { Response.Write("<script>alert('Password is not changed')</script>"); } }
protected void BtnLogin_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); string EncryptedPassword = em.EncryptMyData(TxtPasswd.Text); string mycmd = "select UserType from GeneralInfo where Email='" + TxtUserId.Text + "' and Password = '******'"; dt = dm.SelectQuery(mycmd); if (dt.Rows.Count > 0) { string usertype = dt.Rows[0][0].ToString(); if (usertype.ToLower() == "user") { Session["userid"] = TxtUserId.Text; //to make login secure here userid is email id Response.Write("<script>alert('Valid User for User Zone')</script>"); Response.Redirect("userzone/UserHome.aspx"); } else { Session["adminid"] = TxtUserId.Text; Response.Redirect("adminzone/AdminHome.aspx"); } } else { Response.Write("<script>alert('Invalid user')</script>"); } }
protected void BtnChange_Click(object sender, EventArgs e) { cm.YourCommand = "SELECT *from Tbl_ForgotPassword where code='" + TxtCode.Text + "' and forgotid=(select max(forgotid) from Tbl_ForgotPassword where UserID='" + TxtVerEmail.Text + "')"; DataTable dt = cm.ExecuteSelectByDisconnected(); if (dt != null) { // Validate Valid till //reset password EncryptionManager em = new EncryptionManager(); cm.YourCommand = "UPDATE Tbl_Login set pwd='" + em.EncryptMyData(TxtNewPass.Text) + "' where UserID='" + TxtVerEmail.Text + "'"; if (cm.ExecuteInsertOrUpdateOrDelete()) { Response.Write("<script>alert('Password changed successfully');window.location.href = 'Login.aspx';</script>"); } else { Response.Write("<script>alert('Unable to reset password');</script>"); } } else { Response.Write("<script>alert('Invalid Varification code');window.location.href = '#dialog';</script>"); } }
protected void BtnOk_Click(object sender, EventArgs e) { if (TxtCode.Text == code) { string pass = EncryptionManager.EncryptMyData(epass); LblPass.Text = "Your password is: " + pass; TxtCode.Text = ""; } }
protected void BtnSubmit_Click(object sender, EventArgs e) { if (capcode == TxtCaptcha.Text) { //Response.Write("<script>alert('Do Registration')</script>"); string gender = "", filename = "", epass = ""; if (RbtnMale.Checked == true) { gender = "Male"; } if (RbtnFemale.Checked == true) { gender = "Female"; } epass = EncryptionManager.EncryptMyData(TxtPassword.Text); if (FUProfilePic.HasFile == true) { filename = FUProfilePic.PostedFile.ContentType; } string ext = filename.Substring(filename.LastIndexOf('/') + 1); ext = ext.ToLower(); ext = Path.GetRandomFileName() + "." + ext; string Query1 = "insert into Registration values('" + DDLConnectionType.SelectedValue + "','" + TxtName.Text + "','" + gender + "','" + TxtMobNo.Text + "','" + TxtEmailId.Text + "','" + TxtAddress.Text + "','" + ext + "','" + epass + "','" + DateTime.Now.ToShortDateString() + "')"; string Query2 = "insert into Login values('" + TxtEmailId.Text + "','" + epass + "','user',1,0,'')"; bool b = dm.ExecuteInsertUpdateDelete(Query1); if (b == true) { b = dm.ExecuteInsertUpdateDelete(Query2); if (b == true) { string Msg = "Hellow" + TxtName.Text + "Thanks for registration. Your user id is:" + TxtEmailId.Text + "and your password is:" + TxtPassword.Text + "Regards-GGL"; MySMSSender ss = new MySMSSender(); ss.SendMySMS(TxtMobNo.Text, Msg); FUProfilePic.SaveAs(Server.MapPath("ProfilePic/" + ext)); Response.Write("<script>alert('Registration Successfull')</script>"); } else { Response.Write("<script>alert('Login details are not saved')</script>"); } } else { Response.Write("<script>alert('Database Error')</script>"); } } else { Response.Write("<script>alert('Invalid Captcha Code!')</script>"); } }
protected void ImgBtnRegister_Click(object sender, ImageClickEventArgs e) { if (TxtCaptchaCode.Text == CodeAndImagePath[0]) { //code for Registration string gender = "", mycmd1, mycmd2, EncryptedPassword; if (RdBtnMale.Checked == true) { gender = "Male"; } if (RdBtnFemale.Checked == true) { gender = "Female"; } EncryptedPassword = em.EncryptMyData(TxtPassword.Text); mycmd1 = "insert into GeneralInfo values('" + TxtYourName.Text + "','" + TxtFatherName.Text + "','" + gender + "','" + TxtDOB.Text + "','" + TxtClgName.Text + "','" + TxtCourse.Text + "','" + TxtYear.Text + "','" + TxtAddress.Text + "','" + TxtContactNo.Text + "','" + TxtEmailAddress.Text + "','" + FUPicture.FileName + "','" + EncryptedPassword + "','" + DateTime.Now.ToShortDateString() + "','user')"; // mycmd2 = "insert into Login values('" + TxtEmail.Text + "','" + EncryptedPassword + "','User')"; bool n1 = dm.NonQuery(mycmd1); if (n1 == true) { // bool n2 = dm.NonQuery(mycmd2); // if (n2 == true) // { FUPicture.SaveAs(Server.MapPath("Profile/" + FUPicture.FileName)); LblMessage.Text = "Registration has been Done Successfully"; } // else // { // LblMessage.Text = "Registration Failed"; // } // } else { LblMessage.Text = "Registration Failed"; } } else { LblMessage.Text = "Invalid Captcha"; CodeAndImagePath = cg.GetRandomCodeAndImagePath("CaptchaImages"); ImgCaptcha.ImageUrl = CodeAndImagePath[1]; } }
protected void BtnSubmit_Click(object sender, EventArgs e) { if (capcode == TxtCaptchaCode.Text) { Response.Write("<script>alert('Do Ragistration')</script>"); string gender = "", filename = "", epass = ""; if (RdbMale.Checked == true) { gender = "Male"; } if (RdbFemale.Checked == true) { gender = "Female"; } epass = EncryptionManager.EncryptMyData(TxtPassword.Text); if (FUProfilePicture.HasFile == true) { filename = FUProfilePicture.FileName; } string Query1 = "insert into Registration values('" + TxtName.Text + "','" + gender + "','" + TxtDOB.Text + "','" + TxtAddress.Text + "','" + TxtEmail.Text + "','" + TxtMobileNo.Text + "','" + filename + "','" + epass + "','" + DateTime.Now.ToShortDateString() + "')"; string Query2 = "insert into Login values('" + TxtEmail.Text + "','" + epass + "','User',1,0,'')"; bool b = dm.ExecuteInsertUpdateDelete(Query1); if (b == true) { b = dm.ExecuteInsertUpdateDelete(Query2); if (b == true) { FUProfilePicture.SaveAs(Server.MapPath("ProfilePic/" + filename)); string msg = "Hello " + TxtName.Text + ",Thanks for registration.Your user id is:" + TxtEmail.Text + "and Your Pssword is:" + TxtPassword + "Regards-Kids Planet"; MySmsSender ss = new MySmsSender(); ss.SendMySMS(TxtMobileNo.Text, msg); Response.Write("<script>alert('Registration Successfully! ')</script>"); } else { Response.Write("<script>alert('Login Details are not saved ')</script>"); } } else { Response.Write("<script>alert('Database Error')</script>"); } } else { Response.Write("<script>alert('Invalid Catcha Code')</script>"); } }
protected void BtnChange_Click(object sender, EventArgs e) { ConnectionManager cm = new ConnectionManager(); EncryptionManager em = new EncryptionManager(); cm.YourCommand = "Update Tbl_Login set Pwd='" + em.EncryptMyData(TxtNewPass.Text) + "' where UserID='" + Session["uid"].ToString() + "' and pwd='" + em.EncryptMyData(TxtOldPass.Text) + "'"; if (cm.ExecuteInsertOrUpdateOrDelete()) { LblMsg.ForeColor = Color.Green; LblMsg.Text = "Password changed successfully."; } else { LblMsg.ForeColor = Color.Red; LblMsg.Text = "Invalid Credentials."; } }
public string ValidateUser() { SqlConnection cn = new SqlConnection( ConfigurationManager.ConnectionStrings ["myconstring"].ToString()); SqlCommand cmd = new SqlCommand("SPLogin", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@UserID", SqlDbType.VarChar).Value = UserID; string epass = em.EncryptMyData(UserPass); cmd.Parameters.Add("@pass", SqlDbType.VarChar).Value = epass; cmd.Parameters.Add("@Cntype", SqlDbType.VarChar).Value = connectionType; if (cn.State == ConnectionState.Closed) { cn.Open(); } object ob = cmd.ExecuteScalar(); cn.Close(); if (ob != null) { if (bool.Parse(ob.ToString()) == true) { return("SUCCESS"); } else { return("BLOCKED"); } } else { return("INVALID"); } }
protected void BtnLogin_Click(object sender, EventArgs e) { DBManager dm = new DBManager(); EncryptionManager em = new EncryptionManager(); string cmd = "select * from tbl_login where user_id='" + TxtUserid.Text + "' and passwd='" + em.EncryptMyData(TxtPasswd.Text) + "'"; DataTable dt = dm.ExecuteSelect(cmd); if (dt.Rows.Count > 0) { Session["aid"] = TxtUserid.Text; Response.Redirect("AdminZone/AddNews.aspx"); } else { Response.Write("<script>alert('Userid or Password in not match')</script>"); } }
protected void ImgBtnRegister_Click(object sender, ImageClickEventArgs e) { if (TxtCaptcha.Text == CaptchaCodeWithImage[0]) { FileManager fm = new FileManager(); string ValidationState; bool UploadState; if (FUPhoto.HasFile == true) { fm.MaxFileSizeInMB = 3.0f; fm.MyFileUpload = FUPhoto; ValidationState = fm.ValidateMyFile(); if (ValidationState == "SUCCESS") { UploadState = fm.UploadMyFile("UserPics"); if (UploadState == true) { cm.YourCommand = "INSERT into Tbl_profilePic(file_name,folder,user_id,filetype,filesize,isdel) values('" + fm.MyFileName + "','UserPics','" + TxtEmail.Text + "','" + fm.MyFileType + "','" + fm.FileSizeInMB + "','0')"; cm.ExecuteInsertOrUpdateOrDelete(); } else { Response.Write("<script>alert('Sorry! we are unable to upload picture.');</script>"); } } else { Response.Write("<script>alert('" + ValidationState + "');</script>"); } } if (FUIDProof.HasFile == true) { fm.FileSizeInMB = 5.0f; fm.MyFileUpload = FUIDProof; fm.AllowedExtention = new string[] { ".jpg", ".jpeg", ".pdf" }; ValidationState = fm.ValidateMyFile(); if (ValidationState == "SUCCESS") { UploadState = fm.UploadMyFile("UserIDProof"); if (UploadState == true) { EncryptionManager em = new EncryptionManager(); string EncryptedPass = em.EncryptMyData(TxtPass.Text); bool Gender; if (RdbMale.Checked == true) { Gender = true; } else { Gender = false; } cm.YourCommand = "INSERT into Tbl_Registration values('" + TxtName.Text + "','" + Gender + "','" + DdlConType.SelectedValue + "','" + TxtAddress.Text + "','" + int.Parse(DdlState.SelectedValue) + "','" + int.Parse(DdlCity.SelectedValue) + "','" + int.Parse(TxtPinCode.Text) + "','" + TxtEmail.Text + "','" + TxtMobNo.Text + "','" + EncryptedPass + "','" + fm.MyFileName + "','" + FUIDProof.FileName + "')"; bool b = cm.ExecuteInsertOrUpdateOrDelete(); if (b == true) { LoginManager lm = new LoginManager(); lm.UserID = TxtEmail.Text; lm.UserPass = EncryptedPass; lm.UserStatus = true; lm.connectionType = "Consumer"; lm.LoginCount = 0; b = lm.SetLoginDetails(); if (b == true) { Response.Write("<script>alert('You are registered successfully.');</script>"); } else { Response.Write("<script>alert('You are registered successfully.But we are unable to set login details.');</script>"); } } else { Response.Write("<script>alert('Unable to register.');</script>"); } } } else { Response.Write("<script>alert('" + ValidationState + "');</script>"); } } else { Response.Write("<script>alert('Please upload 1 ID proof.');</script>"); } } else { Response.Write("<script>alert('Invalid Captcha Code.');</script>"); } }
protected void BtnEncrypt_Click(object sender, EventArgs e) { EncryptionManager em = new EncryptionManager(); TxtEncryptedData.Text = em.EncryptMyData(TxtNormalData.Text); }