private void button_re_Click(object sender, EventArgs e) { Form6 fr = new Form6(dataGridView_flt.SelectedRows[0].Cells[0].Value.ToString(), dataGridView_tichet.SelectedRows[0].Cells[1].Value.ToString(), dataGridView_tichet.SelectedRows[0].Cells[2].Value.ToString(), dataGridView_tichet.SelectedRows[0].Cells[3].Value.ToString()); fr.ShowDialog(); dsPubs.Tables["Ticket"].Clear(); ticket.Fill(dsPubs, "Ticket"); Validare(); }
private void button_add_Click(object sender, EventArgs e) { if (txt_title.Text != null || txt_title.Text != "" && txt_code.Text != null || txt_code.Text != "" && dateTimePicker_ex.Checked) { using (SqlCommand newq = new SqlCommand("INSERT INTO Ticket ([ID], [Title], [Code], [Expiry date]) VALUES (@idd, @title, @code, @expr)", Form1.Conn)) { newq.Parameters.Add(new SqlParameter("@idd", id)); newq.Parameters.Add(new SqlParameter("@title", txt_title.Text)); newq.Parameters.Add(new SqlParameter("@code", txt_code.Text)); newq.Parameters.Add(new SqlParameter("@expr", dateTimePicker_ex.Value.ToString("dd/MM/yyyy"))); newq.ExecuteNonQuery(); } //SqlCommand ticket = new SqlCommand("INSERT INTO Ticket ([ID], [Title], [Code], [Expiry date]) VALUES ('" + id + "','" + txt_title.Text + "','" + txt_code.Text + "','" + dateTimePicker_ex.Value.ToString("dd/MM/yyyy") + "')", Form1.Conn); //ticket.ExecuteNonQuery(); this.Close(); Form6 frm = new Form6(id); frm.ShowDialog(); } else { MessageBox.Show(" Title or code is empty! "); } }