public void facturar(Factura obFactura) { SqlConnection con = null; try { con = new Conexion().conectar(); if (con != null) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "UPDATE_FACTURA "; cmd.Parameters.AddWithValue("@NUM_fACTURA", obFactura.numFactura); cmd.Parameters.AddWithValue("@TOTAL", obFactura.total); cmd.Parameters.AddWithValue("@IVA", obFactura.iva); cmd.ExecuteNonQuery(); MessageBox.Show("factura registrada..."); } } catch (Exception e) { MessageBox.Show("Error " + e.Message); } finally { con.Close(); } }
public void deleteFactura(Factura obFactura) { SqlConnection con = null; try { con = new Conexion().conectar(); if (con != null) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DELETE_FACTURA "; cmd.Parameters.AddWithValue("@NUM_FACTURA", obFactura.numFactura); cmd.ExecuteNonQuery(); } } catch (Exception e) { MessageBox.Show("Error " + e.Message); } finally { con.Close(); } }
public static Entidades.Factura datoAEntidad(Factura f) { Entidades.Factura retorno = new Entidades.Factura(); retorno.Anulada = (bool)f.fac_anulada; retorno.Ced_cliente = f.fac_ced_cliente; retorno.Ced_recep = f.fac_ced_recep; retorno.Fecha = (DateTime)f.fac_fecha; retorno.Iva = (double)f.fac_iva; retorno.Numero = f.fac_n_factura; retorno.Subtotal = (double)f.fac_subtotal; retorno.Total = (double)f.fac_total; return retorno; }
public void insertaOrden(Factura obFactura) { SqlConnection con = null; try { con = new Conexion().conectar(); if (con != null) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "INSERT_DET_FACTURA "; cmd.Parameters.AddWithValue("@NUM_FACTURA", obFactura.numFactura); cmd.Parameters.AddWithValue("@ID_REPUESTO", obFactura.idRepuesto); cmd.Parameters.AddWithValue("@REPUESTO_CANT", obFactura.cantRepuesto); cmd.Parameters.AddWithValue("@ID_SERVICIO", obFactura.idServicio); cmd.Parameters.AddWithValue("@SERVICIO_CANT", obFactura.cantServicio); cmd.ExecuteNonQuery(); } } catch (Exception e) { MessageBox.Show("Error " + e.Message); } finally { con.Close(); } }
public void insertaFactura(Factura obFactura) { SqlConnection con = null; try { con = new Conexion().conectar(); if (con != null) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "INSERT_FACTURA "; cmd.Parameters.AddWithValue("@NUMERO", obFactura.numFactura); cmd.Parameters.AddWithValue("@CEDULA", obFactura.cedula); cmd.Parameters.AddWithValue("@MATRICULA", obFactura.matricula); cmd.ExecuteNonQuery(); } } catch (Exception e) { MessageBox.Show("Error " + e.Message); } finally { con.Close(); } }
public List<Factura> getOrden(int nOrden) { List<Factura> listOrden = new List<Factura>(); SqlConnection con = null; try { con = new Conexion().conectar(); StringBuilder cadena = new StringBuilder(); cadena.Append(" SELECT D.ID_DETALLE, R.TIPO REPUESTO ,D.REPUESTO_CANTIDAD , S.TIPO SERVICIO,D.SERVICIO_CANTIDAD, D.VALOR_TOTAL SUBTOTAL "); cadena.Append(" FROM DETALLE_FACTURA D, REPUESTOS R,SERVICIOS S , FACTURA F "); cadena.Append(" WHERE D.ID_FACTURA=F.ID_FACTURA "); cadena.Append(" and d.ID_REPUESTO=r.ID_REPUESTO "); cadena.Append(" and d.ID_SERVICIO=s.ID_SERVICIO "); cadena.Append(" and d.ID_FACTURA= (SELECT F.ID_FACTURA FROM FACTURA F WHERE F.NUMERO=" + nOrden + ") "); SqlCommand cmd = new SqlCommand(cadena.ToString(), con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Factura obFactura = new Factura(); obFactura.idOrdenFact = (int)dr["ID_DETALLE"]; obFactura.nombreRepuesto = dr["REPUESTO"].ToString(); obFactura.cantRepuesto = (int)dr["REPUESTO_CANTIDAD"]; obFactura.nombreservicio = dr["SERVICIO"].ToString(); obFactura.cantServicio = (int)dr["SERVICIO_CANTIDAD"]; obFactura.subTotal = (decimal)dr["SUBTOTAL"]; listOrden.Add(obFactura); } } catch (Exception e) { MessageBox.Show("error: " + e.ToString()); } finally { if (con.State != ConnectionState.Closed) con.Close(); } return listOrden; }