private void actualizacionMasiva() { try { ConectarBD objConect = new ConectarBD(); String usuario = Properties.Settings.Default.UsuarioLogueado.ToString(); String cadenaSql = ""; cadenaSql = "exec dbo.adp_actualizacionMasiva_Articulo "; //============================================================================================================ //ID RUBRO - ID RUBRO - ID RUBRO - ID RUBRO - ID RUBRO - ID RUBRO - ID RUBRO - ID RUBRO - ID RUBRO - ID RUBRO //============================================================================================================ if (cboRubro.Text.ToUpper() == "[TODOS]") { cadenaSql = cadenaSql + " @Articulo_IdRubro = null"; } else { cadenaSql = cadenaSql + " @Articulo_IdRubro = " + obtenerIdRubro().ToString(); } //============================================================================================================ //============================================================================================================ //PRECIOCV - PRECIOCV - PRECIOCV - PRECIOCV - PRECIOCV - PRECIOCV - PRECIOCV - PRECIOCV - PRECIOCV - PRECIOCV //============================================================================================================ if (cboPrecioCV.Text.ToUpper() == "VENTA") { cadenaSql = cadenaSql + " , @Articulo_Precio_CV = 1"; } else { cadenaSql = cadenaSql + " , @Articulo_Precio_CV = 0"; } //============================================================================================================ //============================================================================================================ //TIPO ACTUALIZACIÓN - TIPO ACTUALIZACIÓN - TIPO ACTUALIZACIÓN - TIPO ACTUALIZACIÓN - TIPO ACTUALIZACIÓN - TIPO //============================================================================================================ if (RBporcentaje.Checked) { cadenaSql = cadenaSql + " , @Articulo_TipoAct = 1"; } //ACTUALIZACIÓN POR PORCENTAJE else { cadenaSql = cadenaSql + " , @Articulo_TipoAct = 0"; } //ACTUALIZACIÓN POR VALOR //============================================================================================================ //============================================================================================================ //SUMA O RESTA - SUMA O RESTA - SUMA O RESTA - SUMA O RESTA - SUMA O RESTA - SUMA O RESTA - SUMA O RESTA - SUMA //============================================================================================================ if (cboAumentarDisminuir.Text.ToUpper() == "AUMENTAR") { cadenaSql = cadenaSql + " , @Articulo_SumaResta = 1"; } else { cadenaSql = cadenaSql + " , @Articulo_SumaResta = 0"; } //============================================================================================================ //============================================================================================================ //VALOR - VALOR - VALOR - VALOR - VALOR - VALOR - VALOR - VALOR - VALOR - VALOR - VALOR - VALOR - VALOR - VALOR //============================================================================================================ cadenaSql = cadenaSql + " , @Articulo_Valor = " + txtPrecioPorcentaje.Text; //============================================================================================================ //============================================================================================================ //USUARIO - USUARIO - USUARIO - USUARIO - USUARIO - USUARIO - USUARIO - USUARIO - USUARIO - USUARIO - USUARIO //============================================================================================================ if (usuario != "") { cadenaSql = cadenaSql + " , @Articulo_Login = "******"String"); } //============================================================================================================ objConect.ejecutarQuery(cadenaSql); MessageBox.Show("Actualización finalizada Correctamente.", "Actualización Masiva Artículos", MessageBoxButtons.OK, MessageBoxIcon.Information); limpiarCampos(); } catch (Exception r) { MessageBox.Show(r.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//internal List<Venta> obtenerVentas(DateTime Fecha) internal DataSet obtenerVentas (DateTime Fecha) { try { String cadenaSql = ""; DataSet Ds = new DataSet(); ConectarBD objConect = new ConectarBD(); FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); //List<Venta> VentasDelDia = new List<Venta>(); cadenaSql = "EXEC dbo.adp_obtener_ventas @d_16_fecha = " + fg.fcSql(Fecha.ToString(), "DATETIME"); Ds = objConect.ejecutarQuerySelect(cadenaSql); return Ds; //foreach(DataRow dataRow in Ds.Tables[0].Rows) //{ // Venta venta = new Venta(); // // venta.id = Int32.Parse(dataRow["ID_VENTA"].ToString()); // venta.cantidad_Articulos = Int32.Parse(dataRow["CANTIDAD_ARTICULOS"].ToString()); // venta.importe = double.Parse(dataRow["IMPORTE"].ToString()); // venta.fecha_Venta = DateTime.Parse(dataRow["FECHA_VENTA"].ToString()); // venta.hora_Venta = dataRow["HORA_VENTA"].ToString(); // // VentasDelDia.Add(venta); //} //return VentasDelDia; } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public Double obtenerCajaActual(DateTime fecha) { try { FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); ConectarBD con = new ConectarBD(); DataSet Ds = new DataSet(); Double importe = 0.00; String sSQL = ""; sSQL = "EXEC dbo.adp_ObtenerCajaActual"; sSQL = sSQL + " @fecha_mov = " + fg.fcSql(fecha.ToString(), "DATETIME"); Ds.Reset(); Ds = con.ejecutarQuerySelect(sSQL); if (Ds.Tables[0].Rows.Count > 0) { importe = Double.Parse(Ds.Tables[0].Rows[0]["TOTAL"].ToString()); } return importe; } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
internal void eliminarTipoMovCaja(int id_TipoMovCaja) { try { ConectarBD Conex = new ConectarBD(); String sSQL = "EXEC dbo.adp_eliminarTipoMovCaja @ID_TIPOMOVIMIENTO = " + id_TipoMovCaja; Conex.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
internal void eliminarTipoMovCajaDeHoy(int Id_TipoMovCaja, DateTime Fecsis) { try { ConectarBD Conex = new ConectarBD(); String sSQL = "EXEC dbo.adp_eliminarMovCajaPorFecha "; sSQL = sSQL + " @ID_TIPOMOVIMIENTO = " + Id_TipoMovCaja; sSQL = sSQL + " ,@FECHA_MOV = " + fg.fcSql(Fecsis.ToString(),"DATETIME"); Conex.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void modificarEstadoGlobalSistema(Int32 EstadoNuevo) { try { ConectarBD con = new ConectarBD(); String sSQL; sSQL = "exec adp_actualizar_estado_global @estado = " + EstadoNuevo.ToString(); con.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void modificarFechaSistema(DateTime fechaSistema) { try { ConectarBD con = new ConectarBD(); String sSQL; sSQL = "exec adp_FecSis @FECHA = " + fg.fcSql(fechaSistema.ToString(),"DATETIME"); con.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void actualizaMovimientoVentas(DateTime Fecha) { try { ConectarBD Conex = new ConectarBD(); String sSQL = ""; sSQL = "EXEC dbo.adp_ActualizarMovimientosCaja_Venta "; sSQL = sSQL + " @FECHA = " + fg.fcSql(Fecha.ToString(), "Datetime"); Conex.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public DateTime appFechaSistema() { try { ConectarBD Conex = new ConectarBD(); FuncionesGenerales fg = new FuncionesGenerales(); DataSet Ds = new DataSet(); String ssQL = "EXEC dbo.adp_FecSis"; Ds = Conex.ejecutarQuerySelect(ssQL); return DateTime.Parse(Ds.Tables[0].Rows[0]["FECHA_SISTEMA"].ToString()); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void guardarArticuloVentaTemporal() { try { ConectarBD Conex = new ConectarBD(); String sSQL; sSQL = "EXEC dbo.adp_insertarArticuloVenta_Temporal "; sSQL = sSQL + " @Id_Articulo = 1"; sSQL = sSQL + " ,@Cantidad = " + fg.fcSql(cantidad.ToString(), "INTEGER"); sSQL = sSQL + " ,@Importe = " + txtImporte.Text; Conex.ejecutarQuery(sSQL); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
public DataSet obtenerCamposMovimientosCaja() { try { ConectarBD con = new ConectarBD(); DataSet ds = new DataSet(); FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); String cadenaSql = ""; cadenaSql = "EXEC adp_cbobusqueda_movimientos_caja"; ds = con.ejecutarQuerySelect(cadenaSql); return ds; } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
internal void eliminarTipoMovCaja(int id_TipoMovCaja) { try { ConectarBD Conex = new ConectarBD(); string usuario = Properties.Settings.Default.UsuarioLogueado.ToString(); String sSQL = "EXEC dbo.adp_eliminarTipoMovCaja @ID_TIPOMOVIMIENTO = " + id_TipoMovCaja; if (usuario != "") { sSQL = sSQL + ",@TipoMovCaja_Login = "******"String"); } Conex.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
private void obtenerCodigoNuevoMovimiento() { try { String cadenaSql = "EXEC adp_maximo_TipoMovimiento_Caja"; ConectarBD Conex = new ConectarBD(); DataSet Ds = new DataSet(); Ds = Conex.ejecutarQuerySelect(cadenaSql); if (Ds.Tables[0].Rows.Count > 0) { txtCodigo.Text = Ds.Tables[0].Rows[0]["MAXIMO"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void modificarCajaInicial(DateTime Fecha, String Valor) { try { FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); ConectarBD con = new ConectarBD(); String sSQL; sSQL = "exec adp_modificarCajaInicial "; sSQL = sSQL + " @fecha = " + fg.fcSql(Fecha.ToString(), "DATETIME"); sSQL = sSQL + " ,@Valor = " + fg.fcSql(Valor, "DOUBLE"); con.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException(e.Message.ToString()); } }
public DataSet obtenerMovimientosCaja(DateTime fecha) { try { ConectarBD con = new ConectarBD(); DataSet Ds = new DataSet(); FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); String sSQL = ""; sSQL = "EXEC dbo.adp_ObtenerMovimientosCaja @fecha_mov = " + fg.fcSql(fecha.ToString(),"DATETIME"); Ds.Reset(); Ds = con.ejecutarQuerySelect(sSQL); return Ds; } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
internal DataSet obtenerTiposMovimientosCaja() { try { ConectarBD con = new ConectarBD(); DataSet Ds = new DataSet(); FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); String sSQL = ""; sSQL = "EXEC dbo.adp_obtenerTiposMovsCaja"; Ds.Reset(); Ds = con.ejecutarQuerySelect(sSQL); return Ds; } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
private void altaMovimientoCaja() { try { String Usuario = Properties.Settings.Default.UsuarioLogueado.ToString(); ConectarBD Conex = new ConectarBD(); TimeSpan hora = System.DateTime.Now.TimeOfDay; String Hora = hora.ToString().Substring(0, 8); String CadenaSql = "EXEC adp_nuevo_TipoMovCaja"; CadenaSql = CadenaSql + " @TIPOMOVCAJA_ID = " + txtCodigo.Text.ToString() ; CadenaSql = CadenaSql + " ,@TIPOMOVCAJA_DESC = " + fg.fcSql(txtTipoMovimiento.Text.Trim(), "STRING"); CadenaSql = CadenaSql + " ,@TIPOMOVCAJA_FECHA = " + fg.fcSql(fg.appFechaSistema().ToString(), "STRING"); CadenaSql = CadenaSql + " ,@TIPOMOVCAJA_HORA = " + fg.fcSql(Hora, "STRING"); CadenaSql = CadenaSql + " ,@TIPOMOVCAJA_LOGIN = "******"STRING"); switch (cboEntradaSalida.Text) { case "INGRESO": CadenaSql = CadenaSql + " ,@TIPOMOVCAJA_ES = 1"; break; case "SALIDA": CadenaSql = CadenaSql + " ,@TIPOMOVCAJA_ES = 0"; break; default: throw new System.ArgumentException("Error alta Tipo Movimiento Caja - Ingreso/Salida"); } Conex.ejecutarQuery(CadenaSql); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public string obtenerFechaCajaAbierta() { try { ConectarBD con = new ConectarBD(); DataSet dataSet = new DataSet(); string ssQL; ssQL = "exec adp_obtener_ultimaFechaCajaAbierta"; dataSet.Reset(); dataSet = con.ejecutarQuerySelect(ssQL); if (dataSet.Tables[0].Rows.Count == 0) { throw new System.ArgumentException("No se pudo obtener la última fecha de caja abierta. Consulte con el administrador.", "Estado del sistema"); } return (dataSet.Tables[0].Rows[0]["FechaCajaAbierta"].ToString()); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
private void llenarTablaTemporal() { try { ConectarBD Conex = new ConectarBD(); String sSQL; sSQL = "EXEC dbo.adp_InsertaTodosLosArticulosDeVenta_Temporal "; sSQL = sSQL + " @Id_Venta= " + fg.fcSql(this.Venta.m_Id_Venta.ToString(), "INTEGER"); Conex.ejecutarQuery(sSQL); } catch (Exception) { } }
private void guardarArticuloVentaTemporal() { try { ConectarBD Conex = new ConectarBD(); String sSQL; sSQL = "EXEC dbo.adp_insertarArticuloVenta_Temporal "; sSQL = sSQL + " @Id_Articulo = " + fg.fcSql(txtCodigoArticulo.Text, "INTEGER"); sSQL = sSQL + " ,@Cantidad = " + fg.fcSql(txtCantidad.Text, "INTEGER"); Conex.ejecutarQuery(sSQL); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
private void cargarArticulosEnGrilla() { try { ConectarBD Conex = new ConectarBD(); DataSet DsArticulosVenta = new DataSet(); String sSQL; DataGridView aux = new DataGridView(); sSQL = "EXEC dbo.adp_obtenerArticulosVenta_Temporal "; DsArticulosVenta = Conex.ejecutarQuerySelect(sSQL); if (DsArticulosVenta.Tables[0].Rows.Count > 0) { if (grdItemsVenta.Rows.Count != 0) { aux.DataSource = grdItemsVenta.DataSource; } grdItemsVenta.DataSource = null; grdItemsVenta = fg.agregarBotones(grdItemsVenta, "SELECCIONAR"); grdItemsVenta.DataSource = DsArticulosVenta.Tables[0]; for (int i = 0; i <= grdItemsVenta.Rows.Count - 1; i++) { grdItemsVenta.Rows[i].Cells["SELECCIONAR"].ReadOnly = false; } } else { grdItemsVenta = fg.eliminarBotones(grdItemsVenta, "SELECCIONAR"); grdItemsVenta.DataSource = null; } actualizarPrecioTotalVenta(); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
public void guardarVentaYSusArticulos() { try { ConectarBD Conex = new ConectarBD(); String Hora = System.DateTime.Now.TimeOfDay.ToString().Substring(0, 8); String sSQL; String login = Properties.Settings.Default.UsuarioLogueado.ToString(); sSQL = "EXEC dbo.adp_insertarVentaYArticulos "; sSQL = sSQL + " @FECHA_VENTA = " + fg.fcSql(fg.appFechaSistema().ToString(), "DATETIME"); sSQL = sSQL + " ,@HORA_VENTA = " + fg.fcSql(Hora, "STRING"); if (login != "") { sSQL = sSQL + " ,@USUARIO_VENTA = " + fg.fcSql(login, "String"); } Conex.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void cargarArticulosVenta() { try { ConectarBD conect = new ConectarBD(); DataSet dataSet = new DataSet(); String sSQL; sSQL = "EXEC dbo.adp_obtenerArticulosVenta2 "; sSQL = sSQL + " @Id_Venta = " + fg.fcSql(this.m_Id_Venta.ToString(), "INTEGER"); dataSet = conect.ejecutarQuerySelect(sSQL); this.m_articulos_venta = new List<Articulo_Venta>(); foreach (DataRow dataRow in dataSet.Tables[0].Rows) { Articulo_Venta articulo_venta = new Articulo_Venta(); articulo_venta.m_id_venta = UInt64.Parse(dataRow["ID_VENTA"].ToString()); articulo_venta.m_id_item_venta = UInt64.Parse(dataRow["ID_ITEM_VENTA"].ToString()); articulo_venta.m_id_articulo = UInt64.Parse(dataRow["ID_ARTICULO"].ToString()); articulo_venta.m_cantidad = Int32.Parse(dataRow["CANTIDAD"].ToString()); articulo_venta.m_precio_venta = Double.Parse(dataRow["PRECIO_VENTA"].ToString()); this.m_articulos_venta.Add(articulo_venta); } } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void borrarArticulosVenta_Temporal() { try { ConectarBD Conex = new ConectarBD(); String sSQL; sSQL = "EXEC dbo.adp_BorrarArticulosVenta_Temporal"; Conex.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void cargarDatosVenta() { try { ConectarBD conect = new ConectarBD(); DataSet dataSet = new DataSet(); String sSQL; sSQL = "EXEC dbo.adp_obtenerDatosVenta "; sSQL = sSQL + " @Id_Venta = " + fg.fcSql(this.m_Id_Venta.ToString(), "INTEGER"); dataSet = conect.ejecutarQuerySelect(sSQL); foreach (DataRow dataRow in dataSet.Tables[0].Rows) { Articulo_Venta articulo_venta = new Articulo_Venta(); this.m_cantidad_articulos = Int32.Parse(dataRow["CANTIDAD_ARTICULOS"].ToString()); this.m_importe = Double.Parse(dataRow["IMPORTE"].ToString()); this.m_estado = Int32.Parse(dataRow["ESTADO"].ToString()); this.m_fecha_venta = DateTime.Parse(dataRow["FECHA_VENTA"].ToString()); this.m_hora_venta = dataRow["HORA_VENTA"].ToString(); this.cargarArticulosVenta(); } } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
internal void actualizarVenta(UInt64 id_venta) { try { ConectarBD Conex = new ConectarBD(); String sSQL; String login = Properties.Settings.Default.UsuarioLogueado.ToString(); sSQL = "EXEC dbo.adp_modificarVenta "; sSQL = sSQL + " @Id_Venta = " + fg.fcSql(id_venta.ToString(), "INTEGER"); if (login != "") { sSQL = sSQL + " ,@USUARIO_VENTA = " + fg.fcSql(login, "String"); } Conex.ejecutarQuery(sSQL); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
private bool existeTipoMovimientoCaja() { try { ConectarBD Conex = new ConectarBD(); DataSet Ds = new DataSet(); String CadenaSql; CadenaSql = "EXEC adp_verificoExistencia_TipoMovCaja"; CadenaSql = CadenaSql + " @Codigo = " + fg.fcSql(txtCodigo.Text, "INTEGER"); CadenaSql = CadenaSql + " ,@Descripcion = " + fg.fcSql(txtTipoMovimiento.Text, "STRING"); Ds = Conex.ejecutarQuerySelect(CadenaSql); if (Ds.Tables[0].Rows.Count > 0) { MessageBox.Show("Ya existe un Tipo de Movimiento " + fg.fcSql(txtTipoMovimiento.Text, "STRING") + ".", "Alta de Tipo de Movimiento Caja.", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTipoMovimiento.Focus(); return true; } return false; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); return true; } }
public void borrarArticulosVenta_Temporal(UInt64 Id_ItemVenta) { try { ConectarBD Conex = new ConectarBD(); String sSQL; sSQL = "EXEC dbo.adp_BorrarArticulosVenta_Temporal "; sSQL = sSQL + " @Id_ItemVenta = " + fg.fcSql(Id_ItemVenta.ToString(), "INTEGER"); Conex.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public DataSet obtenerGanancia(DateTime fechaDesde, DateTime fechaHasta) { try { ConectarBD con = new ConectarBD(); DataSet ds = new DataSet(); FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); String cadenaSql = ""; cadenaSql = "EXEC adp_obtener_ganancia @FECHA_DESDE = " + fg.fcSql(fechaDesde.ToString(), "DATETIME"); cadenaSql = cadenaSql + ", @FECHA_HASTA = " + fg.fcSql(fechaHasta.ToString(), "DATETIME"); ds = con.ejecutarQuerySelect(cadenaSql); return ds; } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void eliminarVenta(string codigo) { try { ConectarBD Conex = new ConectarBD(); String sSQL = ""; String login = Properties.Settings.Default.UsuarioLogueado.ToString(); sSQL = "EXEC dbo.adp_eliminarVenta "; sSQL = sSQL + " @Id_Venta = " + fg.fcSql(codigo,"INTEGER"); if (login != "") { sSQL = sSQL + " ,@LOGIN = "******"String"); } Conex.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }