private void button1_Click(object sender, EventArgs e) { try { int id = Convert.ToInt32(tbId.Text); string type = comboBox1.SelectedItem.ToString(); string naim = tbNaim.Text; string naz = tbNazvanie.Text; int price = Convert.ToInt32(tbPrice.Text); mbd.controlquery("Insert into Furnitura values (" + id + ", '" + type + "', '" + naim + "', '" + naz + "', " + price + ");"); MessageBox.Show("Добавлено", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); DataTable dt = mbd.selectionquery("select * from Furnitura; "); dataGridView1.DataSource = dt; } catch { MessageBox.Show("Введите корректные данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void saveOrder(int rbNum, int index, string famil, string name, string otch, string numTel, string mail) { if (rbNum == 1) { DataForBD.IdCustomer = Convert.ToInt32(dt.Rows[index][0]); } else if (rbNum == 2) { DataForBD.IdCustomer = 1; for (int i = 0; i < dt.Rows.Count; i++) { if (Convert.ToInt32(dt.Rows[i][0]) > DataForBD.IdCustomer) { DataForBD.IdCustomer = Convert.ToInt32(dt.Rows[i][0]); } } DataForBD.IdCustomer++; DataForBD.Famil = famil; DataForBD.Name = name; DataForBD.Otchestvo = otch; DataForBD.NumTel = numTel;; DataForBD.Mail = mail; } if (rbNum == 2) { mbd.controlquery("insert into 'customer' (id_customer, Famil ,Name , otchestvo , num_tel, mail )" + "values (" + DataForBD.IdCustomer.ToString() + ", '" + DataForBD.Famil + "' ,'" + DataForBD.Name + "','" + DataForBD.Otchestvo + "', " + DataForBD.NumTel + " , '" + DataForBD.Mail + "' )"); } mbd.controlquery("insert into StroyMaterialZakaz values ( " + DataForBD.IdZakaz + "," + DataForBD.IdOboi + ");"); mbd.controlquery("insert into StroyMaterialZakaz values ( " + DataForBD.IdZakaz + "," + DataForBD.IdPlitka + ");"); foreach (var n in DataForBD.ListZakazMebTeh) { mbd.controlquery("insert into FurnituraZakaz values ( " + n.IdZakaz + "," + n.IdFurnit + "," + n.CoordX + "," + n.CoordY + ");"); } mbd.controlquery("insert into Zakaz values (" + DataForBD.IdZakaz.ToString() + ", " + DataForBD.Length.ToString() + " ," + DataForBD.Width.ToString() + " ," + DataForBD.Height.ToString() + " ," + DataForBD.IdCustomer.ToString() + " ," + DataForBD.Mounth.ToString() + " ," + DataForBD.Summa.ToString() + ")"); Reports rep = new Reports(); rep.blank(DataForBD.IdZakaz); mbd.controlquery("update zakaz set summa = " + Convert.ToString(DataForBD.Summa) + " where id_zakaz = " + Convert.ToString(DataForBD.IdZakaz)); }