Ejemplo n.º 1
0
        protected void btPesquisarColuna_OnClick(object sender, EventArgs e)
        {
            string sErro = string.Empty;

            string sWhere = " DATAVENCIMENTO BETWEEN CONVERT(CHAR(10),'" + DateTime.Parse("01/01/" + ddlYear.SelectedValue).ToString("yyyyMMdd") + "', 101) AND CONVERT(CHAR(10),'" +
                DateTime.Parse("31/12/" + ddlYear.SelectedValue).ToString("yyyyMMdd") + "', 101)";

            List<AccountPayable> listContas = new AccountPayableDAO(IdUserSession).FindByWhere(sWhere, out sErro);

            DataTable dtAno = CreateTableYear();
            Dictionary<string, decimal> listTopCategorias = new Dictionary<string, decimal>();

            //Preenchendo o DataTable com as informações
            foreach (AccountPayable pConta in listContas)
            {
                string sCategoriaDescricao = pConta.CategoryDescription;

                if (ddlType.SelectedValue.Equals("Total"))
                {
                    sCategoriaDescricao = "Total";//QualMes(pConta.DataVencimento.Month, true);

                }

                DataRow[] dr = dtAno.Select("CATEGORIA = '" + sCategoriaDescricao + "'");
                string sMesIndex = WichMonth(pConta.MaturityDate.Month);
                //Verificar se na tabela já existe a categoria
                if (dr != null && dr.Length > 0)
                {
                    int iIndex = int.Parse(dr[0]["INDEX"].ToString());
                    //Se existir verifica qual é o Mês desta conta e preenche a tabela referente ao mes
                    dtAno.Rows[iIndex][sMesIndex] =
                        Decimal.Parse(dtAno.Rows[iIndex][sMesIndex].ToString()) + pConta.TotalPrice;
                }
                else
                {
                    DataRow dr1 = dtAno.NewRow();
                    dr1["CATEGORIA"] = sCategoriaDescricao;
                    dr1[sMesIndex] = pConta.TotalPrice;
                    dtAno.Rows.Add(dr1);

                    for (int i = 0; i < dtAno.Rows.Count; i++)
                    {
                        dtAno.Rows[i]["INDEX"] = i;
                    }
                }
            }

            foreach (DataRow pLinha in dtAno.Rows)
            {
                ChartPointCollection pCollection = new ChartPointCollection();
                for (int i = 1; i < 13; i++)
                {
                    ChartPoint p = new ChartPoint();
                    p.Y = Double.Parse(pLinha[WichMonth(i)].ToString());
                    pCollection.Add(p);
                }

                ChartSeriesSettings c = new ChartSeriesSettings();
                c.Data = pCollection;
                c.Name = pLinha["CATEGORIA"].ToString();

                ColumnChart.Series.Add(c);
            }
        }
Ejemplo n.º 2
0
        protected void btPesquisar_OnClick(object sender, EventArgs e)
        {
            string sErro = string.Empty;

            string sWhere = " DATAVENCIMENTO BETWEEN CONVERT(CHAR(10),'" + DateTime.Parse(txtDataDe.Text).ToString("yyyyMMdd") + "', 101) AND CONVERT(CHAR(10),'" + DateTime.Parse(txtDataAte.Text).ToString("yyyyMMdd") + "', 101)";

            List<AccountPayable> listContas = new AccountPayableDAO(IdUserSession).FindByWhere(sWhere, out sErro);
            ChartPointCollection pCollection = new ChartPointCollection();

            Dictionary<string, decimal> listTopCategorias = new Dictionary<string, decimal>();
            decimal dValorTotal = 0;
            foreach (AccountPayable pConta in listContas)
            {
                if (listTopCategorias.ContainsKey(pConta.CategoryDescription))
                {
                    listTopCategorias[pConta.CategoryDescription] += pConta.TotalPrice;
                }
                else
                {
                    listTopCategorias.Add(pConta.CategoryDescription, pConta.TotalPrice);
                }

                dValorTotal += pConta.TotalPrice;
            }

            var list = listTopCategorias.OrderBy(p => p.Value);
            foreach (KeyValuePair<string, decimal> pConta in list)
            {
                ChartPoint p = new ChartPoint();
                p.Text = pConta.Key;
                decimal dPercentual = (pConta.Value * 100) / dValorTotal;
                p.Y = Double.Parse(ValorComFormatacao(dPercentual, 2).ToString());

                pCollection.Add(p);
            }

            ChartSeriesSettings c = new ChartSeriesSettings();
            c.Data = pCollection;

            PieChart.Type = ChartType.Pie;
            PieChart.Series.Add(c);
        }
Ejemplo n.º 3
0
        private void CarregarGrid(string sWhere = "")
        {
            string sError;
            AccountPayableDAO objContasAPagarDao = new AccountPayableDAO(IdUserSession);
            List<AccountPayable> listContas = new List<AccountPayable>();
            listContas = objContasAPagarDao.FindByWhere(sWhere, out sError);
            Grid_gvListaConta = listContas.OrderBy(p => p.MaturityDate).ToList();
            gvListaConta.DataSource = Grid_gvListaConta;
            if (listContas.Count == 0)
            {
                DataTable dtEmpty = new DataTable();
                dtEmpty.Columns.Add("Id");
                dtEmpty.Columns.Add("CategoryDescription");
                dtEmpty.Columns.Add("Description");
                dtEmpty.Columns.Add("MaturityDate");
                dtEmpty.Columns.Add("TotalPrice");
                dtEmpty.Columns.Add("DatePayment");
                dtEmpty.Columns.Add("PricePayment");

                DataRow dr = dtEmpty.NewRow();
                dr["Id"] = "";
                dr["CategoryDescription"] = "";
                dr["Description"] = "";
                dr["MaturityDate"] = "";
                dr["TotalPrice"] = "";
                dr["DatePayment"] = "";
                dr["PricePayment"] = "";
                dtEmpty.Rows.Add(dr);
                gvListaConta.DataSource = dtEmpty;
            }

            if (TrataMsgPrincipal(sError))
                return;
            gvListaConta.DataBind();
            upGrid.Update();
        }
Ejemplo n.º 4
0
        protected void btExcluir_OnClick(object sender, EventArgs e)
        {
            AccountPayableDAO objSave = new AccountPayableDAO(IdUserSession);
            string sError = string.Empty;
            List<AccountPayable> listConta;
            BuscarItensSelecionado(out listConta);

            foreach (AccountPayable pConta in listConta)
            {
                objSave.Delete(pConta.Id, out sError);
                if (TrataMsgPrincipal(sError))
                    return;
            }

            btPesquisar_Onclick(sender, e);
        }
Ejemplo n.º 5
0
        protected void btGravar_OnClick(object sender, EventArgs e)
        {
            string sError;
            AccountPayableDAO objSave = new AccountPayableDAO(IdUserSession);
            AccountPayable objContas = new AccountPayable();

            objContas.Id = int.Parse(hfIdContaSelecionada.Value);
            objContas.Category = new CategoryDAO(IdUserSession)
                .FindByPK(int.Parse(pddlCategoria.SelectedItem.Value.ToString()), out sError);
            objContas.Description = ptxtDescricao.Text;
            objContas.MaturityDate = DateTime.Parse(ptxtDataVencimento.Text);
            objContas.TotalPrice = Decimal.Parse(ptxtValorTotal.Text);
            if (!String.IsNullOrWhiteSpace(ptxtDataPagamento.Text))
                objContas.DatePayment = DateTime.Parse(ptxtDataPagamento.Text);
            objContas.PricePayment = Decimal.Parse(ptxtValorPago.Text);
            objContas.Document = ptxtDocumento.Text;
            objContas.Historic = ptxtHistorico.Text;
            objContas.User = new UserDAO().FindByPK(IdUserSession, out sError);

            if (TrataMsgPopup(sError))
                return;
            int iTotalParcela = int.Parse(ptxtQtdParcela.Text);
            string sDescricao = objContas.Description;

            for (int i = 0; i < iTotalParcela; i++)
            {
                if (iTotalParcela > 1)
                {
                    objContas.Description = sDescricao + " " + (i + 1) + "/" + iTotalParcela;
                    if (i != 0)
                        objContas.MaturityDate = objContas.MaturityDate.AddMonths(1);
                }

                objSave.Save(objContas, out sError);
                if (TrataMsgPopup(sError))
                    return;

            }
            popup_GestaoDeContas.Hide();
            btPesquisar_Onclick(sender, e);
        }