private void dataGridView1_CelltClick(object sender, DataGridViewCellEventArgs e) { try { string id = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); if (e.ColumnIndex == 7) { DialogResult dr = MessageBox.Show("คุณต้องการลบข้อมูลนี้หรือไม่ ?", "ลบข้อมุล", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { string query = "update verify set status ='DELETE' WHERE ver_id = @id"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@id", id); conn.Open(); try { cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); conn.Close(); this.RenderGrid(); MessageBox.Show("ลบข้อมูลเรียบร้อย"); } catch (Exception ex) { MessageBox.Show("เกิดข้อผิดพลาดในการลบข้อมูลเนื่องจาก : " + ex.Message); conn.Close(); } } } if (e.ColumnIndex == 6) { VerifyAdd da = new VerifyAdd(this); da.ID = id; da.Show(); } if (e.ColumnIndex == 8) { string[] data = new string[4]; data[0] = id; PrintView rw = new PrintView("print_quotation", data); rw.Show(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void button2_Click(object sender, EventArgs e) { VerifyAdd acf = new VerifyAdd(this); acf.Show(); }
public VerifyAddSpares(VerifyAdd FormAdd, String ver_id) { this.Form = FormAdd; this.ver_id = ver_id.ToString(); InitializeComponent(); }