Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            blood_types Type     = (blood_types)Enum.Parse(typeof(blood_types), typeCombo.Text);
            DateTime    expireDT = dateTimePicker1.Value.Date + dateTimePicker1.Value.TimeOfDay;

            BloodbankOperations.add_blood_type(Type, bbNameBox.Text, expireDT);
        }
        //functions to access the no_of_blood_packs array ((they have to be added in the data base))
        public static bool add_blood_type(blood_types b, string bloodbankname, DateTime exp_date)
        {
            /* update:::no need to the commented part
             * int i = (int)b;                             //casting the blood type to be an integer equals to its index in the array
             * no_of_blood_packs[i]++;                     //incrementing number of this type in the array
             */
            string cols   = "bb_id";
            string q      = "select * from BloodBanks where bb_name='" + bloodbankname + "'";
            string result = DatabaseHandler.getvarfromDB(q, cols);       //get th id of the bloodbank name we want to add in

            q = "insert into BloodPacks values (" + exp_date + "," + b + "," + result + ")";
            return(DatabaseHandler.insertdatatodatabase(q));
        }
Example #3
0
        private void packButton_Click(object sender, EventArgs e)
        {
            blood_types[] types = new blood_types[] {
                blood_types.A_pos,
                blood_types.A_neg,
                blood_types.B_pos,
                blood_types.B_neg,
                blood_types.AB_pos,
                blood_types.AB_neg,
                blood_types.O_pos,
                blood_types.O_neg
            };

            //add fix
            LoadTable("select BloodBanks.bb_name,BloodBanks.bb_email,BloodBanks.bb_mobile,BloodBanks.bb_address,BloodBanks.bb_type from BloodBanks INNER JOIN BloodPacks ON bb_id=bpack_bank and bpack_bloodtype='" + types[bTypeComboBox.SelectedIndex].ToString() + "'");
        }
        //
        public static bool remove_blood_type(blood_types b, string bloodbankname)      //it takes argument of blood_types enum parameter
        {
            /* update:::no need to the commented part
             * int i = (int)b;                             //casting the blood type to be an integer equals to its index in the array
             * //must first check the data base if it doesn't equal zero
             * if (no_of_blood_packs[i] > 0)
             * {
             *  no_of_blood_packs[i]--;                     //decrementing number of this type in the array
             * }
             */
            string cols   = "bb_id";
            string q      = "select * from BloodBanks where bb_name='" + bloodbankname + "'";
            string result = DatabaseHandler.getvarfromDB(q, cols);       //get th id of the bloodbank name we want to remove from

            q = "delete from BloodPacks where bpack_bloodtype='" + b + "'and bpack_bank='" + result + "'";
            return(DatabaseHandler.insertdatatodatabase(q));
        }
Example #5
0
        private void signUpButton_Click(object sender, EventArgs e)
        {
            blood_types[] types = new blood_types[] {
                blood_types.A_pos,
                blood_types.A_neg,
                blood_types.B_pos,
                blood_types.B_neg,
                blood_types.AB_pos,
                blood_types.AB_neg,
                blood_types.O_pos,
                blood_types.O_neg
            };

            passMessage.Text   = "";
            emailMessage.Text  = "";
            mobileMessage.Text = "";

            User user = new User();

            user.Name       = nameField.Text;
            user.pictureLoc = imgloc;
            Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match = regex.Match(emailField.Text);

            if (!match.Success)
            {
                emailMessage.Text = "Enter valid email !";
                return;
            }
            user.Email = emailField.Text;

            if (passwordField.Text != confirmPassField.Text)
            {
                passMessage.Text = "Passwords didn't match";
                return;
            }
            user.Password = passwordField.Text;

            Regex regex2 = new Regex(@"^01[0-2]");
            Match match2 = regex2.Match(mobileField.Text);

            if (!match2.Success || mobileField.Text.Length != 11)
            {
                mobileMessage.Text = "Enter valid mobile !";
                return;
            }
            user.mobileNo = mobileField.Text;

            user.HealthCond = healthCondField.Text;
            user.birthdate  = DateTime.Parse(birthDateField.Text);
            user.BloodType  = types[bTypeComboBox.SelectedIndex];

            if (!UserOperations.signUp(user))
            {
                emailMessage.Text = "Used Email!";
            }
            else
            {
                UserHomeForm home = new UserHomeForm();
                home.Show();
                this.Hide();
            }
        }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            blood_types Type = (blood_types)Enum.Parse(typeof(blood_types), typeCombo.Text);

            BloodbankOperations.remove_blood_type(Type, bbNameBox.Text);
        }