public void Cadastrar() { NpgsqlConnection conexao = null; try { conexao = ConectarBD.getConexao(); string sql = "insert into ArmazenarJogo(nomeJogo,preco,quantidade,codigo_cadastro_fk) values" + "('" + this.nomeJogo + "','" + this.preco + "','" + this.quantidade + "','" + this.codigo_cadastro_fk + "')"; NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao); cmd.Parameters.Add(new NpgsqlParameter("@nomeJogo", this.nomeJogo)); cmd.Parameters.Add(new NpgsqlParameter("@marca", this.preco)); cmd.Parameters.Add(new NpgsqlParameter("@preco", this.quantidade)); cmd.Parameters.Add(new NpgsqlParameter("@codigo_cadastro_fk", this.codigo)); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (conexao != null) { conexao.Close(); } } }
public void Cadastrar() { NpgsqlConnection conexao = null; try { conexao = ConectarBD.getConexao(); string sql = "insert into Cadastro(codigo_cadastro,nome,usuario,senha) values" + "('" + this.codigo_cadastro + "','" + this.nome + "','" + this.usuario + "','" + this.senha + "')"; NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao); cmd.Parameters.Add(new NpgsqlParameter("@codigo_cadastro", this.codigo_cadastro)); cmd.Parameters.Add(new NpgsqlParameter("@nome", this.nome)); cmd.Parameters.Add(new NpgsqlParameter("@usuario", this.usuario)); cmd.Parameters.Add(new NpgsqlParameter("@senha", this.senha)); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (conexao != null) { conexao.Close(); } } }
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 bool Entrar() { NpgsqlConnection conexao = null; try { conexao = ConectarBD.getConexao(); String sql = ("Select * from Cadastro where usuario = '" + this.usuario + "' and senha= '" + this.senha + "' and codigo_cadastro= '" + this.codigo_cadastro + "'"); NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao); cmd.Parameters.Add(new NpgsqlParameter("@usuario", this.usuario)); cmd.Parameters.Add(new NpgsqlParameter("@senha", this.senha)); cmd.Parameters.Add(new NpgsqlParameter("@codigo_cadastro", this.codigo_cadastro)); NpgsqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { tem = true; } return(tem); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (conexao != null) { conexao.Close(); } } }
internal int ObtenerId_TipoMovimiento(int Id_Movimiento) { try { FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); ConectarBD con = new ConectarBD(); DataSet Ds = new DataSet(); String sSQL; int ID; sSQL = "exec dbo.adp_obtenerId_TipoMovimientoCaja "; sSQL = sSQL + " @ID_Movimiento = " + Id_Movimiento; Ds.Reset(); Ds = con.ejecutarQuerySelect(sSQL); if (Ds.Tables[0].Rows.Count > 0) { ID = int.Parse(Ds.Tables[0].Rows[0]["ID_TipoMovimiento"].ToString()); } else { throw new System.ArgumentException("Error al intentar obtener el ID tipo Movimiento Caja"); } return(ID); } catch (Exception ex) { throw new System.ArgumentException(ex.Message.ToString()); } }
private void actualizarTipoMovimientoCaja() { try { ConectarBD Conex = new ConectarBD(); String Usuario = Properties.Settings.Default.UsuarioLogueado.ToString(); String sSQL; sSQL = "EXEC dbo.adp_actualizar_TipoMovCaja "; sSQL = sSQL + " @ID_TIPOMOVIMIENTO = " + TipoMovCaja.m_ID_TipoMovimiento; sSQL = sSQL + " ,@DESCRIPCION = " + fg.fcSql(txtDescripcion.Text.Trim(), "STRING"); if (cboEntradaSalida.Text == "INGRESO") { sSQL = sSQL + " ,@INGRESO_SALIDA = 1"; } else { sSQL = sSQL + " ,@INGRESO_SALIDA = 0"; } sSQL = sSQL + " ,@LOGIN_MODIF = " + fg.fcSql(Usuario, "STRING"); Conex.ejecutarQuery(sSQL); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Excluir() { NpgsqlConnection conexao = null; try { conexao = ConectarBD.getConexao(); string sql = "delete from Cadastro where " + " codigo_cadastro" + "=" + this.codigo_cadastro; NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao); cmd.Parameters.Add(new NpgsqlParameter("@codigo_cadastro", this.codigo_cadastro)); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (conexao != null) { conexao.Close(); } } }
public void Atualizar() { NpgsqlConnection conexao = null; try { conexao = ConectarBD.getConexao(); string sql = "update ArmazenarJogo set" + " preco " + " = " + this.preco + " , " + " quantidade " + " = " + this.quantidade + " where " + " codigo " + " = " + this.codigo; NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao); cmd.Parameters.Add(new NpgsqlParameter("@preco", this.preco)); cmd.Parameters.Add(new NpgsqlParameter("@quantidade", this.quantidade)); cmd.Parameters.Add(new NpgsqlParameter("@codigo", this.codigo)); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (conexao != null) { conexao.Close(); } } }
public Double obtenerImporteCajaActual(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.ObtenerImporteCajaActual "; 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 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() + "]"); } }
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() + "]"); } }
private void OpenConnectionDB() { cnn = ConectarBD.getConnection(); try { cnn.Open(); } catch (Exception ex) { MessageBox.Show("Can not open connection ! "); Console.WriteLine(ex.Message); return; } }
internal void eliminarMovCajaPorFecha(DateTime fecha_mov) { try { FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); ConectarBD Conex = new ConectarBD(); String sSQL = "EXEC dbo.adp_eliminarTodosMovCajaDeHoy @fecha_mov = " + fg.fcSql(fecha_mov.ToString(), "DATETIME"); Conex.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(), "String"); con.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() + "]"); } }
private void button1_Click(object sender, EventArgs e) { this.Hide(); Login f = new Login(); f.Closed += (s, args) => this.Close(); NpgsqlConnection conexao = null; conexao = ConectarBD.getConexao(); if (conexao == null) { conexao.Close(); } f.Show(); }
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 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 DataSet obtenerCierreParcialCaja(DateTime fecha) { try { ConectarBD con = new ConectarBD(); DataSet ds = new DataSet(); FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); String cadenaSql = ""; cadenaSql = "EXEC adp_cierre_parcial @FECHA = " + fg.fcSql(fecha.ToString(), "DATETIME"); ds = con.ejecutarQuerySelect(cadenaSql); return(ds); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public DataSet obtenerCamposTiposDeMovimientosCaja() { try { ConectarBD con = new ConectarBD(); DataSet ds = new DataSet(); FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); String cadenaSql = ""; cadenaSql = "EXEC adp_cbobusqueda_tipoMovimientos_caja"; ds = con.ejecutarQuerySelect(cadenaSql); return(ds); } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public void registrarMovimientosCaja(DateTime Fecha, String Hora) { try { FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); ConectarBD con = new ConectarBD(); String sSQL; sSQL = "exec adp_registrar_movimientosCaja "; sSQL = sSQL + " @fecha = " + fg.fcSql(Fecha.ToString(), "DATETIME"); sSQL = sSQL + ",@hora = " + fg.fcSql(Hora, "STRING"); con.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException(e.Message.ToString()); } }
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()); } }
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); } }
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() + "]"); } }
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() + "]"); } }
public void registrarMovimientoCaja(int tipoMovimiento, String descripcion, Double valor, DateTime fecha, String hora) { try { FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); ConectarBD con = new ConectarBD(); String sSQL; sSQL = "exec dbo.adp_registrar_mov_caja "; sSQL = sSQL + " @Tipo_Movimiento = " + fg.fcSql(tipoMovimiento.ToString(), "STRING"); sSQL = sSQL + " ,@Valor = " + fg.fcSql(valor.ToString(), "DOUBLE").Replace(",", "."); sSQL = sSQL + " ,@fecha = " + fg.fcSql(fecha.ToString(), "DATETIME"); sSQL = sSQL + " ,@hora = " + fg.fcSql(hora, "STRING"); con.ejecutarQuery(sSQL); } catch (Exception e) { throw new System.ArgumentException(e.Message.ToString()); } }
public List <ArmazenarJogo> Pesquisar() { NpgsqlConnection conexao = null; try { conexao = ConectarBD.getConexao(); string sql = "select codigo,nomeJogo,preco,quantidade,codigo_cadastro_fk from ArmazenarJogo where " + " codigo" + "=" + this.codigo; NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao); cmd.Parameters.Add(new NpgsqlParameter("@codigo", this.codigo)); NpgsqlDataReader dr = cmd.ExecuteReader(); List <ArmazenarJogo> armazenarJogo = new List <ArmazenarJogo>(); while (dr.Read()) { ArmazenarJogo novoJogo = new ArmazenarJogo(); novoJogo.codigo = Convert.ToInt16(dr["codigo"]); novoJogo.nomeJogo = dr["nomeJogo"].ToString(); novoJogo.preco = Convert.ToDouble(dr["preco"]); novoJogo.quantidade = Convert.ToInt16(dr["quantidade"]); novoJogo.codigo_cadastro_fk = Convert.ToInt16(dr["codigo_cadastro_fk"]); armazenarJogo.Add(novoJogo); } return(armazenarJogo); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (conexao != null) { conexao.Close(); } } }
public List <ArmazenarJogo> Listar() { NpgsqlConnection conexao = null; try { conexao = ConectarBD.getConexao(); string sql = "SELECT * FROM ArmazenarJogo"; NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao); NpgsqlDataReader dr = cmd.ExecuteReader(); List <ArmazenarJogo> armazenarJogo = new List <ArmazenarJogo>(); while (dr.Read()) { ArmazenarJogo novoJogo = new ArmazenarJogo(); novoJogo.codigo = Convert.ToInt16(dr["codigo"]); novoJogo.nomeJogo = dr["nomeJogo"].ToString(); novoJogo.preco = Convert.ToDouble(dr["preco"]); novoJogo.quantidade = Convert.ToInt16(dr["quantidade"]); novoJogo.codigo_cadastro_fk = Convert.ToInt16(dr["codigo_cadastro_fk"]); armazenarJogo.Add(novoJogo); } return(armazenarJogo); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (conexao != null) { conexao.Close(); } } }
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); } }
private void actualizarMovimientoCaja() { try { ConectarBD Conex = new ConectarBD(); TimeSpan hora = System.DateTime.Now.TimeOfDay; DateTime Dia = fg.appFechaSistema(); String Hora = hora.ToString().Substring(0, 8); String sSQL; sSQL = "EXEC dbo.adp_actualizar_MovCaja "; sSQL = sSQL + " @ID_MOVIMIENTO = " + fg.fcSql(txtCodigo.Text, "STRING"); sSQL = sSQL + " ,@VALOR = " + fg.fcSql(txtImporte.Text, "STRING"); sSQL = sSQL + " ,@FECHA = " + fg.fcSql(Dia.ToString(), "DATETIME"); sSQL = sSQL + " ,@HORA = " + fg.fcSql(Hora, "STRING"); Conex.ejecutarQuery(sSQL); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }