Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool flag;

            //MessageBox.Show(d_id.ToString());
            if (d_id > 0)
            {
                try
                {
                    //insert into db donation history
                    BloodBankData bbd = new BloodBankData();

                    DONATION_HISTORY dh = new DONATION_HISTORY();
                    dh.DONOR_ID      = d_id;
                    dh.RECIEVER_ID   = u_id;
                    dh.DONATION_DATE = dateTimePicker1.Value;
                    flag             = bbd.insertDonationHistory(dh);
                    if (flag == true)
                    {
                        MessageBox.Show("Blood Request Successful!", "Blood Request", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error While Requesting Blood!", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                MessageBox.Show("Select a valid column first", "Inavlid Selection", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
0
        public void setID()
        {
            BloodBankData bbd = new BloodBankData();

            id           = bbd.getNextID();
            idLabel.Text = id.ToString();
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //insert into moderators
            bool flag = false;

            BloodBankData bbd = new BloodBankData();

            MODERATORS md = new MODERATORS();

            md.ID        = 5;
            md.NAME      = textBox1.Text;
            md.IMAGE     = convertImageToBinary(pictureBox2.BackgroundImage);
            md.GENDER    = gender;
            md.ADDRESS   = address;
            md.EMAIL     = textBox3.Text;
            md.CELLPHONE = textBox4.Text;
            md.JOIN_DATE = join_date;
            flag         = bbd.insertModerators(md);

            if (flag == true)
            {
                this.Close();
                thread = new Thread(openSignUpSuccessForm);
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }
            else
            {
                MessageBox.Show("Sign Up Failed!", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        private void button7_Click(object sender, EventArgs e)
        {
            //DECLINE
            bool flag;

            button5.Visible = true;
            button7.Visible = true;
            button5.Enabled = true;
            button7.Enabled = true;
            button8.Visible = false;
            button8.Enabled = false;

            if (u_id > 0)
            {
                try
                {
                    BloodBankData bbd = new BloodBankData();
                    flag = bbd.deleteUsers(u_id);
                    if (flag == true)
                    {
                        MessageBox.Show("User Has Been Deleted from USERS Table!", "Delete Successfull", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error While Deleting User from USERS Table", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }

                    flag = bbd.deleteLoginCredentials(u_id);
                    if (flag == true)
                    {
                        MessageBox.Show("User Has Been Deleted from LOGIN_CREDENTIALS Table!", "Delete Successfull", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error While Deleting User from LOGIN_CREDENTIALS Table", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }

                    DataSet         ds  = new DataSet();
                    SqlDbDataAccess da  = new SqlDbDataAccess();
                    SqlCommand      cmd = da.GetCommand("SELECT * FROM USERS, LOGIN_CREDENTIALS WHERE LOGIN_CREDENTIALS.STATUS = 'PENDING' AND LOGIN_CREDENTIALS.ID = USERS.ID;");
                    using (SqlDataAdapter dt = new SqlDataAdapter(cmd))
                    {
                        cmd.Connection.Open();
                        DataTable tbl = new DataTable();
                        dt.Fill(tbl);
                        cmd.Connection.Close();
                        dataGridView1.DataSource = tbl;
                    }
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                MessageBox.Show("Select a valid column first", "Inavlid Selection", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //log in
            try
            {
                password = textBox2.Text;
                this.id  = Convert.ToInt32(textBox1.Text);
            }
            catch (Exception ex)
            {
            }
            if (this.id == 0 || this.password.Equals(" "))
            {
                MessageBox.Show("Enter Username & Password First", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    idVal iv = new idVal(id);

                    BloodBankData bbd = new BloodBankData();
                    loginFlag = bbd.logIn(id, password);
                    if (loginFlag == 3)
                    {
                        this.Close();
                        thread = new Thread(openNewDonorHomeForm);
                        thread.SetApartmentState(ApartmentState.STA);
                        thread.Start();
                    }
                    else if (loginFlag == 2)
                    {
                        this.Close();
                        thread = new Thread(openNewUserHomeForm);
                        thread.SetApartmentState(ApartmentState.STA);
                        thread.Start();
                    }
                    else if (loginFlag == 1)
                    {
                        this.Close();
                        thread = new Thread(openNewModeratorHomeForm);
                        thread.SetApartmentState(ApartmentState.STA);
                        thread.Start();
                    }
                    else
                    {
                        MessageBox.Show("Your account is not active yet or invalid username or password.Please wait for admin approval", "Invalid Login Credentials!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                }
                textBox1.Clear();
                textBox2.Clear();
            }
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            //insert into db as receiver
            name      = textBox1.Text;
            password  = passwordTB.Text.ToString();
            password2 = textBox2.Text.ToString();
            cellphone = textBox4.Text.ToString();
            email     = textBox3.Text.ToString();

            if (!password.Equals(password2) || password.Equals(" "))
            {
                MessageBox.Show("Passwords don't match", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (password.Equals(password2) && !password.Equals(" "))
            {
                if (name.Equals(" ") || gender.Equals(" ") || bloodGroup.Equals(" ") || address.Equals(" ") || cellphone.Equals(" ") || email.Equals(" "))
                {
                    MessageBox.Show("Fill Up All The Fields Properly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    BloodBankData bbd = new BloodBankData();

                    LOGIN_CREDENTIALS lc = new LOGIN_CREDENTIALS();
                    lc.PASSWORD = passwordTB.Text;
                    lc.TYPE     = "RECEIVER";
                    lc.STATUS   = "PENDING";
                    bbd.insertLoginCredentials(lc);

                    USERS u = new USERS();
                    u.ID          = id;
                    u.NAME        = textBox1.Text;
                    u.IMAGE       = convertImageToBinary(pictureBox2.BackgroundImage);
                    u.DOB         = dob;
                    u.GENDER      = gender;
                    u.BLOOD_GROUP = bloodGroup;
                    u.ADDRESS     = address;
                    u.CELLPHONE   = cellphone;
                    u.EMAIL       = email;

                    bbd.insertUsersReceiver(u);

                    textBox1.Clear();
                    textBox2.Clear();
                    textBox3.Clear();
                    passwordTB.Clear();
                    monthCalendar1.ResetText();

                    this.Close();
                    thread = new Thread(openSignUpSuccessForm);
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                }
            }
        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool flag        = false;
            bool idMatchFlag = false;

            currentPassword = textBox1.Text.ToString();
            newPassword     = textBox2.Text.ToString();

            if (currentPassword.Equals("") || newPassword.Equals(""))
            {
                MessageBox.Show("Enter Current Password & New Password Properly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!currentPassword.Equals("") && !newPassword.Equals(""))
            {
                //check current password
                try
                {
                    SqlDbDataAccess da  = new SqlDbDataAccess();
                    SqlCommand      cmd = da.GetCommand("SELECT PASSWORD FROM LOGIN_CREDENTIALS WHERE ID = " + idVal.id);

                    cmd.Connection.Open();

                    SqlDataReader reader = cmd.ExecuteReader();
                    using (reader)
                    {
                        while (reader.Read())
                        {
                            this.pwd = reader.GetString(0);
                        }
                    }
                    reader.Close();
                    cmd.Connection.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to check password in DB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (!pwd.Equals(currentPassword))
                {
                    MessageBox.Show("Wrong Current Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (pwd.Equals(currentPassword))
                {
                    //change to new password
                    try
                    {
                        BloodBankData bbd = new BloodBankData();
                        flag = bbd.updateLoginCredentials_Password(idVal.id, newPassword);
                        if (flag == true)
                        {
                            MessageBox.Show("Password Has Been Changed Successfully!", "Password Changed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            textBox1.Clear();
                            textBox2.Clear();
                            label19.Visible  = false;
                            label20.Visible  = false;
                            textBox1.Visible = false;
                            textBox2.Visible = false;
                            button1.Visible  = false;
                            label19.Enabled  = false;
                            label20.Enabled  = false;
                            textBox1.Enabled = false;
                            textBox2.Enabled = false;
                            button1.Enabled  = false;
                            button3.Enabled  = false;
                            button3.Visible  = false;
                        }
                        else
                        {
                            MessageBox.Show("Failed to Change Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to Change Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Esempio n. 8
0
        private void button8_Click(object sender, EventArgs e)
        {
            bool flag;

            button5.Visible = false;
            button7.Visible = false;
            button5.Enabled = false;
            button7.Enabled = false;
            button8.Visible = true;
            button8.Enabled = true;

            if (u_id > 0)
            {
                DialogResult result = MessageBox.Show("Are you sure you want to delete this user?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        BloodBankData bbd = new BloodBankData();
                        flag = bbd.deleteUsers(u_id);
                        if (flag == true)
                        {
                            MessageBox.Show("User Has Been Deleted from USERS Table!", "Delete Successfull", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error While Deleting User from USERS Table", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                        }

                        flag = bbd.deleteLoginCredentials(u_id);
                        if (flag == true)
                        {
                            MessageBox.Show("User Has Been Deleted from LOGIN_CREDENTIALS Table!", "Delete Successfull", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error While Deleting User from LOGIN_CREDENTIALS Table", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                        }

                        DataSet         ds  = new DataSet();
                        SqlDbDataAccess da  = new SqlDbDataAccess();
                        SqlCommand      cmd = da.GetCommand("SELECT * FROM USERS;");
                        using (SqlDataAdapter dt = new SqlDataAdapter(cmd))
                        {
                            cmd.Connection.Open();
                            DataTable tbl = new DataTable();
                            dt.Fill(tbl);
                            cmd.Connection.Close();
                            dataGridView1.DataSource = tbl;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to delete user", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Select a valid column first", "Inavlid Selection", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }
        }
Esempio n. 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            //insert into db as donor
            bool flagLG  = false;
            bool flagUSR = false;

            name      = textBox1.Text;
            password  = passwordTB.Text.ToString();
            password2 = textBox2.Text.ToString();
            cellphone = textBox4.Text.ToString();
            email     = textBox3.Text.ToString();

            if (!password.Equals(password2) || password.Equals(" "))
            {
                MessageBox.Show("Passwords don't match", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (password.Equals(password2) && !password.Equals(" "))
            {
                if (name.Equals(" ") || gender.Equals(" ") || bloodGroup.Equals(" ") || address.Equals(" ") || cellphone.Equals(" ") || email.Equals(" ") || drugAddiction.Equals(" ") || HIV.Equals(" "))
                {
                    MessageBox.Show("Fill Up All The Fields Properly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    BloodBankData bbd = new BloodBankData();

                    LOGIN_CREDENTIALS lc = new LOGIN_CREDENTIALS();
                    lc.PASSWORD = passwordTB.Text;
                    lc.TYPE     = "DONOR";
                    lc.STATUS   = "PENDING";
                    flagLG      = bbd.insertLoginCredentials(lc);

                    USERS u = new USERS();
                    u.ID                 = id;
                    u.NAME               = textBox1.Text;
                    u.IMAGE              = convertImageToBinary(pictureBox2.BackgroundImage);
                    u.DOB                = dob;
                    u.GENDER             = gender;
                    u.BLOOD_GROUP        = bloodGroup;
                    u.ADDRESS            = address;
                    u.CELLPHONE          = textBox4.Text.ToString();
                    u.EMAIL              = textBox3.Text.ToString(); u.DRUG_ADDICTION = drugAddiction;
                    u.HIV_STATUS         = HIV;
                    u.LAST_DONATION_DATE = donationDate;

                    flagUSR = bbd.insertUsersDonor(u);

                    if (flagLG == true && flagUSR == true)
                    {
                        this.Close();
                        thread = new Thread(openNewSignUpSuccessForm);
                        thread.SetApartmentState(ApartmentState.STA);
                        thread.Start();
                    }
                    else
                    {
                        MessageBox.Show("Failed to sign up. Please fill up the form correctly & try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }