public void bindDetailToEdit(int id) { using (SqlConnection con = new SqlConnection(IGTMAIN.CS)) { string cmdText = "SELECT * FROM User_Details where User_ID=@Id"; SqlCommand cmd = new SqlCommand(cmdText, con); cmd.Parameters.AddWithValue("@Id", id); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { dr.Read(); ddl_User_Type.Text = dr["User_Type"].ToString(); ddl_Status.Text = dr["User_Status"].ToString(); txt_User_Code.Text = dr["User_Code"].ToString(); txt_User_pass.Attributes.Add("value", IGTMAIN.Decryptdata(dr["User_pass"].ToString())); txt_User_Name.Text = dr["User_Name"].ToString(); txt_User_Email.Text = dr["User_Email"].ToString(); txt_User_Phno.Text = dr["User_Phno"].ToString(); } } }
protected void btn_Submit_Click(object sender, EventArgs e) { IGTMAIN.cmdtextAll = "Select * from User_Details "; string script = "Welcome!!!"; if (txt_User_ID.Text.Length != 0 && txt_Password.Text.Length != 0) { using (SqlConnection con = new SqlConnection(IGTMAIN.CS)) { string cmdText = "SELECT * FROM User_Details where User_Code=@Id"; SqlCommand cmd = new SqlCommand(cmdText, con); cmd.Parameters.AddWithValue("@Id", txt_User_ID.Text.ToUpper()); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows == false) { script = "alert(\" Wrong User Name Entered.\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } else if (dr.HasRows == true) { dr.Read(); string _password = dr["User_pass"].ToString(); _password = IGTMAIN.Decryptdata(_password); if (txt_Password.Text.ToUpper() == _password) { Session.RemoveAll(); Session["User_ID"] = dr["User_Name"].ToString(); Session["Login_Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Session["LActive_Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Session["Status"] = "ACTIVE"; Response.Redirect("AdminDefault.aspx"); } else { script = "alert(\" Wrong Password entered.\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } } } } else { script = "alert(\" All Fields are Manadatory. Please fill and Submit again.\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } }
protected void btn_Submit_Click(object sender, EventArgs e) { if (txt_CPass.Text.Length > 0 && txt_NCPass.Text.Length > 0 && txt_NewPass.Text.Length > 0) { using (SqlConnection con = new SqlConnection(IGTMAIN.CS)) { string cmdText = "SELECT * FROM User_Details where User_Code='" + Session["User_ID"] + "'"; SqlCommand cmd = new SqlCommand(cmdText, con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows == false) { script = "alert(\" Wrong User Name Entered.\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } else if (dr.HasRows == true) { dr.Read(); string _password = dr["User_pass"].ToString(); _password = IGTMAIN.Decryptdata(_password); if (txt_CPass.Text == _password) { if (txt_NCPass.Text == txt_NewPass.Text) { updatepassword(); } else { script = "alert(\"New Password and Confirm Password not Matching.\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } } else { script = "alert(\" Wrong Current Password entered.\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } } else { script = "alert(\" All Fields are Manadatory. Please fill and Submit again.\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } } } }