Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["otherUser"] == null)
            {
                Id        = Session["Id"].ToString();
                AccountID = Session["AccountId"].ToString();
            }
            else
            {
                Id        = Session["otherUser"].ToString();
                AccountID = Session["otherAccountId"].ToString();
            }
            using (SqlConnection con = new SqlConnection(conString))
            {
                con.Open();
                string         query = "Select * from ClassTable where DId= '" + AccountID + "' ";
                SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                DataTable      dt    = new DataTable();
                sda.Fill(dt);
                GvClass.DataSource = dt;

                GvClass.DataBind();
                con.Close();
            }
        }
    protected void GvClass_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;
        GvClass.DataSource  = dt;
        GvClass.DataBind();
        AllPageCode();
    }
 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["dtClass"];
         DataView  view       = new DataView(dtCurrency, condition, "", DataViewRowState.CurrentRows);
         GvClass.DataSource   = view.ToTable();
         Session["dtFilter"]  = view.ToTable();
         lblTotalRecords.Text = Resources.Attendance.Total_Records + " : " + view.ToTable().Rows.Count + "";
         GvClass.DataBind();
         AllPageCode();
     }
 }
    protected void GvClass_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GvClass.PageIndex = e.NewPageIndex;
        DataTable dt = (DataTable)Session["dtFilter"];

        GvClass.DataSource = dt;
        GvClass.DataBind();
        AllPageCode();
    }
    private void FillGrid()
    {
        DataTable dtBrand = objDesg.GetClassMaster(Session["CompId"].ToString().ToString());

        lblTotalRecords.Text = Resources.Attendance.Total_Records + ": " + dtBrand.Rows.Count + "";
        Session["dtClass"]   = dtBrand;
        Session["dtFilter"]  = dtBrand;
        if (dtBrand != null && dtBrand.Rows.Count > 0)
        {
            GvClass.DataSource = dtBrand;
            GvClass.DataBind();
            AllPageCode();
        }
        else
        {
            GvClass.DataSource = null;
            GvClass.DataBind();
        }
    }
Example #6
0
        protected void EditLink_Click(object sender, EventArgs e)
        {
            List <string> classId = new List <string>();
            List <string> appId   = new List <string>();
            int           DID     = Convert.ToInt32((sender as Button).CommandArgument);

            Session["DID"] = DID;

            using (SqlConnection con = new SqlConnection(conString))
            {
                con.Open();
                string        query = "Select * from ClassTable where DId= '" + DID + "' ";
                SqlCommand    com   = new SqlCommand(query, con);
                SqlDataReader dr    = com.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        classId.Add(dr["ClassID"].ToString());
                    }
                }
                con.Close();

                for (int i = 0; i < classId.Count; i++)
                {
                    con.Open();
                    query = "Select * from ApprovalTable where ChairPApp='" + 1 + "' and ClassId='" + classId[i] + "'";
                    com   = new SqlCommand(query, con);
                    dr    = com.ExecuteReader();
                    if (dr.HasRows)
                    {
                        dr.Read();
                        appId.Add(dr["ClassId"].ToString());
                    }

                    con.Close();
                }

                int       count = 0;
                DataTable dt    = new DataTable();
                dt.Columns.Add("ClassName", typeof(string));
                dt.Columns.Add("ClassSection", typeof(string));
                dt.Columns.Add("Shift", typeof(string));
                dt.Columns.Add("ClassID", typeof(string));
                for (int i = 0; i < appId.Count; i++)
                {
                    con.Open();
                    query = "Select * from ClassTable where ClassID='" + appId[i] + "'";

                    com = new SqlCommand(query, con);
                    dr  = com.ExecuteReader();
                    if (dr.HasRows)
                    {
                        dr.Read();
                        dt.Rows.Add(new object[] { dr["ClassName"].ToString(), dr["ClassSection"].ToString(), dr["Shift"].ToString(), dr["ClassID"].ToString() });
                        //  appId.Add(dr["ClassId"].ToString());
                        count++;
                    }

                    con.Close();
                }
                GvClass.DataSource = dt;

                GvClass.DataBind();
                DepartmentView.Visible = false;
                if (count == 0)
                {
                    Label1.Visible = true;
                }
                else
                {
                    ClassView.Visible = true;
                }

                /*  string query = "Select * from ClassTable where DId= '" + DID + "' ";
                 *  SqlDataAdapter sda = new SqlDataAdapter(query, con);
                 *  DataTable dt = new DataTable();
                 *  sda.Fill(dt);
                 *  GvClass.DataSource = dt;
                 *
                 *  GvClass.DataBind();
                 *  con.Close();*/
            }
        }