protected void Button1_Click(object sender, EventArgs e)
    {
        int ID_Category = 0;
        if (DropDownList6.SelectedValue != "0")
        {
            ID_Category = int.Parse(DropDownList6.SelectedValue.ToString());
        }
        else if (DropDownList5.SelectedValue != "0")
        {
            ID_Category = int.Parse(DropDownList5.SelectedValue.ToString());
        }
        else if (DropDownList4.SelectedValue != "0")
        {
            ID_Category = int.Parse(DropDownList4.SelectedValue.ToString());
        }
        else if (DropDownList3.SelectedValue != "0")
        {
            ID_Category = int.Parse(DropDownList3.SelectedValue.ToString());
        }
        else if (DropDownList2.SelectedValue != "0")
        {
            ID_Category = int.Parse(DropDownList2.SelectedValue.ToString());
        }
        else if (DropDownList1.SelectedValue != "0")
        {
            ID_Category = int.Parse(DropDownList1.SelectedValue.ToString());
        }
        else
        {
            ID_Category = 0;
        }

        DataTable dt=new  tbl_TermTableAdapter().GetDataByWithActive("True");
        int ID_Term=int.Parse(dt.Rows[0]["Term_ID"].ToString());

        if (LblHidden.ToolTip.Length == 0)
        {

            new tbl_LessonTableAdapter().Insert(
                TextName.Text,
                int.Parse(TextUnit.Text),
                int.Parse(DropDownList7.SelectedValue),
                TextTime.Text,
                ID_Category,ID_Term);
        }
        else
        {
            int ID = int.Parse(Request.QueryString["Lesson_ID"].ToString());
            new tbl_LessonTableAdapter().Update(
                TextName.Text,
                int.Parse(TextUnit.Text),
                int.Parse(DropDownList7.SelectedValue),
                TextTime.Text,
                ID_Category, ID_Term,ID);
        }
        Response.Redirect("~//index.aspx?Type=LessonManage");
    }
示例#2
0
 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
 {
     int ID = int.Parse(((Label)(GridView1.Rows[e.NewEditIndex].FindControl("lblID"))).Text);
     DataTable dt = new tbl_TermTableAdapter().GetDataByTerm_ID(ID);
     if (dt.Rows.Count > 0)
     {
         TextTitle.Text = dt.Rows[0]["Te_Title"].ToString();
         CheckBox1.Checked = bool.Parse(dt.Rows[0]["Active"].ToString());
     }
     LblHidden.ToolTip = ID.ToString();
     GridView1.SelectedIndex = e.NewEditIndex;
 }