public void ForgotPassword(SendEmail objSendEmail)
        {
            List <recexist> listdataexist = new List <recexist>();

            listdataexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cs))
            {
                connection.Open();
                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;
                command.CommandText = "select * from login where login_email ='" + objSendEmail.EmailAddress + "'";
                SqlDataReader re = null;
                re = command.ExecuteReader();
                if (re.HasRows)
                {
                    re.Close();
                    command.CommandText = "update login set forgot_key='" + objSendEmail.getpassword + "' where  login_email ='" + objSendEmail.EmailAddress + "'";
                    command.ExecuteNonQuery();
                    transaction.Commit();
                    string     htmlbody = objSendEmail.EmailBody;
                    SmtpClient client   = new SmtpClient();
                    client.Port                  = 587;
                    client.Host                  = "smtp.gmail.com";
                    client.EnableSsl             = true;
                    client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials           = new NetworkCredential("", "");
                    MailMessage mm = new MailMessage(objSendEmail.EmailAddress, objSendEmail.EmailAddress, objSendEmail.Subject, htmlbody);
                    mm.From       = new MailAddress("*****@*****.**", "Farooq Tech");
                    mm.IsBodyHtml = true;
                    mm.Priority   = MailPriority.Normal;
                    mm.ReplyToList.Add("*****@*****.**");
                    mm.BodyEncoding = Encoding.Default;
                    mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                    client.Send(mm);
                    recexist objdataexist = new recexist();
                    objdataexist.Dataexist = "Found";
                    listdataexist.Add(objdataexist);
                }
                else
                {
                    recexist objdataexist = new recexist();
                    objdataexist.Dataexist = "not found";
                    listdataexist.Add(objdataexist);
                }
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listdataexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listdataexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void userlogin(UserInfo objUserInfo)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cs))
            {
                connection.Open();
                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;
                string varPassword = GetMD5HashData(objUserInfo.Password);
                string exist       = "";
                command.CommandText = "SELECT * FROM  login WHERE   login_email ='" + objUserInfo.Email + "' AND login_password ='******'";
                objadp = new SqlDataAdapter(command.CommandText, connection);
                objadp.SelectCommand.Transaction = transaction;
                dtr = new DataTable();
                objadp.Fill(dtr);
                foreach (DataRow dtrow in dtr.Rows)
                {
                    email      = dtrow["login_email"].ToString();
                    uuseername = dtrow["login_name"].ToString();
                    pass       = dtrow["login_password"].ToString();
                    if (varPassword == pass)
                    {
                        Session["username"] = dtrow["login_name"].ToString();
                        Session["email"]    = dtrow["login_email"].ToString();
                        Session["login_id"] = dtrow["login_id"].ToString();
                        Session["userrole"] = dtrow["login_type"].ToString();
                    }
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "found";
                    listrecexist.Add(Objrecexist);
                    exist = "found";
                }
                if (exist == "")
                {
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "Not Found";
                    listrecexist.Add(Objrecexist);
                }
                transaction.Commit();
            }



            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void FotgotPasswordUpdate(UserInfo objUserInfo)
        {
            List <recexist> listdataexist = new List <recexist>();

            listdataexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand cmd2 =
                    new SqlCommand(
                        "select * from login where forgot_key='" + objUserInfo.Email + "'", con);
                SqlDataReader re = null;
                re = cmd2.ExecuteReader();
                if (!(re.HasRows))
                {
                    recexist objdataexist = new recexist();
                    objdataexist.Dataexist = "not found";
                    listdataexist.Add(objdataexist);
                    con.Close();
                }
                else
                {
                    string varPassword = GetMD5HashData(objUserInfo.Password);
                    con.Close();
                    con.Open();
                    SqlCommand cmd =
                        new SqlCommand("update login set login_password='******' where forgot_key='" + objUserInfo.Email + "'", con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    con.Open();
                    SqlCommand cmd3 =
                        new SqlCommand("update login set forgot_key='' where forgot_key='" + objUserInfo.Email + "'", con);
                    cmd3.ExecuteNonQuery();
                    con.Close();
                    recexist objdataexist = new recexist();
                    objdataexist.Dataexist = "Found";
                    listdataexist.Add(objdataexist);
                }
                con.Close();
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listdataexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listdataexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void UpdateMarks(clsStd ObjEditStdInfo)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string ConnectionString = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection objcon = new SqlConnection(ConnectionString))
            {
                objcon.Open();
                SqlCommand    cmd3 = new SqlCommand("SELECT marks_id FROM marks WHERE subjects_id ='" + ObjEditStdInfo.subjects_id + "' and std_id ='" + ObjEditStdInfo.std_id + "' ", objcon);
                SqlDataReader re   = null;
                re = cmd3.ExecuteReader();
                if (re.HasRows)
                {
                    string marksId = "";
                    while (re.Read())
                    {
                        marksId = re["marks_id"].ToString();
                    }
                    objcon.Close();
                    objcon.Open();
                    SqlCommand cmnd2 = new SqlCommand("UPDATE marks SET std_marks ='" + ObjEditStdInfo.std_marks + "' WHERE marks_id= '" + marksId + "'", objcon);
                    cmnd2.ExecuteNonQuery();
                    objcon.Close();
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "found";
                    listrecexist.Add(Objrecexist);
                }
                else
                {
                    objcon.Close();
                    objcon.Open();
                    SqlCommand cmnd2 = new SqlCommand("insert  into marks (std_marks,std_id,subjects_id) values('" + ObjEditStdInfo.std_marks + "','" + ObjEditStdInfo.std_id + "' ,'" + ObjEditStdInfo.subjects_id + "')", objcon);
                    cmnd2.ExecuteNonQuery();
                    objcon.Close();
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "Not Found";
                    listrecexist.Add(Objrecexist);
                }
                objcon.Close();
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
Example #5
0
        public void fnAddSubject(addstudent ObjAddStd)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cs))
            {
                connection.Open();
                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;
                string exist = "";
                command.CommandText = "SELECT * FROM subjects WHERE subjects_name ='" + ObjAddStd.std_name + "'";
                SqlDataAdapter objadp = new SqlDataAdapter(command.CommandText, connection);
                objadp.SelectCommand.Transaction = transaction;
                DataTable dtr = new DataTable();
                objadp.Fill(dtr);
                foreach (DataRow dtrow in dtr.Rows)
                {
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "found";
                    listrecexist.Add(Objrecexist);
                    exist = "found";
                }
                if (exist == "")
                {
                    command.CommandText = "INSERT INTO subjects (subjects_name, total_marks) VALUES ('" + ObjAddStd.std_name + "', '" + ObjAddStd.std_lastname + "')" + "SELECT SCOPE_IDENTITY()";
                    string insertedID = command.ExecuteScalar().ToString();



                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "Not Found";
                    listrecexist.Add(Objrecexist);
                }
                transaction.Commit();
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void GetUserName(SendEmail objSendEmail)
        {
            List <recexist> listdataexist = new List <recexist>();

            listdataexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cs))
            {
                connection.Open();
                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;
                command.CommandText = "select * from login where login_email ='" + objSendEmail.EmailAddress + "'";
                SqlDataReader re = null;
                re = command.ExecuteReader();
                if (re.HasRows)
                {
                    while (re.Read())
                    {
                        recexist objdataexist = new recexist();
                        objdataexist.Dataexist = Convert.ToString(re["login_name"].ToString());
                        listdataexist.Add(objdataexist);
                    }
                }
                else
                {
                    status = Convert.ToString(re["status"].ToString());
                    recexist objdataexist = new recexist();
                    objdataexist.Dataexist = "Not Found";
                    listdataexist.Add(objdataexist);
                }
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listdataexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listdataexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
Example #7
0
        public void UpdateSubject(addstudent ObjEditStdInfo)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string ConnectionString = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection objcon = new SqlConnection(ConnectionString))
            {
                //objcon.Open();
                //SqlCommand cmd3 = new SqlCommand("SELECT subjects_name FROM subjects WHERE subjects_name ='" + ObjEditStdInfo.std_name + "'", objcon);
                //SqlDataReader re = null;
                //re = cmd3.ExecuteReader();
                //if (re.HasRows)
                //{
                //    recexist Objrecexist = new recexist();
                //    Objrecexist.Dataexist = "found";
                //    listrecexist.Add(Objrecexist);
                //}
                //else
                //{
                objcon.Close();
                objcon.Open();
                SqlCommand cmnd2 = new SqlCommand("UPDATE subjects SET subjects_name ='" + ObjEditStdInfo.std_name + "',total_marks ='" + ObjEditStdInfo.std_lastname + "' WHERE subjects_id= '" + ObjEditStdInfo.std_id + "'", objcon);
                cmnd2.ExecuteNonQuery();
                objcon.Close();
                recexist Objrecexist = new recexist();
                Objrecexist.Dataexist = "Not Found";
                listrecexist.Add(Objrecexist);
                //}
                //objcon.Close();
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void Addclasses(addstudent ObjAddStd)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string ConnectionString = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection objcon = new SqlConnection(ConnectionString))
            {
                objcon.Open();
                SqlCommand    cmd3 = new SqlCommand("SELECT classes_name FROM classes WHERE classes_name ='" + ObjAddStd.std_name + "'", objcon);
                SqlDataReader re   = null;
                re = cmd3.ExecuteReader();
                if (re.HasRows)
                {
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "found";
                    listrecexist.Add(Objrecexist);
                }
                else
                {
                    objcon.Close();
                    objcon.Open();
                    SqlCommand cmnd2 = new SqlCommand("INSERT INTO classes (classes_name) VALUES ('" + ObjAddStd.std_name + "')", objcon);
                    cmnd2.ExecuteNonQuery();
                    objcon.Close();
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "Not Found";
                    listrecexist.Add(Objrecexist);
                }
                objcon.Close();
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void fnAddStd(addstudent ObjAddStd)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cs))
            {
                connection.Open();
                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;
                string varPassword = GetMD5HashData(ObjAddStd.std_password);
                string exist       = "";
                command.CommandText = "SELECT std_name FROM add_std_info WHERE std_name ='" + ObjAddStd.std_name + "' AND std_father ='" + ObjAddStd.std_father + "' AND classes_id ='" + ObjAddStd.std_class + "' AND std_gender ='" + ObjAddStd.std_gender + "' AND std_phone_no ='" + ObjAddStd.std_phone_no + "'";
                objadp = new SqlDataAdapter(command.CommandText, connection);
                objadp.SelectCommand.Transaction = transaction;
                dtr = new DataTable();
                objadp.Fill(dtr);
                foreach (DataRow dtrow in dtr.Rows)
                {
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "found";
                    listrecexist.Add(Objrecexist);
                    exist = "found";
                }
                if (exist == "")
                {
                    command.CommandText = "INSERT INTO add_std_info (std_name, std_lastname,std_father,std_gender, classes_id, std_phone_no) VALUES ('" + ObjAddStd.std_name + "', '" + ObjAddStd.std_lastname + "','" + ObjAddStd.std_father + "', '" + ObjAddStd.std_gender + "', '" + ObjAddStd.std_class + "', '" + ObjAddStd.std_phone_no + "')" + "SELECT SCOPE_IDENTITY()";
                    string insertedID = command.ExecuteScalar().ToString();

                    command.CommandText = "SELECT login_email FROM login WHERE login_email ='" + ObjAddStd.std_email + "' ";
                    objadp = new SqlDataAdapter(command.CommandText, connection);
                    objadp.SelectCommand.Transaction = transaction;
                    dtr = new DataTable();
                    objadp.Fill(dtr);
                    foreach (DataRow dtrow in dtr.Rows)
                    {
                        recexist Objrecexist = new recexist();
                        Objrecexist.Dataexist = "found_email";
                        listrecexist.Add(Objrecexist);
                        exist = "found_email";
                    }


                    if (exist == "")
                    {
                        command.CommandText = "INSERT INTO login (login_email, login_password,login_name,login_type,member_id) VALUES ( '" + ObjAddStd.std_email + "', '" + varPassword + "','" + ObjAddStd.std_name + "','student','" + insertedID + "')";
                        command.ExecuteNonQuery();

                        recexist Objrecexist = new recexist();
                        Objrecexist.Dataexist = "Not Found";
                        listrecexist.Add(Objrecexist);
                        transaction.Commit();
                    }
                }
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }