Beispiel #1
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            string factQuery;

            if (tbSurname.Text == "" || tbName.Text == "" || tbPatronimyc.Text == "" || tbPhone.Text == "" || cbNumSTS.Text == "")
            {
                MessageBox.Show("Заполните все поля!", "Ошибка");
            }
            else
            {
                if (!edit)
                {
                    factQuery = "(surname, name, patronimyc, phone_number, cars_number_sts) VALUES('" +
                                tbSurname.Text + "', '" + tbName.Text + "', '" + tbPatronimyc.Text + "', '" +
                                tbPhone.Text.Replace(" ", "").Replace("(", "").Replace(")", "") + "', '" + cbNumSTS.Text + "');";
                    db.Add("clients", factQuery);
                }
                else
                {
                    factQuery = "surname = '" + tbSurname.Text + "', name = '" + tbName.Text + "', " +
                                "patronimyc = '" + tbPatronimyc.Text + "', phone_number = '" +
                                tbPhone.Text.Replace(" ", "").Replace("(", "").Replace(")", "") +
                                "', cars_number_sts = '" + cbNumSTS.Text + "'";
                    db.Edit("clients", "id_client", idClient, factQuery);
                }

                Hide();
            }
        }