Ejemplo n.º 1
0
        public ListAllDogsForm(string id = null)
        {
            InitializeComponent();
            if (id != null)
            {
                owner = ownerModel.get(id);
            }
            var dogsD   = dogModel.getList();
            int counter = 0;

            foreach (var dog in dogsD.Values)
            {
                if (dog.OwnerID == "")
                {
                    counter++;
                    dogs.Add(dog);
                }
            }
            if (counter > 0)
            {
                UpdateDataGridViewListDog();
                label_No_Dogs_Available.Visible = false;
                button_Ok.Visible            = true;
                button_Questionnaire.Visible = true;
            }
            else
            {
                label_No_Dogs_Available.Visible = true;
                button_Ok.Visible            = false;
                button_Questionnaire.Visible = false;
            }
        }
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 bunifuThinButton_OK_Click(object sender, EventArgs e)
        {
            string username = bunifuTextbox_User._TextBox.Text,
                   password = bunifuTextbox_Password._TextBox.Text;

            if (username != "" && password != "")
            {
                var worker = workerModel.get(username);
                var owner  = ownerModel.get(username);
                if (worker != null)
                {
                    if (worker.ID == username && worker.Password == password)
                    {
                        WorkerOwnerForm workerOwnerForm = new WorkerOwnerForm("Worker", username, worker.Role);
                        workerOwnerForm.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("One of the data is incorrect");
                    }
                }
                else if (owner != null)
                {
                    if (owner.ID == username && owner.Password == password)
                    {
                        WorkerOwnerForm workerOwnerForm = new WorkerOwnerForm("Owner", username);
                        workerOwnerForm.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("One of the data is incorrect");
                    }
                }
                else
                {
                    MessageBox.Show("The user does not exit");
                }
            }
            else if (username == "" && password == "")
            {
                MessageBox.Show("Enter the user's ID and password");
            }
            else if (username == "")
            {
                MessageBox.Show("Enter the user's ID");
            }
            else
            {
                MessageBox.Show("Enter the user's password");
            }
        }
Ejemplo n.º 4
0
        public AUProfileForm(string human = null, string id = null)
        {
            InitializeComponent();
            if (human == "Worker")
            {
                worker = workerModel.get(id);

                textBox_ID.Text       = worker.ID;
                textBox_Password.Text = worker.Password;
                var name = worker.Name.Split(' ');
                textBox_Firstname.Text   = name[0];
                textBox_Lastname.Text    = name[1];
                textBox_DateOfBirth.Text = worker.DateOfBirth;
                textBox_Address.Text     = worker.Address;
                textBox_Phone.Text       = worker.Phone;
                var email = worker.Email.Split('@');
                textBox_firstEmail.Text  = email[0];
                comboBox_Email.Text      = email[1];
                comboBox_Gender.Text     = worker.Gender;
                textBox_DateOfBirth.Text = worker.DateOfBirth;
            }
            else if (human == "Owner")
            {
                owner = ownerModel.get(id);

                textBox_ID.Text       = owner.ID;
                textBox_Password.Text = owner.Password;
                var name = owner.Name.Split(' ');
                textBox_Firstname.Text   = name[0];
                textBox_Lastname.Text    = name[1];
                textBox_DateOfBirth.Text = owner.DateOfBirth;
                textBox_Address.Text     = owner.Address;
                textBox_Phone.Text       = owner.Phone;
                var email = owner.Email.Split('@');
                textBox_firstEmail.Text  = email[0];
                comboBox_Email.Text      = email[1];
                comboBox_Gender.Text     = owner.Gender;
                textBox_DateOfBirth.Text = owner.DateOfBirth;
            }
            textBox_ID.Enabled                      = textBox_Password.Enabled = textBox_Firstname.Enabled =
                textBox_Lastname.Enabled            = textBox_Address.Enabled = textBox_Phone.Enabled =
                    textBox_firstEmail.Enabled      = comboBox_Email.Enabled = comboBox_Gender.Enabled =
                        textBox_DateOfBirth.Enabled = false;
            if (statusUpdateSaveClick == "Update")
            {
                button_UpdateSave.IdleFillColor = Color.Gold;
                button_UpdateSave.ButtonText    = "Update";
            }
        }
