Example #1
0
    protected void GvStudent_Sorting(object sender, GridViewSortEventArgs e)
    {
        DataTable dt      = (DataTable)Session["dtFilter"];
        string    sortdir = "DESC";

        if (ViewState["SortDir"] != null)
        {
            sortdir = ViewState["SortDir"].ToString();
            if (sortdir == "ASC")
            {
                e.SortDirection      = SortDirection.Descending;
                ViewState["SortDir"] = "DESC";
            }
            else
            {
                e.SortDirection      = SortDirection.Ascending;
                ViewState["SortDir"] = "ASC";
            }
        }
        else
        {
            ViewState["SortDir"] = "DESC";
        }



        dt = (new DataView(dt, "", e.SortExpression + " " + ViewState["SortDir"].ToString(), DataViewRowState.CurrentRows)).ToTable();
        Session["dtFilter"]  = dt;
        GvStudent.DataSource = dt;
        GvStudent.DataBind();
        AllPageCode();
    }
Example #2
0
 protected void btnbindrpt_Click(object sender, ImageClickEventArgs e)
 {
     if (ddlOption.SelectedIndex != 0)
     {
         string condition = string.Empty;
         if (ddlOption.SelectedIndex == 1)
         {
             condition = "convert(" + ddlFieldName.SelectedValue + ",System.String)='" + txtValue.Text + "'";
         }
         else if (ddlOption.SelectedIndex == 2)
         {
             condition = "convert(" + ddlFieldName.SelectedValue + ",System.String) like '%" + txtValue.Text + "%'";
         }
         else
         {
             condition = "convert(" + ddlFieldName.SelectedValue + ",System.String) Like '" + txtValue.Text + "%'";
         }
         DataTable dtCurrency = (DataTable)Session["dtStudent"];
         DataView  view       = new DataView(dtCurrency, condition, "", DataViewRowState.CurrentRows);
         GvStudent.DataSource = view.ToTable();
         Session["dtFilter"]  = view.ToTable();
         lblTotalRecords.Text = Resources.Attendance.Total_Records + " : " + view.ToTable().Rows.Count + "";
         GvStudent.DataBind();
         AllPageCode();
     }
 }
        protected void btnsarch_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable StuDT = StudentMst.GetAllActiveData();
                if (StuDT != null)
                {
                    DataTable Student_dt = StuDT.Select("DivId= " + drpdiv.SelectedValue).CopyToDataTable();

                    if (Student_dt != null && Student_dt.Rows.Count > 0)
                    {
                        GvStudent.DataSource = Student_dt;
                        GvStudent.DataBind();
                    }
                }
            }
            catch
            {
            }

            //else
            //{
            //    //MultiView1.ActiveViewIndex = -1;
            //}
        }
        protected void GvStudent_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            StudentMst.Delete(Convert.ToInt32(GvStudent.DataKeys[e.RowIndex].Value));
            DataTable StudentDT = StudentMst.GetAllActiveData();

            GvStudent.DataSource = StudentDT;
            GvStudent.DataBind();
        }
Example #5
0
    protected void GvStudent_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GvStudent.PageIndex = e.NewPageIndex;
        DataTable dt = (DataTable)Session["dtFilter"];

        GvStudent.DataSource = dt;
        GvStudent.DataBind();
        AllPageCode();
    }
Example #6
0
        public void LoadAllStudents(int SessionId, int SchoolId)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("SN");
            dt.Columns.Add("ID");
            dt.Columns.Add("DOEAPPROVAL");
            dt.Columns.Add("Name");
            dt.Columns.Add("BATCH");
            dt.Columns.Add("Year");

            var StudentsInSession = GeneralUtility.GetStudentsInSession(SessionId, SchoolId);

            if (StudentsInSession != null)
            {
                int sn = 0;
                foreach (var item in StudentsInSession)
                {
                    string id       = item.StudentId.ToString();
                    bool   approval = Convert.ToBoolean(item.DOEApproval);
                    string Name     = item.LastName.ToString() + " " + item.MiddleName.ToString() + " " + item.FirstName.ToString();
                    string Batch    = "";
                    if (item.BatchID == null)
                    {
                        Batch = "Not Yet Approved";
                    }
                    else
                    {
                        Batch = item.BatchID.ToString();
                    }
                    string Year = item.Session.Name.ToString();
                    //string school = item.School.Name;
                    sn++;

                    dt.Rows.Add(sn, id, approval, Name, Batch, Year);
                }


                GvStudent.DataSource = dt;
                GvStudent.DataBind();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (Convert.ToString(dt.Rows[i]["DOEAPPROVAL"]).ToUpper() == "TRUE")
                    {
                        CheckBox chk = (CheckBox)GvStudent.Rows[i].FindControl("chkapprove");
                        chk.Checked = true;
                    }
                }
                GvStudent.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
        }
        public void show()
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString);

            string query = "select StudentId, StudentName, Address, Email, Gender, EnrollDate, CourseName from tblStudent order by EnrollDate ";

            con.Open();
            SqlCommand cmd = new SqlCommand(query, con);

            cmd.ExecuteNonQuery();
            DataTable      dt  = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);

            sda.Fill(dt);
            GvStudent.DataSource = dt;
            GvStudent.DataBind();
            con.Close();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                DataTable StdDT = StdMst.GetAllActiveData();
                drpstd.DataSource     = StdDT;
                drpstd.DataTextField  = "StdName";
                drpstd.DataValueField = "Sid";
                drpstd.DataBind();

                drpstd.Items.Insert(0, "SELECT");
                drpstudent.Items.Insert(0, "SELECT");

                DataTable Student_dt = StudentMst.GetAllActiveData();
                GvStudent.DataSource = Student_dt;
                GvStudent.DataBind();
            }
        }
Example #9
0
    private void FillGrid()
    {
        DataTable dtBrand = objDesg.GetStudentMaster(Session["CompId"].ToString().ToString());

        lblTotalRecords.Text = Resources.Attendance.Total_Records + ": " + dtBrand.Rows.Count + "";
        Session["dtStudent"] = dtBrand;
        Session["dtFilter"]  = dtBrand;
        if (dtBrand != null && dtBrand.Rows.Count > 0)
        {
            GvStudent.DataSource = dtBrand;
            GvStudent.DataBind();
            AllPageCode();
        }
        else
        {
            GvStudent.DataSource = null;
            GvStudent.DataBind();
        }
    }
