コード例 #1
0
        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("Введён неверный логин/пароль"); }
        }
コード例 #2
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();
     }
 }
コード例 #3
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("Расписание для данной должности еще не назначено");
            }
        }