Пример #1
0
        public DataTable GetCobranzasAdeudadas(string Patente, string Apellido, DateTime Fecha, int ConDeuda)
        {
            int    b            = 0;
            Int32  CodAuto      = 0;
            string ListaCodAuto = "(";
            string sql          = "";

            if (Patente != "")
            {
                b = 1;
                Clases.cAuto auto = new Clases.cAuto();
                DataTable    trdo = auto.GetAutoxContenidoPatente(Patente);
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["CodAuto"].ToString() != "")
                    {
                        for (int i = 0; i < trdo.Rows.Count; i++)
                        {
                            b       = 1;
                            CodAuto = Convert.ToInt32(trdo.Rows[i]["CodAuto"].ToString());
                            if (ListaCodAuto == "(")
                            {
                                ListaCodAuto = ListaCodAuto + CodAuto.ToString();
                            }
                            else
                            {
                                ListaCodAuto = ListaCodAuto + "," + CodAuto.ToString();
                            }
                        }
                        ListaCodAuto = ListaCodAuto + ")";
                    }
                }
                sql = "select * from Cobranza c,Venta v,Cliente cli,Auto a";
                sql = sql + " where c.CodVenta=v.CodVenta";
                sql = sql + " and v.CodCliente = cli.CodCliente ";
                sql = sql + " and v.CodAutoVendido = a.CodAuto";
                sql = sql + " and c.Saldo >0 ";
                if (ConDeuda == 1)
                {
                    sql = sql + " and c.FechaCompromiso <" + "'" + Fecha.ToShortDateString() + "'";
                }
                if (ListaCodAuto != "(")
                {
                    sql = sql + " and v.CodAutoVendido in " + ListaCodAuto.ToString();
                }
                else
                {
                    sql = sql + " and v.CodAutoVendido=-1";
                }
            }
            if (b == 0)
            {
                string    ListaCliente = "(";
                cCliente  cli          = new cCliente();
                DataTable trdo         = cli.GetClientexApellido(Apellido);
                for (int i = 0; i < trdo.Rows.Count; i++)
                {
                    if (ListaCliente == "(")
                    {
                        ListaCliente = ListaCliente + trdo.Rows[i]["CodCliente"].ToString();
                    }
                    else
                    {
                        ListaCliente = ListaCliente + "," + trdo.Rows[i]["CodCliente"].ToString();
                    }
                }
                ListaCliente = ListaCliente + ")";
                if (ListaCliente == "()")
                {
                    ListaCliente = "(-1)";
                }
                sql = "select * from Cobranza c,Venta v,Cliente cli,Auto a";
                sql = sql + " where c.CodVenta=v.CodVenta";
                sql = sql + " and v.CodCliente = cli.CodCliente ";
                sql = sql + " and v.CodAutoVendido = a.CodAuto";
                sql = sql + " and c.Saldo >0 ";
                if (ConDeuda == 1)
                {
                    sql = sql + " and c.FechaCompromiso <" + "'" + Fecha.ToShortDateString() + "'";
                }
                if (ListaCliente != "(")
                {
                    sql = sql + " and v.CodCliente in " + ListaCliente.ToString();
                }
                else
                {
                    sql = sql + " and v.CodAutoVendido=-1";
                }
            }
            return(cDb.ExecuteDataTable(sql));
        }
Пример #2
0
        public DataTable GetDocumentosAdeudados(string Patente, string Apellido, DateTime Fecha, int ConDeuda, Int32?CodOrden)
        {
            int    b            = 0;
            Int32  CodAuto      = 0;
            string sql          = "";
            string ListaCodAuto = "(";

            if (Patente != "")
            {
                b = 1;
                Clases.cAuto auto = new Clases.cAuto();
                DataTable    trdo = auto.GetAutoxContenidoPatente(Patente);
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["CodAuto"].ToString() != "")
                    {
                        for (int i = 0; i < trdo.Rows.Count; i++)
                        {
                            b       = 1;
                            CodAuto = Convert.ToInt32(trdo.Rows[i]["CodAuto"].ToString());
                            if (ListaCodAuto == "(")
                            {
                                ListaCodAuto = ListaCodAuto + CodAuto.ToString();
                            }
                            else
                            {
                                ListaCodAuto = ListaCodAuto + "," + CodAuto.ToString();
                            }
                        }
                        ListaCodAuto = ListaCodAuto + ")";
                    }
                }
                sql = sql + " select *";
                sql = sql + " from Documento doc ,Orden o, auto a,cliente cli";
                sql = sql + " where doc.CodOrden = o.CodOrden ";
                sql = sql + " and o.CodAuto = a.CodAuto";
                sql = sql + " and o.CodCliente = cli.CodCliente";
                sql = sql + " and doc.Saldo>0";
                if (ListaCodAuto != "(")
                {
                    sql = sql + " and o.CodAuto in " + ListaCodAuto.ToString();
                }
                else
                {
                    sql = sql + " and o.CodAuto=-1";
                }
            }

            if (CodOrden != null)
            {
                sql = sql + " select *";
                sql = sql + " from Documento doc ,Orden o, auto a,cliente cli";
                sql = sql + " where doc.CodOrden = o.CodOrden ";
                sql = sql + " and o.CodAuto = a.CodAuto";
                sql = sql + " and o.CodCliente = cli.CodCliente";
                sql = sql + " and doc.Saldo>0";
                if (CodOrden != -1)
                {
                    sql = sql + " and o.CodOrden =" + CodOrden.ToString();
                }
                b = 1;
            }

            if (b == 0)
            {
                string    ListaCliente = "(";
                cCliente  cli          = new cCliente();
                DataTable trdo         = cli.GetClientexApellido(Apellido);
                for (int i = 0; i < trdo.Rows.Count; i++)
                {
                    if (ListaCliente == "(")
                    {
                        ListaCliente = ListaCliente + trdo.Rows[i]["CodCliente"].ToString();
                    }
                    else
                    {
                        ListaCliente = ListaCliente + "," + trdo.Rows[i]["CodCliente"].ToString();
                    }
                }
                ListaCliente = ListaCliente + ")";
                if (ListaCliente == "()")
                {
                    ListaCliente = "(-1)";
                }
                sql = sql + " select *";
                sql = sql + " from Documento doc,Orden o, auto a,cliente cli";
                sql = sql + " where doc.CodOrden = o.CodOrden ";
                sql = sql + " and o.CodAuto = a.CodAuto";
                sql = sql + " and o.CodCliente = cli.CodCliente";
                sql = sql + " and doc.Saldo > 0";
                if (ListaCliente != "(")
                {
                    sql = sql + " and o.CodCliente in " + ListaCliente.ToString();
                }
                else
                {
                    sql = sql + " and o.CodCliente=-1";
                }
            }
            return(cDb.ExecuteDataTable(sql));
        }