Esempio n. 1
0
    public static List <LastDonationDate> getAllLastDonations()
    {
        List <LastDonationDate> lastDonations = new List <LastDonationDate>();

        try
        {
            SqlCommand command = new SqlCommand("Select * from LastDonationDate");
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                LastDonationDate ld = new LastDonationDate();
                ld.ID           = reader["dID"].ToString();
                ld.User         = UsersDB.getUserbyID(reader["userId"].ToString());
                ld.LastDonation = Convert.ToDateTime(reader["donationDate"]);
                ld.Type         = reader["type"].ToString();
                ld.Status       = reader["status"].ToString();
                lastDonations.Add(ld);
            }
            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(lastDonations);
    }
Esempio n. 2
0
    public static int updateLastDonation(LastDonationDate ld)
    {
        int num = -1;

        try
        {
            SqlCommand command = new SqlCommand("update LastDonationDate set donationDate=@lastdonation, status=@status, type=@type where dId=@id");
            command.Parameters.AddWithValue("@lastdonation", ld.LastDonation);
            command.Parameters.AddWithValue("@status", ld.Status);
            command.Parameters.AddWithValue("@type", ld.Type);
            command.Parameters.AddWithValue("@id", ld.ID);
            command.Connection = connection;
            connection.Open();
            if (command.ExecuteNonQuery() > 0)
            {
                num = 1;
            }
        }
        finally
        {
            connection.Close();
        }
        return(num);
    }
Esempio n. 3
0
    public static int insertLastDonation(LastDonationDate ld)
    {
        int num = -1;

        try
        {
            SqlCommand command = new SqlCommand("insert into LastDonationDate values(@userId, @donationDate, @type, @status)");
            command.Parameters.AddWithValue("@userId", ld.User.UserId);
            command.Parameters.AddWithValue("@donationDate", ld.LastDonation);
            command.Parameters.AddWithValue("@type", ld.Type);
            command.Parameters.AddWithValue("@status", ld.Status);
            command.Connection = connection;
            connection.Open();
            if (command.ExecuteNonQuery() > 0)
            {
                num = 1;
            }
        }
        finally
        {
            connection.Close();
        }
        return(num);
    }
Esempio n. 4
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        List <Users> Userlist = UsersDB.getallUsers();

        if (!CheckTerm.Checked)
        {
            cbTermVali.Visible = true;
            return;
        }
        else
        {
            cbTermVali.Visible = false;

            DateTime check = DateTime.Now.AddYears(-18);
            if (Convert.ToDateTime(tbxDOB.Text) > check)
            {
                lblDOB.Visible = true;
                return;
            }

            foreach (Users u in Userlist)
            {
                if (tbxNRIC.Text == u.nric)
                {
                    lblNRIC.Visible = true;
                    return;
                }
                else
                {
                    lblNRIC.Visible = false;
                }
            }

            foreach (Users u in Userlist)
            {
                if (tbxEmail.Text == u.email)
                {
                    lblEmail.Visible = true;
                    return;
                }
                else
                {
                    lblEmail.Visible = false;
                }
            }

            foreach (Users u in Userlist)
            {
                if (tbxUsername.Text == u.password)
                {
                    lblUsername.Visible = true;
                    return;
                }
                else
                {
                    lblUsername.Visible = false;
                }
            }



            if (tbxHeight.Text == "")
            {
                theight = 0;
            }
            else
            {
                theight = Convert.ToInt32(tbxHeight.Text);
            }


            if (tbxWeight.Text == "")
            {
                tweight = 0;
            }
            else
            {
                tweight = Convert.ToInt32(tbxWeight.Text);
            }


            if (RadioMale.Checked)
            {
                tgender = "Male";
            }
            else
            {
                tgender = "Female";
            }
            if (RadioMSSingle.Checked)
            {
                Rstatus = "Single";
            }
            else if (RadioMSWidowed.Checked)
            {
                Rstatus = "Widowed";
            }
            else if (RadioMSDivorced.Checked)
            {
                Rstatus = "Divorced";
            }
            else
            {
                Rstatus = "Married";
            }

            if (ddllastDAsk.SelectedIndex == 0)
            {
                lblldAsk.Visible = true;
                Panel1.Visible   = false;
                return;
            }
            else if (ddllastDAsk.SelectedIndex == 1)
            {
                if (Convert.ToDateTime(tbxlastDonate.Text) > System.DateTime.Now)
                {
                    lbllastDonate.Visible = true;
                    return;
                }
                else
                {
                    lbllastDonate.Visible = false;
                    lstDonate             = Convert.ToDateTime(tbxlastDonate.Text);
                    if (RadioBlood.Checked)
                    {
                        bloodgroup = "blood";
                    }
                    else
                    {
                        bloodgroup = "platelet";
                    }
                }
            }
            else
            {
                lstDonate  = System.DateTime.Now.AddYears(-10);
                bloodgroup = "blood";
            }



            Users newuser = new Users(tbxEmail.Text, tbxName.Text, Convert.ToDateTime(tbxDOB.Text), tgender, Rstatus, theight, tweight, ddlBloodType.SelectedValue, tbxUsername.Text, tbxPassword.Text, Convert.ToInt32(tbxPhone.Text), tbxNRIC.Text, "null", 0, "null", "Allow", tbxAddress.Text, Convert.ToInt32(tbxZipcode.Text), ddlNationality.SelectedValue, "Default.png", "null", "Can Donate", "null", "null", "null");
            int   num     = UsersDB.insertUser(newuser);
            if (num != -1)
            {
                Users            newu = UsersDB.getUserbyEmail(tbxEmail.Text);
                LastDonationDate ldd  = new LastDonationDate(newu, lstDonate, bloodgroup, "Not in transaction");
                LastDonationDateDB.insertLastDonation(ldd);
                if (checkEmergencyContact.Checked)
                {
                    Session["Username"] = tbxUsername.Text;
                    Server.Transfer("AddationalRegister.aspx");
                }
                else
                {
                    lblOutput.Visible = true;
                    lblOutput.Text    = "Registeration Successful!";
                    string HomePageUrl = "Login.aspx";
                    Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=3;url={0}> ", HomePageUrl)));
                }
            }
            else
            {
                lblOutput.Visible = true;
                lblOutput.Text    = "User Cannot Register!";
                return;
            }
        }
    }