codeproject c# WPF Graphic Editor
codeplex c# WPF Graphic Editor
github c# WPF Graphic Editor
private void button1_Click(object sender, EventArgs e)
{
conpoezdb.Open();
SqlDataAdapter SDA = new SqlDataAdapter("INSERT INTO train(number,place, count, data, time)VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')", conpoezdb);
SDA.SelectCommand.ExecuteNonQuery();
conpoezdb.Close();
MessageBox.Show("saved");
updateView();
}
private void button4_Click(object sender, EventArgs e)
{
updateView();
}
private void updateView()
{
conpoezdb.Open();
SqlDataAdapter SDA = new SqlDataAdapter("SELECT * FROM train", conpoezdb);
DataTable data = new DataTable();
SDA.Fill(data);
dataGridView1.DataSource = data;
conpoezdb.Close();
}
private void button1_Click(object sender, EventArgs e)
{
conpoezdb.Open();
//пишем в бд
SqlDataAdapter SDA = new SqlDataAdapter("INSERT INTO train(number,place, count, data, time)VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')", conpoezdb);
SDA.SelectCommand.ExecuteNonQuery();
//запрашиваем по новой
SqlDataAdapter SDA = new SqlDataAdapter("SELECT * FROM train", conpoezdb);
conpoezdb.Close();
DataTable data = new DataTable();
SDA.Fill(data);
dataGridView1.DataSource = data;
MessageBox.Show("saved");
}
private void textBox8_TextChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "number")
{
SqlConnection po = new SqlConnection("Data Source=max;Initial Catalog=lr;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("SELECT number,name,city, data FROM people WHERE number like '%" + textBox8.Text + "%' ", po);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
else if (comboBox1.Text == "data")
{
SqlConnection po = new SqlConnection("Data Source=max;Initial Catalog=lr;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("SELECT number,name,city, data FROM people WHERE data like '%" + textBox8.Text + "%'", po);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
}
private void button1_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[0].Value != null && row.Cells[0].Value.ToString() == textBox1.Text)
{
var ticketsCell = row.Cells[2];
var count = int.Parse(ticketsCell.Value.ToString());
if (count == 0) MessageBox.Show("Нет билетов!");
else ticketsCell.Value = count - 1;
}
}
}