Advertisement
Guest User

Untitled

a guest
May 31st, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Interop.StdBE900;
  11.  
  12. namespace SaasConsulangApi
  13. {
  14. public partial class frmTiposentidade : Form
  15. {
  16. List<TipoEntidade> tipoEntidades;
  17. Dictionary<string, TipoEntidade[]> TEntidades;
  18. public frmTiposentidade()
  19. {
  20. InitializeComponent();
  21. }
  22.  
  23. private void frmTiposentidade_Load(object sender, EventArgs e)
  24. {
  25.  
  26. }
  27.  
  28. private void btnCancelar_Click(object sender, EventArgs e)
  29. {
  30. this.Close();
  31. }
  32.  
  33. private void label1_Click(object sender, EventArgs e)
  34. {
  35.  
  36. }
  37.  
  38. private void btnCarrega_Click(object sender, EventArgs e)
  39. {
  40. StdBELista lista = new StdBELista();
  41.  
  42. DataTable dt = new DataTable();
  43. dt.Columns.Add("TipoEntidade");
  44. dt.Columns.Add("Descricao");
  45.  
  46. lista = GeralErp.BSO.Consulta("select distinct TipoEntidade,case TipoEntidade when 'C' then 'Cliente' when 'F' then 'Forncedor' when 'S' then 'Acionista/sócio' when 'E' then 'Estado/Ente Público' when 'I' then 'Forn.Imobilizado' when 'N' then 'Sindicato' when 'A' then 'Subscritores de Capital' when 'L' then 'Cred. subs. n/liberada' when 'T' then 'Cons. Assessor Inter.' when 'G' then 'Obrigacionista' when 'R' then 'Outro Credor' when 'D' then 'Outro Devedor' when 'B' then 'Conta Bancária' else TipoEntidade end as Descricao from V_Entidades ");
  47. //dt.Rows.Clear();
  48. while (!lista.NoFim())
  49. {
  50. dt.Rows.Add(lista.Valor("TipoEntidade"), lista.Valor("Descricao"));
  51. lista.Seguinte();
  52. }
  53. dtgvTiposentidade.DataSource = dt;
  54. dtgvTiposentidade.Refresh();
  55. }
  56.  
  57. private void btnExport_Click(object sender, EventArgs e)
  58. {
  59. TipoEntidade t = new TipoEntidade();
  60.  
  61. StdBELista lista = new StdBELista();
  62.  
  63. DataTable dt = new DataTable();
  64. dt.Columns.Add("TipoEntidade");
  65. dt.Columns.Add("Descricao");
  66.  
  67. lista = GeralErp.BSO.Consulta("select distinct TipoEntidade,case TipoEntidade when 'C' then 'Cliente' when 'F' then 'Forncedor' when 'S' then 'Acionista/sócio' when 'E' then 'Estado/Ente Público' when 'I' then 'Forn.Imobilizado' when 'N' then 'Sindicato' when 'A' then 'Subscritores de Capital' when 'L' then 'Cred. subs. n/liberada' when 'T' then 'Cons. Assessor Inter.' when 'G' then 'Obrigacionista' when 'R' then 'Outro Credor' when 'D' then 'Outro Devedor' when 'B' then 'Conta Bancária' else TipoEntidade end as Descricao from V_Entidades ");
  68. // dt.Rows.Clear();
  69. while (!lista.NoFim())
  70. {
  71. TipoEntidade TipoEnt = new TipoEntidade();
  72. TipoEnt.codigo = lista.Valor("TipoEntidade");
  73. TipoEnt.descricao = lista.Valor("Descricao");
  74. TipoEnt = Api.postDataToWebAPI<TipoEntidade>(Api.EnderecoWebAPI + "/rest/api/v1/tipoentidade", TipoEnt, new TipoEntidade { });
  75. if (TipoEnt != null)
  76. {
  77. if (TipoEnt.ID == 0)
  78. {
  79. Console.WriteLine("Erro");
  80. }
  81. }
  82. //BancoCtrl.postDataToWebAPI(ba);
  83.  
  84. lista.Seguinte();
  85. }
  86.  
  87. //b.codigo
  88. //b.descricao
  89.  
  90. TEntidades = Api.getDataFromWebAPI_EX<TipoEntidade[]>(Api.EnderecoWebAPI + "/rest/api/v1/tipoentidade", new TipoEntidade[] { });
  91. /// Auth a = Api.postDataToWebAPI<Auth>(Api.EnderecoWebAPI + "/rest/login", new Login { Username = username, Password = password }, new Auth { });
  92. // MessageBox.Show(Api.Token + " - " + Api.TokenType);
  93. dt = new DataTable();
  94. dt.Columns.Add("TipoEntidade");
  95. dt.Columns.Add("Descricao");
  96. if (TEntidades.Count > 0)
  97. {
  98.  
  99. tipoEntidades = TEntidades["tipoEntidade"].ToList();
  100. foreach (TipoEntidade tipo in tipoEntidades)
  101. {
  102.  
  103. dt.Rows.Add(tipo.codigo, tipo.descricao);
  104.  
  105. }
  106. dtgvTiposentidade.DataSource = dt;
  107. }
  108. }
  109.  
  110. private void btnImportar_Click(object sender, EventArgs e)
  111. {
  112.  
  113. }
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement