Ejemplo n.º 1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (lvDonations.SelectedItems.Count > 0)
     {
         DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete donation " + txtDonationID.Text, "Donations maintenance", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             Donations donations = new Donations(_clientid);
             string    msg       = donations.DeleteDonation(Convert.ToInt32(lvDonations.SelectedItems[0].SubItems[0].Text));
             if (msg == "Successfully deleted donation")
             {
                 lvDonations.SelectedItems[0].Remove();
             }
             else
             {
                 MessageBox.Show(msg, "Donation deletion");
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void LoadDonations()
 {
     Donations = new Donations(_id);
 }
Ejemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //Validate the required fields first
            if (txtFirstName.Text == string.Empty || txtSurname.Text == string.Empty || txtAddressLine1.Text == string.Empty || txtTown.Text == string.Empty || mskPostCode.Text == string.Empty || (txtHomePhone.Text == string.Empty && txtMobilePhone.Text == string.Empty))
            {
                MessageBox.Show("All yellow entry fields plus one phone number must be entered");
                return;
            }

            if (radDonationYes.Checked && (txtReference.Text == string.Empty || mskAmount.Text == string.Empty))
            {
                MessageBox.Show("Amount and Reference fields must be completed for donation.");
                return;
            }

            Clients collClient = new Clients();

            IEnumerable <Client> query;

            query = collClient.Where(s => s.Surname.ToUpper() == txtSurname.Text.ToUpper()).Where(s => s.AddressLine1.ToUpper() == txtAddressLine1.Text.ToUpper());

            Client clientdupe = new Client();

            try {
                clientdupe = query.First <Client>();
            }
            catch (SystemException a) {
                //do nowt just avoid bug
            }
            if (clientdupe.ClientID > 0)
            {
                DialogResult dialogResult = MessageBox.Show("A client is already registered at this address (" + clientdupe.FirstName + " " + (clientdupe.MiddleName == string.Empty ? string.Empty : clientdupe.MiddleName + string.Empty) + clientdupe.Surname + ")" + Environment.NewLine + "Continue saving this client?", "Client Additions", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }


            client.TitleID      = Convert.ToInt32(this.cboTitle.SelectedValue.ToString()) < 1 ? 5 : Convert.ToInt32(this.cboTitle.SelectedValue.ToString());
            client.FirstName    = this.txtFirstName.Text;
            client.MiddleName   = this.txtMiddleName.Text;
            client.Surname      = this.txtSurname.Text;
            client.AddressLine1 = this.txtAddressLine1.Text;
            client.AddressLine2 = this.txtAddressLine2.Text;
            client.Town         = this.txtTown.Text;
            client.Postcode     = this.mskPostCode.Text;
            client.HomePhone    = this.txtHomePhone.Text;
            client.MobilePhone  = this.txtMobilePhone.Text;
            client.DateOfBirth  = this.dtpDOB.Value;
            client.Email        = this.txtEmail.Text;

            client.isActive = true;
            string msg = client.Add();

            if (msg == "Successfully added client")
            {
                bDirty = false;
                if (rtbNotes.Text != string.Empty)
                {
                    Notes collNotes = new Notes(client.ClientID, Notes.NoteType.Client);
                    collNotes.AddNote(client.ClientID, rtbNotes.Text);
                }
                //now add in the attributes.
                for (Int32 i = 0; i < this.clbAttributes.Items.Count; i++)
                {
                    client.Attributes[i].CheckedNew = this.clbAttributes.GetItemChecked(i);
                    client.Attributes[i].LinkID     = client.ClientID;
                    client.Attributes[i].Update(Attribute.AttributeType.client);
                }

                if (radDonationYes.Checked)
                {
                    Donations donations = new Donations();

                    msg = donations.AddDonation(client.ClientID, dtpPaymentDate.Value, Convert.ToDecimal(mskAmount.Text.ToString().Replace("£", "").Replace(" ", "")), txtReference.Text);
                    if (msg != "Successfully saved donation")
                    {
                        MessageBox.Show("Client saved but there has been a problem saving the donation - you can add the donation in the Client Edit form" + Environment.NewLine + msg, "Client Addition");
                        this.Close();
                    }
                }

                MessageBox.Show("Successfully added Client", "Client Addition");
                this.Close();
            }
        }