예제 #1
0
        public List <Venda> ListAll()
        {
            VendaMotorDAO    vm  = new VendaMotorDAO();
            VendaOpcionalDAO vo  = new VendaOpcionalDAO();
            Database         db  = Database.GetInstance();
            string           qry = "SELECT * FROM venda";
            DataSet          ds  = db.ExecuteQuery(qry);

            List <Venda> lv = new List <Venda>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Venda v = new Venda();
                v.Id          = int.Parse(dr["id"].ToString());
                v.Cliente.Id  = int.Parse(dr["idCliente"].ToString());
                v.Vendedor.Id = int.Parse(dr["idVendedor"].ToString());
                v.Carro.Id    = int.Parse(dr["idCarro"].ToString());
                v.DataVenda   = dr["dataVenda"].ToString();
                v.Desconto    = double.Parse(dr["Desconto"].ToString());
                v.NParcelas   = int.Parse(dr["nParcelas"].ToString());
                v.Juros       = double.Parse(dr["juros"].ToString());
                v.PrecoCarro  = double.Parse(dr["precoCarro"].ToString());
                v.PrecoTotal  = double.Parse(dr["precoTotal"].ToString());
                v.Entrada     = double.Parse(dr["entrada"].ToString());
                v.Restante    = double.Parse(dr["restante"].ToString());
                v.ValParcela  = double.Parse(dr["valParcela"].ToString());
                v.PrecoAPAgar = double.Parse(dr["PrecoAPagar"].ToString());
                v.IdCliente   = int.Parse(dr["idCliente"].ToString());
                v.IdVendedor  = int.Parse(dr["idVendedor"].ToString());
                v.IdCarro     = int.Parse(dr["idCarro"].ToString());
                v.Removido    = int.Parse(dr["removido"].ToString());

                v.Cliente        = cliente.Read(v.Cliente.Id);
                v.Carro          = carro.Read(v.Carro.Id);
                v.Vendedor       = vendedor.Read(v.Vendedor.Id);
                v.Carro.Motor    = vm.Read(v.Id);
                v.Carro.Opcional = vo.Read(v.Id);

                lv.Add(v);
            }


            return(lv);
        }
예제 #2
0
        public Venda Read(int key)
        {
            VendaMotorDAO    vm  = new VendaMotorDAO();
            VendaOpcionalDAO vo  = new VendaOpcionalDAO();
            Database         db  = Database.GetInstance();
            string           qry = String.Format("SELECT * FROM venda WHERE id = " + key);
            DataSet          ds  = db.ExecuteQuery(qry);
            Venda            v   = new Venda();

            DataRow dr = ds.Tables[0].Rows[0];

            v.Id          = int.Parse(dr["id"].ToString());
            v.Cliente.Id  = int.Parse(dr["idCliente"].ToString());
            v.Vendedor.Id = int.Parse(dr["idVendedor"].ToString());
            v.Carro.Id    = int.Parse(dr["idCarro"].ToString());
            v.DataVenda   = dr["dataVenda"].ToString();
            v.Desconto    = double.Parse(dr["Desconto"].ToString());
            v.NParcelas   = int.Parse(dr["nParcelas"].ToString());
            v.Juros       = double.Parse(dr["juros"].ToString());
            v.PrecoCarro  = double.Parse(dr["precoCarro"].ToString());
            v.PrecoTotal  = double.Parse(dr["precoTotal"].ToString());
            v.Entrada     = double.Parse(dr["entrada"].ToString());
            v.Restante    = double.Parse(dr["restante"].ToString());
            v.ValParcela  = double.Parse(dr["valParcela"].ToString());
            v.PrecoAPAgar = double.Parse(dr["PrecoAPagar"].ToString());
            v.IdCliente   = int.Parse(dr["idCliente"].ToString());
            v.IdVendedor  = int.Parse(dr["idVendedor"].ToString());
            v.IdCarro     = int.Parse(dr["idCarro"].ToString());
            v.Removido    = int.Parse(dr["removido"].ToString());

            v.Cliente        = cliente.Read(v.Cliente.Id);
            v.Carro          = carro.Read(v.Carro.Id);
            v.Vendedor       = vendedor.Read(v.Vendedor.Id);
            v.Carro.Motor    = vm.Read(v.Id);
            v.Carro.Opcional = vo.Read(v.Id);

            return(v);
        }