Beispiel #1
0
    protected void DeleteTimuFromZuoye(object sender, CommandEventArgs e)//从作业中删除题目
    {
        string        zuoyetimuid = e.CommandArgument.ToString();
        SqlConnection conn        = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString;
        SqlCommand comm = conn.CreateCommand();

        comm.CommandText = "delete from tb_teacherzuoyetimu where zuoyetimuid=" + zuoyetimuid;
        conn.Open();
        comm.ExecuteNonQuery();
        conn.Close();
        BindZuoyeTimu();
        ZuoyeInfo.UpdateTeacherZuoyeZongfen(Request.QueryString["zuoyeid"]);
        FormView1.DataBind();
    }
Beispiel #2
0
    protected void grvw_zuoyetimu_RowUpdating(object sender, GridViewUpdateEventArgs e)//更新题目分值
    {
        string        fenzhi      = ((TextBox)(grvw_zuoyetimu.Rows[grvw_zuoyetimu.EditIndex].FindControl("TextBox1"))).Text.Trim();
        string        zuoyetimuid = grvw_zuoyetimu.DataKeys[e.RowIndex].Value.ToString();
        SqlConnection conn        = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString;
        SqlCommand comm = conn.CreateCommand();

        comm.CommandText = "update tb_teacherzuoyetimu set fenzhi=" + fenzhi + " where zuoyetimuid=" + zuoyetimuid;
        conn.Open();
        comm.ExecuteNonQuery();
        conn.Close();
        grvw_zuoyetimu.EditIndex = -1;
        BindZuoyeTimu();
        ZuoyeInfo.UpdateTeacherZuoyeZongfen(Request.QueryString["zuoyeid"]);
        FormView1.DataBind();
    }
    protected void AddTimuToZuoye(object sender, CommandEventArgs e)//将题目添加到作业,按题目id,questionid
    {
        lbl_fankui.Text = "";
        bool          chenggong  = true;
        string        zuoyeid    = Request.QueryString["zuoyeid"];
        string        questionid = e.CommandArgument.ToString();
        string        fenzhi     = ((TextBox)(((GridViewRow)(((Button)sender).NamingContainer)).FindControl("TextBox1"))).Text.Trim();
        string        tixing     = ((GridViewRow)(((Button)sender).NamingContainer)).Cells[1].Text.Trim();
        SqlConnection conn       = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString;
        SqlCommand comm = conn.CreateCommand();

        try
        {
            comm.CommandText = "insert into tb_teacherzuoyetimu(zuoyeid,questionid,fenzhi) values(@zuoyeid,@questionid,@fenzhi)";
            comm.Parameters.AddWithValue("@zuoyeid", zuoyeid);
            comm.Parameters.AddWithValue("@questionid", questionid);
            comm.Parameters.AddWithValue("@fenzhi", fenzhi);
            conn.Open();
            comm.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            chenggong       = false;
            lbl_fankui.Text = ex.Message;
        }
        finally
        {
            conn.Close();
        }
        if (chenggong)
        {
            ZuoyeInfo.UpdateTeacherZuoyeZongfen(zuoyeid);
            FormView1.DataBind();
            Button shanchubtn = (Button)(((GridViewRow)(((Button)sender).NamingContainer)).FindControl("btn_del"));
            shanchubtn.Enabled       = true;
            ((Button)sender).Enabled = false;
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "", "<script language='javascript'>alert('添加失败!');</script>", false);
        }
    }
    protected void DelTimuFromZuoye(object sender, CommandEventArgs e)//从作业中删除题目,按题目questionid,zuoyeid
    {
        string        questionid = e.CommandArgument.ToString();
        string        zuoyeid    = Request.QueryString["zuoyeid"];
        SqlConnection conn       = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString;
        SqlCommand comm = conn.CreateCommand();

        comm.CommandText = "delete from tb_teacherzuoyetimu where zuoyeid=" + zuoyeid + " and questionid=" + questionid;
        conn.Open();
        comm.ExecuteNonQuery();
        conn.Close();
        ZuoyeInfo.UpdateTeacherZuoyeZongfen(Request.QueryString["zuoyeid"]);
        FormView1.DataBind();
        Button tianjiabtn = (Button)(((Button)sender).NamingContainer.FindControl("btn_add"));

        tianjiabtn.Enabled       = true;
        ((Button)sender).Enabled = false;
    }