111
comboBox4->SelectedIndex = dClients2[Convert::ToInt32(sqlresult[0][3])];
comboBox5->SelectedIndex =
dEmployees2[Convert::ToInt32(sqlresult[0][4])];
textBox1->Text = sqlresult[0][5];
textBox2->Text = sqlresult[0][6];
IFormatProvider^ culture = gcnew CultureInfo("ru-RU", true);
dateTimePicker3->Value = DateTime::ParseExact(sqlresult[0][7], "yyyy-MM-
dd", culture);
dateTimePicker1->Value = DateTime::ParseExact(sqlresult[0][8], "yyyy-MM-
dd", culture);
dateTimePicker2->Value = DateTime::ParseExact(sqlresult[0][9], "yyyy-MM-
dd", culture);
textBox3->Text = sqlresult[0][10];
}
//MessageBox::Show(Convert::ToString(currentID));
}
void Form1::insertNew()
{
String ^ newNumdoc = textBox1->Text;
String ^ newSumm = textBox2->Text;
String ^ newInfo = textBox3->Text;
String ^ newId_typ = Convert::ToString(dTypes1[comboBox1->SelectedIndex]);
String ^ newId_sta = Convert::ToString(dStatuses1[comboBox2->SelectedIndex]);
String ^ newid_sup = Convert::ToString(dsuppliers1[comboBox3->SelectedIndex]);
String ^ newId_cli = Convert::ToString(dClients1[comboBox4->SelectedIndex]);
String ^ newId_emp = Convert::ToString(dEmployees1[comboBox5->SelectedIndex]);
String ^sql = "insert into documents (numdoc, summ, dt, startd, endd, info, id_typ,
id_sta, id_sup, id_cli, id_emp) values('"+newNumdoc+"', "+newSumm+", '"+dateTimePicker3-
>Value.ToString("yyyyMMdd")+"', '"+dateTimePicker1->Value.ToString("yyyyMMdd")+"',
'"+dateTimePicker2->Value.ToString("yyyyMMdd")+"', '"+newInfo+"', "+newId_typ+", "+newId_sta+",
"+newid_sup+", "+newId_cli+", "+newId_emp+")";
this->sqlInsert(sql);
loaddocuments();
}
void Form1::deleteCurrent()
{
int row = dataGridView1->SelectedCells[0]->RowIndex;
int id = Convert::ToInt32(dataGridView1->Rows[row]->Cells[0]->Value);
if (MessageBox::Show("Вы уверены, что хотите удалить запись?", "Удаление",
MessageBoxButtons::YesNo, MessageBoxIcon::Question) ==
System::Windows::Forms::DialogResult::No)
return;
String ^sql = "delete from documents where id_doc="+Convert::ToString(id);
this->sqlOther(sql);
loaddocuments();
}
void Form1::updateCurrent()
{
int row = dataGridView1->SelectedCells[0]->RowIndex;
int id = Convert::ToInt32(dataGridView1->Rows[row]->Cells[0]->Value);