Example #1
0
        public List <BEFactura> getLstFacturaCab(int num_pago, DateTime fecini, DateTime fecfin, string cliente)
        {
            try
            {
                using (cn = new SqlConnection(DAConexion.ConexionBD()))
                {
                    using (cmd = new SqlCommand("spfactura_getAll", cn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@num_pago", SqlDbType.Int).Value         = num_pago;
                        cmd.Parameters.Add("@fecini", SqlDbType.Date).Value          = fecini;
                        cmd.Parameters.Add("@fecfin", SqlDbType.Date).Value          = fecfin;
                        cmd.Parameters.Add("@cliente", SqlDbType.VarChar, 120).Value = cliente;
                        cn.Open();
                        using (dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                objfactura             = new BEFactura();
                                objfactura.num_factura = (dr["num_factura"] == DBNull.Value ? 0 : Convert.ToInt32(dr["num_factura"]));
                                objfactura.id_cliente  = (dr["id_cliente"] == DBNull.Value ? 0 : Convert.ToInt32(dr["id_cliente"]));
                                objfactura.num_pago    = (dr["num_pago"] == DBNull.Value ? 0 : Convert.ToInt32(dr["num_pago"]));
                                objfactura.total       = (dr["total"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["total"]));

                                objmodo_pago          = new BEmodo_pago();
                                objmodo_pago.num_pago = (dr["num_pago"] == DBNull.Value ? 0 : Convert.ToInt32(dr["num_pago"]));
                                objmodo_pago.nombre   = (dr["nom_pago"] == DBNull.Value ? string.Empty : dr["nom_pago"].ToString());
                                objfactura.modo_pago  = objmodo_pago;

                                objcliente            = new BEcliente();
                                objcliente.id_cliente = ((dr["id_cliente"] == DBNull.Value) ? 0 : Convert.ToInt32(dr["id_cliente"]));
                                objcliente.pNombre    = (dr["pNombre"] == DBNull.Value ? string.Empty : dr["pNombre"].ToString());
                                objcliente.sNombre    = (dr["sNombre"] == DBNull.Value ? string.Empty : dr["sNombre"].ToString());
                                objcliente.pApellido  = (dr["pApellido"] == DBNull.Value ? string.Empty : dr["pApellido"].ToString());
                                objcliente.sApellido  = (dr["sApellido"] == DBNull.Value ? string.Empty : dr["sApellido"].ToString());
                                objfactura.cliente    = objcliente;

                                lstBEfactura.Add(objfactura);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cn.Close();
                cn.Dispose();
                cmd.Dispose();
                dr.Dispose();
            }

            return(lstBEfactura);
        }
Example #2
0
        public List <BEcliente> getLstCliente()
        {
            try
            {
                using (cn = new SqlConnection(DAConexion.ConexionBD()))
                {
                    using (cmd = new SqlCommand("spcliente_getAll", cn))
                    {
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cn.Open();

                        using (dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                objcliente            = new BEcliente();
                                objcliente.id_cliente = ((dr["id_cliente"] == DBNull.Value) ? 0 : Convert.ToInt32(dr["id_cliente"]));
                                objcliente.pNombre    = (dr["pNombre"] == DBNull.Value ? string.Empty : dr["pNombre"].ToString());
                                objcliente.sNombre    = (dr["sNombre"] == DBNull.Value ? string.Empty : dr["sNombre"].ToString());
                                objcliente.pApellido  = (dr["pApellido"] == DBNull.Value ? string.Empty : dr["pApellido"].ToString());
                                objcliente.sApellido  = (dr["sApellido"] == DBNull.Value ? string.Empty : dr["sApellido"].ToString());
                                objcliente.Nombres    = objcliente.pNombre + ' ' + objcliente.sNombre + ' ' + objcliente.pApellido + ' ' + objcliente.sApellido;

                                lstBEcliente.Add(objcliente);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally {
                dr.Dispose();
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }

            return(lstBEcliente);
        }
Example #3
0
 public BEFactura()
 {
     cliente   = new BEcliente();
     modo_pago = new BEmodo_pago();
     detalle   = new List <BEdetalle>();
 }