Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.ComponentModel;
- using Ext.Net;
- using System.Data.Generic;
- using ERP.Net;
- namespace ERP.Interface.Forms.Lancamentos
- {
- public enum TipoGridLancamento
- {
- /// <summary>
- /// Exibe todos os títulos de pagar e receber
- /// </summary>
- [Description("#TodosTitulos")]
- Todos,
- /// <summary>
- /// Exibe todos os títulos de pagar e receber que ainda não foram pagas ou recebidos e que não estão em atraso
- /// </summary>
- [Description("#APagar/Receber")]
- PagarReceber,
- /// <summary>
- /// Exibe todos os títulos de pagar e receber que estão em atraso
- /// </summary>
- [Description("#Atrasados")]
- Atrasado,
- /// <summary>
- /// Exibe todos os títulos de pagar e receber que já foram pagos ou recebidos
- /// </summary>
- [Description("#Pagos/Recebidos")]
- PagosRecebidos
- }
- public partial class GridLancamento : System.Web.UI.UserControl
- {
- #region Propriedades
- private System.Data.Generic.DataReader CurrentDataReader
- {
- get { return this.Session["adm_PessoaPagarReceberBase"] as System.Data.Generic.DataReader; }
- set { this.Session["adm_PessoaPagarReceberBase"] = value; }
- }
- public string Title
- {
- get { return grdInner.Title; }
- set { grdInner.Title = value; }
- }
- public TipoGridLancamento Tipo { get; set; }
- #endregion
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!X.IsAjaxRequest)
- {
- PopulatePessoa();
- }
- }
- #region Métodos Populate
- private void PopulatePessoa()
- {
- //abrir query
- ERP.Query.Query q = new Query.Query("adm_PessoaPagarReceberBase");
- //abrir recordset
- System.Data.Generic.DataReader dr = Connection.ExecuteSelect(Convert.ToCommand(q));
- //agrupar por pessoa
- var group = from t in dr
- group t by new
- {
- eguid = ((object[])t)[dr.GetOrdinal("adm_pessoa_eguid")].ToString(),
- guid = ((object[])t)[dr.GetOrdinal("adm_pessoa_guid")].ToString(),
- nomeFantasia = ((object[])t)[dr.GetOrdinal("adm_pessoa_nomefantasia")].ToString(),
- razaoSocial = ((object[])t)[dr.GetOrdinal("adm_pessoa_razaosocial")].ToString()
- } into g
- select new
- {
- eguid = g.Key.eguid,
- guid = g.Key.guid,
- razaoSocial = g.Key.razaoSocial,
- nomeFantasia = g.Key.nomeFantasia,
- };
- dsPessoa.DataSource = group;
- dsPessoa.DataBind();
- CurrentDataReader = dr;
- }
- #endregion
- protected void BeforeExpand(object sender, DirectEventArgs e)
- {
- IList<object> data = new List<object>();
- System.Data.Generic.DataReader dr = CurrentDataReader;
- dr.MoveTo(MoveToPos.BOF);
- dsMain.RemoveAll();
- //dr.Filter("adm_pessoa_guid", e.ExtraParams["guid"]);
- while (dr.Read())
- {
- int atraso = 0;
- DateTime vencimento = dr.GetDateTime("fin_lancc_datamovimento");
- DateTime emissao = dr.GetDateTime("fin_lancc_datalancamento");
- atraso = emissao.DateDiff(vencimento).Days;
- data.Add(new
- {
- guid = dr.GetString("adm_pessoa_guid"),
- vencimento = Format.Date(vencimento),
- emissao = Format.Date(emissao),
- atraso = atraso,
- saldo = 0,
- desconto = 0,
- acrescimo = 0,
- valorTotal = dr.GetDouble("fin_lancc_valor"),
- documento = dr.GetString("tab_lan_eguid"),
- boleto = "",
- guidTipoLan = dr.GetString("adm_tipolan_guid"),
- TipoLan = string.Format("{0} - {1}", dr.GetString("adm_tipolan_eguid"), dr.GetString("adm_tipolan_descricao"))
- });
- }
- dsMain.DataSource = data;
- dsMain.DataBind();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement