private void inicio() { try { txtID.Text = string.Empty; txtFundo.Text = string.Empty; txtFundo.Focus(); cFundo cfun = new cFundo(); using (DataTable dt = cfun.preenche_lista_fundo()) { #region listview lvSetor.Clear(); lvSetor.View = View.Details; lvSetor.LabelEdit = true; lvSetor.AllowColumnReorder = true; lvSetor.CheckBoxes = false; lvSetor.FullRowSelect = true; lvSetor.GridLines = true; lvSetor.Sorting = SortOrder.Ascending; lvSetor.Columns.Add("Código", 50); lvSetor.Columns.Add("Fundo", 330, HorizontalAlignment.Left); for (int i = 0; i < dt.Rows.Count; i++) { DataRow drw = dt.Rows[i]; ListViewItem lvi = new ListViewItem(drw["ID_FUNDO"].ToString()); lvi.SubItems.Add(drw["FUNDO"].ToString()); lvSetor.Items.Add(lvi); } lblTotalReg.Text = string.Concat("Total de ", lvSetor.Items.Count, " registro(s)"); #endregion } if (lvSetor.Items.Count == 0) { mnuOculto.Enabled = false; } else { mnuOculto.Enabled = true; } if (lvSetor.Items.Count > 0) { lvSetor.Items[0].Selected = true; lvSetor_Click(null, null); } } catch (Exception ex) { #region LOG ERRO cLog lg = new cLog(); lg.log = ex.Message.Replace("'", ""); lg.form = this.Text; lg.metodo = "Inicio"; lg.dt = DateTime.Now; lg.usersistema = cGlobal.userlogado; lg.userRede = Environment.UserName; lg.terminal = Environment.MachineName; lg.tp_flag = false; lg.grava_log(lg); #endregion } }
private void inicio() { try { txtRazaoSocial.Text = string.Empty; txtSiglaSac.Text = string.Empty; txtSiglaFy.Text = string.Empty; mktCnpjCpf.Text = string.Empty; mktCnpjCpf.ReadOnly = true; mktCnpjCpf.BackColor = Color.White; rbCnpj.Checked = false; rbCpf.Checked = false; txtRazaoSocial.Focus(); cFundo fd = new cFundo(); using (DataSet ds = fd.preenche_lista_fundo()) { using (DataTable dt = ds.Tables["Fundo"]) { #region listview lvFundo.Clear(); lvFundo.View = View.Details; lvFundo.LabelEdit = false; lvFundo.AllowColumnReorder = true; lvFundo.CheckBoxes = false; lvFundo.FullRowSelect = true; lvFundo.GridLines = true; lvFundo.Sorting = SortOrder.Ascending; lvFundo.Columns.Add("", 0); lvFundo.Columns.Add("Razão Social", 290, HorizontalAlignment.Left); lvFundo.Columns.Add("Sigla SAC", 100, HorizontalAlignment.Center); lvFundo.Columns.Add("Sigla FY", 100, HorizontalAlignment.Center); lvFundo.Columns.Add("CNPJ/CPF", 150, HorizontalAlignment.Center); //lvFundo.Columns.Add("Cadastro por", 120, HorizontalAlignment.Left); //lvFundo.Columns.Add("Data Cadastro", 120, HorizontalAlignment.Left); for (int i = 0; i < dt.Rows.Count; i++) { DataRow drw = dt.Rows[i]; ListViewItem lvi = new ListViewItem(drw["ID_FUNDO"].ToString()); lvi.SubItems.Add(drw["RAZAO_SOCIAL"].ToString()); lvi.SubItems.Add(drw["SIGLA_SAC"].ToString()); lvi.SubItems.Add(drw["SIGLA_FY"].ToString()); if (drw["CNPJ_CPF"].ToString().Length == 14) { lvi.SubItems.Add(string.Concat(drw["CNPJ_CPF"].ToString().Substring(0, 2), ".", drw["CNPJ_CPF"].ToString().Substring(2, 3), ".", drw["CNPJ_CPF"].ToString().Substring(5, 3), "/", drw["CNPJ_CPF"].ToString().Substring(8, 4), "-", drw["CNPJ_CPF"].ToString().Substring(12, 2)).Replace(",", ".")); } else if (drw["CNPJ_CPF"].ToString().Length == 11) { lvi.SubItems.Add(string.Concat(drw["CNPJ_CPF"].ToString().Substring(0, 3), ".", drw["CNPJ_CPF"].ToString().Substring(3, 3), ".", drw["CNPJ_CPF"].ToString().Substring(6, 3), "-", drw["CNPJ_CPF"].ToString().Substring(9, 2)).Replace(",", ".")); } //lvi.SubItems.Add(drw["USERCAD"].ToString()); //lvi.SubItems.Add(drw["DTCAD"].ToString()); lvFundo.Items.Add(lvi); } lblTotalReg.Text = string.Concat("Total de ", lvFundo.Items.Count, " registro(s)"); #endregion } } if (lvFundo.Items.Count == 0) { mnuOculto.Enabled = false; } else { mnuOculto.Enabled = true; } if (lvFundo.Items.Count > 0) { lvFundo.Items[0].Selected = true; lvFundo_Click(null, null); } } catch (Exception ex) { #region LOG ERRO cLog lg = new cLog(); lg.log = ex.Message.Replace("'", ""); lg.form = this.Text; lg.metodo = "inicio"; lg.dt = DateTime.Now; lg.usersistema = cGlobal.userlogado; lg.userRede = Environment.UserName; lg.terminal = Environment.MachineName; lg.tp_flag = false; lg.grava_log(lg); #endregion } }