Advertisement
desenvolvedores

GridPanel-CodeBehind

Jun 22nd, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.ComponentModel;
  8. using Ext.Net;
  9. using System.Data.Generic;
  10. using ERP.Net;
  11.  
  12. namespace ERP.Interface.Forms.Lancamentos
  13. {
  14.     public enum TipoGridLancamento
  15.     {
  16.         /// <summary>
  17.         /// Exibe todos os títulos de pagar e receber
  18.         /// </summary>
  19.         [Description("#TodosTitulos")]
  20.         Todos,
  21.  
  22.         /// <summary>
  23.         /// 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
  24.         /// </summary>
  25.         [Description("#APagar/Receber")]
  26.         PagarReceber,
  27.  
  28.         /// <summary>
  29.         /// Exibe todos os títulos de pagar e receber que estão em atraso
  30.         /// </summary>
  31.         [Description("#Atrasados")]
  32.         Atrasado,
  33.  
  34.         /// <summary>
  35.         /// Exibe todos os títulos de pagar e receber que já foram pagos ou recebidos
  36.         /// </summary>
  37.         [Description("#Pagos/Recebidos")]
  38.         PagosRecebidos
  39.     }
  40.  
  41.     public partial class GridLancamento : System.Web.UI.UserControl
  42.     {
  43.         #region Propriedades
  44.         private System.Data.Generic.DataReader CurrentDataReader
  45.         {
  46.             get { return this.Session["adm_PessoaPagarReceberBase"] as System.Data.Generic.DataReader; }
  47.             set { this.Session["adm_PessoaPagarReceberBase"] = value; }
  48.         }
  49.         public string Title
  50.         {
  51.             get { return grdInner.Title; }
  52.             set { grdInner.Title = value; }
  53.         }
  54.  
  55.         public TipoGridLancamento Tipo { get; set; }
  56.         #endregion
  57.  
  58.         protected void Page_Load(object sender, EventArgs e)
  59.         {
  60.             if (!X.IsAjaxRequest)
  61.             {
  62.                 PopulatePessoa();
  63.             }
  64.         }
  65.  
  66.         #region Métodos Populate
  67.         private void PopulatePessoa()
  68.         {
  69.             //abrir query
  70.             ERP.Query.Query q = new Query.Query("adm_PessoaPagarReceberBase");
  71.  
  72.             //abrir recordset
  73.             System.Data.Generic.DataReader dr = Connection.ExecuteSelect(Convert.ToCommand(q));
  74.  
  75.             //agrupar por pessoa
  76.             var group = from t in dr
  77.                         group t by new
  78.                         {
  79.                             eguid = ((object[])t)[dr.GetOrdinal("adm_pessoa_eguid")].ToString(),
  80.                             guid = ((object[])t)[dr.GetOrdinal("adm_pessoa_guid")].ToString(),
  81.                             nomeFantasia = ((object[])t)[dr.GetOrdinal("adm_pessoa_nomefantasia")].ToString(),
  82.                             razaoSocial = ((object[])t)[dr.GetOrdinal("adm_pessoa_razaosocial")].ToString()
  83.                         } into g
  84.                         select new
  85.                         {
  86.                             eguid = g.Key.eguid,
  87.                             guid = g.Key.guid,
  88.                             razaoSocial = g.Key.razaoSocial,
  89.                             nomeFantasia = g.Key.nomeFantasia,
  90.                         };
  91.  
  92.             dsPessoa.DataSource = group;
  93.             dsPessoa.DataBind();
  94.  
  95.             CurrentDataReader = dr;
  96.         }
  97.         #endregion
  98.  
  99.         protected void BeforeExpand(object sender, DirectEventArgs e)
  100.         {
  101.             IList<object> data = new List<object>();
  102.  
  103.             System.Data.Generic.DataReader dr = CurrentDataReader;
  104.  
  105.             dr.MoveTo(MoveToPos.BOF);
  106.  
  107.             dsMain.RemoveAll();
  108.  
  109.             //dr.Filter("adm_pessoa_guid", e.ExtraParams["guid"]);
  110.  
  111.             while (dr.Read())
  112.             {
  113.                 int atraso = 0;
  114.                 DateTime vencimento = dr.GetDateTime("fin_lancc_datamovimento");
  115.                 DateTime emissao = dr.GetDateTime("fin_lancc_datalancamento");
  116.                 atraso = emissao.DateDiff(vencimento).Days;
  117.  
  118.                 data.Add(new
  119.                 {
  120.                     guid = dr.GetString("adm_pessoa_guid"),
  121.                     vencimento = Format.Date(vencimento),
  122.                     emissao = Format.Date(emissao),
  123.                     atraso = atraso,
  124.                     saldo = 0,
  125.                     desconto = 0,
  126.                     acrescimo = 0,
  127.                     valorTotal = dr.GetDouble("fin_lancc_valor"),
  128.                     documento = dr.GetString("tab_lan_eguid"),
  129.                     boleto = "",
  130.                     guidTipoLan = dr.GetString("adm_tipolan_guid"),
  131.                     TipoLan = string.Format("{0} - {1}", dr.GetString("adm_tipolan_eguid"), dr.GetString("adm_tipolan_descricao"))
  132.                 });
  133.             }
  134.  
  135.             dsMain.DataSource = data;
  136.             dsMain.DataBind();
  137.         }
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement