public static bool Eliminar(long id, facturacion.Vistas.VListaVentas form) { MySqlConnection SqlCon = new MySqlConnection(Conexion.Cn); try { SqlCon.Open(); MySqlCommand command = new MySqlCommand(String.Format("UPDATE " + table + " SET estado='anulado' where id='" + id + "';"), SqlCon); if (command.ExecuteNonQuery() == 1) { ToastNotification.Show(form, " La venta se elimino correctamente", global::facturacion.Properties.Resources.ok, 3000, (eToastGlowColor.Green), (eToastPosition.TopRight)); SqlCon.Close(); return(true); } else { ToastNotification.Show(form, "La venta no se pudo eliminar", global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight)); SqlCon.Close(); return(false); } } catch (Exception e) { ToastNotification.Show(form, e.Message, global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopLeft)); return(false); } }
internal static bool Insertar(MFactura objeto, facturacion.Vistas.VListaVentas form) { MySqlConnection SqlCon = new MySqlConnection(Conexion.Cn); try { SqlCon.Open(); string query001 = "INSERT INTO " + table + "(idVenta,idCodigo,codControl,QR,numFactura,fecEmision) Values(@idVenta,@idCodigo,@codControl,@QR,@numFactura,@fecEmision)"; MySqlCommand command = new MySqlCommand(query001, SqlCon); command.Parameters.AddWithValue("@idVenta", objeto.idVenta); command.Parameters.AddWithValue("@idCodigo", objeto.idCodigo); command.Parameters.AddWithValue("@codControl", objeto.codControl); command.Parameters.AddWithValue("@QR", objeto.QR); command.Parameters.AddWithValue("@numFactura", objeto.numFactura); command.Parameters.AddWithValue("@fecEmision", objeto.fecEmision); if (command.ExecuteNonQuery() == 1) { ToastNotification.Show(form, "Factura Creada Correctamente", global::facturacion.Properties.Resources.ok, 3000, (eToastGlowColor.Green), (eToastPosition.TopRight)); SqlCon.Close(); return(true); } else { ToastNotification.Show(form, "La factura no pudo ser Creada", global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight)); SqlCon.Close(); return(false); } } catch (MySqlException e) { ToastNotification.Show(form, e.Message, global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopLeft)); return(false); } }
public static bool Editar(int id, MVentas objeto, facturacion.Vistas.VListaVentas form) { MySqlConnection SqlCon = new MySqlConnection(Conexion.Cn); try { SqlCon.Open(); string query001 = "UPDATE " + table + " SET idCliente=@idCliente,idUsuario=@idUsuario,fecVenta=@fecVenta,montoTotal=@montoTotal,montoLiteral=@montoLiteral,tipo=@tipo,estado=@estado where id=@id;"; MySqlCommand command = new MySqlCommand(query001, SqlCon); command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@idCliente", objeto.idCliente); command.Parameters.AddWithValue("@idUsuario", objeto.idUsuario); command.Parameters.AddWithValue("@fecVenta", objeto.fecVenta); command.Parameters.AddWithValue("@montoTotal", objeto.montoTotal); command.Parameters.AddWithValue("@montoLiteral", objeto.montoLiteral); command.Parameters.AddWithValue("@tipo", objeto.tipo); command.Parameters.AddWithValue("@estado", objeto.estado); if (command.ExecuteNonQuery() == 1) { ToastNotification.Show(form, "venta Editada Correctamente", global::facturacion.Properties.Resources.ok, 3000, (eToastGlowColor.Green), (eToastPosition.TopRight)); SqlCon.Close(); return(true); } else { ToastNotification.Show(form, "La venta no pudo ser Editado", global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight)); SqlCon.Close(); return(false); } } catch (MySqlException e) { ToastNotification.Show(form, e.Message, global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopLeft)); return(false); } }