Exemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string  sqltext = "";
            ConnSql con     = new ConnSql();

            if (TextBox1.Text == "")
            {
                WebMessage.Show("输入初始密码!");
            }
            else if (TextBox2.Text == "")
            {
                WebMessage.Show("请输入密码!");
            }
            else if (TextBox2.Text != TextBox3.Text)
            {
                WebMessage.Show("输入的两次密码不相同!");
            }
            else if (TextBox2.Text.Length < 6)
            {
                WebMessage.Show("密码长度小于6");
            }
            else if (TextBox1.Text != Session["password"].ToString())
            {
                WebMessage.Show("你输入原始密码不正确!");
            }
            else
            {
                sqltext = "update student set pwd='" + TextBox2.Text + "'where sno='" + Session["username"].ToString() + "'";
                con.RunSql(sqltext);
                Session["password"] = TextBox2.Text;//保存新密码到Session
                WebMessage.Show("修改密码正确!", "selectCourse.aspx");
            }
        }
 protected void b_send_Click(object sender, EventArgs e)
 {
     if (tb_cno.Text.Length == 0)
     {
         WebMessage.Show("请输入课程号!");
     }
     else
     {
         ConnSql con = new ConnSql();
         System.Data.DataTable table = new System.Data.DataTable();
         string tno    = con.RunSqlReturnTable("select tno from teacher where tname='" + ddl_lt.Text.Trim() + "'").Rows[0][0].ToString();
         int    result =
             con.RunSql("insert into course(cno,cname,tno,xs,skdd) values ('" +
                        tb_cno.Text.Trim() + "','" +
                        tb_cname.Text.Trim() + "','" +
                        tno + "','" +
                        tb_cth.Text.Trim() + "','" +
                        tb_classAdd.Text.Trim() + "')");
         if (result == 1)
         {
             WebMessage.Show("添加成功");
         }
         else
         {
             WebMessage.Show("添加失败");
         }
     }
 }
Exemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            ConnSql con = new ConnSql();

            con.RunSql("insert stu_course(sno,cno) values('" +
                       Label9.Text.Trim() + "','" + Label11.Text.Trim() + "')");
            Response.Redirect("QueryCourse.aspx");
        }
Exemplo n.º 4
0
        protected void Button1_Click(object sender, EventArgs e)    //添加
        {
            ConnSql con     = new ConnSql();
            string  sqltext = "";

            sqltext = "insert student(sno,sname,sex,birthday) values('" + TextBox1.Text.Trim() + "','" + TextBox2.Text.Trim() + "','" + DropDownList1.SelectedIndex.ToString() + "','" + TextBox3.Text.Trim() + "')";
            con.RunSql(sqltext);
            TextBox1.Text = "添加成功";
            TextBox2.Text = string.Empty;
            TextBox3.Text = DateTime.Now.ToString("yyyy-MM-dd");
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            ConnSql con     = new ConnSql();
            string  sqltext = "";

            sqltext = "delete student where sno='" + TextBox1.Text.Trim() + "'";
            if (con.RunSql(sqltext) == 1)
            {
                WebMessage.Show("删除成功");
            }
            else
            {
                WebMessage.Show("删除失败");
            }
        }
Exemplo n.º 6
0
        protected void Button_Confirm(object sender, EventArgs e)
        {
            if (Username.Text == "")
            {
                WebMessage.Show("请输入用户名");
            }
            else if (name.Text == "")
            {
                WebMessage.Show("请输入姓名");
            }
            else if (xueyuan.Text == "")
            {
                WebMessage.Show("请输入学院");
            }
            else if (banji.Text == "")
            {
                WebMessage.Show("请输入班级");
            }
            else if (Password.Text == "")
            {
                WebMessage.Show("请输入密码");
            }
            else if (Check.Text == "")
            {
                WebMessage.Show("请再次输入密码");
            }
            else if (Password.Text != Check.Text)
            {
                WebMessage.Show("密码不一致!");
            }

            else
            {
                string  sql  = "INSERT INTO bookuser (id,pwd,name,class,xueyuan,status,sex,admin,times1) VALUES ('" + Username.Text.Trim() + "','" + Password.Text.Trim() + "','" + name.Text.Trim() + "','" + banji.Text.Trim() + "','" + xueyuan.Text.Trim() + "','1','" + RadioButtonList1.SelectedValue + "','0','0')";
                ConnSql conn = new ConnSql();
                int     s    = conn.RunSql(sql);
                if (s > 0)
                {
                    WebMessage.Show("添加成功", "Index.aspx");
                }
                else
                {
                    WebMessage.Show("添加失败");
                }
            }
        }
        protected void bSend_Click(object sender, EventArgs e)
        {
            //!Error 学生姓名过长会 截断字符串
            ConnSql con     = new ConnSql();
            int     sex_tmp = rb_girl.Checked ? 1 : 0; //  暂存性别信息 女true 男false

            sex_tmp = con.RunSql("update student set sname = '" + tb_sname.Text.Trim() + "', sex="
                                 + sex_tmp + ", birthday = '"
                                 + tb_birth.Text.Trim() + "' where sno = '"
                                 + tb_sno.Text.Trim() + "'");
            if (sex_tmp.Equals(1))
            {
                WebMessage.Show("执行成功");
            }
            else
            {
                WebMessage.Show("执行失败");
            }
        }
        protected void btn_edit_Click(object sender, EventArgs e)
        {
            ConnSql con = new ConnSql();
            string  sql = "update course set " +
                          "cname = '" + tb_cname.Text + "'," +
                          "xs = " + int.Parse(tb_lt.Text.Trim()) + "," +
                          "skdd = '" + tb_addr.Text + "'," +
                          "tno = '" + ddl_tch.SelectedValue + "'" +
                          " where cno = '" + tb_cno.Text + "'";

            try
            {
                con.RunSql(sql);
            }
            catch (Exception ex)
            {
                WebMessage.Show(ex.ToString());
                throw;
            }
        }
