public bool insertarRegistrar(CL_RegistrarVentas reg) { bool resp = false; try { OracleCommand cmd = new OracleCommand(); cmd.Connection = cone; cmd.CommandText = "INSERT INTO REGISTROVENTAS VALUES(SEQ_REG.NEXTVAL," + reg.id_compra + "," + reg.total + "," + reg.propitna + ")"; cmd.CommandType = CommandType.Text; if (cone.State.Equals(ConnectionState.Closed)) { cone.Open(); } int res = cmd.ExecuteNonQuery(); if (res > 0) { resp = true; } } catch (Exception ex) { throw new Exception("Insertar error: " + ex.Message); } return(resp); }
public List <CL_RegistrarVentas> obtenerListadoRegistrarVentas() { List <CL_RegistrarVentas> lista = new List <CL_RegistrarVentas>(); try { OracleCommand cmd = new OracleCommand(); cmd.Connection = cone; cmd.CommandText = "SELECT * FROM REGISTROVENTAS"; cmd.CommandType = CommandType.Text; if (cone.State.Equals(ConnectionState.Closed)) { cone.Open(); } OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { CL_RegistrarVentas aux_ventas = new CL_RegistrarVentas(); aux_ventas.id_compra = Convert.ToInt32(dr["ID_COMPRA"].ToString()); aux_ventas.id_registrar = Convert.ToInt32(dr["ID_REGISTRO_VENTAS"].ToString()); aux_ventas.propitna = Convert.ToInt32(dr["PROPINA"].ToString()); aux_ventas.total = Convert.ToInt32(dr["TOTAL"].ToString()); lista.Add(aux_ventas); } } catch (Exception ex) { throw new Exception(ex.Message); } return(lista); }
public bool insertarRegistrarVentas(string xmlRegistrarVenta) { bool resp = false; CL_RegistrarVentas registrarVentas = Util.DeserializeRegistrarVentas <CL_RegistrarVentas>(xmlRegistrarVenta); DAO_RegistrarVentas dao = new DAO_RegistrarVentas(); resp = dao.insertarRegistrar(registrarVentas); return(resp); }
private static void TestInsertarRegistroVentaOracle() { CL_RegistrarVentas ventas = new CL_RegistrarVentas(); ventas.id_compra = 2; ventas.total = 100; ventas.propitna = 10; DAO_RegistrarVentas dao = new DAO_RegistrarVentas(); dao.insertarRegistrar(ventas); }
private void btn_finalizar_Click(object sender, EventArgs e) { try { if (dgv_pedido.Rows.Count != 0) { CL_Compra comp = new CL_Compra(); comp.Usuario = Util.usuario; comp.Fecha_compra = DateTime.Now.ToString("yyyy/MM/dd"); int precio = precioTotal(); comp.Total_Pago = precio; string xmlCompra = Util.SerializeCompra <CL_Compra>(comp); //MessageBox.Show(xmlCompra); bool resp = serv.insertarCompra(xmlCompra); if (resp) { List <CL_DetalleCompra> listaDetalle = new List <CL_DetalleCompra>(); foreach (DataGridViewRow item in dgv_pedido.Rows) { if (Convert.ToInt32(item.Cells[0].Value) != 0) { CL_DetalleCompra det = new CL_DetalleCompra(); CL_Producto pro = new CL_Producto(); pro.Id_producto = Convert.ToInt32(item.Cells[0].Value); det.Producto = pro; det.Cantidad = Convert.ToInt32(item.Cells[3].Value); listaDetalle.Add(det); } } foreach (CL_DetalleCompra item2 in listaDetalle) { string xmlDetalle = Util.SerializeDetalleCompra <CL_DetalleCompra>(item2); serv.insertarDetalleCompra(xmlDetalle); } CL_RegistrarVentas registrarVentas = new CL_RegistrarVentas(); registrarVentas.id_compra = new DAO_Compra().maxIdCompra(); registrarVentas.total = precioTotal(); registrarVentas.propitna = Convert.ToInt32(Math.Round((precioTotal() * 0.10), 0)); string xmlRegistroCompra = Util.SerializeRegistrarVentas <CL_RegistrarVentas>(registrarVentas); serv.insertarRegistrarVentas(xmlRegistroCompra); lbl_mensaje.Text = "Pedido Exitoso"; Util.data = null; Util.listPedidos.Remove(id); foreach (DataRow item in Util.dataSala.Rows) { if (item[1].ToString() == id.ToString()) { //Util.dataSala.Rows[Convert.ToInt32(item[1].ToString())].Delete(); Util.dataSala.Rows.Remove(item); return; //lbl_mensaje.Text = item[1].ToString(); } } } else { lbl_mensaje.Text = "Pedido no Exitoso, Intentelo Mas Tarde"; } } else { lbl_mensaje.Text = "Ingrese Productos Al Carrito"; } } catch (Exception ex) { throw new Exception(ex.Message); } }