protected void btnView_OnClick(object sender, EventArgs e)
 {
     dtinfo.ShortDatePattern = "dd/MM/yyyy";
     dtinfo.DateSeparator    = "/";
     if (rbtndate.Checked == true)
     {
         fillgrid("date", Convert.ToDateTime(txtDate.Text, dtinfo));
     }
     else if (rbtnFollowupDate.Checked == true)
     {
         fillgrid("nextdate", Convert.ToDateTime(txtDate.Text, dtinfo));
     }
     GridCounselling.Focus();
 }
Exemplo n.º 2
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();
    }
    protected void btnSubmit_Onclick(object sender, EventArgs e)
    {
        con.Close();
        con.Open();
        dtinfo.DateSeparator    = "/";
        dtinfo.ShortDatePattern = "dd/MM/yyyy";
        SqlCommand cmd   = new SqlCommand("select max(CounsellingNo) from Followup where CID='" + lblCID.Text.ToString() + "'", con);
        int        inCid = Convert.ToInt32(cmd.ExecuteScalar());

        cmd = new SqlCommand("update Followup set Response=@Response,Comments=@Comments,Counselor=@Counselor where CID='" + Convert.ToInt32(lblCID.Text) + "' and CounsellingNo='" + inCid + "'", con);
        cmd.Parameters.AddWithValue("@Response", ddlResponse.SelectedValue.ToString());
        cmd.Parameters.AddWithValue("@Comments", txtdetail.Text.ToString());
        cmd.Parameters.AddWithValue("@Counselor", txtCounselor.Text.ToString());
        cmd.ExecuteNonQuery();

        cmd = new SqlCommand("insert into Followup(CounsellingNo,FollowUpDate,Response,Comments,Counselor,CID) Values(@CounsellingNo,@FollowUpDate,@Response,@Comments,@Counselor,@CID)", con);
        cmd.Parameters.AddWithValue("@CounsellingNo", inCid + 1);
        if (string.IsNullOrEmpty(txtNextDate.Text) || txtNextDate.Text == "")
        {
            cmd.Parameters.AddWithValue("@FollowUpDate", DBNull.Value);
        }
        else
        {
            cmd.Parameters.AddWithValue("@FollowUpDate", Convert.ToDateTime(txtNextDate.Text.ToString(), dtinfo));
        }
        //cmd.Parameters.AddWithValue("@FollowUpDate", Convert.ToDateTime(txtNextDate.Text.ToString(), dtinfo));
        cmd.Parameters.AddWithValue("@Response", ddlResponse.SelectedValue.ToString());
        cmd.Parameters.AddWithValue("@Comments", txtdetail.Text.ToString());
        cmd.Parameters.AddWithValue("@Counselor", txtCounselor.Text.ToString());
        cmd.Parameters.AddWithValue("@CID", Convert.ToInt32(lblCID.Text));
        cmd.ExecuteNonQuery();
        con.Close();
        GridCounselling.Focus();
        txtdetail.Text    = "";
        txtCounselor.Text = "";
    }