private void addAgentButton_Click(object sender, EventArgs e)                                                    // Агенты бюро (Добавление)
        {
            string f  = null;
            string i  = null;
            string o  = null;
            string kt = null;

            try
            {
                f  = fBox.Text;
                i  = iBox.Text;
                o  = oBox.Text;
                kt = ktBox.Text;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (fBox.Text != String.Empty && iBox.Text != String.Empty && oBox.Text != String.Empty)
            {
                string query = "insert into [Агенты бюро] (Фамилия, Имя, Отчество, [Контактный телефон])" +
                               "values (" + $"'{f}','{i}','{o}','{kt}'" + ")";
                int?result = DBConnectionService.SendCommandToSqlServer(query);
                if (result != null && result > 0)
                {
                    MessageBox.Show("Done", "Saving object", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    showButton1.PerformClick();
                    fBox.Clear();
                    iBox.Clear();
                    oBox.Clear();
                    ktBox.Clear();
                }
            }
            else
            {
                MessageBox.Show("Не все поля заполнены");
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string fName = null;
            string lName = null;
            string sName = null;
            int?   wExp  = null;
            int?   pos   = null;

            try
            {
                fName = textBox1.Text;
                lName = textBox2.Text;
                sName = textBox3.Text;
                wExp  = Convert.ToInt32(textBox4.Text);
                var posResult = DBConnectionService.SendScalarQueryToSqlServer($"select id from position where name='{comboBox1.Text}'");
                if (posResult == null)
                {
                    throw new Exception("\"Position\" value is not correct");
                }
                else
                {
                    pos = Convert.ToInt32(posResult);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string query = "insert into teacher (first_name, last_name, sur_name, degree_id, position_id, work_expirience)" +
                           "values (" + $"'{fName}','{lName}','{sName}',null,{pos},{wExp}" + ")";
            int?result = DBConnectionService.SendCommandToSqlServer(query);

            if (result != null && result > 0)
            {
                MessageBox.Show("Done", "Saving object", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
예제 #3
0
        private void Button2_Click(object sender, EventArgs e)
        {
            string tb1 = textBox1.Text;
            string tb2 = textBox2.Text;
            string tb3 = textBox3.Text;
            string tb4 = textBox4.Text;
            string tb5 = textBox5.Text;
            string tb6 = textBox6.Text;
            string tb7 = textBox7.Text;
            string tb8 = textBox8.Text;

            int x = Convert.ToInt32(textBox1.Text);
            int y = Convert.ToInt32(textBox2.Text);
            int u = Convert.ToInt32(textBox3.Text);
            int i = Convert.ToInt32(textBox4.Text);
            int o = Convert.ToInt32(textBox7.Text);

            string query = "INSERT INTO dbo.Номера ([Номер телефона гостиницы], [Номер], [Вместимость], [Цена], [Город], [Название], [Комфортность], [Страны]) VALUES ('" + tb1 + "','" + tb2 + "','" + tb3 + "','" + tb4 + "','" + tb5 + "','" + tb6 + "','" + tb7 + "','" + tb8 + "')";
            int?   count = DBConnectionService.SendCommandToSqlServer(query);

            MessageBox.Show("добавлено" + count + "строк");
        }
        private void addVButton_Click(object sender, EventArgs e)                                                                // Вакансии (Добавление)
        {
            int?   np  = null;
            int?   d   = null;
            string tuo = null;
            string k   = null;
            string zp  = null;

            try
            {
                np  = Convert.ToInt32((npComboBox.SelectedItem as IdentityItem)?.Id);
                d   = Convert.ToInt32((dBox.SelectedItem as IdentityItem)?.Id);
                tuo = tuoBox.Text;
                k   = kBox.Text;
                zp  = zpBox.Text;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string query = "insert into Вакансии ([id работодателя], [id должности], [Требуемый уровень образования], Квалификация, [Заработная плата], Открытая)" +
                           "values (" + $"'{np}','{d}','{tuo}','{k}','{zp}','{tip1}'" + ")";
            int?result = DBConnectionService.SendCommandToSqlServer(query);

            if (result != null && result > 0)
            {
                MessageBox.Show("Done", "Saving object", MessageBoxButtons.OK, MessageBoxIcon.Information);
                showButton3.PerformClick();
                npComboBox.SelectedIndex = -1;
                dBox.SelectedIndex       = -1;
                tuoBox.Clear();
                kBox.Clear();
                zpBox.Clear();
            }
        }
        private void updDButton_Click(object sender, EventArgs e)                                                             // Должности (Изменение)
        {
            string d = null;

            try
            {
                d = originalDBox2.Text;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int    n     = int.Parse(dataGridView7.CurrentRow.Cells[0].Value.ToString());
            string query = "UPDATE Должности SET Должность = '" + d + "'" +
                           "WHERE [id должности] = '" + n + "'";
            int?result = DBConnectionService.SendCommandToSqlServer(query);

            if (result != null && result > 0)
            {
                MessageBox.Show("Done", "Saving object", MessageBoxButtons.OK, MessageBoxIcon.Information);
                showButton7.PerformClick();
            }
        }
        private void addDButton_Click(object sender, EventArgs e)                                                             // Должности (Добавление)
        {
            string d = null;

            try
            {
                d = originalDBox1.Text;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string query = "insert into Должности (Должность)" +
                           "values ('" + d + "')";
            int?result = DBConnectionService.SendCommandToSqlServer(query);

            if (result != null && result > 0)
            {
                MessageBox.Show("Done", "Saving object", MessageBoxButtons.OK, MessageBoxIcon.Information);
                showButton7.PerformClick();
                originalDBox1.Clear();
            }
        }
        private void updVDButton_Click(object sender, EventArgs e)                                                            // Виды деятельности (Изменение)
        {
            string vd = null;

            try
            {
                vd = vdBox1.Text;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int    n     = int.Parse(dataGridView6.CurrentRow.Cells[0].Value.ToString());
            string query = "UPDATE [Виды деятельности] SET [Вид деятельности] = '" + vd + "'" +
                           "WHERE [id деятельности] = '" + n + "'";
            int?result = DBConnectionService.SendCommandToSqlServer(query);

            if (result != null && result > 0)
            {
                MessageBox.Show("Done", "Saving object", MessageBoxButtons.OK, MessageBoxIcon.Information);
                showButton6.PerformClick();
            }
        }
        private void addVDButton_Click(object sender, EventArgs e)                                                             // Виды деятельности (Добавление)
        {
            string vd = null;

            try
            {
                vd = vdBox.Text;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string query = "insert into [Виды деятельности] ([Вид деятельности])" +
                           "values ('" + vd + "')";
            int?result = DBConnectionService.SendCommandToSqlServer(query);

            if (result != null && result > 0)
            {
                MessageBox.Show("Done", "Saving object", MessageBoxButtons.OK, MessageBoxIcon.Information);
                showButton6.PerformClick();
                vdBox.Clear();
            }
        }
        private void addSdButton_Click(object sender, EventArgs e)                                                         // Сделки (Добавление)
        {
            DateTime dz;
            int?     s   = null;
            int?     v   = null;
            int?     a   = null;
            string   kms = null;

            try
            {
                dz  = dateTimePicker3.Value;
                s   = Convert.ToInt32((SComboBox.SelectedItem as IdentityItem)?.Id);
                v   = Convert.ToInt32((VComboBox.SelectedItem as IdentityItem)?.Id);
                a   = Convert.ToInt32((AComboBox.SelectedItem as IdentityItem)?.Id);
                kms = kmsBox.Text;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string query = "insert into Сделки ([Дата заключения], [id соискателя], [id вакансии], [id агента], Комиссионные)" +
                           "values (" + $"'{dz}','{s}','{v}','{a}','{kms}'" + ")";
            int?result = DBConnectionService.SendCommandToSqlServer(query);

            if (result != null && result > 0)
            {
                MessageBox.Show("Done", "Saving object", MessageBoxButtons.OK, MessageBoxIcon.Information);
                showButton5.PerformClick();
                dateTimePicker3.Value   = DateTime.Now;
                SComboBox.SelectedIndex = -1;
                VComboBox.SelectedIndex = -1;
                AComboBox.SelectedIndex = -1;
                kmsBox.Clear();
            }
        }