Exemple #1
0
        private void editSacrament(SacramentType sacrament, DataRow dr)
        {
            User user = User.getCurrentUser();

            if (user.userPrivilegeLevel == UserPrivileges.Supervisor)
            {
                if (AdminCredentialDialog.Show() != DialogResult.Yes)
                {
                    return;
                }
            }

            SacramentForm f      = new SacramentForm(OperationType.Edit, sacrament, dr);
            DialogResult  result = f.ShowDialog();

            if (result == DialogResult.OK)
            {
                Notification.Show(State.SacramentEditSuccess);
            }
            else if (result != DialogResult.Cancel)
            {
                Notification.Show(State.SacramentEditFail);
            }

            loadSacrament(sacrament);
        }
 private void delete_button_bloodletting_Click(object sender, EventArgs e)
 {
     if (AdminCredentialDialog.Show() == DialogResult.Yes)
     {
         if (!dh.isBloodDonationClaimed(int.Parse(blooddonation_dataGridView_bloodletting.CurrentRow.Cells["blooddonationID"].Value.ToString())))
         {
             dh.deleteBloodDonation(int.Parse(blooddonation_dataGridView_bloodletting.CurrentRow.Cells["blooddonationID"].Value.ToString()));
             refreshBloodDonation();
             delete_button_bloodletting.Enabled      = false;
             addDonation_button_bloodletting.Enabled = false;
             clearAddInfo();
             addDonation_button_bloodletting.Text = "Add";
         }
         else
         {
             Notification.Show(State.CannotDeleteBloodAlreadyClaimed);
         }
     }
 }
Exemple #3
0
        private void delete_button_Click(object sender, EventArgs e)
        {
            User u = User.getCurrentUser();

            if (u.userPrivilegeLevel == UserPrivileges.Admin)
            {
                CustomMessage msg = new CustomMessage();
                if (msg.Show("Are you sure you want to delete this event?", MessageDialogButtons.YesNoCancel, MessageDialogIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        dh.deleteBloodDonationEvent(bloodlettingID);
                        close_button.PerformClick();
                    }
                    catch
                    {
                        dh.conn.Close();
                        Notification.Show(State.CannotDeleteBloodEvent);
                    }
                }
            }
            else if (AdminCredentialDialog.Show() == DialogResult.Yes)
            {
                CustomMessage msg = new CustomMessage();
                if (msg.Show("Are you sure you want to delete this event?", MessageDialogButtons.YesNoCancel, MessageDialogIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        dh.deleteBloodDonationEvent(bloodlettingID);
                        close_button.PerformClick();
                    }
                    catch
                    {
                        dh.conn.Close();
                        Notification.Show(State.CannotDeleteBloodEvent);
                    }
                }
            }
        }
Exemple #4
0
 private void save_button_Click(object sender, EventArgs e)
 {
     if (AdminCredentialDialog.Show() == DialogResult.Yes)
     {
         if (!dh.isItemTypeExist(name_textbox.Text, IncomeTypeID, book_combobox.SelectedIndex, cashreceipt_cashdisbursment))
         {
             if (name_textbox.Text.Trim() == "" || book_combobox.Text == "")
             {
                 Notification.Show(State.MissingFields);
             }
             else
             {
                 if (IncomeTypeID == 0)
                 {
                     dh.addItemType(name_textbox.Text, book_combobox.SelectedIndex, suggestedPrice_nud.Value, (active_button.Checked ? 1 : 2), cashreceipt_cashdisbursment, details_textbox.Text);
                     IncomeTypeID = dh.getMaxIncomeType();
                     Notification.Show(State.ItemTypeAdded);
                 }
                 else
                 {
                     dh.editIncomeType(IncomeTypeID, name_textbox.Text, book_combobox.SelectedIndex, suggestedPrice_nud.Value, (active_button.Checked ? 1 : 2), cashreceipt_cashdisbursment, details_textbox.Text);
                     Notification.Show(State.ChangesSaved);
                 }
                 this.Close();
             }
         }
         else
         {
             Notification.Show(State.ItemTypeUsed);
         }
     }
     else
     {
         Notification.Show(State.WrongCredentials);
     }
 }
Exemple #5
0
 private void edit_button_Click(object sender, EventArgs e)
 {
     if (edit_button.Tag.ToString() == "e")
     {
         User u = User.getCurrentUser();
         if (u.userPrivilegeLevel == UserPrivileges.Admin)
         {
             event_name.ReadOnly          = false;
             start_dateTimePicker.Enabled = true;
             dtpTimeStart.Enabled         = true;
             venue_textbox.ReadOnly       = false;
             details_textarea.ReadOnly    = false;
             edit_button.Tag              = "s";
             edit_button.Image            = Properties.Resources.icons8_Save_Filled_32__1_;
             start_dateTimePicker.Enabled = true;
             dtpTimeStart.Enabled         = true;
             cancel_button.Visible        = true;
             dtpTimeStart.Enabled         = true;
         }
         else
         {
             if (AdminCredentialDialog.Show() == DialogResult.Yes)
             {
                 event_name.ReadOnly          = false;
                 start_dateTimePicker.Enabled = true;
                 dtpTimeStart.Enabled         = true;
                 venue_textbox.ReadOnly       = false;
                 details_textarea.ReadOnly    = false;
                 edit_button.Tag              = "s";
                 edit_button.Image            = Properties.Resources.icons8_Save_Filled_32__1_;
                 start_dateTimePicker.Enabled = true;
                 dtpTimeStart.Enabled         = true;
                 cancel_button.Visible        = true;
             }
         }
     }
     else
     {
         if (event_name.Text.Trim() == "" || (start_dateTimePicker.Value.Date > end_DateTimePicker.Value.Date) || venue_textbox.Text.Trim() == "")
         {
             Notification.Show(State.MissingFields);
         }
         else if (dh.isEventNameExist(event_name.Text, bloodlettingID))
         {
             Notification.Show(State.EventNameUsed);
         }
         else if (new DateTime(start_dateTimePicker.Value.Year, start_dateTimePicker.Value.Month, start_dateTimePicker.Value.Day, dtpTimeStart.Value.Hour, dtpTimeStart.Value.Minute, 0) >
                  new DateTime(end_DateTimePicker.Value.Year, end_DateTimePicker.Value.Month, end_DateTimePicker.Value.Day, dtpTimeEnd.Value.Hour, dtpTimeEnd.Value.Minute, 0))
         {
             Notification.Show(State.invalidTime);
         }
         else
         {
             if (bloodlettingID.Equals(0))
             {
                 dh.addBloodDonationEvent(event_name.Text, new DateTime(start_dateTimePicker.Value.Year, start_dateTimePicker.Value.Month, start_dateTimePicker.Value.Day, dtpTimeStart.Value.Hour, dtpTimeStart.Value.Minute, 0)
                                          , new DateTime(end_DateTimePicker.Value.Year, end_DateTimePicker.Value.Month, end_DateTimePicker.Value.Day, dtpTimeEnd.Value.Hour, dtpTimeEnd.Value.Minute, 0)
                                          , venue_textbox.Text, details_textarea.Text);
                 bloodlettingID = dh.getMaxBloodEvent() + 1;
                 Notification.Show(State.EventAdded);
             }
             else
             {
                 dh.editBloodDonationEvent(bloodlettingID, event_name.Text, new DateTime(start_dateTimePicker.Value.Year, start_dateTimePicker.Value.Month, start_dateTimePicker.Value.Day, dtpTimeStart.Value.Hour, dtpTimeStart.Value.Minute, 0)
                                           , new DateTime(end_DateTimePicker.Value.Year, end_DateTimePicker.Value.Month, end_DateTimePicker.Value.Day, dtpTimeEnd.Value.Hour, dtpTimeEnd.Value.Minute, 0), venue_textbox.Text, details_textarea.Text);
                 Notification.Show(State.ChangesSaved);
             }
             edit_button.Tag            = "e";
             edit_button.Image          = Properties.Resources.icons8_Pencil_32__1_;
             event_name.ReadOnly        = true;
             end_DateTimePicker.Enabled = false;
             dtpTimeEnd.Enabled         = false;
             venue_textbox.ReadOnly     = true;
             details_textarea.ReadOnly  = true;
             this.Close();
         }
     }
 }
        private void edit_button_Click(object sender, EventArgs e)
        {
            if (edit_button.Tag.ToString() == "s")
            {
                cancel_button.Visible = false;
                delete_button.Visible = false;
                if (fn.Text != "" && mn.Text != "" && ln.Text != "" && address_textbox.Text != "" && contactNumber_textbox.MaskFull && bloodtype_combobox.Text != "")
                {
                    if (hasProfile)                                                                                                                                             //edit
                    {
                        if (dh.countSameDonor(fn.Text, mn.Text, ln.Text, sf.Text, address_textbox.Text, contactNumber_textbox.Text, bloodtype_combobox.SelectedIndex + 1) != 0) //someone exists
                        {
                            int from = dh.getBloodDonorWhere(fn.Text, mn.Text, ln.Text, sf.Text, address_textbox.Text, contactNumber_textbox.Text, bloodtype_combobox.SelectedIndex + 1);
                            if (from != ProfileID)
                            {
                                DialogResult result = MessageBox.Show("A profile is already existing do you wish to merge the donations?", "", MessageBoxButtons.YesNoCancel);
                                if (result == DialogResult.Yes)
                                {
                                    dh.mergeDonations(from, ProfileID);
                                    Notification.Show(State.MergingDone);
                                }
                            }
                        }
                        dh.editBloodDonor(ProfileID, fn.Text, mn.Text, ln.Text, sf.Text, address_textbox.Text, contactNumber_textbox.Text, bloodtype_combobox.SelectedIndex + 1);
                        edit_button.Image = Properties.Resources.icons8_Pencil_32__1_;
                        edit_button.Tag   = "e";
                        refreshPerson();
                    }
                    else//add
                    {
                        if (dh.countSameDonor(fn.Text, mn.Text, ln.Text, sf.Text, address_textbox.Text, contactNumber_textbox.Text, bloodtype_combobox.SelectedIndex) == 0)
                        {
                            dh.addBloodDonor(fn.Text, mn.Text, ln.Text, sf.Text, address_textbox.Text, contactNumber_textbox.Text, bloodtype_combobox.SelectedIndex + 1);
                            Notification.Show(State.ProfileAdded);
                            edit_button.Tag   = "e";
                            edit_button.Image = Properties.Resources.icons8_Pencil_32__1_;
                            hasProfile        = true;
                            refreshPerson();
                        }
                        else
                        {
                            Notification.Show(State.ProfileExists);
                            ClearProfile();
                        }
                    }
                }
                else
                {
                    Notification.Show(State.MissingFields);
                }
            }
            else
            {
                if (AdminCredentialDialog.Show() == DialogResult.Yes)
                {
                    profileEditmode();
                    edit_button.Tag   = "s";
                    edit_button.Image = Properties.Resources.icons8_Save_Filled_32__1_;
                    if (hasProfile)
                    {
                        fn.Text = firstname_label_bloodletting.Text;
                        ln.Text = lastname_label_bloodletting.Text;
                        sf.Text = suffix_label_bloodletting.Text;
                        mn.Text = mi_label_bloodletting.Text;

                        firstname = firstname_label_bloodletting.Text;
                        midname   = mi_label_bloodletting.Text;
                        lastname  = lastname_label_bloodletting.Text;
                        suffix    = suffix_label_bloodletting.Text;
                        contact   = contactNumber_textbox.Text;
                        addres    = address_textbox.Text;
                    }
                    cover.Visible         = true;
                    cancel_button.Visible = true;
                    delete_button.Visible = true;
                }
            }
        }