private void CarregaCupom() { try { if (_list.Count() == 0) { _list = SqliteDataAccess.CarregaDadosEstacionamento(); } int idInicial = 1; if (_listCupom.Count() == 0) { _listCupom = SqliteDataAccess.CarregaUltimoCupom(); } else { idInicial = _listCupom[0].id; } DataGridTableStyle tableStyle = new DataGridTableStyle(); DataGridTextBoxColumn txtColumn = new DataGridTextBoxColumn(); txtColumn.HeaderText = "Coluna 1"; txtColumn.Width = 100; tableStyle.GridColumnStyles.Add(txtColumn); DataGridTextBoxColumn txtColumn2 = new DataGridTextBoxColumn(); txtColumn2.HeaderText = "Coluna 2"; txtColumn2.Width = 50; tableStyle.GridColumnStyles.Add(txtColumn2); DataGrid ordGrid = new DataGrid(); ordGrid.TableStyles.Add(tableStyle); DataTable dTable = new DataTable(); dTable.Columns.Add(new DataColumn("Coluna 1")); dTable.Columns.Add(new DataColumn("Coluna 2")); /*DataRow dr = dTable.NewRow(); * dr["Coluna 1"] = ""; * dr["Coluna 2"] = ""; * dTable.Rows.Add(dr);*/ DataRow dr = dTable.NewRow(); dr["Coluna 1"] = "\t\tENTRADA"; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Cupom\t :"; dr["Coluna 2"] = NumeroCupom(idInicial + 1); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Placa\t\t :"; dr["Coluna 2"] = txtPlaca.Text; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Entrada\t :"; dr["Coluna 2"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm"); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Cabine\t :"; dr["Coluna 2"] = "SAORAFAEL"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Usuario\t :"; dr["Coluna 2"] = "ADMIN"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Local\t\t :"; dr["Coluna 2"] = "PATIO"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Tabela\t :"; dr["Coluna 2"] = cmbTipo.SelectedItem.ToString().Substring(0, 6); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Seja bem vindo!"; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = _list[0].nome; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "CNPJ\t :"; dr["Coluna 2"] = _list[0].cnpj; dTable.Rows.Add(dr); ordGrid.DataSource = dTable.DefaultView; ordGrid.Refresh(); richTextBox1.Text = ""; float[] tabs = { 30, 60 }; _stringFormat.SetTabStops(0, tabs); for (int i = 0; i < dTable.Rows.Count; i++) { for (int j = 0; j < dTable.Columns.Count; j++) { richTextBox1.Text += "\t" + dTable.Rows[i][j].ToString() + (j == 0 ? "\t" : "\n"); } } richTextBox1.SelectAll(); richTextBox1.SelectionTabs = new int[] { 30, 60 }; richTextBox1.AcceptsTab = true; richTextBox1.Select(0, 0); } catch (Exception ex) { throw ex; } }
private void CarregaCupom() { if (!btnImprimirSegundaVia.Enabled && !btnRegSaida.Enabled) { richTextBox1.Text = ""; return; } try { if (_listEmpresa.Count() == 0) { _listEmpresa = SqliteDataAccess.CarregaDadosEstacionamento(); } int idInicial = 1; if (_listRegistro.Count() == 0) { _listRegistro = SqliteDataAccess.CarregaUltimoCupom(); } else { idInicial = _listRegistro[0].id; } DataGridTableStyle tableStyle = new DataGridTableStyle(); DataGridTextBoxColumn txtColumn = new DataGridTextBoxColumn(); txtColumn.HeaderText = "Coluna 1"; txtColumn.Width = 100; tableStyle.GridColumnStyles.Add(txtColumn); DataGridTextBoxColumn txtColumn2 = new DataGridTextBoxColumn(); txtColumn2.HeaderText = "Coluna 2"; txtColumn2.Width = 50; tableStyle.GridColumnStyles.Add(txtColumn2); DataGrid ordGrid = new DataGrid(); ordGrid.TableStyles.Add(tableStyle); DataTable dTable = new DataTable(); dTable.Columns.Add(new DataColumn("Coluna 1")); dTable.Columns.Add(new DataColumn("Coluna 2")); if (_listRegistro.Count > 0) { DataRow dr = dTable.NewRow(); dr["Coluna 1"] = "\t\tSAIDA"; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Via\t\t :"; dr["Coluna 2"] = (_listRegistro[0].data_saida != DateTime.MinValue ? "2" : "1"); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Cupom\t :"; dr["Coluna 2"] = NumeroCupom(idInicial); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Placa\t\t :"; dr["Coluna 2"] = txtPlaca.Text; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Entrada\t :"; dr["Coluna 2"] = _listRegistro[0].data_entrada.ToString("dd/MM/yyyy HH:mm"); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Saida\t\t :"; dr["Coluna 2"] = (_listRegistro[0].data_saida == DateTime.MinValue ? DateTime.Now.ToString("dd/MM/yyyy HH:mm") : _listRegistro[0].data_saida.ToString("dd/MM/yyyy HH:mm")); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Permanencia:"; dr["Coluna 2"] = lbDiarias.Text; dTable.Rows.Add(dr); if (_horas > 24 && _horas < 26) { _diarias = 1; dr = dTable.NewRow(); dr["Coluna 1"] = "Tolerancia:"; dr["Coluna 2"] = "1 hora"; dTable.Rows.Add(dr); } dr = dTable.NewRow(); dr["Coluna 1"] = "Cabine\t :"; dr["Coluna 2"] = "SAORAFAEL"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Usuário\t :"; dr["Coluna 2"] = "ADMIN"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Local\t\t :"; dr["Coluna 2"] = "PATIO"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Tabela\t :"; dr["Coluna 2"] = RetornaTipoValor(_listRegistro[0].tipo); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "TOTAL\t :"; dr["Coluna 2"] = "R$ " + _valor.ToString() + ",00"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = _listEmpresa[0].nome; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "CNPJ\t :"; dr["Coluna 2"] = _listEmpresa[0].cnpj; dTable.Rows.Add(dr); ordGrid.DataSource = dTable.DefaultView; ordGrid.Refresh(); richTextBox1.Text = ""; float[] tabs = { 30, 60 }; _stringFormat.SetTabStops(0, tabs); for (int i = 0; i < dTable.Rows.Count; i++) { for (int j = 0; j < dTable.Columns.Count; j++) { richTextBox1.Text += "\t" + dTable.Rows[i][j].ToString() + (j == 0 ? "\t" : "\n"); } } richTextBox1.SelectAll(); richTextBox1.SelectionTabs = new int[] { 30, 60 }; richTextBox1.AcceptsTab = true; richTextBox1.Select(0, 0); } } catch (Exception ex) { throw ex; } }