protected void GetCoursesID(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                courseId            = CourseList.SelectedValue;
                Session["courseId"] = courseId;
                if (courseId.Equals("NA"))
                {
                }
                else
                {
                    CourseErr.Visible = false;
                    using (SqlConnection con = new SqlConnection(conString))
                    {
                        con.Open();
                        string        query = "Select CreditHours from Course where CourseId='" + courseId + "'";
                        SqlCommand    com   = new SqlCommand(query, con);
                        SqlDataReader dr    = com.ExecuteReader();
                        dr.Read();
                        if (dr.HasRows)
                        {
                            if (dr["CreditHours"].Equals("2+1"))
                            {
                                con.Close();

                                AssDiv.Visible      = true;
                                AssLabelDiv.Visible = true;

                                AssErr.Visible = false;
                                string query2 = "Select * from Teacher where Department='" + Session["AccountId"].ToString() + "'";
                                con.Open();
                                SqlDataAdapter sda2 = new SqlDataAdapter(query2, con);
                                DataTable      dt2  = new DataTable();
                                sda2.Fill(dt2);

                                AssisTeacherList.DataSource = dt2;
                                AssisTeacherList.DataBind();
                                AssisTeacherList.DataTextField  = "TName";
                                AssisTeacherList.DataValueField = "TId";
                                AssisTeacherList.DataBind();

                                AssisTeacherList.Items.Insert(0, new ListItem("Select", "NA"));
                            }
                            else
                            {
                                AssDiv.Visible      = false;
                                AssLabelDiv.Visible = false;
                                AssErr.Visible      = false;
                            }
                        }
                        con.Close();
                    }
                }
            }
        }
示例#2
0
        private void EditClick(object sender, EventArgs e)
        {
            PnlMain.Visible = true;
            // ShowTTForm.Visible = false;
            string temp = ((LinkButton)sender).ID.ToString();

            Session["TTId"] = temp;
            if (Page.IsPostBack)
            {
                string[] classInfo  = new string[2];
                string[] courseInfo = new string[2];
                string   q          = "Select * from TimeTable where Id='" + temp + "'";
                con.Open();
                SqlCommand    com = new SqlCommand(q, con);
                SqlDataReader dr  = com.ExecuteReader();
                dr.Read();

                if (dr.HasRows)
                {
                    classInfo = GetClassInfo(dr["ClassId"].ToString());
                    //ShiftList.SelectedValue = classInfo[1];
                    ShiftList.SelectedIndex = ShiftList.Items.IndexOf(ShiftList.Items.FindByText(classInfo[1]));

                    Section.Text             = classInfo[2];
                    courseInfo               = GetCourseInfo(dr["CourseId"].ToString());
                    CourseList.SelectedIndex = CourseList.Items.IndexOf(CourseList.Items.FindByText(courseInfo[1]));
                    Session["courseId"]      = CourseList.SelectedValue;

                    //CourseList.SelectedItem.Text = courseInfo[1];
                    //TeacherList.SelectedItem.Text = GetTeacherInfo(dr["TId"].ToString());
                    string Tname = GetTeacherInfo(dr["TId"].ToString());
                    TeacherList.SelectedIndex = TeacherList.Items.IndexOf(TeacherList.Items.FindByText(Tname));
                    Session["TeacId"]         = TeacherList.SelectedValue;

                    STime.Text  = dr["STime"].ToString();
                    ETime.Text  = dr["ETime"].ToString();
                    RoomNo.Text = dr["ClassRoomNo"].ToString();
                    SemesterList.SelectedValue = dr["SemesterNo"].ToString();
                    DaysList.SelectedValue     = dr["Day"].ToString();
                    Tname = GetTeacherInfo(dr["AId"].ToString());

                    if (!dr["AId"].Equals("0"))
                    {
                        AssDiv.Visible = true;
                        AssErr.Visible = false;
                        string query2 = "Select * from Teacher where Department='" + Session["AccountId"].ToString() + "'";
                        con.Close();
                        con.Open();
                        SqlDataAdapter sda2 = new SqlDataAdapter(query2, con);
                        DataTable      dt2  = new DataTable();
                        sda2.Fill(dt2);

                        AssisTeacherList.DataSource = dt2;
                        AssisTeacherList.DataBind();
                        AssisTeacherList.DataTextField  = "TName";
                        AssisTeacherList.DataValueField = "TId";
                        AssisTeacherList.DataBind();

                        AssisTeacherList.Items.Insert(0, new ListItem("Select", "NA"));
                        AssisTeacherList.SelectedIndex = AssisTeacherList.Items.IndexOf(AssisTeacherList.Items.FindByText(Tname));
                        Session["AssisId"]             = AssisTeacherList.SelectedValue;
                        con.Close();
                    }
                    else
                    {
                        AssDiv.Visible = false;
                        AssErr.Visible = false;
                    }
                    using (SqlConnection con = new SqlConnection(conString))
                    {
                        con.Close();
                        string currentyear = DateTime.Now.Year.ToString();
                        con.Open();
                        string         query = "Select * from ClassTable where DId='" + Session["AccountId"].ToString() + "'  and Year='" + currentyear + "' and Shift='" + classInfo[1] + "'";
                        SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                        DataTable      dt    = new DataTable();
                        sda.Fill(dt);
                        ClassList.DataSource = dt;
                        ClassList.DataBind();
                        ClassList.DataTextField  = "ClassName";
                        ClassList.DataValueField = "ClassId";
                        ClassList.DataBind();

                        ClassList.Items.Insert(0, new ListItem("Select", "NA"));
                        Section.Text            = dt.Rows[0][2].ToString();
                        ClassList.SelectedIndex = ClassList.Items.IndexOf(ClassList.Items.FindByText(classInfo[0]));
                        Session["classId"]      = ClassList.SelectedValue;
                        con.Close();
                    }
                }
                con.Close();
                AddTT.Visible    = false;
                UpdateTT.Visible = true;
            }
            //Response.Redirect("proforma.aspx");
        }