Exemplo 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!";
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                displayCoordinatorDropDownList();
                if (Request.QueryString["volunteerid"] != null)
                {
                    objVolunteer.VolunteerID = Request.QueryString["volunteerid"];
                    int errorCode = objVolunteer.getDetails();

                    if (errorCode == 0)
                    {
                        lblName.Text = objVolunteer.Name;
                        dd_Coordinator.SelectedValue = objVolunteer.coordinatorID.ToString();
                    }
                    else if (errorCode == -2)
                    {
                        lblMessage.Text      = "Unable to retrieve Volunteer details for ID " + objVolunteer.VolunteerID;
                        lblMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
        }