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();
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
 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.Select("job", 5, "", where);
         if (selection.Length.Equals(0))
         {
             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();
     }
 }
Пример #4
0
        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("Расписание для данной должности еще не назначено");
            }
        }