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.Select("person", 13, "", 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("Выделите всю строку"); };
        }
Esempio n. 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 = (Guid)chooseDept.SelectedValue;
            Job        schedJob  = new Job(); schedJob.id = (Guid)chooseJob.SelectedValue;
            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.Select("schedule", 17, "", where);
            if (selection.Length.Equals(0))
            {
                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.Update("schedule", where, set);
                MessageBox.Show("Расписание обновлено");
            }
            ScheduleForm_Load(sender, e);
        }
        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 enterBtn_Click(object sender, EventArgs e)
        {
            userlog          = new User();
            userlog.username = login.Text;
            userlog.password = pass.Text;
            List <string>[] selected = dbConnect.Select("person", 13, "", "username="******"job", 5, "", "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();
                }
                else
                {
                    MessageBox.Show("Введён неверный логин/пароль");
                }
            }
            catch (IndexOutOfRangeException) { MessageBox.Show("Введён неверный логин/пароль"); }
        }
Esempio n. 5
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();
     }
 }
Esempio n. 6
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("Расписание для данной должности еще не назначено");
            }
        }