Ejemplo n.º 1
0
 protected void Grid_OnselectedIndexChanged(object sender, EventArgs e)
 {
     if (GridCounselling.Rows.Count > 0)
     {
         pnlCounselling.Visible = true; pnlhome.Visible = false;
         fillProfile(Convert.ToInt32(GridCounselling.SelectedRow.Cells[1].Text.ToString()));
         rbtnFollowupDate.Checked = true;
         SqlDataAdapter ad = new SqlDataAdapter("select * from Followup where CID='" + Convert.ToInt32(GridCounselling.SelectedRow.Cells[1].Text.ToString()) + "'", con);
         DataSet        ds = new DataSet();
         ad.Fill(ds);
         GridCounselling.DataSource = ds;
         GridCounselling.DataBind();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Convert.ToString(Server.HtmlEncode(Request.Cookies["MyLogin"]["PWD"])) == "")
         {
             Response.Redirect("../Login.aspx");
         }
         else
         {
             if (!IsPostBack)
             {
                 dtinfo.ShortDatePattern = "dd/MM/yyyy";
                 dtinfo.DateSeparator    = "/";
                 pnlCounselling.Visible  = false;
                 rbtndate.Checked        = true;
                 maikal mk  = new maikal();
                 int    lvl = mk.returnlevel(Server.HtmlEncode(Request.Cookies["MyLogin"]["UID"]).ToString(), Server.HtmlEncode(Request.Cookies["MyLogin"]["PWD"]).ToString());
                 txtDate.Text        = DateTime.Now.ToString("dd/MM/yyyy");
                 txtCurrentDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
                 SqlDataAdapter ad = new SqlDataAdapter("select * from Counselling where Date Between '" + Convert.ToDateTime(txtDate.Text, dtinfo).AddMonths(-1) + "' and '" + Convert.ToDateTime(txtDate.Text, dtinfo) + "'", con);
                 DataSet        ds = new DataSet();
                 ad.Fill(ds);
                 GridCounselling.DataSource = ds;
                 GridCounselling.DataBind();
                 GridCounselling.Focus();
             }
             if (rbtnFollowupDate.Checked == true)
             {
                 if (lblCID.Text.ToString() == null)
                 {
                     SqlDataAdapter ad = new SqlDataAdapter("select * from Followup where CID='" + Convert.ToInt32(lblCID.Text) + "'", con);
                     DataSet        ds = new DataSet();
                     ad.Fill(ds);
                     GridCounselling.DataSource = ds;
                     GridCounselling.DataBind();
                 }
             }
             btnView.Focus();
         }
     }
     catch (NullReferenceException ex)
     {
         Response.Redirect("../Login.aspx");
     }
 }
    private void fillgrid(string type, DateTime dt)
    {
        string qry = "";

        if (type == "date")
        {
            qry = "select * from Counselling where Date='" + dt + "'";
        }
        else if (type == "nextdate")
        {
            qry = "select * from Followup where FollowUpDate='" + dt + "'";
        }
        SqlDataAdapter ad = new SqlDataAdapter(qry, con);
        DataSet        ds = new DataSet();

        ad.Fill(ds);
        GridCounselling.DataSource = ds;
        GridCounselling.DataBind();
    }