protected string displayVolunteer(uint id)
    {
        string result = "";

        DateTime dt = new DateTime(1901, 1, 1);
        GFRC.Volunteer display = new GFRC.Volunteer(id);
        GFRC.Login modifiedby = new GFRC.Login(display.ModifiedBy);

        result = "<table class=\"display\"><tr><td>";
        result += string.Format("Volunteer ID: </td><td>{0}</td></tr><tr><td>", display.gvoID);
        result += string.Format("Name: </td><td>{0}</td></tr><tr><td>", display.Name);
        result += string.Format("Address: </td><td>{0}</td></tr><tr><td>", display.Address);
        result += string.Format("Postal Address: </td><td>{0}</td></tr><tr><td>", display.PostalAddress);
        result += string.Format("Email: </td><td>{0}</td></tr><tr><td>", display.Email);
        result += string.Format("Home #: </td><td>{0}</td></tr><tr><td>", display.HomePh);
        result += string.Format("Mobile #: </td><td>{0}</td></tr><tr><td>", display.MobilePh);
        result += string.Format("D.O.B: </td><td>{0}</td></tr><tr><td>", display.DOB.ToString("dd MMMM yyyy"));
        result += string.Format("Status: </td><td>{0}</td></tr><tr><td>", display.Status);
        result += string.Format("Refferred by: </td><td>{0}</td></tr><tr><td>", display.Referred);
        result += string.Format("Documentation: </td><td>{0}</td></tr><tr><td>", display.ReferredDoc);
        result += string.Format("Police Check? </td><td>{0}</td></tr><tr><td>", display.Police.ToString());
        result += string.Format("Documentation: </td><td>{0}</td></tr><tr><td>", display.PoliceDoc);
        result += string.Format("Had Induction? </td><td>{0}</td></tr><tr><td>", display.Induction.ToString());
        result += string.Format("Application: </td><td>{0}</td></tr><tr><td>", display.Application);
        if (display.DateModified != dt)
            result += string.Format("Last Modified: </td><td>{0}</td></tr><tr><td>", display.DateModified.ToString("dd/MM/yyyy hh:mm tt"));
        else
            result += string.Format("Last Modified: </td><td></td></tr><tr><td>");
        result += string.Format("Modified By: </td><td>{0}</td></tr></table>", modifiedby.Username);

        return result;
    }
    protected void btnEditVolunteer_Click(object sender, EventArgs e)
    {
        string name = txtName.Text, address = txtAddress.Text, postal = txtPostal.Text, email = txtEmail.Text, home = txtHomePh.Text, mobile = txtMobilePh.Text, status = drpStatus.SelectedItem.Value, referred = txtReferred.Text;
        string referreddoc = fReferredDoc.PostedFile.FileName, policedoc = fPoliceDoc.PostedFile.FileName, application = fApplication.PostedFile.FileName;
        bool police = chkPolice.Checked, induction = chkInduction.Checked;
        DateTime dob = Convert.ToDateTime(txtDOB.Text), datemodified = DateTime.Now;
        uint gvoid = Convert.ToUInt32(lblShowID.Text), modifiedby = Convert.ToUInt32(Session["UserID"]);

        if (postal == null || postal == "")
            postal = " ";
        if (home == null || home == "")
            home = " ";
        if (referred == null || referred == "")
            referred = " ";
        if (referreddoc == null || referreddoc == "")
            referreddoc = txtRefDoc.Text;
        if (policedoc == null || policedoc == "")
            policedoc = txtRefDoc.Text;
        if (application == null || application == "")
            application = txtApp.Text;

        GFRC.Volunteer update = new GFRC.Volunteer(gvoid, name, address, postal, email, home, mobile, dob, status, referred, referreddoc, police, policedoc, induction, application, datemodified, modifiedby);
        update.editVolunteer(update);
        Response.Redirect("/VolunteerView.aspx?form=view&ID=" + update.gvoID);
    }
 protected void btnSearchVolunteer_Click(object sender, EventArgs e)
 {
     uint id = Convert.ToUInt32(txtID.Text);
     GFRC.Volunteer search = new GFRC.Volunteer(id);
     if (search.Name == "")
         searchError.Text = "The user you searched for doesn't seem to exist. Please try again.";
     else
         Response.Redirect("/VolunteerView.aspx?form=view&ID=" + id);
 }
    protected string displayAdmin(uint id)
    {
        string result = "";

        DateTime dt = new DateTime(1901, 1, 1);
        GFRC.Login display = new GFRC.Login(id);
        GFRC.Volunteer link = new GFRC.Volunteer(display.gvoID);
        GFRC.Login modifiedby = new GFRC.Login(display.ModifiedBy);

        result = "<table class=\"display\"><tr><td>";
        result += string.Format("Login ID: </td><td>{0}</td></tr><tr><td>", display.gloID);
        result += string.Format("Username: </td><td>{0}</td></tr><tr><td>", display.Username);
        result += string.Format("Note: </td><td>{0}</td></tr><tr><td>", display.Note);
        result += string.Format("Active? </td><td>{0}</td></tr><tr><td>", display.Active.ToString());
        result += string.Format("Status: </td><td>{0}</td></tr><tr><td>", display.Status);
        result += string.Format("Link To: </td><td>{0}</td></tr><tr><td>", link.ToString());
        if (display.DateModified != dt)
            result += string.Format("Last Modified: </td><td>{0}</td></tr><tr><td>", display.DateModified.ToString("dd/MM/yyyy hh:mm tt"));
        else
            result += string.Format("Last Modified: </td><td></td></tr><tr><td>");
        result += string.Format("Modified By: </td><td>{0}</td></tr></table>", modifiedby.Username);

        return result;
    }
    protected void btnAddVolunteer_Click(object sender, EventArgs e)
    {
        string name = txtName.Text, address = txtAddress.Text, postal = txtPostal.Text, email = txtEmail.Text, home = txtHomePh.Text, mobile = txtMobilePh.Text, status = drpStatus.SelectedItem.Value, referred = txtReferred.Text;
        string referreddoc = fReferredDoc.PostedFile.FileName, policedoc = fPoliceDoc.PostedFile.FileName, application = fApplication.PostedFile.FileName;
        bool police = chkPolice.Checked, induction = chkInduction.Checked;
        DateTime dob = Convert.ToDateTime(txtDOB.Text);

        if (postal == null || postal == "")
            postal = " ";
        if (home == null || home == "")
            home = " ";
        if (referred == null || referred == "")
            referred = " ";
        if (referreddoc == null || referreddoc == "")
            referreddoc = " ";
        if (policedoc == null || policedoc == "")
            policedoc = " ";
        if (application == null || application == "")
            application = " ";

        GFRC.Volunteer create = new GFRC.Volunteer(name, address, postal, email, home, mobile, dob, status, referred, referreddoc, police, policedoc, induction, application);
        create.createVolunteer(create);
            Response.Redirect("/VolunteerView.aspx?form=view&ID=" + create.gvoID);
    }
    protected void showVolunteer(uint id)
    {
        GFRC.Volunteer display = new GFRC.Volunteer(id);

        lblShowID.Text = display.gvoID.ToString();
        txtName.Text = display.Name;
        txtAddress.Text = display.Address;
        txtPostal.Text =  display.PostalAddress;
        txtEmail.Text =  display.Email;
        txtHomePh.Text = display.HomePh;
        txtMobilePh.Text = display.MobilePh;
        txtDOB.Text = display.DOB.ToString("dd/MM/yyyy");
        drpStatus.Items.FindByValue(display.Status).Selected = true;
        txtReferred.Text = display.Referred;
        txtRefDoc.Text = display.ReferredDoc;
        chkPolice.Checked = display.Police;
        txtPolDoc.Text = display.PoliceDoc;
        chkInduction.Checked = display.Induction;
        txtApp.Text = display.Application;
    }
Exemple #7
0
        public bool editVolunteer(Volunteer edit)
        {
            bool result = false;
            // Command
            string query = String.Format(@"UPDATE gfrc_volunteer SET gvo_name = '{0}', gvo_address= '{1}', gvo_postal_address = '{2}', gvo_email = '{3}', gvo_home_ph = '{4}', gvo_mobile_ph ='{5}', gvo_dob = '{6}', gvo_status = '{7}', gvo_referred = '{8}', " +
                                            "gvo_referred_doc = '{9}', gvo_police = {10}, gvo_police_doc = '{11}', gvo_induction = {12}, gvo_application = '{13}', date_modified = '{14}', modified_by = {15} " +
                                            "WHERE gvo_id = {16}",
                                            edit.Name, edit.Address, edit.PostalAddress, edit.Email, edit.HomePh, edit.MobilePh, edit.DOB, edit.Status, edit.Referred,
                                            edit.ReferredDoc, edit.Police, edit.PoliceDoc, edit.Induction, edit.Application, edit.DateModified, edit.ModifiedBy, edit.gvoID);

            int affected = 0;

            try
            {
                using (conn)
                {
                    conn.Open();
                    cmd = new OleDbCommand(query, conn);
                    affected = cmd.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {
                result = false;
            }
            finally
            {
                if (rdr != null)
                    rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            // checks if rows were affected by the insert query
            if (affected > 0)
            {
                result = true;
            }

            return result;
        }
Exemple #8
0
        public bool createVolunteer(Volunteer create)
        {
            bool result = false;
            // Command
            string query = String.Format(@"INSERT INTO gfrc_volunteer (gvo_name, gvo_address, gvo_postal_address, gvo_email, gvo_home_ph, gvo_mobile_ph, gvo_dob, gvo_status, gvo_referred, " +
                                            "gvo_referred_doc, gvo_police, gvo_police_doc, gvo_induction, gvo_application) " +
                                            "VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', {10}, '{11}', {12}, '{13}')",
                                            create.Name, create.Address, create.PostalAddress, create.Email, create.HomePh, create.MobilePh, create.DOB, create.Status,
                                            create.Referred, create.ReferredDoc, create.Police, create.PoliceDoc, create.Induction, create.Application);

            int affected = 0;

            try
            {
                using (conn)
                {
                    conn.Open();
                    cmd = new OleDbCommand(query, conn);
                    affected = cmd.ExecuteNonQuery();

                    // checks if rows were affected by the insert query
                    if (affected > 0)
                    {
                        result = true;

                        query = String.Format(@"SELECT gvo_id FROM gfrc_volunteer WHERE gvo_id = (SELECT MAX(gvo_id) FROM gfrc_volunteer)");
                        cmd = new OleDbCommand(query, conn);
                        rdr = cmd.ExecuteReader();

                        while (rdr.Read())
                        {
                            // Set gloID
                            _gvoID = Convert.ToUInt32(rdr.GetInt32(0));
                        }
                    }

                }
            }
            catch (Exception e)
            {
                result = false;
            }
            finally
            {
                if (rdr != null)
                    rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            return result;
        }