示例#1
0
        private void deleteBookingBTN_Click(object sender, EventArgs e)
        {
            //Which booking to delet
            int bookingId = GetIdOfSelectedRow(bookingHistoryDataGridView);

            //if bookingId is valid
            if (bookingId > 0)
            {
                //And if starttime is after current time
                if ((DateTime)bookingHistoryDataGridView[3,
                                                         HelperMethod.GetSelectedRowIndex(bookingHistoryDataGridView)
                    ].Value > DateTime.Now)
                {
                    //then remove booking
                    _dataAccess.DeleteBooking(bookingId);

                    RefreshTables();

                    deleteInfoLabel.Text = "Booking successfully removed";
                }
                else
                {
                    deleteInfoLabel.Text = "You cannot delete booking \nafter it started.";
                }
            }
        }
示例#2
0
文件: zoo.cs 项目: ztgz/MyZoo
        /* ----------------- Helper Methods ------------------------*/
        private int GetIdOfSelectedRow()
        {
            int row = HelperMethod.GetSelectedRowIndex(searchDataGridView);

            if (row >= 0)
            {
                return((int)searchDataGridView[0, row].Value);
            }

            return(-1);
        }
示例#3
0
文件: Diagnosis.cs 项目: ztgz/MyZoo
        private void removeMedicine_Click(object sender, EventArgs e)
        {
            int rowIndex = HelperMethod.GetSelectedRowIndex(medicineDataGridView);

            if (rowIndex >= 0)
            {
                string medicineName = medicineDataGridView[0, rowIndex].Value.ToString();

                _dataAccess.RemoveMedicineRelation(diagnosisId, medicineName);

                FillMedicineList();
            }
        }
示例#4
0
文件: zoo.cs 项目: ztgz/MyZoo
        private void editBTN_Click(object sender, EventArgs e)
        {
            int id = GetIdOfSelectedRow();

            if (id > 0)
            {
                //Try to get weight from animal
                decimal.TryParse(searchDataGridView[1,
                                                    HelperMethod.GetSelectedRowIndex(searchDataGridView)].Value.ToString(),
                                 out decimal weight);

                OpenAnimalEditForm(id, weight);
            }
        }
示例#5
0
        //Open diagnosis form
        private void button1_Click(object sender, EventArgs e)
        {
            int bookingId = GetIdOfSelectedRow(bookingHistoryDataGridView);

            //If bookingId is valid
            if (bookingId > 0)
            {
                this.Hide();

                int animalId = (int)bookingHistoryDataGridView
                               [1, HelperMethod.GetSelectedRowIndex(bookingHistoryDataGridView)].Value;

                Diagnosis diagnosisForm = new Diagnosis(bookingId, animalId, this);

                diagnosisForm.Show();
            }
        }
示例#6
0
文件: zoo.cs 项目: ztgz/MyZoo
        private void editParentsBTN_Click(object sender, EventArgs e)
        {
            int id = GetIdOfSelectedRow();

            if (id > 0)
            {
                int row = HelperMethod.GetSelectedRowIndex(searchDataGridView);

                //Open form with (id, species, parent1, parent2, zoo form)
                EditParents parentsForm = new EditParents(id,
                                                          searchDataGridView[2, row].Value.ToString(),
                                                          int.Parse(searchDataGridView[6, row].Value.ToString()),
                                                          int.Parse(searchDataGridView[7, row].Value.ToString()),
                                                          this
                                                          );

                this.Hide();

                parentsForm.Show();
            }
        }
示例#7
0
        /*------------------------- Button clicks that changes record or open forms------------------------------*/
        private void bookTimeBTN_Click(object sender, EventArgs e)
        {
            int selectedRow = HelperMethod.GetSelectedRowIndex(freeTimesDataGridView);

            if (selectedRow < 0)
            {
                return;
            }

            /*Load the data that will be in the booking*/
            int vetId    = (int)freeTimesDataGridView[0, selectedRow].Value;
            int animalId = (int)freeTimesDataGridView[3, selectedRow].Value;

            DateTime startDate = (DateTime)freeTimesDataGridView[1, selectedRow].Value;
            DateTime endDate   = (DateTime)freeTimesDataGridView[1, selectedRow].Value;

            //Add booking record
            _dataAccess.AddBooking(animalId, vetId, startDate, endDate);

            //Reload tables
            RefreshTables();
        }