Exemplo n.º 9
0
    protected void logout(object sender, EventArgs e)
    {
        string userid = Session["username"].ToString();//获取Session["user_id"]的值
        string strsql = " update users set zx=0 where username='******'";

        con.RunSql(strsql);//如果用户退出,修改用户在线信息为0
        Session["username"]  = null;
        Session["password"]  = null;
        Session["nc"]        = "";
        Session["jf"]        = "";
        Session["realname"]  = "";//session值均设为空
        Session["url"]       = null;
        Session["last_time"] = "";
        state.Text           = "游客";
        User_Join.Visible    = true;
        Exit.Visible         = false;
        ts_hl.Visible        = false;
        ts_hl.Text           = "短消息";
        //跳转到登陆界面
        Response.Redirect("Default.aspx");
    }
Exemplo n.º 10
0
        protected void Button_Login(object sender, EventArgs e)
        {
            if (Username.Text == "")
            {
                WebMessage.Show("请输入用户名");
            }
            else if (Password.Text == "")
            {
                WebMessage.Show("请输入密码");
            }
            else if (yzm.Text == "")
            {
                WebMessage.Show("请输入验证码");
            }
            else
            {
                string    sqltext = "select * from bookuser where id='" + Username.Text + "'";
                DataTable table   = new DataTable();
                ConnSql   cn      = new ConnSql();
                table = cn.RunSqlReturnTable(sqltext);
                if (table.Rows.Count <= 0)
                {
                    WebMessage.Show("用户名错误!");
                }
                else if (table.Rows[0][1].ToString().Trim() != Password.Text)
                {
                    WebMessage.Show("密码错误!");
                }
                else if (table.Rows[0][4].ToString().Trim() == "0")
                {
                    WebMessage.Show("账户处于挂失状态,无法登陆!");
                }
                else if (yzm.Text != btn_yzm.Text)
                {
                    WebMessage.Show("验证码输入错误");
                }
                else
                {
                    ConnSql con = new ConnSql();
                    string  sql = "update bookuser SET last_login_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff") + "' WHERE id='" + table.Rows[0][0].ToString() + "'";
                    con.RunSql(sql);
                    //保存登录的用户的用户名和密码到Session对象
                    Session["Admin"] = table.Rows[0][5].ToString();
                    if (Session["Admin"].ToString() == "1")
                    {
                        Session["Username"] = table.Rows[0][0].ToString();
                        Session["Password"] = table.Rows[0][1].ToString();
                        Session["Name"]     = table.Rows[0][2].ToString();
                        Session["Time"]     = table.Rows[0][6].ToString();
                        Session["id"]       = Username.Text;
                        WebMessage.Show("登录成功,管理员:" + Session["Name"].ToString().Trim() + "欢迎您!", "/Admin/Index/Index.aspx");
                    }

                    else if (Session["Admin"].ToString() == "0")
                    {
                        Session["Username"] = table.Rows[0][0].ToString();
                        Session["Password"] = table.Rows[0][1].ToString();
                        Session["Name"]     = table.Rows[0][2].ToString();
                        Session["Time"]     = table.Rows[0][6].ToString();
                        Session["id"]       = Username.Text;
                        WebMessage.Show("登录成功," + Session["Name"].ToString().Trim() + "同学,欢迎您!", "/Home/Index/Index.aspx");
                    }
                }
            }
        }