protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = dataconn.getcon();

        con.Open();
        SqlCommand mycom = new SqlCommand("select question from tb_Student  where ID='"
                                          + Convert.ToString(Session["ID"]) + "'", con);

        this.labQuePwd.Text = Convert.ToString(mycom.ExecuteScalar());
        con.Close();
    }
Example #2
0
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        SqlConnection cn = dataconn.getcon();

        cn.Open();
        SqlCommand com   = new SqlCommand("select count(*) from Student where ID='" + TextBox1.Text + "'", cn);
        int        count = Convert.ToInt32(com.ExecuteScalar());

        if (TextBox1.Text == "")
        {
            Response.Write("<script>alert('用户名不能为空');</script>");
        }


        else if (count > 0)
        {
            Session["ID"] = TextBox1.Text;
            Response.Redirect("getpwd2.aspx");
        }
        else
        {
            Response.Write("<script>alert('该用户名不存在');</script>");
            return;
        }
        cn.Close();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = dataconn.getcon();

        con.Open();
        string     sqlstr1  = "select count(*) from Score where UserID ='" + Session["ID"] + "' and PaperID='" + ddlQueName.SelectedValue + "'";
        SqlCommand mycom    = new SqlCommand(sqlstr1, con);
        int        intcount = Convert.ToInt32(mycom.ExecuteScalar());

        Application["d1"]    = ddlLesson.SelectedItem;
        Session["PaperID"]   = ddlQueName.SelectedValue;
        Session["PaperName"] = ddlQueName.SelectedItem;
        if (this.ddlQueName.Text == "")
        {
            Response.Write("<script lanuage=javascript>alert('您还没有选择考试套题,请重新选择!');location='javascript:history.go(-1)'</script>");
        }
        else if (intcount > 0)
        {
            Response.Write("<script lanuage=javascript>alert('此套题已经答过!');location='javascript:history.go(-1)'</script>");
        }
        else
        {
            Response.Redirect("wait.aspx");
        }
    }
    public static string DeleteAll(string s)
    {
        string[] str  = s.Split('*');
        string   Tsql = "delete from Chapter where ID='";

        for (int i = 0; i < str.Length; i++)
        {
            Tsql += str[i] + "'";
            if (i + 1 < str.Length)
            {
                Tsql += " or ID='";
            }
        }
        Datacon       dataconn = new Datacon();
        SqlConnection cn       = dataconn.getcon();

        cn.Open();
        SqlCommand com = cn.CreateCommand();

        com.CommandText = Tsql;
        if (com.ExecuteNonQuery() > 0)
        {
            return("true");
        }
        else
        {
            return("false");
        }
        cn.Close();
    }
Example #5
0
    protected void InitData()
    {
        int          multiProblemID = int.Parse(Request["ID"].ToString()); //取出传递过来的试题编号
        MultiProblem multiproblem   = new MultiProblem();                  //创建单选题对象

        if (multiproblem.LoadData(multiProblemID))                         //如果取出题目信息,分别放在相应控件显示
        {
            db.ecDropDownList(ddlCourse, "select *from Course where c_id=(select c_id from MultiProblem where ID='" + multiProblemID + " ')", "c_name", "c_id");
            txtTitle.Text   = multiproblem.Title;
            txtAnswerA.Text = multiproblem.AnswerA;
            txtAnswerB.Text = multiproblem.AnswerB;
            txtAnswerC.Text = multiproblem.AnswerC;
            txtAnswerD.Text = multiproblem.AnswerD;
            string        answer = multiproblem.Answer.ToString();
            SqlConnection cn     = db.getcon();
            cn.Open();
            string     sqlstr1 = "select Answer from MultiProblem where ID='" + Request["ID"].ToString() + "'";
            SqlCommand cmd1    = new SqlCommand(sqlstr1, cn);
            Label1.Text = cmd1.ExecuteScalar().ToString();
        }
        else                //查询出错,给出提示
        {
            Response.Write("<script>alert('加载数据错误!');</script>");
            Response.Write("<script>window.location.href='ChangeDuoXuan'</script>");
        }
    }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection cn = dataconn.getcon();

        cn.Open();
        //string str = "select Question from tb_Student where ID='" + Convert.ToString(Session["ID"]) + "'";


        if (!IsPostBack)
        {
            SqlCommand mycom = new SqlCommand("select question from Student  where ID='"
                                              + Convert.ToString(Session["ID"]) + "'", cn);
            this.Label2.Text = Convert.ToString(mycom.ExecuteScalar());
            cn.Close();
        }
    }
Example #7
0
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     SqlConnection cn = dataconn.getcon();
     cn.Open();
     int id = int.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
     string ID = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();
     string Name = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
     string PWD = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
     string JoinTime = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString();
     SqlDataReader dr;
     string sql = "Update Admin Set ID='" + ID + "',Name='" + Name + "',PWD='" + PWD + "',JoinTime='" + JoinTime + "' Where ID=" + id + "";
     SqlCommand myCommand = new SqlCommand(sql, cn);
     dr = myCommand.ExecuteReader();
     GridView1.EditIndex = -1;
     cn.Close();
     dataconn.bind(GridView1, "select * from Admin  order by ID DESC");
 }
Example #8
0
    private void getcom(int i)
    {
        SqlConnection cn = dataconn.getcon();

        cn.Open();
        SqlCommand com = cn.CreateCommand();

        switch (i)
        {
        case 1:
            com.CommandText = "select count(*) from Student where ID='" + this.TextBox5.Text + "'and PWD='" + this.TextBox6.Text + "'";
            int count1 = Convert.ToInt32(com.ExecuteScalar());
            if (count1 > 0)
            {
                Session["ID"]  = TextBox5.Text;
                Session["PWD"] = TextBox6.Text;
                Response.Redirect("User/or.aspx");
            }
            else
            {
                Response.Write("<script language=javascript>alert('用户名或密码错误!')</script>");
            }
            break;

        case 2:
            com.CommandText = "select count(*) from Admin where name='" + TextBox5.Text + "'and PWD='" + TextBox6.Text + "'";
            int count2 = Convert.ToInt32(com.ExecuteScalar());
            if (count2 > 0)
            {
                Session["ID"]  = TextBox5.Text;
                Session["PWD"] = TextBox6.Text;
                Page.Response.Redirect("Admin/admin.aspx");
            }
            else
            {
                Response.Write("<script>alert('用户名或密码错误!')</script>");
                Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");
            }
            break;

        case 3:
            com.CommandText = "select count(*) from Teacher where id='" + this.TextBox5.Text + "'and pwd='" + this.TextBox6.Text + "'";
            int count3 = Convert.ToInt32(com.ExecuteScalar());
            if (count3 > 0)
            {
                Session["ID"]  = TextBox5.Text;
                Session["PWD"] = TextBox6.Text;
                Response.Redirect("Teacher/teacher.aspx");
            }
            else
            {
                Response.Write("<script language=javascript>alert('用户名或密码错误!')</script>");
                Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");
            }
            break;
        }
    }
Example #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = dataconn.getcon();

        con.Open();
        SqlCommand mycom1 = new SqlCommand("select ID,Pwd from tb_Student where ID='" + Convert.ToString(Session["ID"]) + "'", con);
        SqlCommand mycom2 = new SqlCommand("select PWD from tb_Student where ID='" + Convert.ToString(Session["ID"]) + "'", con);

        this.txtStuID.Text  = Convert.ToString(mycom1.ExecuteScalar());
        this.txtStuPwd.Text = Convert.ToString(mycom2.ExecuteScalar());
        con.Close();
    }
Example #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Button4.Attributes.Add("onclick", "javascript:return window.confirm('您确定要删除吗?')");
        if (!IsPostBack)
        {
            /*验证是否登陆了系统*/
            if (Session["User_Row"] != "Admin")
            {
                Response.Write("<script>top.location.href='../404.html';</script>");
                return;
            }

            dataconn.bindinfostring(GridView1, "select * from Major order by ID DESC", "ID");

            //查询数据
            SqlConnection cn = dataconn.getcon();
            cn.Open();
            string     sqlstr1 = "select count(*) from Major";
            SqlCommand cmd1    = new SqlCommand(sqlstr1, cn);
            Label5.Text = cmd1.ExecuteScalar().ToString();
        }
    }
Example #11
0
    protected void Button_insertinto_Click(object sender, EventArgs e)
    {
        Datacon       dataconn = new Datacon();
        SqlConnection cn       = dataconn.getcon();

        cn.Open();
        SqlCommand com = cn.CreateCommand();

        com.CommandText = "update TaoTi set PaperName='" + TextBox_PaperName.Text + "',PaperState='" + TextBox_PaperState.Text + "',AnswerTime='" + TextBox_AnswerTime.Text + "' where PaperID='" + PaperID + "'";
        if (com.ExecuteNonQuery() > 0)
        {
            Response.Write("<script>alert('修改成功!');window.parent.location.reload();</script>");
        }
    }
