Пример #1
0
        private void button8_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                int RowIndex = dataGridView1.SelectedCells[0].RowIndex;
                switch (dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["categoryDataGridViewTextBoxColumn"].Value.ToString())
                {
                    #region Client
                    case "1":
                        tabControl2.SelectedTab = ClientTab;
                        Client client = new Client(Int32.Parse(dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[0].Value.ToString()));
                        client.Name = textBox_ClientName.Text;
                        client.DateOfBirdh = DateTime.Parse(textBox_ClientBirth.Value.ToShortDateString());
                        client.ParisNumber = textBox_ClientParis.Text;
                        client.Adress.Addres = textBox_ClientAdress.Text;
                        client.Adress.City = textBox_ClientCity.Text;
                        client.Adress.Province = textBox_ClientProvince.Text;
                        client.Adress.Country = textBox_ClientCountry.Text;
                        client.Adress.PostalCode = textBox_ClientPostal.Text;
                        client.Adress.Phone = textBox_ClientPhone.Text;
                        client.Adress.Email = textBox_ClientEmail.Text;
                        client.EmergencyContact.Name = textBox_ClientEmerName.Text;
                        client.EmergencyContact.Phone = textBox_ClientEmPhone.Text;
                        client.EmergencyContact.Relation = textBox_ClientRelation.Text;
                        client.Transportation.HandyDARTNumber = textBox_ClientHD.Text;
                        client.DoctorName = textBox_ClientDocName.Text;
                        client.DoctorPhone = textBoxClientDocPhone.Text;
                        client.Own = radioButton4.Checked;
                        client.PharmacistName = textBox_ClientPharmName.Text;
                        client.PharmacistPhone = textBox_ClientPharmPhone.Text;
                        client.Member = ClientMember.Checked;
                        if (toolStripTextBox_EmName.Visible && client.DopEmergencyContact == null)
                        {
                            client.DopEmergencyContact = new EmergencyContact();
                            client.DopEmergencyContact.Name = toolStripTextBox_EmName.Text;
                            client.DopEmergencyContact.Phone = toolStripTextBox_EmPhone.Text;
                            client.DopEmergencyContact.Relation = toolStripTextBox54.Text;
                            client.DopEmergencyContact.AddEmergencyContactTo(client);
                        }
                        else if (toolStripTextBox_EmName.Visible)
                        {
                            client.DopEmergencyContact.Name = toolStripTextBox_EmName.Text;
                            client.DopEmergencyContact.Phone = toolStripTextBox_EmPhone.Text;
                            client.DopEmergencyContact.Relation = toolStripTextBox54.Text;
                        }

                        client.Attendance.Monday = checkBox2.Checked;
                        client.Attendance.Tuesday = checkBox3.Checked;
                        client.Attendance.Wednesday = checkBox4.Checked;
                        client.Attendance.Thursday = checkBox5.Checked;
                        client.Attendance.Friday = checkBox6.Checked;
                        client.Transportation.Monday = checkBox11.Checked;
                        client.Transportation.Tuesday = checkBox10.Checked;
                        client.Transportation.Wednesday = checkBox9.Checked;
                        client.Transportation.Thursday = checkBox8.Checked;
                        client.Transportation.Friday = checkBox7.Checked;
                        client.Transportation.Address = client.Adress.Addres;
                        client.Transportation.Phone = client.Adress.Phone;
                        if (client.Own) { client.Transportation.Category = "Own"; } else { client.Transportation.Category = "HandyDART"; }
                        client.Update();
                        profilesTableAdapter.Fill(tDayDataSet.Profiles);
                        dataGridView1.Rows[RowIndex].Selected = true;
                        button8.Enabled = false;
                        break;
                    #endregion
                    case "2":
                        Employee employee = new Employee(Int32.Parse(dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[0].Value.ToString()));
                        employee.Name = textBox_EmpName.Text;
                        employee.DateOfBirdh = DateTime.Parse(textBox_EmpBirth.Value.ToShortDateString());
                        employee.HireDate = DateTime.Parse(textBox_EmpHire.Value.ToShortDateString());
                        employee.Position = textBox_EmpPosition.Text;
                        employee.SIN = textBox_EmpSin.Text;
                        if (radioButton1.Checked) { employee.PositionType = "Causal"; }
                        if (radioButton2.Checked) { employee.PositionType = "Part time"; }
                        if (radioButton3.Checked) { employee.PositionType = "Full time"; }

                        employee.Adress.Addres = textBox_EmpAdress.Text;
                        employee.Adress.City = textBox_EmpCity.Text;
                        employee.Adress.Province = textBox_EmpProvince.Text;
                        employee.Adress.Country = textBox_EmpCountry.Text;
                        employee.Adress.PostalCode = textBox_EmpPostal.Text;
                        employee.Adress.Phone = textBox_EmpPhone.Text;
                        employee.Adress.Email = textBox_EmpEmail.Text;
                        employee.Adress.Cell = textBox_EmpCell.Text;
                        employee.EmergencyContact.Name = textBox_EmpEmerCN.Text;
                        employee.EmergencyContact.Phone = textBox_EmerCP.Text;
                        employee.EmergencyContact.Relation = textBox_EmpRelation.Text;
                        employee.Attendance.Monday = checkBox16.Checked;
                        employee.Attendance.Tuesday = checkBox15.Checked;
                        employee.Attendance.Wednesday = checkBox14.Checked;
                        employee.Attendance.Thursday = checkBox13.Checked;
                        employee.Attendance.Friday = checkBox12.Checked;
                        employee.Update();
                        profilesTableAdapter.Fill(tDayDataSet.Profiles);
                        dataGridView1.Rows[RowIndex].Selected = true;
                        button8.Enabled = false;
                        break;
                    case "3":
                        tabControl2.SelectedTab = VolunteerTab;
                        Profile volonteer = new Profile(Int32.Parse(dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[0].Value.ToString()));
                        volonteer.Name = textBox_VolName.Text;
                        volonteer.DateOfBirdh = DateTime.Parse(textBox_VolBirth.Value.ToShortDateString());
                        volonteer.Adress.Addres = textBox_VolAdress.Text;
                        volonteer.Adress.City = textBox_VolCity.Text;
                        volonteer.Adress.Province = textBox_VolProvince.Text;
                        volonteer.Adress.Country = textBox_VolCountry.Text;
                        volonteer.Adress.PostalCode = textBox_VolPostal.Text;
                        volonteer.Adress.Phone = textBox_VolPhone.Text;
                        volonteer.Adress.Email = textBox_VolEmail.Text;
                        volonteer.Adress.Cell = textBox_VolCell.Text;
                        volonteer.EmergencyContact.Name = textBox_VolEmerCN.Text;
                        volonteer.EmergencyContact.Phone = textBox_VolEmerCP.Text;
                        volonteer.EmergencyContact.Relation = textBox_VolEmerRelation.Text;
                        volonteer.Attendance.Monday = checkBox21.Checked;
                        volonteer.Attendance.Tuesday = checkBox20.Checked;
                        volonteer.Attendance.Wednesday = checkBox19.Checked;
                        volonteer.Attendance.Thursday = checkBox18.Checked;
                        volonteer.Attendance.Friday = checkBox17.Checked;
                        volonteer.Update();
                        profilesTableAdapter.Fill(tDayDataSet.Profiles);
                        dataGridView1.Rows[RowIndex].Selected = true;
                        button8.Enabled = false;
                        break;
                    case "4":

                        textBox_BoardOccupation.Visible = true;
                        label48.Visible = true;
                        Profile board = new Profile(Int32.Parse(dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[0].Value.ToString()));
                        board.Name = textBox_BoardName.Text;
                        board.Occupation = textBox_BoardOccupation.Text;
                        board.DateOfBirdh = DateTime.Parse(textBox_BoardBirth.Value.ToShortDateString());
                        board.Adress.Addres = textBox_BoardAdress.Text;
                        board.Adress.City = textBox_BoardCity.Text;
                        board.Adress.Province = textBox_BoardProvince.Text;
                        board.Adress.Country = textBox_BoardCountry.Text;
                        board.Adress.Cell = textBox_BoardCell.Text;
                        board.Adress.PostalCode = textBox_BoardPostal.Text;
                        board.Adress.Phone = textBox_BoardPhone.Text;
                        board.Adress.Email = textBox_BoardEmail.Text;
                        board.Update();
                        profilesTableAdapter.Fill(tDayDataSet.Profiles);
                        dataGridView1.Rows[RowIndex].Selected = true;
                        button8.Enabled = false;
                        break;
                    case "5":
                        textBox_BoardOccupation.Visible = false;
                        label48.Visible = false;
                        Profile other = new Profile(Int32.Parse(dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[0].Value.ToString()));
                        other.Name = textBox_BoardName.Text;
                        other.DateOfBirdh = DateTime.Parse(textBox_BoardBirth.Value.ToShortDateString());
                        other.Adress.Addres = textBox_BoardAdress.Text;
                        other.Adress.City = textBox_BoardCity.Text;
                        other.Adress.Province = textBox_BoardProvince.Text;
                        other.Adress.Country = textBox_BoardCountry.Text;
                        other.Adress.Cell = textBox_BoardCell.Text;
                        other.Adress.PostalCode = textBox_BoardPostal.Text;
                        other.Adress.Phone = textBox_BoardPhone.Text;
                        other.Adress.Email = textBox_BoardEmail.Text;
                        other.Update();
                        profilesTableAdapter.Fill(tDayDataSet.Profiles);
                        dataGridView1.Rows[RowIndex].Selected = true;
                        button8.Enabled = false;
                        break;
                }
            }
        }