private void saveDepBtn_Click(object sender, EventArgs e) { if (depName.Text.Equals("") || jobs.Count.Equals(0)) { MessageBox.Show("Поле названия отдела или список должностей отдела"); } else { Department changeDep = new Department(depName.Text, jobs); List <string> jobsListNameList = new List <string>(); foreach (Job sub in jobs) { jobsListNameList.Add(sub.id.ToString()); } string wherechange = "name=" + dbConnect.Transform(changeDep.departmentName) + " and joblist=" + dbConnect.Transform(String.Join(",", jobsListNameList)); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("department", "", wherechange)); if (selection.Length.Equals(0)) { string where = "name=" + dbConnect.Transform(targetDept.departmentName); string set = "name=" + dbConnect.Transform(changeDep.departmentName) + ", joblist=" + dbConnect.Transform(String.Join(",", jobsListNameList)); DBConnect.SendMessageFromSocket(dbConnect.Update("department", where, set)); } else { MessageBox.Show("Такая должность уже существует"); } DepartmentForm_Load(sender, e); } }
private void saveScheduleBtn_Click(object sender, EventArgs e) { listSched.Clear(); foreach (CheckedListBox sub in cbAllControl) { resultChecker(sub); } Department schedDept = new Department(); schedDept.id = new Guid(chooseDept.SelectedValue.ToString()); Job schedJob = new Job(); schedJob.id = new Guid(chooseJob.SelectedValue.ToString()); Schedule sh = new Schedule(schedDept, schedJob, listSched.ToArray()); string where = "fk_department=" + dbConnect.Transform(sh.dept.id.ToString()) + " and fk_job=" + dbConnect.Transform(sh.job.id.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("schedule", "", where)); if (selection.Length.Equals(0)) { DBConnect.SendMessageFromSocket(dbConnect.Insert("schedule", dbConnect.Transform(sh.id.ToString()), dbConnect.Transform(sh.dept.id.ToString()), dbConnect.Transform(sh.job.id.ToString()), String.Join(",", listSched))); MessageBox.Show("Создано новое расписание"); } else { string set = "fmonday=" + sh.firstmonday + ", ftuesday=" + sh.firsttuesday + ", fwednesday=" + sh.firstwednesday + ", fthursday=" + sh.firstthursday + ", ffriday=" + sh.firstfriday + ", fsaturday=" + sh.firstsaturday + ", fsunday=" + sh.firstsunday + ", smonday=" + sh.secondmonday + ", stuesday=" + sh.secondtuesday + ", swednesday=" + sh.secondwednesday + ", sthursday=" + sh.secondthursday + ", sfriday=" + sh.secondfriday + ", ssaturday=" + sh.secondsaturday + ", ssunday=" + sh.secondsunday; DBConnect.SendMessageFromSocket(dbConnect.Update("schedule", where, set)); MessageBox.Show("Расписание обновлено"); } ScheduleForm_Load(sender, e); }
private void delSchedBtn_Click(object sender, EventArgs e) { Department schedDept = new Department(); schedDept.id = new Guid(chooseDept.SelectedValue.ToString()); Job schedJob = new Job(); schedJob.id = new Guid(chooseJob.SelectedValue.ToString()); Schedule delSched = new Schedule(); delSched.dept = schedDept; delSched.job = schedJob; string where = "fk_department=" + dbConnect.Transform(delSched.dept.id.ToString()) + " and fk_job=" + dbConnect.Transform(delSched.job.id.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("schedule", "", where)); if (!selection.Length.Equals(0)) { DBConnect.SendMessageFromSocket(dbConnect.Delete("schedule", where)); MessageBox.Show("Расписание удалено"); foreach (CheckedListBox sub in cbAllControl) { for (int a = 0; a < sub.Items.Count; a++) { sub.SetItemChecked(a, false); } } } else { MessageBox.Show("Для вашего запроса расписание ещё не назначено"); } ScheduleForm_Load(sender, e); }
private void saveJobBtn_Click(object sender, EventArgs e) { if (rankCB.Text.Equals("") || jobName.Text.Equals("")) { MessageBox.Show("Поле названия должности или разряда должности пустое"); } else { Job changeJob = new Job(jobName.Text, (string)rankCB.SelectedItem, (int)salaryRank.Value); string where = "name=" + dbConnect.Transform(targetJob.jobName) + " and salary=" + dbConnect.Transform(targetJob.salary.ToString()) + " and jobrank=" + dbConnect.Transform(targetJob.jobRank); string set = "name=" + dbConnect.Transform(changeJob.jobName) + ", jobrank=" + dbConnect.Transform(changeJob.jobRank) + ", salary=" + dbConnect.Transform(changeJob.salary.ToString()) + ", workerslist=" + dbConnect.Transform(String.Join(", ", changeJob.workers)); string wheresearch = "name=" + dbConnect.Transform(changeJob.jobName) + " and salary=" + dbConnect.Transform(changeJob.salary.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("job", "", wheresearch)); if (selection.Length > 0) { MessageBox.Show("Вы пытаетесь обновить должность до такой, которая уже существует"); } else { DBConnect.SendMessageFromSocket(dbConnect.Update("job", where, set)); } JobForm_Load(sender, e); } }
private void addDepBtn_Click(object sender, EventArgs e) { if (depName.Text.Equals("") || jobs.Count.Equals(0)) { MessageBox.Show("Поле названия отдела или список должностей отдела"); } else { Department newDept = new Department(depName.Text, jobs); string where = "name=" + dbConnect.Transform(newDept.departmentName); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("department", "", where)); if (selection.Length.Equals(0)) { List <string> jobsListNameList = new List <string>(); foreach (Job sub in jobs) { jobsListNameList.Add(sub.id.ToString()); } DBConnect.SendMessageFromSocket(dbConnect.Insert("department", dbConnect.Transform(newDept.id.ToString()), dbConnect.Transform(newDept.departmentName), dbConnect.Transform(String.Join(",", jobsListNameList)))); DepartmentForm_Load(sender, e); } else { MessageBox.Show("Такая должность уже существует"); } depName.Clear(); listJobs.Items.Clear(); } }
private void deleteDepBtn_Click(object sender, EventArgs e) { Department delDept = new Department(chooseDept.Text, jobs); delDept.id = new Guid(chooseDept.SelectedValue.ToString()); string where = "iddept=" + dbConnect.Transform(delDept.id.ToString()); DBConnect.SendMessageFromSocket(dbConnect.Delete("department", where)); DepartmentForm_Load(sender, e); }
private void chooseJob_DropDownClosed(object sender, EventArgs e) { try { string where = "idjob=" + dbConnect.Transform(chooseJob.SelectedValue.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("job", "", where)); salaryRank.Value = Int32.Parse(selection[0][3]); rankCB.Text = selection[0][2]; targetJob = new Job(chooseJob.Text, (string)rankCB.SelectedItem, (int)salaryRank.Value); } catch (NullReferenceException) { } }
private void deleteJobBtn_Click(object sender, EventArgs e) { Job delJob = new Job(chooseJob.Text, (string)rankCB.SelectedItem, (int)salaryRank.Value); delJob.id = new Guid(chooseJob.SelectedValue.ToString()); string where = "idjob=" + dbConnect.Transform(delJob.id.ToString()); DBConnect.SendMessageFromSocket(dbConnect.Delete("job", where)); JobForm_Load(sender, e); }
private void minusPersonBtn_Click(object sender, EventArgs e) { try { string where = "idperson= " + dbConnect.Transform(infTable.SelectedRows[0].Cells[0].Value.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("person", "", where)); DBConnect.SendMessageFromSocket(dbConnect.Delete("person", where)); } catch (Exception) { MessageBox.Show("Выделите всю строку"); }; OperationsForm_Load(sender, e); }
private void editPersonBtn_Click(object sender, EventArgs e) { try { pers.Close(); Worker transfer = new Worker(); string item = infTable.SelectedRows[0].Cells[0].Value.ToString(); string where = "idperson=" + dbConnect.Transform(item); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("person", "", where)); transfer.id = new Guid(selection[0][0]); transfer.name = selection[0][1]; transfer.gender = selection[0][2]; transfer.dateBirth = Convert.ToDateTime(selection[0][3]); transfer.married = Convert.ToBoolean(Convert.ToInt32(selection[0][4])); transfer.photo = selection[0][5]; Department transfDept = new Department(); if (selection[0][6].Equals("")) { transfDept.id = new Guid(); } else { transfDept.id = new Guid(selection[0][6]); } transfer.dept = transfDept; Job transfJob = new Job(); if (selection[0][7].Equals("")) { transfJob.id = new Guid(); } else { transfJob.id = new Guid(selection[0][7]); } transfer.job = transfJob; transfer.statusIsFired = Convert.ToBoolean(Convert.ToInt32(selection[0][8])); transfer.archiveData = selection[0][9]; Schedule transfSched = new Schedule(); if (selection[0][10].Equals("")) { transfSched.id = new Guid(); } else { transfSched.id = new Guid(selection[0][10]); } transfer.schedule = transfSched; pers = new PersonForm(transfer, rules, user); pers.Show(); } catch (Exception) { MessageBox.Show("Выделите всю строку"); } }
private void jobAddBtn_Click(object sender, EventArgs e) { string where = "idjob=" + dbConnect.Transform(jobsName.SelectedValue.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("job", "", where)); Job newJob = new Job(selection[0][1], selection[0][2], Convert.ToInt32(selection[0][3])); newJob.id = new Guid(jobsName.SelectedValue.ToString()); int cycle = (int)numberOfJob.Value; for (int a = 0; a < cycle; a++) { string res = newJob.jobName + "(" + newJob.jobRank + "), ставка: " + newJob.salary + "$"; listJobs.Items.Add(res); jobs.Add(newJob); } }
private void chooseJob_DropDownClosed(object sender, EventArgs e) { Guid jobId = new Guid(chooseJob.SelectedValue.ToString()); List <string[]> selectedDays = new List <string[]>(); if (chooseDept.SelectedItem != null) { string where = "fk_department=" + dbConnect.Transform(chooseDept.SelectedValue.ToString()) + " and fk_job=" + dbConnect.Transform(chooseJob.SelectedValue.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("schedule", "", where)); if (!selection.Length.Equals(0)) { for (int a = 3; a < selection[0].Count; a++) { selectedDays.Add(selection[0][a].Split(',')); } int countCB = 0; foreach (string[] sub in selectedDays) { for (int a = 0; a < 3; a++) { if (sub[a].Equals("none")) { cbAllControl[countCB].SetItemChecked(a, false); } else { cbAllControl[countCB].SetItemChecked(a, true); } } countCB++; } } else { MessageBox.Show("Для вашего запроса расписание ещё не назначено"); foreach (CheckedListBox sub in cbAllControl) { for (int a = 0; a < sub.Items.Count; a++) { sub.SetItemChecked(a, false); } } } } }
private void firePerson_Click(object sender, EventArgs e) { Worker fireWorker = new Worker(); fireWorker.name = persSurname.Text + " " + persName.Text + " " + persFatherName.Text; statusFired.Checked = true; fireWorker.statusIsFired = statusFired.Checked; string where = "name=" + dbConnect.Transform(fireWorker.name); List <string>[] check = DBConnect.SendMessageFromSocket(dbConnect.Select("person", "", where)); if (!check.Length.Equals(0)) { fireWorker.id = new Guid(check[0][0]); where = "idperson= " + dbConnect.Transform(fireWorker.id.ToString()); string set = "isfired =" + dbConnect.Transform(dbConnect.BoolToTiny(fireWorker.statusIsFired)); DBConnect.SendMessageFromSocket(dbConnect.Update("person", where, set)); } else { MessageBox.Show("Такого сотрудника нет в базе"); } }
private void addJobBtn_Click(object sender, EventArgs e) { if (rankCB.Text.Equals("") || jobName.Text.Equals("")) { MessageBox.Show("Поле названия должности или разряда должности пустое"); } else { Job newJob = new Job(jobName.Text, (string)rankCB.Text, (int)salaryRank.Value); string where = "name=" + dbConnect.Transform(newJob.jobName) + " and salary=" + dbConnect.Transform(newJob.salary.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("job", "", where)); if (selection.Length.Equals(0)) { DBConnect.SendMessageFromSocket(dbConnect.Insert("job", dbConnect.Transform(newJob.id.ToString()), dbConnect.Transform(newJob.jobName), dbConnect.Transform(newJob.jobRank), dbConnect.Transform(newJob.salary.ToString()), dbConnect.Transform(String.Join(", ", newJob.workers)))); JobForm_Load(sender, e); } else { MessageBox.Show("Такая должность уже существует"); } jobName.Clear(); } }
private void chooseDept_DropDownClosed(object sender, EventArgs e) { listJobs.Items.Clear(); try { jobs.Clear(); string where = "iddept=" + dbConnect.Transform(chooseDept.SelectedValue.ToString()); List <string>[] selection = DBConnect.SendMessageFromSocket(dbConnect.Select("department", "", where)); List <string> selectedJobs = selection[0][2].Split(',').ToList(); string res = "", previous = ""; Job tempJob = new Job(); foreach (string sub in selectedJobs) { if (sub.Equals(previous)) { Job subJob = tempJob; jobs.Add(subJob); listJobs.Items.Add(res); continue; } else { where = "idjob=" + dbConnect.Transform(sub); try { List <string>[] subSelection = DBConnect.SendMessageFromSocket(dbConnect.Select("job", "", where)); Job subJob = new Job(subSelection[0][1], subSelection[0][2], Convert.ToInt32(subSelection[0][3])); subJob.id = new Guid(sub); tempJob = subJob; res = subJob.jobName + "(" + subJob.jobRank + "), ставка: " + subJob.salary + "$"; listJobs.Items.Add(res); jobs.Add(subJob); previous = sub; } catch (Exception) { } } } targetDept = new Department(chooseDept.Text, jobs); } catch (NullReferenceException) { } }
private void enterBtn_Click(object sender, EventArgs e) { userlog = new User(); userlog.username = login.Text; userlog.password = pass.Text; List <string>[] selected = DBConnect.SendMessageFromSocket(dbConnect.Select("person", "", "username="******" ", ""))));//dbConnect.Select("person", "", "username="******"job", "", "idjob=" + dbConnect.Transform(selected[0][7].ToString()))); if (selected[0][1].Equals("Admin")) { userlog = new Administrator(); rules = userlog.sendRules(); } else if (selected[0][1].Equals("Director")) { userlog = new Director(); rules = userlog.sendRules(); } else { userlog = new Secretary(); rules = userlog.sendRules(); } oper = new OperationsForm(userlog, rules); sched = new ScheduleForm(rules, userlog); sched.MdiParent = this; oper.MdiParent = this; pass.Clear(); panelMain.Hide(); oper.Show(); } } catch (IndexOutOfRangeException) { MessageBox.Show("Введён неверный логин/пароль"); } }
private void updatePersBtn_Click(object sender, EventArgs e) { Worker updWorker = new Worker(); try { updWorker.name = persSurname.Text + " " + persName.Text + " " + persFatherName.Text; string where = "name=" + dbConnect.Transform(updWorker.name); string persGender = ""; if (persMale.Checked) { persGender = "male"; } if (persFemale.Checked) { persGender = "female"; } updWorker.gender = persGender; updWorker.dateBirth = persBirthDate.Value; updWorker.married = persMarried.Checked; updWorker.photo = transferWorker.photo; try { if (pathPhoto != null) { updWorker.photo = pathPhoto.Replace('\\', '/'); } } catch (ArgumentException) { } updWorker.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; updWorker.dept = pDept; updWorker.job = pJob; where = "fk_department=" + dbConnect.Transform(updWorker.dept.id.ToString()) + " and fk_job=" + dbConnect.Transform(updWorker.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; updWorker.schedule = workSched; updWorker.statusIsFired = false; if (!statusWorking.Checked) { statusWorking.Checked = true; } User newUser = new User(); newUser.username = persSurname.Text; if (!transferWorker.name.Equals(updWorker.name)) { where = "name=" + dbConnect.Transform(updWorker.name); List <string>[] check = DBConnect.SendMessageFromSocket(dbConnect.Select("person", "", where)); if (!check.Length.Equals(0)) { MessageBox.Show("Такой сотрудник есть в базе"); } else { List <string>[] checkRules = DBConnect.SendMessageFromSocket(dbConnect.Select("job", "", "idjob=" + dbConnect.Transform(updWorker.job.id.ToString()))); if (checkRules[0][1].Equals("Director") & rules.Equals("director")) { MessageBox.Show("Вы не можете назначать глав отделов"); } else { where = "idperson=" + dbConnect.Transform(transferWorker.id.ToString()); string set = "name=" + dbConnect.Transform(updWorker.name) + ", gender=" + dbConnect.Transform(updWorker.gender) + ", birthdate=" + dbConnect.Transform(updWorker.dateBirth.ToString("yyyy-MM-dd")) + ", married=" + dbConnect.Transform(dbConnect.BoolToTiny(updWorker.married)) + ", photo=" + dbConnect.Transform(updWorker.photo) + ", fk_department=" + dbConnect.Transform(updWorker.dept.id.ToString()) + ", fk_job=" + dbConnect.Transform(updWorker.job.id.ToString()) + ", archive=" + updWorker.archiveData + ", fk_workerschedule=" + dbConnect.Transform(updWorker.schedule.id.ToString()) + ", username="******"person", where, set)); jobsArchive.Clear(); MessageBox.Show("Данные обновлены"); } } } else { List <string>[] checkRules = DBConnect.SendMessageFromSocket(dbConnect.Select("job", "", "idjob=" + dbConnect.Transform(updWorker.job.id.ToString()))); if (checkRules[0][1].Equals("Director") & rules.Equals("director")) { MessageBox.Show("Вы не можете назначать глав отделов"); } else { where = "idperson=" + dbConnect.Transform(transferWorker.id.ToString()); string set = "name=" + dbConnect.Transform(updWorker.name) + ", gender=" + dbConnect.Transform(updWorker.gender) + ", birthdate=" + dbConnect.Transform(updWorker.dateBirth.ToString("yyyy-MM-dd")) + ", married=" + dbConnect.Transform(dbConnect.BoolToTiny(updWorker.married)) + ", photo=" + dbConnect.Transform(updWorker.photo) + ", fk_department=" + dbConnect.Transform(updWorker.dept.id.ToString()) + ", fk_job=" + dbConnect.Transform(updWorker.job.id.ToString()) + ", archive=" + updWorker.archiveData + ", fk_workerschedule=" + dbConnect.Transform(updWorker.schedule.id.ToString()) + ", username="******"person", where, set)); jobsArchive.Clear(); MessageBox.Show("Данные обновлены"); } } } else { MessageBox.Show("Расписание для данной должности еще не назначено"); } } catch (Exception) { } }
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("Расписание для данной должности еще не назначено"); } }