Example #12
0
    protected void Button_insertinto_Click(object sender, EventArgs e)
    {
        Datacon       dataconn = new Datacon();
        SqlConnection cn       = dataconn.getcon();

        cn.Open();
        SqlCommand com = cn.CreateCommand();

        com.CommandText = "update Course set c_name='" + TextBox_c_name.Text.ToString().Trim() + "' where c_id='" + TextBox_c_id.Text.ToString().Trim() + "'";
        if (com.ExecuteNonQuery() > 0)
        {
            Response.Write("<script>alert('修改成功!" + TextBox_c_name.Text + TextBox_c_id.Text + "');window.parent.location.reload();</script>");
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     //在文本框中显示管理员信息
     if (!IsPostBack)
     {
         SqlConnection con = dataconn.getcon();
         con.Open();
         SqlDataAdapter mydataadapter = new SqlDataAdapter("select * from tb_Administrator where ID=" + Request["id"], con);
         DataSet        mydataset     = new DataSet();
         mydataadapter.Fill(mydataset, "tb_Administrator");
         DataRowView rowview = mydataset.Tables["tb_Administrator"].DefaultView[0];
         this.txtAdminName.Text = Convert.ToString(rowview["Name"]);
         this.txtAdminPwd.Text  = Convert.ToString(rowview["PWD"]);
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Page.IsPostBack == false)
     {
         SqlConnection con = dataconn.getcon();
         con.Open();
         SqlDataAdapter mydataadapter = new SqlDataAdapter("select * from tb_Profession where id="
                                                           + Request["id"], con);
         DataSet mydataset = new DataSet();
         mydataadapter.Fill(mydataset, "tb_Profession");
         DataRowView rowview = mydataset.Tables["tb_Profession"].DefaultView[0];
         this.txtProName.Text = Convert.ToString(rowview["Name"]);
         con.Close();
     }
 }
    public int checkDel(string key)
    {
        Datacon dacon = new Datacon();
        SqlConnection con = dacon.getcon();
        string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        //SqlCommand myCommand = new SqlCommand("INSERT INTO xxfb(NewsName, NewsContent, NewsDate) VALUES('" + caption + "','" + editor + "', '" + time + "')", con);

        SqlCommand myCommand = new SqlCommand(" delete  from xxfb where MessagesId=@NewsId", con);
        myCommand.Parameters.Add(new SqlParameter("@NewsId", SqlDbType.Int, 50));
        myCommand.Parameters["@NewsId"].Value = key;
        myCommand.Connection.Open();
        int i = (int)myCommand.ExecuteNonQuery();
        myCommand.Connection.Close();
        return i;
    }
Example #16
0
    public void ST_check_Login()
    {
        //打开数据库连接,并调用公共类中的getcon方法
        SqlConnection con = dataconn.getcon();

        con.Open();
        string     sqlstr1  = "select count(*) from tb_StuResult where stu_id ='" + Session["StuName"] + "'";
        SqlCommand mycom    = new SqlCommand(sqlstr1, con);
        int        intcount = Convert.ToInt32(mycom.ExecuteScalar());

        if (intcount > 0)
        {
            Response.Write("<script>alert('对不起!您只能答一套题!');location='zaixian_kaoshi.aspx'</script>");
        }
    }
Example #17
0
    //自定义方法getcom方法,判断是否是管理员还是考生
    private void getcom(int i)
    {
        //打开数据库连接,并调用公共类中的getcon方法
        SqlConnection con = dataconn.getcon();

        con.Open();
        //创建一个新的SqlCommand实例对象
        SqlCommand com = con.CreateCommand();

        switch (i)
        {
        case 1:
            com.CommandText = "select count(*) from tb_Administrator where Name='" + this.txtUserName.Text + "'and PWD='" + this.txtPwd.Text + "'";
            //获取SQL语句的值 强制转换成数值类型
            int count1 = Convert.ToInt32(com.ExecuteScalar());
            //判断数据库中是否存在数据
            if (count1 > 0)
            {
                Application["Name"] = txtUserName.Text; //成功
                Application["PWD"]  = txtPwd.Text;      //成功
                //如果登录成功,则跳转到管理员页面
                Page.Response.Redirect("HouAdmin/admin.aspx");
            }
            else
            {
                //如果登录失败,则弹出错误信息
                Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>");
            }
            break;

        case 2:
            com.CommandText = "select count(*) from tb_Student where ID='" + txtUserName.Text + "' and PWD='" + txtPwd.Text + "'";
            int count2 = Convert.ToInt32(com.ExecuteScalar());
            if (count2 > 0)
            {
                Application["ID"]  = txtUserName.Text;
                Application["PWD"] = txtPwd.Text;
                Page.Response.Redirect("QianUser/zaixian_kaoshi.aspx");
            }
            else
            {
                Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>");
                return;
            }
            break;
        }
    }
Example #18
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         dataconn.ecDropDownList(ddlProfession, "select * from tb_Profession", "Name", "id");
         SqlConnection con = dataconn.getcon();
         con.Open();
         SqlDataAdapter mydataadapter = new SqlDataAdapter("select * from tb_Lesson where ID="
                                                           + Request["id"], con);
         DataSet mydataset = new DataSet();
         mydataadapter.Fill(mydataset, "tb_lesson");
         DataRowView rowview = mydataset.Tables["tb_lesson"].DefaultView[0];
         this.txtLessName.Text = Convert.ToString(rowview["Name"]);
         ddlProfession.Text    = Convert.ToString(rowview["ofProfession"]);
         con.Close();
     }
 }
Example #19
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        SqlConnection cn = dataconn.getcon();

        cn.Open();
        int           id     = int.Parse(((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString());
        string        c_name = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
        string        c_date = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
        SqlDataReader dr;
        string        sql       = "Update Course Set c_name='" + c_name + "',c_date='" + c_date + "'  Where c_id=" + id + "";
        SqlCommand    myCommand = new SqlCommand(sql, cn);

        dr = myCommand.ExecuteReader();
        GridView1.EditIndex = -1;
        cn.Close();
        dataconn.bind(GridView1, "select * from Course where teacher_id='" + Session["ID"] + "' order by c_id DESC");
    }
    protected void btnTest_Click(object sender, EventArgs e)
    {
        string sqlstr = "select * from tb_Profession";
        //创建一个新的数据库连接对象
        SqlConnection sqlconn = dataconn.getcon();

        //打开数据库连接
        sqlconn.Open();
        //定义并初使化命令对象
        SqlCommand sqlcom = new SqlCommand(sqlstr, sqlconn);
        //创建一个数据阅读器
        SqlDataReader read = sqlcom.ExecuteReader();

        //如果记录不为空
        read.Read();
        if (read.HasRows)
        {
            if (this.txtProName.Text.Trim() == read["Name"].ToString().Trim())
            {
                Label2.Text     = "该专业已经存在,请重新填写专业名称";
                txtProName.Text = "";
                txtProName.Focus();
                btnAdd.Enabled  = false;
                Label2.Visible  = true;
                btnTest.Enabled = true;
                return;
            }
            else
            {
                Label2.Visible  = true;
                Label2.Text     = "该专业可以进行正常注册";
                btnAdd.Enabled  = true;
                btnTest.Enabled = false;
            }
        }
        else
        {
            Label2.Visible  = true;
            Label2.Text     = "该专业可以进行正常注册";
            btnAdd.Enabled  = true;
            btnTest.Enabled = false;
        }
        //关闭数据阅读器
        read.Close();
    }
Example #21
0
    protected void GridView1_RowUpdating1(object sender, GridViewUpdateEventArgs e)
    {
        SqlConnection cn = dataconn.getcon();

        cn.Open();
        int           id         = int.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
        string        PaperName  = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
        string        PaperState = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString();
        string        AnswerTime = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString();
        SqlDataReader dr;
        string        sql       = "Update TaoTi Set PaperName='" + PaperName + "',PaperState='" + PaperState + "',AnswerTime='" + AnswerTime + "' Where PaperID=" + id + "";
        SqlCommand    myCommand = new SqlCommand(sql, cn);

        dr = myCommand.ExecuteReader();
        GridView1.EditIndex = -1;
        cn.Close();
        dataconn.bind(GridView1, "select * from TaoTi where teacher_id='" + Session["ID"] + "' order by PaperID DESC");
    }
Example #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["ID"] == null)
         {
             Response.Write("<script>alert('非法登录!');location='../Index.aspx'</script>");
         }
         else
         {
             SqlConnection cn = dataconn.getcon();
             cn.Open();
             string     sqlstr1 = "select Name from Admin where name='" + Session["ID"] + "'";
             SqlCommand cmd1    = new SqlCommand(sqlstr1, cn);
             Label3.Text = cmd1.ExecuteScalar().ToString();
         }
     }
 }
    public static string Delete(string s)
    {
        Datacon       dataconn = new Datacon();
        SqlConnection cn       = dataconn.getcon();

        cn.Open();
        SqlCommand com = cn.CreateCommand();

        com.CommandText = "delete from Chapter where ID='" + s + "'";
        if (com.ExecuteNonQuery() > 0)
        {
            return("true");
        }
        else
        {
            return("false");
        }
        cn.Close();
    }