Ejemplo n.º 5
0
        private bool UpdateDataGridViewListMeeting()
        {
            dataGridView_ListMeeting.Rows.Clear();
            Meeting_Adopter.Items.Clear();
            Meeting_Adopter.Items.Add("Yes");
            Meeting_Adopter.Items.Add("No");
            Meeting_Adopter.Items.Add("Yet");
            char[] arr = { '-', ':', ' ' };
            try
            {
                foreach (var meeting in meetings)
                {
                    var date = meeting.DateOfMeeting.Split(arr);
                    var time = meeting.TimeOfMeeting.Split(arr);

                    int year  = int.Parse(date[0]);
                    int month = int.Parse(date[1]);
                    int day   = int.Parse(date[2]);
                    int hour  = int.Parse(time[0]);
                    int min   = int.Parse(time[1]);
                    if (time[2] == "PM")
                    {
                        if (12 != hour)
                        {
                            hour += 12;
                        }
                    }
                    else
                    {
                        if (12 == hour)
                        {
                            hour = 00;
                        }
                    }
                    DateTime dateTime = new DateTime(year, month, day + 1);
                    if (meeting.Adopter == "Yet" | DateTime.Now <= dateTime)
                    {
                        dataGridView_ListMeeting.Rows.Add(meeting.ID, meeting.DogID, dogModel.get(meeting.DogID).Name, meeting.WorkerID,
                                                          workerModel.get(meeting.WorkerID).Name, meeting.OwnerID, ownerModel.get(meeting.OwnerID).Name,
                                                          meeting.DateOfMeeting, meeting.TimeOfMeeting, meeting.Adopter);
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        public ChooseDogForm(string id, int[] arrD, int[] arrH, string gender, string breed, string character)
        {
            InitializeComponent();
            if (id != null)
            {
                owner = ownerModel.get(id);
            }
            var dogsD   = dogModel.getList();
            int counter = 0;

            foreach (var dog in dogsD.Values)
            {
                if (dog.OwnerID == null || dog.OwnerID == "")
                {
                    var date   = dog.DateOfBirth.Split('-');
                    int age    = DateTime.Now.Year - int.Parse(date[0]);
                    int height = int.Parse(dog.Height);
                    if ((arrD[0] != arrD[1] && arrD[0] < age && age < arrD[1]) || (arrD[0] == arrD[1] && arrD[0] < age) &&
                        (arrH[0] != arrH[1] && arrH[0] < height && height < arrH[1]) || (arrH[0] == arrH[1] && arrH[0] < height))
                    {
                        if (dog.Gender == gender && dog.Breed == breed && dog.Character == character)
                        {
                            counter++;
                            dogs.Add(dog);
                        }
                    }
                }
            }
            if (counter > 0)
            {
                UpdateDataGridViewListDog();
                label_No_Dogs_Available.Visible = false;
                button_Ok.Enabled = true;
            }
            else
            {
                label_No_Dogs_Available.Visible = false;
                button_Ok.Enabled = false;
            }
        }
Ejemplo n.º 7
0
 public WorkerOwnerForm(string human = "", string id = "", string role = "")
 {
     InitializeComponent();
     label_Title.Text = human;
     bunifuImageButton_AddWorker.Visible = false;
     if (human == "Worker")
     {
         person = workerModel.get(id);//אדם ולא עובד
         if (role == "Employee")
         {
             button_Dog.BackColor = button_Meeting.BackColor = button_Profile.BackColor = Color.Green;
         }
         else if (role == "Management")
         {
             bunifuImageButton_AddWorker.Visible = true;
             button_Dog.BackColor = button_Meeting.BackColor = button_Profile.BackColor = Color.Blue;
         }
     }
     else if (human == "Owner")
     {
         person = ownerModel.get(id);
         button_Dog.BackColor = button_Meeting.BackColor = button_Profile.BackColor = Color.Orange;
     }
 }
Ejemplo n.º 8
0
        public AUMeetingForm(string func = null, string personID = null, string meetingID = null)
        {
            InitializeComponent();
            function         = func;
            label_Title.Text = func + " Meeting";
            workerId         = personID;
            var worker  = workerModel.get(personID);
            var owner   = ownerModel.get(personID);
            var meeting = meetingModel.get(meetingID);

            var dogs   = dogModel.getList();
            var owners = ownerModel.getList();

            foreach (var w in workerModel.getList().Values)
            {
                comboBox_Worker.Items.Add(w.ID + " " + w.Name);
            }
            foreach (var dog in dogs.Values)
            {
                comboBox_DogChip.Items.Add(dog.ID + " " + dog.Name);
            }
            foreach (var o in owners.Values)
            {
                comboBox_OwnerID.Items.Add(o.ID + " " + o.Name);
            }
            if (worker != null)
            {
                comboBox_Worker.Text    = worker.ID + " " + worker.Name;
                comboBox_Worker.Enabled = false;
                if (function == "Update")
                {
                    bunifuTextbox_ID._TextBox.Text = meeting.ID;
                    bunifuTextbox_ID.Enabled       = false;
                    comboBox_DogChip.Text          = meeting.DogID + " " + dogs[meeting.DogID].Name;
                    comboBox_DogChip.Enabled       = false;
                    comboBox_OwnerID.Text          = meeting.OwnerID + " " + owners[meeting.OwnerID].Name;
                    comboBox_OwnerID.Enabled       = false;
                    dateTimePicker_Date.Value.ToString(meeting.DateOfMeeting);
                    dateTimePicker_Time.Text = meeting.TimeOfMeeting;
                }
                else
                {
                    int  counter = 1;
                    bool bl      = true;
                    while (bl)
                    {
                        if (dogModel.get(counter.ToString()) == null)
                        {
                            bl = false;
                        }
                        else
                        {
                            counter++;
                        }
                    }
                    bunifuTextbox_ID._TextBox.Text    = counter.ToString();
                    bunifuTextbox_ID._TextBox.Enabled = false;
                }
            }
            else
            {
                int  counter = 1;
                bool bl      = true;
                while (bl)
                {
                    if (meetingModel.get(counter.ToString()) == null)
                    {
                        bl = false;
                    }
                    else
                    {
                        counter++;
                    }
                }
                bunifuTextbox_ID._TextBox.Text    = counter.ToString();
                bunifuTextbox_ID._TextBox.Enabled = false;
                var dogID = meetingID;
                comboBox_DogChip.Text    = dogID + " " + dogs[dogID].Name;
                comboBox_OwnerID.Text    = owner.ID + " " + owner.Name;
                comboBox_DogChip.Enabled = false;
                comboBox_OwnerID.Enabled = false;
            }
        }
Ejemplo n.º 9
0
        private void bunifuThinButton_Create_Click(object sender, EventArgs e)
        {
            label_Error_ID.Visible         = false; label_Error_Password_1.Visible = false;
            label_Error_Password_2.Visible = false; label_Error_Firstname.Visible = false;
            label_Error_Lastname.Visible   = false; label_Error_Date.Visible = false;
            label_Error_Email.Visible      = false; label_Error_Phone.Visible = false;
            label_Error_Address.Visible    = false; label_Error_Gender.Visible = false;

            bool idB = false, passB = false, firstnameB = false, lastnameB = false,
                 dateB = false, emailB = false, phoneB = false, addressB = false, genderB = false;

            string id = "", pass = "", name = "", date = "", email = "", phone = "", address = "",
                   gender = "";
            var owner     = ownerModel.get(textBox_ID.Text);
            var worker    = workerModel.get(textBox_ID.Text);

            //ID
            if (textBox_ID.Text == "" || textBox_ID.TextLength != 9 || (person != "Worker" && owner != null) || (person == "Worker" && worker != null))
            {
                //label_Error_ID.Visible = true;
                //label_Error_ID.Location = new Point(label_Error_ID.Location.X - 100, label_Error_ID.Location.Y);
                if (textBox_ID.Text == "")
                {
                    label_Error_ID.Text = "Enter your ID";
                }
                else if (textBox_ID.TextLength != 9)
                {
                    label_Error_ID.Text = "Enter full ID (9 number)";
                }
                else if (owner != null)
                {
                    label_Error_ID.Text = "The user with ID number exits";
                }
                else if (worker != null)
                {
                    label_Error_ID.Text = "The user with ID number exits";
                }
            }
            else
            {
                idB = true;
                id  = textBox_ID.Text;
            }

            //password
            if (textBox_Password_1.Text == "" || textBox_Password_2.Text == "")
            {
                if (textBox_Password_1.Text == "")
                {
                    label_Error_Password_1.Text    = "Enter your password";
                    label_Error_Password_1.Visible = true;
                }
                if (textBox_Password_2.Text == "")
                {
                    label_Error_Password_2.Text    = "Enter your password";
                    label_Error_Password_2.Visible = true;
                }
            }
            if (textBox_Password_1.Text != textBox_Password_2.Text)
            {
                label_Error_Password_2.Text    = "the passwords do not match";
                label_Error_Password_2.Visible = true;
            }
            else
            {
                passB = true;
                pass  = textBox_Password_1.Text;
            }
            //firstname
            if (textBox_Firstname.Text == "")
            {
                label_Error_Firstname.Visible = true;
                label_Error_Firstname.Text    = "Enter your firstname";
            }
            else
            {
                firstnameB = true;
            }

            //lastname
            if (textBox_Lastname.Text == "")
            {
                label_Error_Lastname.Visible = true;
                label_Error_Lastname.Text    = "Enter your lastname";
            }
            else
            {
                lastnameB = true;
            }

            if (firstnameB && lastnameB)
            {
                name = textBox_Firstname.Text + " " + textBox_Lastname.Text;
            }

            //phone
            if (textBox_Phone.TextLength > 0 && textBox_Phone.TextLength < 10)
            {
                label_Error_Phone.Visible = true;
                label_Error_Phone.Text    = "Enter correct your phone";
            }
            else
            {
                phoneB = true;
                phone  = textBox_Phone.Text;
            }

            //Email
            if (textBox_firstEmail.Text != "" && comboBox_Email.Text == "Choose mail")
            {
                label_Error_Email.Visible = true;
                label_Error_Email.Text    = "Enter correct name email";
            }
            else if (textBox_firstEmail.Text == "" && comboBox_Email.Text != "Choose mail")
            {
                label_Error_Email.Visible = true;
                label_Error_Email.Text    = "Choose mail";
            }
            else
            {
                emailB = true;
                email  = textBox_firstEmail.Text + "@" + comboBox_Email.Text;
            }

            //Date of birth
            date = textBox_DateOfBirth.Value.ToShortDateString();

            //Address
            address = textBox_Address.Text;

            //Gender
            if (comboBox_Gender.Text == "Choose Gender")
            {
                label_Error_Gender.Visible = true;
                label_Error_Gender.Text    = "Choose your gender";
            }
            else
            {
                genderB = true;
                gender  = comboBox_Gender.Text;
            }


            if (idB && passB && firstnameB && lastnameB && genderB)
            {
                this.Hide();
                if (person != "Worker")
                {
                    ownerModel.add(new Owner(id, name, date, gender, pass, phone, email, address));
                    WorkerOwnerForm workerOwnerForm = new WorkerOwnerForm("Owner", id);
                    workerOwnerForm.ShowDialog();
                }
                else
                {
                    workerModel.add(new Worker(id, name, date, gender, pass, phone, email, address, "Employee"));
                }
            }
        }