Guest User

Untitled

a guest
Jun 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. private void Pagos_CellClick(object sender, DataGridViewCellEventArgs e)
  2. {
  3. if (this.Pagos.Columns[e.ColumnIndex].Name == "colBotones")
  4. {
  5. string mesa = this.numMesa.Trim();
  6. int id_producto = Convert.ToInt32(this.Pagos.Rows[e.RowIndex].Cells[0].Value.ToString());
  7. string nombre = Convert.ToString(this.Pagos.Rows[e.RowIndex].Cells[1].Value.ToString());
  8. double precio = Convert.ToDouble(this.Pagos.Rows[e.RowIndex].Cells[2].Value.ToString());
  9. double cantidad = Convert.ToDouble(this.Pagos.Rows[e.RowIndex].Cells[3].Value.ToString());
  10. double subtotal = Convert.ToDouble(this.Pagos.Rows[e.RowIndex].Cells[4].Value.ToString());
  11.  
  12. String consulta = "DELETE FROM Productos where mesa = @mesa and @id_producto = id_producto and nombre = @nombre and precio = @precio and cantidad = @cantidad and subtotal = @subtotal LIMIT 1";
  13. SQLiteCommand cmd = new SQLiteCommand(consulta, conexion);
  14.  
  15. cmd.Parameters.Clear();
  16. cmd.Parameters.Add(new SQLiteParameter("@mesa", mesa));
  17. cmd.Parameters.Add(new SQLiteParameter("@id_producto", id_producto));
  18. cmd.Parameters.Add(new SQLiteParameter("@nombre", nombre));
  19. cmd.Parameters.Add(new SQLiteParameter("@precio", precio));
  20. cmd.Parameters.Add(new SQLiteParameter("@cantidad", cantidad));
  21. cmd.Parameters.Add(new SQLiteParameter("@subtotal", subtotal));
  22.  
  23. cmd.ExecuteNonQuery();
  24.  
  25. Pagos.Rows.RemoveAt(Pagos.CurrentRow.Index);
  26. }
  27. }
  28.  
  29. private void Pagos_CellClick(object sender, DataGridViewCellEventArgs e)
  30. {
  31. if (this.Pagos.Columns[e.ColumnIndex].Name == "colBotones")
  32. {
  33. string mesa = this.numMesa.Trim();
  34. int id_producto = Convert.ToInt32(this.Pagos.Rows[e.RowIndex].Cells[0].Value.ToString());
  35. string nombre = Convert.ToString(this.Pagos.Rows[e.RowIndex].Cells[1].Value.ToString());
  36. double precio = Convert.ToDouble(this.Pagos.Rows[e.RowIndex].Cells[2].Value.ToString());
  37. double cantidad = Convert.ToDouble(this.Pagos.Rows[e.RowIndex].Cells[3].Value.ToString());
  38. double subtotal = Convert.ToDouble(this.Pagos.Rows[e.RowIndex].Cells[4].Value.ToString());
  39.  
  40. String consulta = "DELETE FROM Productos where mesa = @mesa and @id_producto = id_producto and nombre = @nombre and precio = @precio and cantidad = @cantidad and subtotal = @subtotal LIMIT 1";
  41. SQLiteCommand cmd = new SQLiteCommand(consulta, conexion);
  42.  
  43. cmd.Parameters.Clear();
  44. cmd.Parameters.Add(new SQLiteParameter("@mesa", mesa));
  45. cmd.Parameters.Add(new SQLiteParameter("@id_producto", id_producto));
  46. cmd.Parameters.Add(new SQLiteParameter("@nombre", nombre));
  47. cmd.Parameters.Add(new SQLiteParameter("@precio", precio));
  48. cmd.Parameters.Add(new SQLiteParameter("@cantidad", cantidad));
  49. cmd.Parameters.Add(new SQLiteParameter("@subtotal", subtotal));
  50.  
  51. cmd.ExecuteNonQuery();
  52.  
  53. Pagos.Rows.RemoveAt(Pagos.CurrentRow.Index);
  54. }
  55. }
  56.  
  57. Delete from table_name where rowid IN (Select rowid from table_name limit X);
Add Comment
Please, Sign In to add comment