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(); }
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); } }
private void button_Ok_Click(object sender, EventArgs e) { string dogIndex = null; if ((dogIndex = dataGridView_ListDog.Rows[dataGridView_ListDog.CurrentCell.RowIndex].Cells[0].Value.ToString()) != "") { //owner.AddDogID(dogIndex); dogModel.get(dogIndex).OwnerID = owner.ID; //Meeting// var meetings = new MeetingModel().getList(); //אז יציג הודעה שיש לך מפגש לכל זה foreach (var m in meetings.Values) { //אם יש פגישה לאותו כלב ועם אותו לקוח אז טעות if (m.DogID == dogIndex && m.OwnerID == owner.ID && m.Adopter == "Yet") { MessageBox.Show("You have meeting for this dog"); return; } } Form form = new AUMeetingForm("Add", owner.ID, dogIndex); Close(); form.Show(); } else { dogIndex = null; } }
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; } }
public AUDogForm(string func = null, string dogID = null) { InitializeComponent(); function = func; label_Title.Text = func + "Dog"; if (func == "Update") {// מכניס את כל פרטי הכלב הרצוי לתאים var d = dogModel.get(dogID); bunifuTextbox_Chip._TextBox.Enabled = false; bunifuTextbox_Chip._TextBox.Text = d.ID; bunifuTextbox_Name._TextBox.Text = d.Name; dateTimePicker_Date.Text = d.DateOfBirth; bunifuTextbox_Height._TextBox.Text = d.Height; bunifuTextbox_Weight._TextBox.Text = d.Weight; bunifuTextbox_Color._TextBox.Text = d.Color; comboBox_Gender.Text = d.Gender; string breed = d.Breed; string character = d.Character; //Breed if (breed == radioButton_Bulldog.Text) { radioButton_Bulldog.Checked = true; } else if (breed == radioButton_Poodle.Text) { radioButton_Poodle.Checked = true; } else if (breed == radioButton_Beagle.Text) { radioButton_Beagle.Checked = true; } else if (breed == radioButton_Rottweiler.Text) { radioButton_Rottweiler.Checked = true; } else if (breed == radioButton_Dachshund.Text) { radioButton_Dachshund.Checked = true; } else if (breed == radioButton_Mix.Text) { radioButton_Mix.Checked = true; } //Character if (character == radioButton_Calm.Text) { radioButton_Calm.Checked = true; } else if (breed == radioButton_Furious.Text) { radioButton_Furious.Checked = true; } else if (breed == radioButton_Funny.Text) { radioButton_Funny.Checked = true; } else if (breed == radioButton_Friendly.Text) { radioButton_Friendly.Checked = true; } } //אחרת לא צריך להכניס כלום }