Beispiel #1
0
        public DataTable ClienteListaHoy(string fecha)
        {
            DataTable dt = dbc.query("SELECT h.CL_CODIGO as CLIENTE ,c.CL_NOMBRE as NOMBRE" +
                                     ",HI_BALCAP as CAPITAL" +
                                     ",HI_BALINT as INTEREST" +
                                     ",(HI_BALCAP + HI_BALINT) as TOTAL " +
                                     ",HI_DOCUM as CUOTA " +
                                     " FROM historia h  " +
                                     "INNER JOIN prestamos p on (h.PRESTAMOID=p.PRESTAMOID)" +
                                     "INNER JOIN clientes c on (h.CL_CODIGO=c.CL_CODIGO)" +
                                     "WHERE h.HI_FECHA='" + fecha + "' AND h.HI_BALCAP >0 and p.INACTIVO=0   order by c.CL_NOMBRE");

            return(dt);
        }
Beispiel #2
0
        public int Update(string PrestamoID, DateTime pfecha, double capital, double taza, double cuota, string formadepago, string distribution, double capitalviejo, double interesviejo)
        {
            string sqlIns = "UPDATE prestamos set CO_FECHA=@CO_FECHA, CO_CAPITAL=@CO_CAPITAL,CO_INTERES=@CO_INTERES, CO_CANPAG=@CO_CANPAG,CO_TIPPAG=@CO_TIPPAG,CO_DISTRI=@CO_DISTRI,CO_ACTUAL=@CO_ACTUAL,CO_REAL=@CO_REAL,CO_CAPI=@CO_CAPI,CO_BALI=@CO_BALI,CO_CAVEN=@CO_CAVEN  WHERE PRESTAMOID=@PRESTAMOID";

            SqlCommand cmdIns = new SqlCommand(sqlIns);

            cmdIns.Parameters.AddWithValue("@CO_FECHA", pfecha);
            cmdIns.Parameters.AddWithValue("@CL_CODIGO", CODIGO);
            cmdIns.Parameters.AddWithValue("@CO_CAPITAL", capital);
            cmdIns.Parameters.AddWithValue("@CO_ACTUAL", Math.Round((capital / cuota), 2, MidpointRounding.AwayFromZero) * cuota);
            cmdIns.Parameters.AddWithValue("@CO_REAL", Math.Round((capital / cuota), 2, MidpointRounding.AwayFromZero) * cuota);
            cmdIns.Parameters.AddWithValue("@CO_CAPI", Math.Round((capital / cuota), 2, MidpointRounding.AwayFromZero) * cuota);
            cmdIns.Parameters.AddWithValue("@CO_BALI", "0.00");
            cmdIns.Parameters.AddWithValue("@CO_CAVEN", "0.00");
            cmdIns.Parameters.AddWithValue("@CO_INTERES", taza);
            cmdIns.Parameters.AddWithValue("@CO_CANPAG", cuota);
            cmdIns.Parameters.AddWithValue("@CO_TIPPAG", formadepago);
            cmdIns.Parameters.AddWithValue("@CO_DISTRI", distribution);
            cmdIns.Parameters.AddWithValue("@PRESTAMOID", PrestamoID);

            dbc.query(cmdIns);
            dbc.query_insert(String.Format("UPDATE clientes set CL_ACTUAL=CL_ACTUAL - {0}, CL_CAPITAL=CL_CAPITAL - {0},CL_INTERES=CL_INTERES - {1} where CL_CODIGO='{2}'", capitalviejo, interesviejo, CODIGO));
            dbc.query_insert(String.Format("DELETE FROM historia where PRESTAMOID={0}", PrestamoID));
            // insert cuota into historia
            DateTime sDate   = new DateTime(pfecha.Year, pfecha.Month, pfecha.Day);
            double   interes = 0.00;

            for (int i = 1; i <= cuota; i++)
            {
                if (formadepago == "S")
                {
                    sDate   = sDate.AddDays(7);
                    interes = (capital * taza / 100) * (cuota / WEEKLY);
                }
                else if (formadepago == "Q")
                {
                    sDate   = sDate.AddDays(15);
                    interes = (capital * taza / 100) * (cuota / SEMIMONTHLY);
                }
                else if (formadepago == "M")
                {
                    sDate   = sDate.AddMonths(1);
                    interes = (capital * taza / 100) * (cuota / MONTHLY);
                }
                else if (formadepago == "D")
                {
                    sDate   = sDate.AddDays(1);
                    interes = (capital * taza / 100) * (cuota / DAILY);
                }

                string sqlcIns = "INSERT INTO historia (PRESTAMOID,CL_CODIGO,HI_FECHA,HI_FECPAG,HI_FECVEN,HI_TIPO,HI_DOCUM,HI_BALCAP,HI_BALINT,HI_TIPPRE,HI_CAPITAL,HI_INTERES ) VALUES (@PRESTAMOID,@CL_CODIGO,@HI_FECHA,@HI_FECPAG,@HI_FECVEN,@HI_TIPO,@HI_DOCUM,@HI_BALCAP,@HI_BALINT,@HI_TIPPRE,@HI_CAPITAL,@HI_INTERES)";

                SqlCommand cmdcIns = new SqlCommand(sqlcIns);
                cmdcIns.Parameters.AddWithValue("@PRESTAMOID", PrestamoID);
                cmdcIns.Parameters.AddWithValue("@CL_CODIGO", CODIGO);
                cmdcIns.Parameters.AddWithValue("@HI_FECHA", sDate);
                cmdcIns.Parameters.AddWithValue("@HI_FECPAG", pfecha);
                cmdcIns.Parameters.AddWithValue("@HI_FECVEN", pfecha);
                cmdcIns.Parameters.AddWithValue("@HI_TIPO", "F");
                cmdcIns.Parameters.AddWithValue("@HI_DOCUM", i + "/" + cuota);
                cmdcIns.Parameters.AddWithValue("@HI_BALCAP", capital / cuota);
                cmdcIns.Parameters.AddWithValue("@HI_BALINT", interes / cuota);
                cmdcIns.Parameters.AddWithValue("@HI_TIPPRE", "1");
                cmdcIns.Parameters.AddWithValue("@HI_CAPITAL", capital / cuota);
                cmdcIns.Parameters.AddWithValue("@HI_INTERES", interes / cuota);
                int cresultID = dbc.query_insert(cmdcIns);
            }
            //update cliente balance same.

            dbc.query_insert(String.Format("UPDATE clientes set CL_ACTUAL=CL_ACTUAL + {0}, CL_CAPITAL=CL_CAPITAL + {0},CL_INTERES=CL_INTERES + {1} where CL_CODIGO='{2}'", ((capital / cuota) * cuota), interes, CODIGO));


            return(int.Parse(PrestamoID));
        }