UserControl.cs public int index;
public void InsertIndex(int index)
{
this.index = index;
}
public void InsertTempOutcomes()
{
string query = "INSERT INTO TempOutcomes(RoomId,UserId,NameGoods,PriceGoods,AmountGoods,DataStart,DataFinish) VALUES((SELECT Name FROM Rooms WHERE Id=
@roomId),(SELECT Name FROM Users WHERE Id=
@userId),(SELECT Name FROM Store WHERE Id=@id),(SELECT Price FROM Store WHERE Id=@id),
@amount,
@dataStart,
@dataFinish)";
int goodsId = comboBoxGoods.SelectedIndex + 1;
try
{
command = new SQLiteCommand(query,connection);
command.Parameters.AddWithValue("
@amount",textBoxAmount.Text);
command.Parameters.AddWithValue("
@dataStart",dateTimePicker.Value);
command.Parameters.AddWithValue("@id", goodsId);
command.Parameters.AddWithValue("
@dataFinish", dateTimePicker.Value.AddSeconds(seconds));
command.Parameters.AddWithValue("
@roomId",index);
command.ExecuteNonQuery();
}
catch(Exception ex) { MessageBox.Show(ex.Message); }
finally { connection.Close(); }
}