Example #24
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        SqlConnection cn = dataconn.getcon();

        cn.Open();
        string        id       = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();
        string        name     = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
        string        pwd      = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
        string        JoinTime = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString();
        string        degree   = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString();
        SqlDataReader dr;
        string        sql       = "Update Teacher Set name='" + name + "',pwd='" + pwd + "',JoinTime='" + JoinTime + "',degree='" + degree + "'  Where id=" + id + "";
        SqlCommand    myCommand = new SqlCommand(sql, cn);

        dr = myCommand.ExecuteReader();
        GridView1.EditIndex = -1;
        cn.Close();
        dataconn.bind(GridView1, "select * from Teacher order by id DESC");
    }
    public static string Update(string s)
    {
        string[]      str      = s.Split('*');
        Datacon       dataconn = new Datacon();
        SqlConnection cn       = dataconn.getcon();

        cn.Open();
        SqlCommand com = cn.CreateCommand();

        com.CommandText = "update Chapter set Name='" + str[1] + "' where ID='" + str[0] + "'";
        if (com.ExecuteNonQuery() > 0)
        {
            return("true");
        }
        else
        {
            return("false");
        }
        cn.Close();
    }
Example #26
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (this.txtAdminName.Text != "")
     {
         SqlConnection con = dataconn.getcon();
         con.Open();
         string     sqlstr1  = "select count(*) from tb_Teacher where Name='" + txtAdminName.Text.ToString() + "'";
         SqlCommand mycom    = new SqlCommand(sqlstr1, con);
         int        intcount = Convert.ToInt32(mycom.ExecuteScalar());
         if (intcount > 0)
         {
             Response.Write("<script>alert('对不起!此教师已经添加!');location='teacherInsert.aspx'</script>");
         }
         else
         {
             dataconn.eccom("exec add_teacher '" + txtAdminName.Text + "','" + txtAdminPwd.Text + "'");
             Response.Write("<script lanuage=javascript>alert('添加成功!');location='Teacher.aspx'</script>");
         }
     }
 }
Example #27
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = dataconn.getcon();

        con.Open();
        SqlCommand com   = new SqlCommand("select count(*) from tb_Student where ID='" + txtStuID.Text + "'", con);
        int        count = Convert.ToInt32(com.ExecuteScalar());

        if (count > 0)
        {
            Session["ID"] = txtStuID.Text;
            Page.Response.Redirect("InfoPwdd.aspx");
        }
        else
        {
            Response.Write("<script>alert('无此学生编号或输入有误');location='javascript:history.go(-1)'</script>");
            return;
        }
        con.Close();
    }
Example #28
0
    public void InitData()
    {
        int          judgeProblemID = int.Parse(Request["ID"].ToString()); //取出传递过来的试题编号
        JudgeProblem judgeproblem   = new JudgeProblem();                  //创建判断题对象

        if (judgeproblem.LoadData(judgeProblemID))                         //如果取出题目信息,分别放在相应控件显示
        {
            db.ecDropDownList(ddlCourse, "select * from Course where c_id=(select c_id from JudgeProblem where ID='" + judgeProblemID + "' )", "c_name", "c_id");
            txtTitle.Text = judgeproblem.Title;
            SqlConnection cn = db.getcon();
            cn.Open();
            string     sqlstr1 = "select Answer from JudgeProblem where ID='" + Request["ID"].ToString() + "'";
            SqlCommand cmd1    = new SqlCommand(sqlstr1, cn);
            Label1.Text = cmd1.ExecuteScalar().ToString();
        }
        else                //查询出错,给出提示
        {
            Response.Write("<script>alert('加载数据错误!');</script>");
            Response.Write("<script>window.location.href='ChangePanDuan.aspx'</script>");
        }
    }
