Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Elderlies objElder = new Elderlies();

            objElder.ElderID = Request.QueryString["ElderID"];
            objElder.getDetails();
            objElder.status = objElder.getStatus();

            if (rblSuccess.SelectedIndex == 0)
            {
                lblChanges.Text     = objElder.setSuccess();
                txtFeedback.Visible = false;
            }

            else
            {
                lblChanges.Text     = objElder.setUnsuccess();
                txtFeedback.Visible = true;

                //Feedback coding

                if (txtFeedback.Text.Length > 1)
                {
                    Volunteers objVolunteer = new Volunteers();
                    objVolunteer.EmailAddr = Session["LoginID"].ToString();
                    objVolunteer.Password  = objVolunteer.getPass();
                    objVolunteer.getDetails();
                    string feedbacktext = txtFeedback.Text;
                    string strConn      = ConfigurationManager.ConnectionStrings["P2ConnectionString"].ToString();

                    SqlConnection conn = new SqlConnection(strConn);

                    SqlCommand cmd = new SqlCommand("INSERT INTO Feedback(VolunteerID, ElderID, Feedback, DateCreated) Output inserted.FeedbackID " +
                                                    "Values(@volunteerid, @ElderID, @feedbacktext, GetDate())", conn);

                    string elderid = Request.QueryString["ElderID"];
                    cmd.Parameters.AddWithValue("@volunteerid", objVolunteer.VolunteerID);
                    cmd.Parameters.AddWithValue("@ElderID", elderid);
                    cmd.Parameters.AddWithValue("@feedbacktext", feedbacktext);

                    SqlDataAdapter daFeedback = new SqlDataAdapter(cmd);

                    DataSet result = new DataSet();

                    conn.Open();

                    int id = cmd.ExecuteNonQuery();

                    conn.Close();
                    lblFeedback.Text = "Success Sent!";
                }

                else
                {
                    lblFeedback.Text = "Error!";
                }
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet    result       = new DataSet();
            Elderlies  objElder     = new Elderlies();
            Volunteers objVolunteer = new Volunteers();

            objVolunteer.EmailAddr = Session["LoginID"].ToString();
            objVolunteer.getPass();
            objVolunteer.getId();

            int errorCode = objVolunteer.getPrepare(ref result);

            if (errorCode == 0)
            {
                gvElderPrepare.DataSource = result.Tables["ElderDetails"];
                gvElderPrepare.DataBind();
            }
        }
Ejemplo n.º 3
0
        protected int DisplayNameOnLabel()
        {
            string searchColumn = "";
            string searchValue  = "";

            searchColumn = "Name";
            searchValue  = txtSearchElderInput.Text;

            Volunteers objVolunteer = new Volunteers();

            objVolunteer.EmailAddr = Session["LoginID"].ToString();
            objVolunteer.getPass();
            objVolunteer.getId();
            string VolID = objVolunteer.getId();

            string strConn = ConfigurationManager.ConnectionStrings
                             ["P2ConnectionString"].ToString();

            SqlConnection conn = new SqlConnection(strConn);

            SqlCommand cmd = new SqlCommand("SELECT * FROM Elder WHERE " + searchColumn + " =@value AND VolunteerID = @VolunteerID", conn);

            cmd.Parameters.AddWithValue("@value", txtSearchElderInput.Text);

            try
            {
                conn.Open();
                conn.Close();

                return(1);
            }
            catch
            {
                return(0);
            }
        }
Ejemplo n.º 4
0
        protected int searchElders()
        {
            string searchColumn = "";
            string searchValue  = "";
            string sqlCommand   = "";

            Volunteers objVolunteer = new Volunteers();

            objVolunteer.EmailAddr = Session["LoginID"].ToString();
            objVolunteer.getPass();
            objVolunteer.getId();
            string VolID = objVolunteer.getId();


            if (rdoSerial.Checked)
            {
                searchColumn = "SerialNo";
                searchValue  = txtSearchElderInput.Text + "%";
                DisplayNameOnLabel();
                sqlCommand = " LIKE";
                if (searchValue == "%%")
                {
                    return(0);
                }
            }

            else
            {
                searchColumn = "Name";
                searchValue  = txtSearchElderInput.Text + "%";
                sqlCommand   = " LIKE";

                if (searchValue == "%%")
                {
                    return(0);
                }
            }

            string strConn = ConfigurationManager.ConnectionStrings
                             ["P2ConnectionString"].ToString();

            SqlConnection conn = new SqlConnection(strConn);

            SqlCommand cmd = new SqlCommand("SELECT * FROM Elder WHERE " + searchColumn + sqlCommand + " @value AND VolunteerID = @VolunteerID", conn);

            cmd.Parameters.AddWithValue("@value", searchValue);
            cmd.Parameters.AddWithValue("@VolunteerID", VolID);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataSet result = new DataSet();

            try
            {
                conn.Open();
                da.Fill(result, "ElderDetails");
                conn.Close();

                gvElderN.DataSource = result.Tables["ElderDetails"];
                gvElderN.DataBind();

                if (result.Tables["ElderDetails"].Rows.Count == 0)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            catch
            {
                return(0);
            }
        }