static void Main(string[] args) { Produto prod1 = new Produto(); prod1.Codigo = "001"; prod1.Modelo = "Mouse Optico"; prod1.Marca = "HP"; prod1.ImpostoFederal = 1.50; prod1.ImpostoProvincial = 1.00; prod1.Valor = 15.50; Registradora reg1 = new Registradora(); reg1.AddProduto(prod1); Produto prod2 = new Produto("002", "Teclado", "Microsoft", 2.00, 20.00, 1.00); reg1.AddProduto(prod2); Console.WriteLine("Nome Prod1:" + reg1.GetNomeDoProduto(prod1)); Console.WriteLine("Nome Prod2:" + reg1.GetNomeDoProduto(prod2)); Console.WriteLine("Total: {0:0.00}", reg1.Total); Boleto b1 = new Boleto(); b1.Comprador = "daniela"; b1.Valor = reg1.Total; b1.SetVencimento(); b1.Taxa = 1.00; b1.AplicaDesconto(10, false); Console.WriteLine("Nome Comprador:" + b1.Comprador); Console.WriteLine("Valor:" + b1.Valor); Console.WriteLine("Vencimento:" + b1.Vencimento); Console.ReadKey(); }
public List <Registradora> GetRegistradorasPorFechas(DateTime desde, DateTime hasta) { List <Registradora> regList = new List <Registradora>(); try { OpenConnection(); NpgsqlCommand cmdSel = new NpgsqlCommand("select * from registradora where fecha BETWEEN @desde and @hasta and cerrada = true order by id_registradora ", npgsqlConn); cmdSel.Parameters.Add("@desde", NpgsqlTypes.NpgsqlDbType.Date).Value = desde; cmdSel.Parameters.Add("@hasta", NpgsqlTypes.NpgsqlDbType.Date).Value = hasta; NpgsqlDataReader drCaja = cmdSel.ExecuteReader(); while (drCaja.Read()) { Registradora reg = new Registradora(); reg.Fecha = (DateTime)drCaja["fecha"]; reg.HoraMinutosApertura = Convert.ToString((int)drCaja["hora_apertura"]) + ":" + Convert.ToString((int)drCaja["minutos_apertura"]); reg.HoraMinutosCierre = Convert.ToString((int)drCaja["hora_cierra"]) + ":" + Convert.ToString((int)drCaja["minutos_cierre"]); reg.Id_Registradora = (int)drCaja["id_registradora"]; reg.Id_Usuario = (int)drCaja["usuario_registrado"]; reg.Dinero_en_caja_calculado = (double)drCaja["dinero_en_caja_calculado"]; reg.Dinero_en_caja_ciere = (double)drCaja["dinero_en_caja_cierre"]; reg.Dinero_inicial = (double)drCaja["dinero_inicial"]; try { reg.Descripcion = (string)drCaja["descripcion"]; } catch { } regList.Add(reg); } drCaja.Close(); } finally { CloseConnection(); } UsuariosAdap usAd = new UsuariosAdap(); foreach (Registradora r in regList) { foreach (Usuarios us in usAd.GetUsuarios()) { if (r.Id_Usuario == us.Id_usuario) { r.Usuario = us.Nombre; } } } return(regList); }
public void CierreCaja(Registradora r) { try { this.OpenConnection(); NpgsqlCommand cmdSave = new NpgsqlCommand("UPDATE registradora set cerrada = true, hora_cierra = @hora, " + "minutos_cierre = @minutos,dinero_en_caja_cierre = @dinero_caja, dinero_en_caja_calculado = @calculado, descripcion=@descripcion where cerrada = false ", npgsqlConn); cmdSave.Parameters.Add("@hora", NpgsqlTypes.NpgsqlDbType.Integer).Value = r.Hora_cierre; cmdSave.Parameters.Add("@minutos", NpgsqlTypes.NpgsqlDbType.Integer).Value = r.Minutos_cierre; cmdSave.Parameters.Add("@dinero_caja", NpgsqlTypes.NpgsqlDbType.Double).Value = r.Dinero_en_caja_ciere; cmdSave.Parameters.Add("@calculado", NpgsqlTypes.NpgsqlDbType.Integer).Value = r.Dinero_en_caja_calculado; cmdSave.Parameters.Add("@descripcion", NpgsqlTypes.NpgsqlDbType.Text).Value = r.Descripcion; cmdSave.ExecuteNonQuery(); } finally { CloseConnection(); } }
public int GetIdCajaAbierta() { try { this.OpenConnection(); NpgsqlCommand cmdSel = new NpgsqlCommand("SELECT MAX(id_registradora) as id_registradora from registradora where cerrada = false group by cerrada", npgsqlConn); NpgsqlDataReader dr = cmdSel.ExecuteReader(); Registradora reg = new Registradora(); while (dr.Read()) { reg.Id_Registradora = (int)dr["id_registradora"]; } dr.Close(); return(reg.Id_Registradora); } finally { CloseConnection(); } }
public void AperturaCaja(Registradora r) { try { this.OpenConnection(); NpgsqlCommand cmdSave = new NpgsqlCommand("insert into registradora(cerrada,hora_apertura,hora_cierra,minutos_apertura, " + "minutos_cierre,dinero_inicial,dinero_en_caja_cierre,dinero_en_caja_calculado,usuario_registrado,fecha) " + "values(false,@hora,0,@minutos,0,@inicial,0,0,@usuario,@fecha)", npgsqlConn); cmdSave.Parameters.Add("@hora", NpgsqlTypes.NpgsqlDbType.Integer).Value = r.Hora_apertura; cmdSave.Parameters.Add("@minutos", NpgsqlTypes.NpgsqlDbType.Integer).Value = r.Minutos_apertura; cmdSave.Parameters.Add("@inicial", NpgsqlTypes.NpgsqlDbType.Double).Value = r.Dinero_inicial; cmdSave.Parameters.Add("@usuario", NpgsqlTypes.NpgsqlDbType.Integer).Value = r.Id_Usuario; cmdSave.Parameters.Add("@fecha", NpgsqlTypes.NpgsqlDbType.Date).Value = r.Fecha; cmdSave.ExecuteNonQuery(); } finally { CloseConnection(); } }
public bool ExisteCajaAbierta() { try { this.OpenConnection(); NpgsqlCommand cmdSel = new NpgsqlCommand("SELECT MAX(id_registradora) as id,cerrada from registradora group by cerrada order by id DESC limit 1", npgsqlConn); NpgsqlDataReader dr = cmdSel.ExecuteReader(); Registradora reg = new Registradora(); while (dr.Read()) { reg.Cerrada = (bool)dr["cerrada"]; } if (reg.Cerrada == true) { return(false); } else { return(true); } } finally { CloseConnection(); } }