private void btAdd_Click(object sender, EventArgs e)
        {
            if (tbSurname.Text == "" || tbName.Text == "" || tbPatronimyc.Text == "" || tbPhone.Text == "" || cbPosition.Text == "")
            {
                MessageBox.Show("Заполните все поля!", "Ошибка");
            }
            else
            {
                string factQuery;
                if (!edit)
                {
                    factQuery = "(`surname`, `name`, `patronimyc`, `phone_number`,`position_position`, " +
                                "`rating`) VALUES('" + tbSurname.Text + "', '" + tbName.Text + "', '" +
                                tbPatronimyc.Text + "', '" +
                                tbPhone.Text.Replace(" ", "").Replace("(", "").Replace(")", "") + "', '" + cbPosition.Text + "', '" + tbRating.Text + "');";
                    db.Add("employees", factQuery);
                }
                else
                {
                    factQuery = "`surname` = '" + tbSurname.Text + "', `name` = '" + tbName.Text + "', `patronimyc` = '" +
                                tbPatronimyc.Text + "', `phone_number` = '" + tbPhone.Text.Replace(" ", "").Replace("(", "").Replace(")", "")
                                + "',`position_position` = '" + cbPosition.Text + "', `rating` = '" + tbRating.Text + "'";
                    db.Edit("employees", "id_employee", idEmployee, factQuery);
                }

                Hide();
            }
        }
Exemple #2
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            if (tbIDRepair.Text == "" || tbName.Text == "" || tbCost.Text == "" || cbCategory.Text == "" || cbPosition.Text == "")
            {
                MessageBox.Show("Заполните все поля!", "Ошибка");
            }
            else
            {
                string factQuery;

                if (!edit)
                {
                    factQuery = "(`id_repair`, `name`, `category`, `cost`, `position_position`) VALUES('" +
                                tbIDRepair.Text + "', '" + tbName.Text + "', '" + cbCategory.Text + "', '" + tbCost.Text + "', '" + cbPosition.Text + "');";
                    db.Add("repairs", factQuery);
                }
                else
                {
                    factQuery = "`name` = '" + tbName.Text + "', `category` = '" + cbCategory.Text + "', " +
                                "`cost` = '" + tbCost.Text + "', `position_position` = '" + cbPosition.Text + "'";
                    db.Edit("repairs", "id_repair", tbIDRepair.Text, factQuery);
                }

                Hide();
            }
        }
        private void btAdd_Click(object sender, EventArgs e)
        {
            string factQuery;

            if (tbNumSTS.Text == "" || tbBrand.Text == "" || tbModel.Text == "" || cbYear.Text == "")
            {
                MessageBox.Show("Заполните все поля!", "Ошибка");
            }
            else
            {
                if (!edit)
                {
                    if (!checkBoxIsDateEmpty.Checked)
                    {
                        factQuery = "(number_sts, brand, model, year_created, date_to) VALUES('" +
                                    tbNumSTS.Text.Replace(" ", "") + "', '" + tbBrand.Text + "', '" + tbModel.Text + "', '" + cbYear.Text + "', '"
                                    + dtpDateTO.Value.ToString("yyyy-MM-dd") + "');";
                    }
                    else
                    {
                        factQuery = "(number_sts, brand, model, year_created) VALUES('" +
                                    tbNumSTS.Text.Replace(" ", "") + "', '" + tbBrand.Text + "', '" + tbModel.Text + "', '" + cbYear.Text + "');";
                    }

                    db.Add("cars", factQuery);
                }
                else
                {
                    factQuery = "brand = '" + tbBrand.Text + "', " + "model = '" +
                                tbModel.Text + "', year_created = '" + cbYear.Text + "', date_to = '"
                                + dtpDateTO.Value.ToString("yyyy-MM-dd") + "'";

                    db.Edit("cars", "number_sts", tbNumSTS.Text.Replace(" ", ""), factQuery);
                }

                Hide();
            }
        }
        private void btAdd_Click(object sender, EventArgs e)
        {
            if (tbNameAction.Text != "")
            {
                string factQuery;

                if (!edit)
                {
                    factQuery = "(name, text) VALUES('" + tbNameAction.Text + "', '" + tbTextAction.Text + "');";
                    db.Add("actions", factQuery);
                }
                else
                {
                    factQuery = "name = '" + tbNameAction.Text + "', text = '" + tbTextAction.Text + "'";
                    db.Edit("actions", "id_action", idAction, factQuery);
                }

                Hide();
            }
            else
            {
                MessageBox.Show("Заполните поле \"Название акции\"!", "Ошибка");
            }
        }