Example #10
0
        protected void GvStudent_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GvStudent.PageIndex = e.NewPageIndex;
            using (SqlConnection con = new SqlConnection(conString))
            {
                con.Open();
                SqlDataAdapter sda = new SqlDataAdapter("Select * from Student ", con);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);

                GvStudent.DataSource = dt;

                if (dt.Rows[0][13].ToString().Equals("1"))
                {
                }
                GvStudent.DataBind();

                con.Close();
            }
            // GvStudent.DataBind();

            ConfirmMsg.Text = "";
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Session["ConfirmReg"].Equals(""))
                {
                    ConfirmMsg.Text = "Account has been created successfully";
                }
                else
                {
                    ConfirmMsg.Text = "";
                }
            }
            catch (Exception ex)
            {
                ConfirmMsg.Text = "";
            }

            if (!IsPostBack) //check if the webpage is loaded for the first time.
            {
                ViewState["PreviousPage"] =
                    Request.UrlReferrer;//Saves the Previous page url in ViewState
            }

            if (!Page.IsPostBack)
            {
                try
                {
                    if (Session["Index"].Equals("0"))
                    {
                        DDSelectUser.SelectedIndex = 0;

                        stdView.Visible     = true;
                        TeacherView.Visible = false;

                        using (SqlConnection con = new SqlConnection(conString))
                        {
                            con.Open();
                            SqlDataAdapter sda = new SqlDataAdapter("Select * from Student ", con);
                            DataTable      dt  = new DataTable();
                            sda.Fill(dt);

                            GvStudent.DataSource = dt;

                            GvStudent.DataBind();

                            con.Close();
                        }
                    }
                    if (Session["Index"].Equals("1"))
                    {
                        DDSelectUser.SelectedIndex = 1;

                        stdView.Visible     = false;
                        CPView.Visible      = true;
                        TeacherView.Visible = false;
                        Label2.Visible      = false;
                        using (SqlConnection con = new SqlConnection(conString))
                        {
                            string cp = "ChairPerson";
                            con.Open();
                            SqlDataAdapter sda = new SqlDataAdapter("SELECT Department.DId,Department.DepartmentName,Department.TId,Teacher.TName,Teacher.TId FROM  Department INNER JOIN Teacher ON Department.TId = Teacher.TId  ", con);
                            DataTable      dt  = new DataTable();
                            sda.Fill(dt);
                            GVCP.DataSource = dt;

                            GVCP.DataBind();



                            con.Close();
                        }
                    }
                    if (Session["Index"].Equals("2"))
                    {
                        DDSelectUser.SelectedIndex = 2;

                        stdView.Visible     = false;
                        CPView.Visible      = false;
                        TeacherView.Visible = true;
                        Label2.Visible      = true;
                        using (SqlConnection con = new SqlConnection(conString))
                        {
                            con.Open();
                            string query = "SELECT Department.DId,Department.DepartmentName,Teacher.TName,Teacher.TId,Teacher.Image,Teacher.Conatact,Teacher.Email,Teacher.Degree,Teacher.Department FROM Teacher  INNER JOIN Department ON Teacher.Department = Department.DId  ";
                            // string query = "SELECT Department.DId,Department.DepartmentName,Teacher.TName,Teacher.TId,Teacher.Image,Teacher.Conatact,Teacher.Email,Teacher.Degree,Teacher.Department FROM Teacher  INNER JOIN Department ON Teaccher.Department = Department.DId  ";
                            SqlDataAdapter sda = new SqlDataAdapter(query, con);
                            DataTable      dt  = new DataTable();
                            sda.Fill(dt);
                            GVTeacher.DataSource = dt;

                            GVTeacher.DataBind();
                            con.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Session["Index"] = "";
                    DDSelectUser.SelectedIndex = 0;

                    stdView.Visible     = true;
                    TeacherView.Visible = false;

                    using (SqlConnection con = new SqlConnection(conString))
                    {
                        con.Open();

                        SqlDataAdapter sda = new SqlDataAdapter("Select * from Student ", con);
                        DataTable      dt  = new DataTable();
                        sda.Fill(dt);

                        GvStudent.DataSource = dt;

                        if (dt.Rows[0][13].ToString().Equals("1"))
                        {
                        }
                        GvStudent.DataBind();

                        con.Close();
                    }
                }
            }
            //if(Page.IsPostBack)
            //{

            //}
        }
Example #12
0
        protected void DDSelectUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DDSelectUser.SelectedIndex == 0)
            {
                Session["Index"]    = "0";
                ConfirmMsg.Text     = "";
                stdView.Visible     = true;
                CPView.Visible      = false;
                TeacherView.Visible = false;
                Label2.Visible      = true;
                using (SqlConnection con = new SqlConnection(conString))
                {
                    con.Open();
                    SqlDataAdapter sda = new SqlDataAdapter("Select * from Student ", con);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    GvStudent.DataSource = dt;
                    if (dt.Rows[0][13].ToString().Equals("1"))
                    {
                    }
                    GvStudent.DataBind();
                    con.Close();
                }
            }
            else if (DDSelectUser.SelectedIndex == 2)
            {
                Session["Index"]    = "2";
                ConfirmMsg.Text     = "";
                stdView.Visible     = false;
                CPView.Visible      = false;
                TeacherView.Visible = true;
                Label2.Visible      = true;
                using (SqlConnection con = new SqlConnection(conString))
                {
                    con.Open();
                    string query = "SELECT Department.DId,Department.DepartmentName,Teacher.TName,Teacher.TId,Teacher.Image,Teacher.Conatact,Teacher.Email,Teacher.Degree,Teacher.Department FROM Teacher  INNER JOIN Department ON Teacher.Department = Department.DId  ";
                    // string query = "SELECT Department.DId,Department.DepartmentName,Teacher.TName,Teacher.TId,Teacher.Image,Teacher.Conatact,Teacher.Email,Teacher.Degree,Teacher.Department FROM Teacher  INNER JOIN Department ON Teaccher.Department = Department.DId  ";
                    SqlDataAdapter sda = new SqlDataAdapter(query, con);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    GVTeacher.DataSource = dt;

                    GVTeacher.DataBind();
                    con.Close();
                }
            }
            else if (DDSelectUser.SelectedIndex == 1)
            {
                Session["Index"]    = "1";
                ConfirmMsg.Text     = "";
                stdView.Visible     = false;
                CPView.Visible      = true;
                TeacherView.Visible = false;
                Label2.Visible      = false;
                using (SqlConnection con = new SqlConnection(conString))
                {
                    string cp = "ChairPerson";
                    con.Open();
                    SqlDataAdapter sda = new SqlDataAdapter("SELECT Department.DId,Department.DepartmentName,Department.TId,Teacher.TName,Teacher.TId FROM  Department INNER JOIN Teacher ON Department.TId = Teacher.TId  ", con);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    GVCP.DataSource = dt;

                    GVCP.DataBind();



                    con.Close();
                }
            }
        }
 protected void GvStudentDataBind(object sender, EventArgs e)
 {
     GvStudent.DataBind();
 }