예제 #1
0
        public DataTable getMensalidades(String matCod)
        {
            DataTable result = new DataTable();
            result.Columns.Add("vcmto", typeof(String));
            result.Columns.Add("valor", typeof(String));
            result.Columns.Add("dtpgmto", typeof(String));
            result.Columns.Add("user", typeof(String));
            result.Columns.Add("dias", typeof(String));

            sql = "SELECT * FROM entrada WHERE mat_cod = @1";
            sql = sql.Replace("@1", matCod);
            bco.conecta();
            bco.executeQuery(sql, out dt);
            bco.desconecta();

            Matricula mat = new Matricula();
            mat.Id = matCod;
            mat = mat.getById();
            String[] diaInicio = mat.DtIni.Split('/');
            Modalidade mod = new Modalidade();
            mod.Id = mat.ModId;
            mod = mod.getById();
            int fator = 0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow linha = result.NewRow();
                if (i == 0 && mat.DtVcmto != diaInicio[0])
                    fator = 1;
                if (mat.Tipo == "m")
                {
                    DateTime mensAtual = DateTime.Parse(mat.DtIni).AddMonths(i + fator);
                    DateTime mensAtual2 = new DateTime(mensAtual.Year, mensAtual.Month, Convert.ToInt32(mat.DtVcmto));
                    linha["vcmto"] = mensAtual2.ToShortDateString();
                }
                linha["valor"] = dt.Rows[i]["ent_valor"];
                linha["dtpgmto"] = DateTime.Parse(dt.Rows[i]["cai_data"].ToString()).ToShortDateString();
                Usuario user = new Usuario();
                user.Id = Convert.ToInt32(dt.Rows[i]["acess_id"]);
                user = user.getUserById();
                linha["user"] = user.Login;
                if (mat.Tipo == "d")
                {
                    linha["dias"] = Convert.ToDecimal(dt.Rows[i]["ent_valor"]) / Convert.ToDecimal(mod.ValorD);
                }

                if(mat.Tipo == "d" && dt.Rows[i]["ent_desc"].ToString().Contains("Pagamento de")
                    || mat.Tipo == "m" && dt.Rows[i]["ent_desc"].ToString().Contains("Pagamento mensalidade"))
                    result.Rows.Add(linha);
            }

            return result;
        }