private void preencher_terminais() { ListViewItem item; //DBApp db = new DBApp(); //SqlCommand comm = db.Conn.CreateCommand(); //comm.CommandText = "SELECT TRM_DESCRICAO, TRM_IP, TRM_PORTA, TRM_IND FROM Terminais ORDER BY TRM_DESCRICAO"; //SqlDataReader reader = comm.ExecuteReader(); DBApp db = new DBApp(); SqlDataReader reader = db.getReader("SELECT TRM_DESCRICAO, TRM_IP, TRM_PORTA, TRM_IND FROM Terminais ORDER BY TRM_DESCRICAO"); listRelogios.Items.Clear(); while (reader.Read()) { item = new ListViewItem(); item.Text = reader["TRM_DESCRICAO"].ToString().Trim(); item.SubItems.Add(reader["TRM_IP"].ToString().Trim()); item.SubItems.Add(reader["TRM_PORTA"].ToString().Trim()); item.SubItems.Add(reader["TRM_IND"].ToString()); item.ImageIndex = 0; listRelogios.Items.Add(item); } reader.Close(); db.closeConnection(); }
private void RepEdicao_Load(object sender, EventArgs e) { if (Terminal > 0) { db = new DBApp(); //SqlCommand Comm = db.Conn.CreateCommand(); //Comm.CommandText = "SELECT TRM_DESCRICAO, TRM_IP, TRM_PORTA, TRM_RAZAOSOCIAL, TRM_CNPJ, TRM_CPF, " + // "TRM_ENDERECO, TRM_NUMERO, TRM_SERIAL FROM Terminais WHERE TRM_IND = " + Terminal.ToString() + " " + // "ORDER BY TRM_DESCRICAO"; //SqlDataReader reader = Comm.ExecuteReader(); SqlDataReader reader = db.getReader("SELECT TRM_DESCRICAO, TRM_IP, TRM_PORTA, TRM_RAZAOSOCIAL, TRM_CNPJ, TRM_CPF, " + "TRM_ENDERECO, TRM_NUMERO, TRM_SERIAL FROM Terminais WHERE TRM_IND = " + Terminal.ToString() + " " + "ORDER BY TRM_DESCRICAO"); reader.Read(); edDescricao.Text = reader["TRM_DESCRICAO"].ToString().Trim(); edIp.Text = reader["TRM_IP"].ToString().Trim(); edPorta.Text = reader["TRM_PORTA"].ToString().Trim(); edRazaoSocial.Text = reader["TRM_RAZAOSOCIAL"].ToString().Trim(); edCnpj.Text = reader["TRM_CNPJ"].ToString().Trim(); edCpf.Text = reader["TRM_CPF"].ToString().Trim(); edEndereco.Text = reader["TRM_ENDERECO"].ToString().Trim(); edNumero.Text = reader["TRM_NUMERO"].ToString().Trim(); edSerial.Text = reader["TRM_SERIAL"].ToString().Trim(); reader.Close(); db.closeConnection(); } else { edPorta.Text = Consts.PORTAPADRAO.ToString(); } }
private void preencher_funcionarios(int Terminal) { ListViewItem item; DBApp db = new DBApp(); //SqlCommand comm = db.Conn.CreateCommand(); //comm.CommandText = "SELECT FUNC_NOME, CAR_DESCRICAO, CRA_NUMERO, FUNC_PIS, FUNC_IND, " + // "dbo.fn_getdatetime(TRMF_ARMAZENADO_EM) AS TRMF_ARMAZENADO_EM " + // "FROM Funcionarios " + // "LEFT JOIN Cargos ON CAR_IND = FUNC_CARGO " + // "LEFT JOIN Crachas ON CRA_FUNC = FUNC_IND " + // "INNER JOIN TerminaisFuncionarios ON TRMF_FUNC = FUNC_IND " + // "WHERE TRMF_TERMINAL = " + Terminal + " AND FUNC_DT_DEM IS NULL AND FUNC_MARCADO_EXCLUSAO = 0 " + // "ORDER BY FUNC_NOME"; //SqlDataReader reader = comm.ExecuteReader(); SqlDataReader reader = db.getReader("SELECT FUNC_NOME, CAR_DESCRICAO, CRA_NUMERO, FUNC_PIS, FUNC_IND, " + "dbo.fn_getdatetime(TRMF_ARMAZENADO_EM) AS TRMF_ARMAZENADO_EM " + "FROM Funcionarios " + "LEFT JOIN Cargos ON CAR_IND = FUNC_CARGO " + "LEFT JOIN Crachas ON CRA_FUNC = FUNC_IND " + "INNER JOIN TerminaisFuncionarios ON TRMF_FUNC = FUNC_IND " + "WHERE TRMF_TERMINAL = " + Terminal + " AND FUNC_DT_DEM IS NULL AND FUNC_MARCADO_EXCLUSAO = 0 " + "ORDER BY FUNC_NOME"); listFuncionarios.Items.Clear(); while (reader.Read()) { item = new ListViewItem(); item.Text = reader["FUNC_NOME"].ToString().Trim(); item.SubItems.Add(reader["CAR_DESCRICAO"].ToString().Trim()); item.SubItems.Add(reader["CRA_NUMERO"].ToString()); item.SubItems.Add(reader["FUNC_PIS"].ToString().Trim()); item.SubItems.Add(reader["FUNC_IND"].ToString()); item.SubItems.Add(reader["TRMF_ARMAZENADO_EM"].ToString()); listFuncionarios.Items.Add(item); } reader.Close(); db.closeConnection(); }