Example #29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["User_Name"] == null || Session["User_Row"].ToString() != "Teacher")
     {
         Response.Write("<script>alert('非法登录!')</script>");
         Response.Write("<script language=javascript>top.location.href='../Login.aspx'</script>");
     }
     if (!IsPostBack)
     {
         Datacon       dataconn = new Datacon();
         SqlConnection cn       = dataconn.getcon();
         cn.Open();
         SqlCommand com = cn.CreateCommand();
         com.CommandText = "select count(*) from student_score";
         int count1 = Convert.ToInt32(com.ExecuteScalar());
         Label1.Text = count1.ToString();
         cn.Close();
         SqlDataSource1.ConnectionString = ConfigurationSettings.AppSettings["connectionstring"].ToString();
         SqlDataSource1.SelectCommand    = "select * from student_score";
     }
 }
Example #30
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (this.txtAdminName.Text != "")
     {
         SqlConnection con = dataconn.getcon();
         con.Open();
         string     sqlstr1  = "select count(*) from tb_Administrator where Name='" + txtAdminName.Text.ToString() + "'";
         SqlCommand mycom    = new SqlCommand(sqlstr1, con);
         int        intcount = Convert.ToInt32(mycom.ExecuteScalar());
         if (intcount > 0)
         {
             Response.Write("<script>alert('对不起!此管理员已经添加!');location='AdminInsert.aspx'</script>");
         }
         else
         {
             dataconn.eccom("insert into tb_Administrator(Name,PWD)values('" + txtAdminName.Text + "','" + txtAdminPwd.Text + "')");
             //Page.Response.Redirect("admin.aspx");
             Response.Write("<script lanuage=javascript>alert('添加成功!');location='admin.aspx'</script>");
         }
     }
 }
Example #31
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["User_Name"] == null || Session["User_Row"].ToString() != "Teacher")
         {
             Response.Write("<script>alert('非法登录!')</script>");
             Response.Write("<script language=javascript>top.location.href='../Login.aspx'</script>");
         }
         try
         {
             PaperID = Request.QueryString["PaperID"].ToString();
             Datacon       dataconn = new Datacon();
             SqlConnection cn       = dataconn.getcon();
             cn.Open();
             SqlCommand com = cn.CreateCommand();
             com.CommandText = "select * from TaoTi where PaperID='" + PaperID + "'";
             SqlDataReader dr = com.ExecuteReader();
             if (dr.Read())
             {
                 TextBox_PaperID.Text    = PaperID;
                 TextBox_c_id.Text       = dr["c_id"].ToString();
                 TextBox_PaperName.Text  = dr["PaperName"].ToString();
                 TextBox_PaperState.Text = dr["PaperState"].ToString();
                 TextBox_AnswerTime.Text = dr["AnswerTime"].ToString();
                 TextBox_Score.Text      = dr["Score"].ToString();
                 TextBox_teacher_id.Text = dr["teacher_id"].ToString();
             }
             else
             {
                 Response.Write("<script>alert('信息获取失败!');window.parent.location.reload();</script>");
             }
             cn.Close();
         }
         catch
         {
             Response.Write("<script>window.parent.location.reload();</script>");
         }
     }
 }
    int SQLInsert(string filename1, string filename2, string path)
    {
        int i = 0;
        try
        {
            Datacon dacon = new Datacon();
        SqlConnection con = dacon.getcon();
        SqlCommand myCommand = new SqlCommand("insert into checkRecord(username,filenameS,filenameC,date,QRString,QRLevel,QRVersion,path,IP)  values('" + Session["username"] + "','" + filename1 + "','" + filename2 + "','" + DateTime.Now.ToString() + "','" + Label22.Text + "','" + Label26.Text + "','" + Label25.Text + "','" + path + "','" + Label27.Text + "')", con);
        myCommand.Connection.Open();
            i = (int)myCommand.ExecuteNonQuery();

            myCommand.Connection.Close();
            staticCount(filename1, Session["username"].ToString());

        }
        catch (Exception e)
        {
            Label35.Text = "译码结果在查询信息过程出错。错误:" + e.Message;
        }

        return i;
    }