コード例 #1
0
        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.Select("job", 5, "", wheresearch);
                if (selection.Length > 0)
                {
                    MessageBox.Show("Вы пытаетесь обновить должность до такой, которая уже существует");
                }
                else
                {
                    dbConnect.Update("job", where, set);
                }
                JobForm_Load(sender, e);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        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("Такого сотрудника нет в базе");
            }
        }