private void recruitPerson_Click(object sender, EventArgs e) { string fullname = persSurname.Text + " " + persName.Text + " " + persFatherName.Text; string persGender = ""; if (persMale.Checked) { persGender = "male"; } if (persFemale.Checked) { persGender = "female"; } Person newPerson = new Person(fullname, persGender, persBirthDate.Value, persMarried.Checked, pathPhoto); Worker newWorker = new Worker(); newWorker.id = newPerson.id; newWorker.name = newPerson.name; newWorker.gender = newPerson.gender; newWorker.dateBirth = newPerson.dateBirth; newWorker.married = newPerson.married; if (persPic != null) { newWorker.photo = newPerson.photo.Replace('\\', '/'); } newWorker.archiveData = dbConnect.Transform(String.Join(",", jobsArchive)); Department pDept = new Department(); pDept.id = new Guid(presentDept.SelectedValue.ToString()); Job pJob = new Job(); pJob.id = new Guid(presentJob.SelectedValue.ToString()); pJob.jobRank = presentJobRank.SelectedText; newWorker.dept = pDept; newWorker.job = pJob; string where = "fk_department=" + dbConnect.Transform(newWorker.dept.id.ToString()) + " and fk_job=" + dbConnect.Transform(newWorker.job.id.ToString()); Schedule workSched = new Schedule(); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("schedule", "", where)); if (!selection.Length.Equals(0)) { workSched.id = new Guid(selection[0][0]); workSched.job = pJob; workSched.dept = pDept; newWorker.schedule = workSched; newWorker.statusIsFired = false; if (!statusWorking.Checked) { statusWorking.Checked = true; } User newUser = new User(); where = "iddept=" + dbConnect.Transform(newWorker.dept.id.ToString()); List <string>[] checkdept = DBConnect.SendMessageFromSocket(dbConnect.Select("department", "", where)); newWorker.dept.departmentName = checkdept[0][1]; if (newWorker.dept.departmentName.Equals("Personnel")) { newUser.username = persSurname.Text; newUser.passGen(); } else { newUser.username = ""; newUser.password = ""; } where = "name=" + dbConnect.Transform(newWorker.name); List <string>[] check = DBConnect.SendMessageFromSocket(dbConnect.Select("person", "", where)); if (check.Length.Equals(0)) { List <string>[] checkRules = DBConnect.SendMessageFromSocket(dbConnect.Select("job", "", "idjob=" + dbConnect.Transform(newWorker.job.id.ToString()))); if (checkRules[0][1].Equals("Director") & rules.Equals("director")) { MessageBox.Show("Вы не можете назначать глав отделов"); } else { DBConnect.SendMessageFromSocket(dbConnect.Insert("person", dbConnect.Transform(newWorker.id.ToString()), dbConnect.Transform(newWorker.name), dbConnect.Transform(newWorker.gender), dbConnect.Transform(newWorker.dateBirth.ToString("yyyy-MM-dd")) , dbConnect.Transform(dbConnect.BoolToTiny(newWorker.married)), dbConnect.Transform(newWorker.photo), dbConnect.Transform(newWorker.dept.id.ToString()), dbConnect.Transform(newWorker.job.id.ToString()), dbConnect.Transform(dbConnect.BoolToTiny(newWorker.statusIsFired)), newWorker.archiveData, dbConnect.Transform(newWorker.schedule.id.ToString()), dbConnect.Transform(newUser.username), dbConnect.Transform(newUser.password))); persName.Clear(); persSurname.Clear(); persFatherName.Clear(); jobsArchive.Clear(); } } else { MessageBox.Show("Такой сотрудник есть в базе"); } } else { MessageBox.Show("Расписание для данной должности еще не назначено"); } }