Ejemplo n.º 1
0
        private void bunifuFlatButton_Ok_Click(object sender, EventArgs e)
        {
            var  dogStr = comboBox_DogChip.Text.Split(' ');
            var  owner  = comboBox_OwnerID.Text.Split(' ');
            var  w      = comboBox_Worker.Text.Split(' ');
            bool ok     = false;
            var  error  = meetingModel.get(bunifuTextbox_ID._TextBox.Text);

            if (error != null)
            {
                MessageBox.Show("There is a meeting with this ID");
                bunifuTextbox_ID.Focus();
                return;
            }
            if (bunifuTextbox_ID._TextBox.Text != "" && comboBox_DogChip.Text != "" && comboBox_OwnerID.Text != "")
            {
                if ((DateTime.Now.Year < dateTimePicker_Date.Value.Year) ||
                    (DateTime.Now.Year == dateTimePicker_Date.Value.Year && DateTime.Now.Month < dateTimePicker_Date.Value.Month) ||
                    (DateTime.Now.Year == dateTimePicker_Date.Value.Year && DateTime.Now.Month == dateTimePicker_Date.Value.Month && DateTime.Now.Day < dateTimePicker_Date.Value.Day))
                {
                    ok = true;
                }
                if (ok)
                {
                    Meeting meeting = new Meeting(bunifuTextbox_ID._TextBox.Text, dogStr[0], owner[0], w[0], dateTimePicker_Date.Text, dateTimePicker_Time.Text);
                    var     dog     = dogModel.get(dogStr[0]);
                    if (function == "Update")
                    {
                        meetingModel.update(meeting);
                        dogModel.update(dog);
                    }
                    else if (function == "Add")
                    {
                        meetingModel.add(meeting);
                        dogModel.update(dog);
                    }

                    Hide();
                }
                else
                {
                    MessageBox.Show("Give a reasonable date and time");
                }
            }
            else
            {
                MessageBox.Show("Fill in the missing cells");
            }
        }
Ejemplo n.º 2
0
 private void button_Delete_Click(object sender, EventArgs e)
 {
     if ((dogIndex = dataGridView_ListDog.Rows[dataGridView_ListDog.CurrentCell.RowIndex].Cells[0].Value.ToString()) != "")
     {
         DialogResult dialogResult = MessageBox.Show("Do you want delete this dog with ID : " + dogIndex, "Delete", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             if (role == "Worker")
             {
                 dogModel.remove(dogModel.get(dogIndex));
             }
             else
             {
                 var d = dogModel.get(dogIndex);
                 d.OwnerID = "";
                 dogModel.update(d);
                 var owner = ownerModel.get(ownerID);
                 owner.deleteDogID(dogIndex);
                 ownerModel.update(owner);
             }
         }
     }
     else
     {
         dogIndex = null;
     }
     loading();
 }
Ejemplo n.º 3
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            string id;

            for (int i = 0; i < dataGridView_ListMeeting.Rows.Count; i++)
            {
                if ((id = dataGridView_ListMeeting.Rows[i].Cells[0].Value.ToString()) != "")
                {
                    if (dataGridView_ListMeeting.Rows[i].Cells[9].Value.ToString() != "Yet")
                    {
                        var meeting = meetingModel.get(id);
                        meeting.Adopter = dataGridView_ListMeeting.Rows[i].Cells[9].Value.ToString();
                        meetingModel.update(meeting);
                        if (dataGridView_ListMeeting.Rows[i].Cells[9].Value.ToString() == "Yes")
                        {
                            //connection between owner to dog
                            var owner = ownerModel.get(dataGridView_ListMeeting.Rows[i].Cells[5].Value.ToString());
                            owner.AddDogID(dataGridView_ListMeeting.Rows[i].Cells[1].Value.ToString());
                            var dog = dogModel.get(dataGridView_ListMeeting.Rows[i].Cells[1].Value.ToString());
                            dog.OwnerID = owner.ID;
                            ownerModel.update(owner);
                            dogModel.update(dog);

                            //delete all another meetings for this dog
                            var meet = meetingModel.getList();
                            foreach (var m in meet.Values)
                            {
                                if (m.ID != id && m.DogID == dog.ID)
                                {
                                    meetingModel.remove(m);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            loading();
        }
Ejemplo n.º 4
0
        private void bunifuFlatButton_Ok_Click(object sender, EventArgs e)
        {
            string chip   = bunifuTextbox_Chip._TextBox.Text;
            string name   = bunifuTextbox_Name._TextBox.Text;
            string dob    = dateTimePicker_Date.Text;
            string height = bunifuTextbox_Height._TextBox.Text;
            string weight = bunifuTextbox_Weight._TextBox.Text;
            string color  = bunifuTextbox_Color._TextBox.Text;
            string gender = comboBox_Gender.Text;

            //Breed
            string breed = "";

            if (radioButton_Bulldog.Checked)
            {
                breed = "Bulldog";
            }
            else if (radioButton_Poodle.Checked)
            {
                breed = "Poodle";
            }
            else if (radioButton_Beagle.Checked)
            {
                breed = "Beagle";
            }
            else if (radioButton_Rottweiler.Checked)
            {
                breed = "Rottweiler";
            }
            else if (radioButton_Dachshund.Checked)
            {
                breed = "Dachshund";
            }
            else if (radioButton_Mix.Checked)
            {
                breed = "Mix";
            }

            //Character
            string character = "";

            if (radioButton_Calm.Checked)
            {
                character = "Calm";
            }
            else if (radioButton_Furious.Checked)
            {
                character = "Furious";
            }
            else if (radioButton_Funny.Checked)
            {
                character = "Funny";
            }
            else if (radioButton_Friendly.Checked)
            {
                character = "Friendly";
            }

            Dog dog1 = dogModel.get(chip);

            if ((function == "Add") && dog1 != null)
            {
                MessageBox.Show("The dog with this id is exist");
                return;
            }

            try {
                int.Parse(height);
                int.Parse(weight);
            }
            catch (Exception)
            {
                MessageBox.Show("Height and weight fields must be a numbers");
                return;
            }

            if (chip == "" || name == "" || height == "" || weight == "" || color == "" && gender == "" || breed == "" || character == "")
            {
                MessageBox.Show("Please fill in all the fields");
                return;
            }
            Dog dog = new Dog(chip, name, dob, gender, "", height, weight, color, breed, character);

            if (function == "Add")
            {
                dogModel.add(dog);
            }
            else
            {
                dogModel.update(dog);
            }



            this.Hide();
        }