void ActualizarTodo() { foreach (var series in chart1.Series) { series.Points.Clear(); } OdbcDataReader mostrar = logic.consultaActivos(); try { if (mostrar == null) { MessageBox.Show("Actualmente no existen Activos disponibles para graficar."); } else { while (mostrar.Read()) { chart1.Series["Series1"].Points.AddXY("", mostrar.GetDouble(2)); chart1.Series["Series2"].Points.AddXY(mostrar.GetString(0), mostrar.GetDouble(1)); chart1.Series["Series3"].Points.AddXY("", mostrar.GetDouble(3)); } } } catch (Exception err) { Console.WriteLine("Se encontro un error: " + err.Message); } }
private void getTotal() { if (compraActual != "") { try { OdbcConnection conexion = ASG_DB.connectionResult(); string sql = sql = string.Format("SELECT SUBTOTAL FROM CONTROL_COMPRA WHERE ID_COMPRA = {0};", compraActual); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { total = 0; total = reader.GetDouble(0); while (reader.Read()) { total += reader.GetDouble(0); } label5.Text = string.Format("Q.{0:###,###,###,##0.00##}", total); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void cargaFactura() { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT SUBTOTAL_FACTURA, DESCUENTO_FACTURA, TOTAL_FACTURA, (SELECT NOMBRE_USUARIO FROM USUARIO WHERE ID_USUARIO = VENDEDOR),FECHA_EMISION_FACTURA FROM FACTURA WHERE ID_FACTURA = '{0}' ;", idFactura); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { label5.Text = string.Format("Q.{0:###,###,###,##0.00##}", reader.GetDouble(0)); label1.Text = string.Format("Q.{0:###,###,###,##0.00##}", reader.GetDouble(1)); label7.Text = string.Format("Q.{0:###,###,###,##0.00##}", reader.GetDouble(2)); label18.Text = reader.GetString(3); vendedor = label18.Text; label15.Text = reader.GetString(4); totalF = label7.Text; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void graficasGanancia() { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT MONTHNAME(F.FECHA_EMISION_FACTURA) AS MES, TRUNCATE(SUM(F.TOTAL_FACTURA),2) AS TOTAL FROM FACTURA F WHERE(YEAR(F.FECHA_EMISION_FACTURA) = YEAR(NOW()) AND F.ESTADO_TUPLA = TRUE AND F.ESTADO_FACTURA = 1) GROUP BY MES DESC; "); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { Mes.Add(reader.GetString(0)); Ganancia.Add(reader.GetDouble(1)); while (reader.Read()) { Mes.Add(reader.GetString(0)); Ganancia.Add(reader.GetDouble(1)); } chart4.Series[0].Points.DataBindXY(Mes, Ganancia); } else { // MessageBox.Show("NO EXISTEN DATOS PARA MOSTRAR GRAFICAS!", "ESTADISTICAS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show("FALLO LA CONEXION CON LA BASE DE DATOS!" + "\n" + ex.ToString(), "ESTADISTICAS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } conexion.Close(); }
private void productosAgotados() { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT COUNT(ID_MERCADERIA) FROM MERCADERIA WHERE ESTADO_TUPLA = TRUE AND TOTAL_UNIDADES = 0 AND ID_SUCURSAL = {0};", idSucursal); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { if (reader.GetDouble(0) <= 0) { label5.Text = "0"; } else { label5.Text = string.Format("{0:#,###,###,###,###}", reader.GetDouble(0)); } } else { label5.Text = "0"; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } conexion.Close(); }
private void cotizacionesPendinetes() { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT COUNT(ID_FACTURA) FROM FACTURA WHERE ESTADO_TUPLA = TRUE AND ESTADO_FACTURA = 0 AND ID_SUCURSAL = {0};", idSucursal); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { if (reader.GetDouble(0) <= 0) { label9.Text = "0"; } else { label9.Text = string.Format("{0:#,###,###,###,###}", reader.GetDouble(0)); } } else { label9.Text = "0"; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } conexion.Close(); }
//obtener datos para el ingreso de productos public Producto obtenerProductoDetalle(int id_producto) { producto = new Producto(); try { string sComando = string.Format( "SELECT id_producto, nombre_producto, costo_producto, precio_producto " + "FROM productos " + "WHERE id_producto = {0} ;", id_producto); OdbcDataReader reader = transaccion.ConsultarDatos(sComando); if (reader.HasRows) { while (reader.Read()) { producto.ID_PRODUCTO = reader.GetInt32(0); producto.NOMBRE_PRODUCTO = reader.GetString(1); producto.COSTO_PRODUCTO = reader.GetDouble(2); producto.PRECIO_PRODUCTO = reader.GetDouble(3); } } return(producto); } catch (OdbcException ex) { mensaje = new Mensaje("Error en la operacion con la Base de Datos: \n" + ex.Message); mensaje.Show(); return(null); } }
private void cargacuentasCobrar() { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT COUNT(ID_CLIENTE) FROM CUENTA_POR_COBRAR_CLIENTE WHERE ESTADO_TUPLA = TRUE AND ESTADO_CUENTA = TRUE;"); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { if (reader.GetDouble(0) <= 0) { label2.Text = "0"; } else { label2.Text = string.Format("{0:#,###,###,###,###}", reader.GetDouble(0)); } } else { label2.Text = "0"; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } conexion.Close(); }
private void duplicaFactura(string codigo) { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT F.ID_CLIENTE, F.ID_FACTURA, F.FECHA_EMISION_FACTURA, (SELECT NOMBRE_CLIENTE FROM CLIENTE WHERE ID_CLIENTE = F.ID_CLIENTE ), (SELECT APELLIDO_CLIENTE FROM CLIENTE WHERE ID_CLIENTE = F.ID_CLIENTE ), F.TIPO_FACTURA, F.ID_SUCURSAL, F.SUBTOTAL_FACTURA, F.DESCUENTO_FACTURA, F.TOTAL_FACTURA FROM FACTURA F WHERE ID_FACTURA = '{0}';", codigo); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { // MessageBox.Show("FACTURA DUPLICADA"); textBox4.Text = reader.GetString(0); duplicaDetalle(reader.GetString(1)); textBox2.Text = reader.GetString(2); textBox3.Text = reader.GetString(3) + " " + reader.GetString(4); textBox6.Text = reader.GetString(5); cargaSucursales(reader.GetString(6)); label11.Text = string.Format("Q.{0:###,###,###,##0.00##}", reader.GetDouble(7)); label8.Text = string.Format("Q.{0:###,###,###,##0.00##}", reader.GetDouble(8)); totalFactura = "" + reader.GetDouble(9); label12.Text = string.Format("Q.{0:###,###,###,##0.00##}", reader.GetDouble(9)); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } conexion.Close(); }
private void graficasGananciaPeriodos() { OdbcConnection conexion = ASG_DB.connectionResult(); try { double total = 0; string sql = string.Format("SELECT * FROM VISTA_GANANCIA_PERIODO; "); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { Meses.Add(reader.GetString(0)); total = total + (reader.GetDouble(2) - reader.GetDouble(1)); Ganancias.Add(reader.GetDouble(2) - reader.GetDouble(1)); while (reader.Read()) { Meses.Add(reader.GetString(0)); total = total + (reader.GetDouble(2) - reader.GetDouble(1)); Ganancias.Add(reader.GetDouble(2) - reader.GetDouble(1)); } //label26.Text = string.Format("Q.{0:###,###,###,##0.00##}", total); chart2.Series[0].Points.DataBindXY(Meses, Ganancias); } else { // MessageBox.Show("NO EXISTEN DATOS PARA MOSTRAR GRAFICAS!", "ESTADISTICAS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show("FALLO LA CONEXION CON LA BASE DE DATOS!" + "\n" + ex.ToString(), "ESTADISTICAS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } conexion.Close(); }
private void btnGenerar_Click(object sender, EventArgs e) { double precioOriginal = 0; double precioActualizado = 0; if (txtPrice.Text == "") { MessageBox.Show("INGRESAR UN VALOR PARA CANCELAR DEUDA"); } else { double aux = double.Parse(txtPrice.Text.ToString()); try { string cadena = "SELECT C.nitCliente, C.nombres, C.apellidos,FACENCCRED.idFacturaEncabezadoCredito, FACENCCRED.serie, FACENCCRED.fecha, TC.nombre, TC.cantidadDias, FACENCCRED.total FROM CLIENTE C, FACTURAENCABEZADOCREDITO FACENCCRED, TIPOCREDITO TC WHERE FACENCCRED.nitCliente = C.nitCliente AND FACENCCRED.idTipoCredito = TC.idTipoCredito AND FACENCCRED.estatus = false AND C.nitCliente = " + int.Parse(cmbCode.Text) + " AND FACENCCRED.idFacturaEncabezadoCredito = " + int.Parse(textBox1.Text.ToString()) + "; "; OdbcCommand cma = new OdbcCommand(cadena, cn.nuevaConexion()); OdbcDataReader reader = cma.ExecuteReader(); while (reader.Read()) { precioOriginal = reader.GetDouble(8); //MessageBox.Show("ORIGINAL: " + reader.GetDouble(8)); } } catch (Exception ex) { MessageBox.Show("ERROR AL MOSTRAR DATOS AL DATAGRIDVIEW ORIGINALL " + ex); } precioActualizado = precioOriginal - aux; if (precioActualizado == 0) { try { string Modificar = "UPDATE FACTURAENCABEZADOCREDITO SET estatus = true WHERE idFacturaEncabezadoCredito=" + Int32.Parse(textBox1.Text); OdbcCommand Consulta = new OdbcCommand(Modificar, cn.nuevaConexion()); OdbcDataReader leer = Consulta.ExecuteReader(); MessageBox.Show("Ha realizado todos los pagos correspondientes a esta factura"); } catch (Exception ex) { MessageBox.Show("No se pudieron mostrar los registros en este momento intente mas tarde" + ex); } } // MessageBox.Show("ACTUALIZADO: " + precioActualizado); try { string Modificar = "UPDATE FACTURAENCABEZADOCREDITO SET total = '" + precioActualizado + "' WHERE idFacturaEncabezadoCredito=" + Int32.Parse(textBox1.Text); OdbcCommand Consulta = new OdbcCommand(Modificar, cn.nuevaConexion()); OdbcDataReader leer = Consulta.ExecuteReader(); MessageBox.Show("Los datos fueron actualizados correctamente "); actualizar(); } catch (Exception ex) { MessageBox.Show("No se pudieron mostrar los registros en este momento intente mas tarde" + ex); } } }
public Component FindComponentById(int componentId, OdbcConnection connection) { ComponentDto componentDto; var commandText = $"SELECT {Components.Quantity}, {Components.IngredientId}, {Components.UnitId} FROM {Components.TableName} WHERE {Components.Id} = {componentId};"; var command = new OdbcCommand(commandText, connection); using (OdbcDataReader reader = command.ExecuteReader()) { if (!reader.Read()) { throw new ComponentIdNotFoundOdbcDataException(componentId); } componentDto = new ComponentDto { Id = componentId, IngredientId = reader.GetInt32(1), Quantity = reader.GetDouble(0), UnitId = reader.GetInt32(2) }; } Ingredient ingredient = ingredientDataProvider.FindIngredientById(componentDto.IngredientId, connection); Unit unit = unitDataProvider.FindUnitById(componentDto.UnitId, connection); return(new Component( id: componentDto.Id, ingredient: ingredient, quantity: componentDto.Quantity, unit: unit )); }
//Funcion para agregar una nueva cuenta contable a la tabla de cuentas contables public bool funcSaldoOk(int Codigo, double Cantidad) { string Sql = "SELECT SALDO_ACTUAL_CUENTA_CONTABLE FROM CUENTA_CONTABLE WHERE PK_ID_CUENTA_CONTABLE=" + Codigo + ";"; try { OdbcCommand Command = new OdbcCommand(Sql, Con.conexion()); OdbcDataReader Reader = Command.ExecuteReader(); if (Reader.Read()) { if (Reader.GetDouble(0) >= Cantidad) { return(true); } else { return(false); } } else { return(false); } } catch (Exception Ex) { Console.WriteLine(Ex.Message.ToString() + " \nError en asignarCombo, revise los parametros \n -\n -"); return(false); } }
public Tuple <string, double, int> funcObtenerDatoPolDet(int CodigoPoliza, int CodigoCuenta) { int Debe = 0; string Cuenta = ""; double Monto = 0; try { string Buscar = "SELECT C.NOMBRE_CUENTA_CONTABLE, P.MONTO_POLIZA_DETALLE, P.DEBE_POLIZA_DETALLE FROM CUENTA_CONTABLE C" + ",POLIZA_DETALLE P WHERE C.PK_ID_CUENTA_CONTABLE=P.PK_ID_CUENTA_CONTABLE AND P.PK_POLIZA_ENCABEZADO=" + CodigoPoliza + " AND P.PK_ID_CUENTA_CONTABLE=" + CodigoCuenta; OdbcCommand Comm = new OdbcCommand(Buscar, Con.conexion()); OdbcDataReader Reader = Comm.ExecuteReader(); if (Reader.Read()) { Debe = Reader.GetInt32(2); Cuenta = Reader.GetString(0); Monto = Reader.GetDouble(1); } return(Tuple.Create(Cuenta, Monto, Debe)); } catch (Exception Ex) { Console.WriteLine(Ex.Message.ToString() + " \nError en asignarCombo, revise los parametros \n -\n -"); return(Tuple.Create(Cuenta, Monto, Debe)); } }
private void totalCredito() { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT SUM(TOTAL_FACTURA) FROM FACTURA WHERE ESTADO_TUPLA = TRUE AND ESTADO_FACTURA = 1 AND TIPO_FACTURA = 'CREDITO' AND FECHA_EMISION_FACTURA >= curdate();"); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { if (reader.IsDBNull(0)) { label6.Text = "0"; } else { credito = reader.GetDouble(0); label6.Text = string.Format("Q.{0:###,###,###,##0.00##}", credito); } } else { label6.Text = "0"; } } catch (Exception ex) { MessageBox.Show("FALLO LA CONEXION CON LA BASE DE DATOS!" + "\n" + ex.ToString(), "ESTADISTICAS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } conexion.Close(); }
//JOSUE AXEL TOMA LOS DATOS DE LA BD Y LOS ASIGNA EN VARIABLES LOCALES public void llenar_datos() { int i = 0; OdbcConnection conexion = TaquillaDB.getDB(); try { string sql = string.Format("SELECT PRECIO_TIPO FROM TIPO;"); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { precio_tipo[i] = precio_boleto * reader.GetDouble(0); if (i == 0) { Lbl_precioAdulto.Text = "Q" + Convert.ToString(precio_tipo[i]); } else if (i == 1) { Lbl_precioNinio.Text = "Q" + Convert.ToString(precio_tipo[i]); } else if (i == 2) { Lbl_precio3ra.Text = "Q" + Convert.ToString(precio_tipo[i]); } i++; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); this.Close(); } conexion.Close(); }
private void cargaCreditos() { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("select sum(total_factura) from caja_facturas where tipo_factura = 'CREDITO' and id_caja = {0};", codigoCaja); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { if (reader.IsDBNull(0)) { label10.Text = string.Format("Q.{0:###,###,###,##0.00##}", 0); } else { label10.Text = string.Format("Q.{0:###,###,###,##0.00##}", reader.GetDouble(0)); } conexion.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } conexion.Close(); }
public static List <StaticGoods> getList(OdbcDataReader reader) { List <StaticGoods> list = new List <StaticGoods>(); StaticGoods s; while (reader.Read()) { s = new StaticGoods(); s.G_ID = reader.GetString(0); s.Date = reader.GetDate(1); s.Price = reader.GetDouble(2); s.Num = reader.GetDouble(3); list.Add(s); } return(list); }
private void cmbCodigoCuenta_SelectedIndexChanged(object sender, EventArgs e) { try { //Se obtine el monto actual de la cuenta string Banco = "SELECT * FROM CUENTA_BANCARIA WHERE pk_id_numero_cuenta_bancaria = " + Int32.Parse(cmbCodigoCuenta.SelectedItem.ToString()); OdbcCommand ComandBanco = new OdbcCommand(Banco, cn.conexion()); OdbcDataReader MostarBanco = ComandBanco.ExecuteReader(); while (MostarBanco.Read()) { txtSaldoActual.Text = (MostarBanco.GetDouble(4)).ToString(); try { //al obetener el saldo actual de la cuenta se verifica si se puede convertir a un tipo float, si no se puede convertir el saldo esta almacenado incorrectamente float.Parse(txtSaldoActual.Text.ToString()); SaldoActual = float.Parse(txtSaldoActual.Text.ToString()); } catch (Exception ex) { MessageBox.Show("Error al obtener el saldo actual de la cuenta bancaria, verifique que el numero almacenado sea valido", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show("Error al obtener Datos" + ex); } }
//funcion para obtener todos los encabezados public Tuple <int, DateTime, string, double> funcObtenerDatoPolEnc(int Codigo) { int CodigoEnc = 0; DateTime Fecha = DateTime.Now; string Descripcion = ""; double Monto = 0; try { string Buscar = "SELECT PK_POLIZA_ENCABEZADO, FECHA_POLIZA_ENCABEZADO, DESCRIPCION_POLIZA_ENCABEZADO, TOTAL_POLIZA_ENCABEZADO" + " FROM POLIZA_ENCABEZADO WHERE PK_POLIZA_ENCABEZADO=" + Codigo; OdbcCommand Comm = new OdbcCommand(Buscar, Con.conexion()); OdbcDataReader Reader = Comm.ExecuteReader(); if (Reader.Read()) { CodigoEnc = Reader.GetInt32(0); Fecha = Reader.GetDateTime(1); Descripcion = Reader.GetString(2); Monto = Reader.GetDouble(3); } return(Tuple.Create(CodigoEnc, Fecha, Descripcion, Monto)); } catch (Exception Ex) { Console.WriteLine(Ex.Message.ToString() + " \nError en asignarCombo, revise los parametros \n -\n -"); return(Tuple.Create(CodigoEnc, Fecha, Descripcion, Monto)); } }
private void ganancias() { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT * FROM GANANCIAS;"); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { if (reader.IsDBNull(0)) { label8.Text = "0"; } else { double totalParcial = reader.GetDouble(0); double totalVenta = efectivo + credito; ganancia = totalVenta - totalParcial; label8.Text = string.Format("Q.{0:###,###,###,##0.00##}", ganancia); } } else { label8.Text = "0"; } } catch (Exception ex) { MessageBox.Show("FALLO LA CONEXION CON LA BASE DE DATOS!" + "\n" + ex.ToString(), "ESTADISTICAS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } conexion.Close(); }
void read() { OdbcDataReader reader = this.AccessDb(); while (reader.Read()) { artikellist.Add(new Article { id = (uint)reader.GetInt32(0), name = reader.GetString(1), description = reader.GetString(2), size = reader.GetString(3), color = reader.GetString(4), menge = (uint)reader.GetInt32(5), Price = reader.GetDouble(6) }) ; ReadArticles(); } foreach (Article a in artikellist) { Console.WriteLine(a); } odbcConnection.Close(); }
public Impuesto obtenerImpuestos(int id_impuesto) { Impuesto impuesto = new Impuesto(); try { string sComando = string.Format( "SELECT tasa_impuesto " + "FROM impuestos " + "WHERE id_impuesto = {0};", id_impuesto); OdbcDataReader reader = transaccion.ConsultarDatos(sComando); if (reader.HasRows) { while (reader.Read()) { impuesto.TASA_IMPUESTO = reader.GetDouble(0); } } return(impuesto); } catch (OdbcException ex) { mensaje = new Mensaje("Error en la operacion con la Base de Datos: \n" + ex.Message); mensaje.Show(); return(null); } }
private void algoritmoRecalculo(string codigo, string sucursal, double cantidad) { OdbcConnection conexion = ASG_DB.connectionResult(); try { string sql = string.Format("SELECT ID_CLASIFICACION, TOTAL_UNIDADES, ID_SUCURSAL FROM MERCADERIA WHERE ID_MERCADERIA = '{0}' AND ID_SUCURSAL = (SELECT ID_SUCURSAL FROM SUCURSAL WHERE NOMBRE_SUCURSAL = '{1}' LIMIT 1);", codigo, sucursal); OdbcCommand cmd = new OdbcCommand(sql, conexion); OdbcDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { //MessageBox.Show(reader.GetString(0) + " " +reader.GetDouble(1) + " " +reader.GetString(1)); recalculaStock(reader.GetString(0), reader.GetDouble(1), reader.GetString(2), codigo, cantidad); } else { // MessageBox.Show("erroneo"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } conexion.Close(); }
public static List <Orderlist> getList(OdbcDataReader reader) { List <Orderlist> list = new List <Orderlist>(); Orderlist s; while (reader.Read()) { s = new Orderlist(); s.O_ID = reader.GetString(0); s.G_ID = reader.GetString(1); s.Price = reader.GetDouble(2); s.Num = reader.GetDouble(3); s.Discount = reader.GetDouble(4); list.Add(s); } return(list); }
//obtener datos para el datagrid de detalle de movimiento public List <MovimientoDetalle> llenarDGVMovimientoDetalle(int id_movimiento_inventario_encabezado) { SQL_Producto producto = new SQL_Producto(); List <MovimientoDetalle> movimientoDetalleList = new List <MovimientoDetalle>(); try { string sComando = string.Format("" + "SELECT " + "id_movimiento_inventario_detalle, " + "id_producto, " + "cantidad_movimiento, " + "costo_producto, " + "precio_producto " + "FROM movimientos_inventario_detalle " + "WHERE id_movimiento_inventario_encabezado = {0}; ", id_movimiento_inventario_encabezado); OdbcDataReader reader = transaccion.ConsultarDatos(sComando); if (reader.HasRows) { while (reader.Read()) { MovimientoDetalle movimientoDetalleTmp = new MovimientoDetalle(); movimientoDetalleTmp.ID_MOVIMIENTO_INVENTARIO_DETALLE = reader.GetInt32(0); movimientoDetalleTmp.PRODUCTO = producto.obtenerProducto(reader.GetInt32(1)); movimientoDetalleTmp.CANTIDAD = reader.GetInt32(2); movimientoDetalleTmp.COSTO = reader.GetDouble(3); movimientoDetalleTmp.PRECIO = reader.GetDouble(4); movimientoDetalleList.Add(movimientoDetalleTmp); } } return(movimientoDetalleList); } catch (OdbcException ex) { mensaje = new Mensaje("Error en la operacion con la Base de Datos: \n" + ex.Message); mensaje.Show(); return(null); } return(null); }
//ADD public static bool AddOrder(Order order, List <Orderlist> ol)//order属性E_ID传递进来,其他不用 { //系统自动生成订单号 order.ID = IDFormat.getID_Date16(); double o_price = 0; order.Time = DateTime.Now.Date; //先行插入order string sqlorder = String.Format("insert into `marketmanage`.`order` (`O_ID`, `O_Price`, `O_time`, `E_ID`) " + "values ('{0}','{1}','{2}','{3}')", order.ID, o_price, order.Time, order.E_ID); ExecuteSQL.ExecuteNonQuerySQL_GetBool(sqlorder); //插入订单列表 foreach (Orderlist orderlist in ol) { //根据ID查询商品价格 string sql1 = "select G_Price from Goods where G_ID='" + orderlist.G_ID + "'"; OdbcConnection odbcConnection = DBManager.GetOdbcConnection(); odbcConnection.Open(); OdbcCommand odbcCommand = new OdbcCommand(sql1, odbcConnection); OdbcDataReader odbcDataReader = odbcCommand.ExecuteReader(CommandBehavior.CloseConnection); odbcDataReader.Read(); orderlist.Price = odbcDataReader.GetDouble(0); odbcConnection.Close(); //orderlist string sql = "INSERT INTO `marketmanage`.`orderlist` (`O_ID`, `G_ID`, `OL_Price`, `OL_Num`, `OL_Discount`) " + "VALUES" + " ('" + order.ID + "', '" + orderlist.G_ID + "','" + orderlist.Price + "', '" + orderlist.Num + "', '" + orderlist.Discount + "')"; ExecuteSQL.ExecuteNonQuerySQL_GetBool(sql); //更新商品表库存 string sql_goods = "update goods set G_Store=G_Store-" + orderlist.Num + " where G_ID='" + orderlist.G_ID + "'"; ExecuteSQL.ExecuteNonQuerySQL_GetBool(sql_goods); //更新库存表 string sql_store = "select * from storelist where G_ID='" + orderlist.G_ID + "'";// order by SL_ProduceDate desc";//升序输出结果集 odbcConnection = DBManager.GetOdbcConnection(); odbcConnection.Open(); odbcCommand = new OdbcCommand(sql_store, odbcConnection); odbcDataReader = odbcCommand.ExecuteReader(); odbcDataReader.Read(); string gi_id = odbcDataReader.GetString(1); string sql_storee = "update storelist set SL_Num=SL_Num-" + orderlist.Num + " where G_ID='" + orderlist.G_ID + "' and GI_ID='" + gi_id + "'"; odbcCommand = new OdbcCommand(sql_storee, odbcConnection); odbcConnection.Close(); //更新商品统计表 StatisticGoods_C.AddData(orderlist.G_ID, orderlist.Num, orderlist.Price); //订单金额 o_price += orderlist.Price; } //更新销售统计表 StatisticDay_C.AddData(o_price); //更新订单价格(whole) string sqlorder_p = "update `marketmanage`.`order` set `O_Price`=" + o_price + " where O_ID='" + order.ID + "'"; return(ExecuteSQL.ExecuteNonQuerySQL_GetBool(sqlorder_p)); }
public static List <Supplier_List_Goods> GetSupplierAndLists(OdbcDataReader reader) { List <Supplier_List_Goods> list = new List <Supplier_List_Goods>(); Supplier_List_Goods s; while (reader.Read()) { s = new Supplier_List_Goods(); s.S_ID = reader.GetString(0); s.S_Name = reader.GetString(1); s.G_ID = reader.GetString(2); s.G_Name = reader.GetString(3); s.SL_Price = reader.GetDouble(4); s.G_Price = reader.GetDouble(5); s.G_Store = reader.GetDouble(6); list.Add(s); } return(list); }
public static List <GoodsIn> getList(OdbcDataReader reader) { List <GoodsIn> list = new List <GoodsIn>(); GoodsIn s; while (reader.Read()) { s = new GoodsIn(); s.GI_ID = reader.GetString(0); s.G_ID = reader.GetString(1); s.S_ID = reader.GetInt32(2); s.PriceIn = reader.GetDouble(3); s.Num = reader.GetDouble(4); s.Date = reader.GetDate(5); s.OriginPlace = reader.GetString(6); list.Add(s); } return(list); }
private void marca() { if (string.IsNullOrWhiteSpace(txt_precio1.Text)) { MessageBox.Show("Campo obligatorio vacío", "Campo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Cambiando precio..."); string scad = "select * from producto where id_marca = " + codmarca; OdbcCommand mcd = new OdbcCommand(scad, Conexion.ObtenerConexion()); OdbcDataReader mdr = mcd.ExecuteReader(); int j = 1; string scad4 = "DELETE FROM precio where id_marca=" + codmarca + " and id_tipo = " + codtipo; OdbcCommand mcd4 = new OdbcCommand(scad4, Conexion.ObtenerConexion()); OdbcDataReader mdr4 = mcd4.ExecuteReader(); while (mdr.Read()) { codp = mdr.GetInt16(0); float costo = Convert.ToInt32(mdr.GetDouble(4)); float costo2 = Convert.ToInt32(txt_precio1.Text); float mult = costo * (costo2 / 100); float total = mult + (Convert.ToInt32(costo)); string scad3 = "SELECT id_categoria from producto where id_producto = '" + codp + "'"; OdbcCommand mcd3 = new OdbcCommand(scad3, Conexion.ObtenerConexion()); OdbcDataReader mdr3 = mcd3.ExecuteReader(); if (mdr3.Read()) { codc = mdr3.GetInt16(0); } OdbcCommand mcd2 = new OdbcCommand( string.Format("insert into precio (precio, id_bien, id_tipo, id_marca, id_categoria) values ('{0}','{1}','{2}','{3}','{4}')", total, codp, codtipo, codmarca, codc), Conexion.ObtenerConexion()); OdbcDataReader mdr2 = mcd2.ExecuteReader(); j++; costo = 0; costo2 = 0; mult = 0; total = 0; codm = 0; codc = 0; codp = 0; } MessageBox.Show("Precios modificados... presione Actualizar"); codtipo = 0; } }