private CivInfoBO ReadRecord(SqlCeDataReader reader) { CivInfoBO result = new CivInfoBO(); result.Name = reader.GetString(0); result.Value = reader.GetString(1); return result; }
public static TVigilante GetVigilanteFromDr(SqlCeDataReader dr) { TVigilante v = new TVigilante(); v.vigilanteId = dr.GetInt32(0); v.nombre = dr.GetString(1); v.tag = dr.GetString(2); v.tagf = dr.GetString(3); return v; }
public static TRonda GetRondaFromDr(SqlCeDataReader dr) { TRonda r = new TRonda(); r.rondaId = dr.GetInt32(0); r.nombre = dr.GetString(1); r.tag = dr.GetString(2); r.tagf = dr.GetString(3); return r; }
public static TAdministrador GetAdministradorFromDr(SqlCeDataReader dr) { TAdministrador adm = new TAdministrador(); adm.administradorId = dr.GetInt32(0); adm.nombre = dr.GetString(1); adm.login = dr.GetString(2); adm.password = dr.GetString(3); adm.email = dr.GetString(4); adm.nivel = dr.GetInt32(5); return adm; }
public static TPunto GetPuntoFromDr(SqlCeDataReader dr) { TPunto p = new TPunto(); p.puntoId = dr.GetInt32(0); p.nombre = dr.GetString(1); p.edificioId = dr.GetInt32(2); p.tag = dr.GetString(3); p.cota = dr.GetString(4); p.cubiculo = dr.GetString(5); p.observaciones = dr.GetString(6); return p; }
public static TTerminal GetTerminalFromDr(SqlCeDataReader dr) { TTerminal t = new TTerminal(); t.terminalId = dr.GetInt32(0); t.numero = dr.GetString(1); t.nombre = dr.GetString(2); if (dr[3] != DBNull.Value) t.fechaAlta = dr.GetDateTime(3); if (dr[4] != DBNull.Value) t.fechaBaja = dr.GetDateTime(4); return t; }
public static TDescargaLinea GetDescargaLineaFromDr(SqlCeDataReader dr) { TDescargaLinea dl = new TDescargaLinea(); dl.descargaLineaId = dr.GetInt32(0); dl.descargaId = dr.GetInt32(1); dl.tag = dr.GetString(2); dl.fechaHora = dr.GetDateTime(3); dl.tipo = dr.GetString(4); dl.tipoId = dr.GetInt32(5); dl.nombre = dr.GetString(6); dl.incidenciaId = dr.GetInt32(7); dl.observaciones = dr.GetString(8); return dl; }
public static TVigilante GetVigilanteFromDr(SqlCeDataReader dr) { TVigilante vig = new TVigilante(); vig.vigilanteId = dr.GetInt32(0); vig.nombre = dr.GetString(1); return vig; }
public static TIncidencia GetIncidenciaFromDr(SqlCeDataReader dr) { TIncidencia inci = new TIncidencia(); inci.incidenciaId = dr.GetInt32(0); inci.nombre = dr.GetString(1); return inci; }
public static TGrupo GetGrupoFromDr(SqlCeDataReader dr) { TGrupo g = new TGrupo(); g.grupoId = dr.GetInt32(0); g.nombre = dr.GetString(1); return g; }
public static TEdificio GetEdificioFromDr(SqlCeDataReader dr) { TEdificio edif = new TEdificio(); edif.edificioId = dr.GetInt32(0); edif.nombre = dr.GetString(1); edif.grupoId = dr.GetInt32(2); return edif; }
public static TRonda GetRondaFromDr(SqlCeDataReader dr) { TRonda r = new TRonda(); bool primero = true; while (dr.Read()) { if (primero) { r.rondaId = dr.GetInt32(0); r.nombre = dr.GetString(1); r.tag = dr.GetString(2); r.tagf = dr.GetString(3); r.RondasPuntos = new List<TRondaPunto>(); primero = false; } TRondaPunto rp = new TRondaPunto(); TPunto p = new TPunto(); TEdificio e = new TEdificio(); TGrupo g = new TGrupo(); rp.rondaPuntoId = dr.GetInt32(4); rp.orden = dr.GetInt32(5); p.puntoId = dr.GetInt32(6); p.nombre = dr.GetString(7); e.edificioId = dr.GetInt32(8); p.tag = dr.GetString(9); e.nombre = dr.GetString(10); g.grupoId = dr.GetInt32(11); g.nombre = dr.GetString(12); p.cota = dr.GetString(13); p.cubiculo = dr.GetString(14); r.mintime = dr.GetInt32(15); r.maxtime = dr.GetInt32(16); p.csnmax = dr.GetInt32(17); p.csnmargen = dr.GetInt32(18); p.lastcontrol = dr.GetDateTime(19); e.Grupo = g; p.Edificio = e; rp.Punto = p; rp.Ronda = r; r.RondasPuntos.Add(rp); } return r; }
private bool duplicate(SqlCeConnection conn, string catname, string query) { try { SqlCeDataReader reader = null; SqlCeCommand cmd = new SqlCeCommand(query, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (catname.ToLower() == reader.GetString(0).ToLower()) { return(true); } } return(false); } catch (Exception ex) { MessageBox.Show("Error occured while checking for duplicate entry"); return(true); } }
public static TTipoDispositivo GetTTipoDispositivo(string nombre, SqlCeConnection conn) { TTipoDispositivo ta = null; string sql = String.Format("SELECT * FROM TipoDispositivo WHERE nombre='{0}'", nombre); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TTipoDispositivo(); ta.TipoDispositivoId = dr.GetInt32(0); ta.Nombre = dr.GetString(1); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }
public Info() { // // Required for Windows Form Designer support // InitializeComponent(); string connectionString; connectionString = "DataSource=Baza.sdf; Password=matrix1"; SqlCeConnection cn = new SqlCeConnection(connectionString); cn.Open(); SqlCeCommand cmd2 = cn.CreateCommand(); cmd2.CommandText = "SELECT * FROM opcje WHERE id = 1"; cmd2.Prepare(); SqlCeDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { serial = dr.GetString(11); } serial_t.Text = serial; licence = GetDeviceID().Substring(1, 10); deviceid.Text = licence; this.Height = Screen.PrimaryScreen.Bounds.Height; this.Width = Screen.PrimaryScreen.Bounds.Width; Update(); // // TODO: Add any constructor code after InitializeComponent call // cn.Close(); }
public static void SyncDataToServer() { string query = "select q_query from LTB_QUERY"; List <string> list = new List <string>(); using (SqlCeDataReader reader = LocalDataService.GetInstance().ExecuteReader(query)) { while (reader.Read()) { list.Add(reader.GetString(0)); } } foreach (string text in list) { DataService.GetInstance().ExecuteNonQuery(text); } string delText = "delete from LTB_QUERY"; //LocalDataService.GetInstance().ExecuteNonQuery(delText); }
public static TTipoAnomalia GetTTipoAnomalia(int id, SqlCeConnection conn) { TTipoAnomalia ta = null; string sql = String.Format("SELECT * FROM TipoAnomalia WHERE tipo_anomalia_id={0}", id); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TTipoAnomalia(); ta.TipoAnomaliaId = dr.GetInt32(0); ta.Nombre = dr.GetString(1); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }
public IList <Vehicle> FetchVehicles() { IList <Vehicle> vozila = new List <Vehicle>(); using (var com = new SqlCeCommand("SELECT * FROM Vozila", _connection)) { SqlCeDataReader reader = com.ExecuteReader(); while (reader.Read()) { var id = reader.GetInt32(0); var lineNumber = reader.GetInt32(1); var type = reader.GetString(2); vozila.Add(new Vehicle(lineNumber, type) { Id = id }); } } return(vozila); }
// 填写cells的内容,具体为time时间、union工会下的经费信息,按groupBy分组 private void FillCells(Excel.Range cells, DateTime time, string union, string groupBy) { cells[1, 1] = "纳税人名称"; cells[1, 2] = "实缴金额"; string sql = @"SELECT c.CompanyName, f.Received FROM CompanyInfo c INNER JOIN Funds f ON c.CompanyID = f.CompanyID WHERE f.Time = @time AND c." + groupBy + " = @group" + (union != null ? " AND c.[Union] = '" + union + "'" : ""); using (var cmd = new SqlCeCommand(sql, database_.GetConnection())) { cmd.Parameters.AddWithValue("@time", time); cmd.Parameters.Add("@group", SqlDbType.NVarChar); double fileTotal = 0; int row = 2; foreach (string group in categories_[groupBy]) { cmd.Parameters[1].Value = group; SqlCeDataReader reader = cmd.ExecuteReader(); double groupTotal = 0; while (reader.Read()) { cells[row, 1] = reader.GetString(0); cells[row, 2] = Math.Round(reader.GetDouble(1), 2); groupTotal += cells[row, 2].Value; ++row; } reader.Close(); cells.Rows[row].Font.Bold = true; cells[row, 1] = group; cells[row, 2] = groupTotal; fileTotal += groupTotal; groupTotal = 0; ++row; } cells.Rows[row].Font.Bold = true; cells[row, 1] = "合计"; cells[row, 2] = fileTotal; } }
/// <summary> /// Charge la liste complète de tous les tireurs depuis la base de donnée /// </summary> public void GetAllTireurs() { Clear(); using (SqlCeConnection con = new SqlCeConnection(BaseDeDonnee.InfoConnexion)) { con.Open(); using (SqlCeCommand com = new SqlCeCommand("SELECT * FROM tireurs ORDER BY nom ASC", con)) { SqlCeDataReader objReader = com.ExecuteReader(); while (objReader.Read()) { int id = objReader.GetInt32(0); int idEquipe = objReader.GetInt32(1); string nom = objReader.GetString(2); DateTime dateDeNaissance = objReader.GetDateTime(3); Add(new Tireur(id, idEquipe, nom, dateDeNaissance)); } } } }
public static TPunto GetPuntoFromDr(SqlCeDataReader dr) { TGrupo g = new TGrupo(); TEdificio e = new TEdificio(); TPunto p = new TPunto(); p.puntoId = dr.GetInt32(0); p.nombre = dr.GetString(1); e.edificioId = dr.GetInt32(2); p.tag = dr.GetString(3); p.cota = dr.GetString(4); p.cubiculo = dr.GetString(5); p.observaciones = dr.GetString(6); e.nombre = dr.GetString(7); g.grupoId = dr.GetInt32(8); g.nombre = dr.GetString(9); p.csnmax = dr.GetInt32(10); p.csnmargen = dr.GetInt32(11); p.lastcontrol = dr.GetDateTime(12); return p; }
public Form16(SmartDeviceApplication2.Form15 form15a) { // // Required for Windows Form Designer support // form15 = form15a; string connectionString; string fileName = "Baza.sdf"; connectionString = "DataSource=Baza.sdf; Password=matrix1"; SqlCeConnection cn = new SqlCeConnection(connectionString); cn.Open(); SqlCeCommand cmd2 = cn.CreateCommand(); cmd2.CommandText = "SELECT * FROM opcje WHERE id = 1"; cmd2.Prepare(); SqlCeDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { transfer = dr.GetString(1); com = dr.GetString(2); ip = dr.GetString(3); ufile = dr.GetString(4); dfile = dr.GetString(5); bdll = dr.GetString(6); bflag = dr.GetBoolean(7); ipflag = dr.GetBoolean(8); port = dr.GetInt32(9); skaner = dr.GetString(10); } cn.Close(); InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // }
public CadastraUser(string id) { InitializeComponent(); try { Connection sqlExecut = new Connection(); SqlCeDataReader dr = sqlExecut.ReturnQuery(querys.sql_selectCadastro_user + id); if (dr.Read()) { lb_codigo.Text = String.Concat(dr.GetInt32(0), ""); tb_nome.Text = dr.GetString(1); dt_nascimento.Text = String.Concat(dr.GetString(2), ""); tb_endereco.Text = dr.GetString(3); tb_telefone.Text = dr.GetString(4); tb_email.Text = dr.GetString(5); cb_documento.Text = dr.GetString(6); tb_documento.Text = dr.GetString(7); tb_obs.Text = dr.GetString(8); } dr.Close(); } catch (Exception err) { MessageBox.Show(err.Message, "Puts!", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { pb_perfil.Image = Image.FromFile(ctrlImg.GetUrl(lb_codigo.Text, "user")); } catch { tsb_removeImg.PerformClick(); } }
public static IList <TIncidenciaEvolucion> GetTIncidenciaEvolucions(SqlCeConnection conn) { IList <TIncidenciaEvolucion> l = new List <TIncidenciaEvolucion>(); string sql = "SELECT * FROM IncidenciaEvolucion WHERE abm <> 2 ORDER BY incidencia_id DESC"; using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { TIncidenciaEvolucion tIncidenciaEvolucion = new TIncidenciaEvolucion() { IncidenciaEvolucionId = dr.GetInt32(0), Comentarios = dr.GetString(3), Operativo = dr.GetBoolean(5) }; if (dr[2] != DBNull.Value) { tIncidenciaEvolucion.FechaEvolucion = dr.GetDateTime(2); } if (dr[4] != DBNull.Value) { tIncidenciaEvolucion.TUsuario = GetTUsuario(dr.GetInt32(4), conn); } tIncidenciaEvolucion.Abm = dr.GetByte(6); if (tIncidenciaEvolucion != null) { l.Add(tIncidenciaEvolucion); } } if (!dr.IsClosed) { dr.Close(); } } return(l); }
public static TPunto GetPuntoFromDr(SqlCeDataReader dr) { TGrupo g = new TGrupo(); TEdificio e = new TEdificio(); TPunto p = new TPunto(); p.puntoId = dr.GetInt32(0); p.nombre = dr.GetString(1); e.edificioId = dr.GetInt32(2); p.tag = dr.GetString(3); p.cota = dr.GetString(4); p.cubiculo = dr.GetString(5); p.observaciones = dr.GetString(6); e.nombre = dr.GetString(7); g.grupoId = dr.GetInt32(8); g.nombre = dr.GetString(9); p.csnmax = dr.GetInt32(10); p.csnmargen = dr.GetInt32(11); p.lastcontrol = dr.GetDateTime(12); return(p); }
/// <summary> /// Gets List of Enrolment Numbers of Students Corresponding to Serial Numbers /// </summary> /// <param name="_serialNos">Array of Serial Numbers (ID) of students of one class(period/batch)</param> /// <returns>List of Enrolment Numbers(string)</returns> private List <string> GetEnrolmentNoFromDB(int[] _serialNos) { StringBuilder inClause = new StringBuilder(); List <string> enrolNos = new List <string>(); foreach (var student in _serialNos) { inClause.Append('\''); inClause.Append(student); inClause.Append('\''); inClause.Append(','); } inClause.Length -= 1; try { SqlCeConnection con = new SqlCeConnection(@"Data Source=|DataDirectory|\Student_Data.sdf"); con.Open(); string query = "SELECT ADMISSION_NO FROM STUD_DATA WHERE STUD_DATA.SERIAL IN (" + inClause.ToString() + ')'; SqlCeCommand comm = new SqlCeCommand(query, con); SqlCeDataReader reader = comm.ExecuteReader(); while (reader.Read()) { string enrolNo = reader.GetString(0); enrolNos.Add(enrolNo); } con.Close(); } catch (SqlCeException _sqlexception) { MessageBox.Show("Sorry the following Error Occured : " + _sqlexception.Message); return(null); } return(enrolNos); }
public static TInstalacion GetTInstalacion(string nombre, SqlCeConnection conn) { TInstalacion ta = null; string sql = String.Format("SELECT * FROM Instalacion WHERE nombre='{0}'", nombre); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TInstalacion(); ta.InstalacionId = dr.GetInt32(0); ta.Nombre = dr.GetString(1); ta.Abm = dr.GetByte(2); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }
public static TFabricante GetTFabricante(int id, SqlCeConnection conn) { TFabricante ta = null; string sql = String.Format("SELECT * FROM Fabricante WHERE fabricante_id={0}", id); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TFabricante(); ta.FabricanteId = dr.GetInt32(0); ta.Nombre = dr.GetString(2); ta.Abm = dr.GetByte(3); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }
//End of year changes. made and sold YTD = 0. 1231 = current onhand. private void button2_Click(object sender, EventArgs e) { var result = MessageBox.Show("Are you sure you wish to run end of year?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { conn.Open(); SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Table2", conn); SqlCeCommand cmd2 = new SqlCeCommand("UPDATE Table2 SET madeYTD = 0, soldYTD = 0, onHand1231 = @1 WHERE barcode = @2", conn); SqlCeDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { cmd2.Parameters.AddWithValue("@1", rdr.GetInt32(1).ToString()); cmd2.Parameters.AddWithValue("@2", rdr.GetString(0)); cmd2.ExecuteNonQuery(); cmd2.Parameters.Clear(); } reloadGrid(); conn.Close(); MessageBox.Show("End of year executed successfully."); } }
public static TModeloDispositivo GetTModeloDispositivo(int id, SqlCeConnection conn) { TModeloDispositivo ta = null; string sql = String.Format("SELECT * FROM ModeloDispositivo WHERE modelo_id={0}", id); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TModeloDispositivo(); ta.ModeloDispositivoId = dr.GetInt32(0); ta.Nombre = dr.GetString(1); ta.Abm = dr.GetByte(2); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }
private void FinalInvoice_Load(object sender, EventArgs e) { dboperation operation = new dboperation(); SqlCeConnection conn = operation.dbConnection(Settings.Default.DatabasePath); string query = "SELECT prefix FROM regdetails WHERE Id=1"; SqlCeCommand cmd = new SqlCeCommand(query, conn); SqlCeDataReader reader = null; try { reader = cmd.ExecuteReader(); while (reader.Read()) { invoiceprefix = reader.GetString(0); } } catch (Exception ex) { MessageBox.Show("" + ex); } calculation(); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { try { string connexionString = (@"Data Source=C:\Users\pc\documents\visual studio 2010\Projects\gestion_café\gestion_café\base_café.sdf"); SqlCeConnection connexion = new SqlCeConnection(connexionString); connexion.Open(); SqlCeCommand cmd6 = new SqlCeCommand("select * from caissiers where prenom=@prenom_saisie", connexion); string varprenom = comboBox1.Text; cmd6.Parameters.AddWithValue("@prenom_saisie", varprenom); SqlCeDataReader rdr = null; rdr = cmd6.ExecuteReader(); while (rdr.Read()) { if (rdr.GetString(2) == varprenom) { panel1.Visible = (true); verifid.Visible = (false); pictureBox1.Visible = (false); idntxt.Text = rdr.GetString(0); nomtxt.Text = rdr.GetString(1); prenomtxt.Text = rdr.GetString(2); dntxt.Text = rdr.GetString(3); teletxt.Text = rdr.GetString(4); var imgByData = (Byte[])rdr["pic"]; var bitmap = new Bitmap(new MemoryStream(imgByData)); pictureBox2.Image = bitmap; } } connexion.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } idtxt.Text = ""; }
public static TAgenteExtintor GetTAgenteExtintor(string descripcion, SqlCeConnection conn) { TAgenteExtintor ta = null; string sql = String.Format("SELECT * FROM AgenteExtintor WHERE descripcion='{0}'", descripcion); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TAgenteExtintor(); ta.AgenteExtintorId = dr.GetInt32(0); ta.Descripcion = dr.GetString(2); ta.Abm = dr.GetByte(3); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }
public static TEstado GetTEstado(string nombre, SqlCeConnection conn) { TEstado Estado = null; using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = String.Format("SELECT * FROM Estado WHERE nombre = '{0}'", nombre); SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Estado = new TEstado() { EstadoId = dr.GetInt32(0), Nombre = dr.GetString(1), }; } if (!dr.IsClosed) { dr.Close(); } } return(Estado); }
public static TResponsable GetTResponsable(string nombre, SqlCeConnection conn) { TResponsable tr = null; string sql = String.Format("SELECT * FROM Responsable WHERE nombre='{0}'", nombre); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { tr = new TResponsable(); tr.ResponsableId = dr.GetInt32(0); tr.Nombre = dr.GetString(1); tr.Abm = dr.GetByte(2); } if (!dr.IsClosed) { dr.Close(); } } return(tr); }
public void FillTabs(TabControl tab, string sql) { try { using (SqlCeConnection conn = new SqlCeConnection(connString.ConnectionString)) { conn.Open(); using (SqlCeCommand command = new SqlCeCommand(sql, conn)) using (SqlCeDataReader reader = command.ExecuteReader()) { while (reader.Read()) { tab.Controls.Add(new TabPage(reader.GetString(0))); } } } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static TPrioridad GetTPrioridad(string nombre, SqlCeConnection conn) { TPrioridad tp = null; string sql = String.Format("SELECT * FROM Prioridad WHERE nombre='{0}'", nombre); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { tp = new TPrioridad(); tp.PrioridadId = dr.GetInt32(0); tp.Nombre = dr.GetString(1); tp.Abm = dr.GetByte(2); } if (!dr.IsClosed) { dr.Close(); } } return(tp); }
public static TGrupoTrabajo GetGrupoTrabajo(int id, SqlCeConnection conn) { TGrupoTrabajo grupot = null; using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = String.Format("SELECT * FROM Grupo_Trabajo WHERE grupo_trabajo_id = {0}", id); SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { grupot = new TGrupoTrabajo() { Grupo_trabajo_id = dr.GetInt32(0), Nombre = dr.GetString(1) }; } if (!dr.IsClosed) { dr.Close(); } } return(grupot); }
static private List <SubBalanceDetails> querySubBalanceDetails(string query) { List <SubBalanceDetails> queryResults = new List <SubBalanceDetails>(); SqlCeConnection connection = new SqlCeConnection(Properties.Settings.Default.FFDBConnectionString); SqlCeCommand command = new SqlCeCommand(query, connection); connection.Open(); SqlCeDataReader reader = command.ExecuteReader(); // Iterate through the results while (reader.Read()) { queryResults.Add(new SubBalanceDetails(reader.GetInt32(0), reader.GetString(1), reader.GetDecimal(2))); } // Always call Close the reader and connection when done reading reader.Close(); command.Dispose(); connection.Close(); return(queryResults); }
private void subCatagoryInitiation_Load(object sender, EventArgs e) { try { SqlCeDataReader reader = null; dboperation operation = new dboperation(); SqlCeConnection conn = null; conn = operation.dbConnection(Settings.Default.DatabasePath); string query = "SELECT Catagory FROM catagory"; SqlCeCommand cmd = new SqlCeCommand(query, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { // Add Catagory List selectcatcombo.Items.Add(reader.GetString(0)); } load_subcat_gridview(conn); operation.closeDBConnection(conn); } catch (Exception ex) { } }
public static TEmpresa GetTEmpresa(int id, SqlCeConnection conn) { TEmpresa ta = null; string sql = String.Format("SELECT * FROM Empresa WHERE empresa_id={0}", id); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TEmpresa(); ta.EmpresaId = dr.GetInt32(0); ta.Nombre = dr.GetString(1); ta.Abm = dr.GetByte(2); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }
public static string GetParametro(string chave) { //string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.dbintegracaoConnectionString"].ConnectionString; string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.ConnectionString"].ConnectionString; string retorno = string.Empty; //MySqlConnection con = new MySqlConnection(ConnectionString); SqlCeConnection con = new SqlCeConnection(ConnectionString); try { con.Open(); //MySqlCommand cmd = new MySqlCommand("SELECT valor from parametro where chave = ?chave", con); SqlCeCommand cmd = new SqlCeCommand("SELECT valor from parametro where chave = @chave", con); cmd.Parameters.AddWithValue("@chave", chave); //MySqlDataReader dr = cmd.ExecuteReader(); SqlCeDataReader dr = cmd.ExecuteReader(); bool HasRows = dr.Read(); if (HasRows) { retorno = dr.GetString(0); } dr.Close(); dr.Dispose(); cmd.Dispose(); return(retorno); } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } }
public Form71(int licence) { // // Required for Windows Form Designer support // //lic = licence; string connectionString; lic = licence; connectionString = "DataSource=Baza.sdf; Password=matrix1"; SqlCeConnection cn = new SqlCeConnection(connectionString); cn.Open(); SqlCeCommand cmd2 = cn.CreateCommand(); cmd2.CommandText = "SELECT * FROM opcje WHERE id = 1"; cmd2.Prepare(); SqlCeDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { transfer = dr.GetString(1); com = dr.GetString(2); ip = dr.GetString(3); ufile = dr.GetString(4); dfile = dr.GetString(5); bdll = dr.GetString(6); bflag = dr.GetBoolean(7); ipflag = dr.GetBoolean(8); port = dr.GetInt32(9); skaner = dr.GetString(10); } cn.Close(); InitializeComponent(); this.Height = Screen.PrimaryScreen.Bounds.Height; this.Width = Screen.PrimaryScreen.Bounds.Width; Update(); }
static JournalItem ReadOneJournalItem(SqlCeDataReader reader) { var journalItem = new JournalItem(); if (!reader.IsDBNull(reader.GetOrdinal("JournalItemType"))) journalItem.JournalItemType = (JournalItemType)reader.GetByte(reader.GetOrdinal("JournalItemType")); if (!reader.IsDBNull(reader.GetOrdinal("SystemDateTime"))) journalItem.SystemDateTime = reader.GetDateTime(reader.GetOrdinal("SystemDateTime")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceDateTime"))) journalItem.DeviceDateTime = reader.GetDateTime(reader.GetOrdinal("DeviceDateTime")); if (!reader.IsDBNull(reader.GetOrdinal("ObjectUID"))) journalItem.ObjectUID = reader.GetGuid(reader.GetOrdinal("ObjectUID")); if (!reader.IsDBNull(reader.GetOrdinal("Name"))) journalItem.Name = reader.GetString(reader.GetOrdinal("Name")); if (!reader.IsDBNull(reader.GetOrdinal("Description"))) journalItem.Description = reader.GetString(reader.GetOrdinal("Description")); if (!reader.IsDBNull(reader.GetOrdinal("ObjectState"))) journalItem.ObjectState = reader.GetInt32(reader.GetOrdinal("ObjectState")); if (!reader.IsDBNull(reader.GetOrdinal("GKObjectNo"))) journalItem.GKObjectNo = (ushort)reader.GetInt16(reader.GetOrdinal("GKObjectNo")); if (!reader.IsDBNull(reader.GetOrdinal("GKIpAddress"))) journalItem.GKIpAddress = reader.GetString(reader.GetOrdinal("GKIpAddress")); if (!reader.IsDBNull(reader.GetOrdinal("GKJournalRecordNo"))) journalItem.GKJournalRecordNo = reader.GetInt32(reader.GetOrdinal("GKJournalRecordNo")); if (!reader.IsDBNull(reader.GetOrdinal("KAUNo"))) journalItem.ControllerAddress = (ushort)reader.GetInt32(reader.GetOrdinal("KAUNo")); if (!reader.IsDBNull(reader.GetOrdinal("StateClass"))) journalItem.StateClass = (XStateClass)reader.GetByte(reader.GetOrdinal("StateClass")); if (!reader.IsDBNull(reader.GetOrdinal("UserName"))) journalItem.UserName = reader.GetString(reader.GetOrdinal("UserName")); if (!reader.IsDBNull(reader.GetOrdinal("ObjectStateClass"))) journalItem.ObjectStateClass = (XStateClass)reader.GetByte(reader.GetOrdinal("ObjectStateClass")); if (!reader.IsDBNull(reader.GetOrdinal("ObjectName"))) journalItem.ObjectName = reader.GetString(reader.GetOrdinal("ObjectName")); if (!reader.IsDBNull(reader.GetOrdinal("AdditionalDescription"))) journalItem.AdditionalDescription = reader.GetString(reader.GetOrdinal("AdditionalDescription")); if (!reader.IsDBNull(reader.GetOrdinal("Subsystem"))) journalItem.SubsystemType = (XSubsystemType)reader.GetByte(reader.GetOrdinal("Subsystem")); return journalItem; }
// // GetUserFromReader // A helper function that takes the current row from the SqlCeDataReader // and hydrates a MembershipUser from the values. Called by the // MembershipUser.GetUser implementation. // private MembershipUser GetUserFromReader(SqlCeDataReader reader) { if (string.IsNullOrWhiteSpace(reader.GetString(1))) return null; object providerUserKey = null; string strGooid = Guid.NewGuid().ToString(); if (reader.GetValue(0).ToString().Length > 0) providerUserKey = new Guid(reader.GetValue(0).ToString()); else providerUserKey = new Guid(strGooid); string username = reader.GetString(1); string email = reader.GetString(2); string passwordQuestion = reader.IsDBNull(3) ? string.Empty : reader.GetString(3); string comment = reader.IsDBNull(4) ? string.Empty : reader.GetString(4); bool isApproved = reader.IsDBNull(5) ? false : reader.GetBoolean(5); bool isLockedOut = reader.IsDBNull(6) ? false : reader.GetBoolean(6); DateTime creationDate = reader.IsDBNull(7) ? DateTime.UtcNow : reader.GetDateTime(7); DateTime lastLoginDate = reader.IsDBNull(8) ? DateTime.UtcNow : reader.GetDateTime(8); DateTime lastActivityDate = reader.IsDBNull(9) ? DateTime.UtcNow : reader.GetDateTime(9); DateTime lastPasswordChangedDate = reader.IsDBNull(10) ? DateTime.UtcNow : reader.GetDateTime(10); DateTime lastLockedOutDate = reader.IsDBNull(11) ? DateTime.UtcNow : reader.GetDateTime(11); MembershipUser u = new MembershipUser(this.Name, username, providerUserKey, email, passwordQuestion, comment, isApproved, isLockedOut, creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate, lastLockedOutDate); return u; }
private void AddString(StringBuilder builder, SqlCeDataReader reader, String column) { String text = reader.GetString(reader.GetOrdinal(column)); if (!StringUtils.IsEmpty(text)) { if (builder.Length > 0) { builder.Append(" "); } builder.Append(text); } }
private String GetDefinitionText(SqlCeDataReader reader) { return reader.GetString(reader.GetOrdinal("Definition")); }
private DailyUsageBO ReadRecord(SqlCeDataReader reader) { DailyUsageBO result = new DailyUsageBO(); result.Day = reader.GetDateTime(0); result.Month = reader.GetString(1); result.Upload = reader.GetDouble(2); result.Download = reader.GetDouble(3); result.Total = reader.GetDouble(4); if (!reader.IsDBNull(5)) result.Period = new Period(reader.GetString(5)); return result; }
static string TryGetNullableString(SqlCeDataReader reader, int index) { if (!reader.IsDBNull(index)) return reader.GetString(index); else return ""; }
static FS2JournalItem ReadOneJournalItem(SqlCeDataReader reader) { var journalItem = new FS2JournalItem(); if (!reader.IsDBNull(reader.GetOrdinal("Id"))) journalItem.No = reader.GetInt32(reader.GetOrdinal("Id")); if (!reader.IsDBNull(reader.GetOrdinal("SystemTime"))) journalItem.SystemTime = reader.GetDateTime(reader.GetOrdinal("SystemTime")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceTime"))) journalItem.DeviceTime = reader.GetDateTime(reader.GetOrdinal("DeviceTime")); if (!reader.IsDBNull(reader.GetOrdinal("Description"))) journalItem.Description = reader.GetString(reader.GetOrdinal("Description")); if (!reader.IsDBNull(reader.GetOrdinal("Detalization"))) journalItem.Detalization = reader.GetString(reader.GetOrdinal("Detalization")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceName"))) journalItem.DeviceName = reader.GetString(reader.GetOrdinal("DeviceName")); if (!reader.IsDBNull(reader.GetOrdinal("PanelName"))) journalItem.PanelName = reader.GetString(reader.GetOrdinal("PanelName")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceUID"))) journalItem.DeviceUID = reader.GetGuid(reader.GetOrdinal("DeviceUID")); if (!reader.IsDBNull(reader.GetOrdinal("PanelUID"))) journalItem.PanelUID = reader.GetGuid(reader.GetOrdinal("PanelUID")); if (!reader.IsDBNull(reader.GetOrdinal("ZoneName"))) journalItem.ZoneName = reader.GetString(reader.GetOrdinal("ZoneName")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceCategory"))) journalItem.DeviceCategory = reader.GetInt32(reader.GetOrdinal("DeviceCategory")); if (!reader.IsDBNull(reader.GetOrdinal("StateType"))) journalItem.StateType = (StateType)reader.GetInt32(reader.GetOrdinal("StateType")); if (!reader.IsDBNull(reader.GetOrdinal("SubsystemType"))) journalItem.SubsystemType = (SubsystemType)reader.GetInt32(reader.GetOrdinal("SubsystemType")); if (!reader.IsDBNull(reader.GetOrdinal("UserName"))) journalItem.UserName = reader.GetString(reader.GetOrdinal("UserName")); return journalItem; }
private String GetTranslationText(SqlCeDataReader reader) { return reader.GetString(reader.GetOrdinal("Translation")); }
private EntDiscover DataReaderToObject(SqlCeDataReader reader) { EntDiscover machine = new EntDiscover(); machine.MachineID = reader.GetInt32(reader.GetOrdinal("MachineID")); machine.IPAddr = reader.GetString(reader.GetOrdinal("IPAddress")); machine.LastChecked = reader.GetDateTime(reader.GetOrdinal("LastChecked")); machine.Discovered = reader.GetBoolean(reader.GetOrdinal("Discovered")); machine.StatusMessage = reader.GetString(reader.GetOrdinal("StatusMessage")); machine.DomainName = reader.GetString(reader.GetOrdinal("DomainName")); machine.MachineName = reader.GetString(reader.GetOrdinal("MachineName")); machine.CredentialID = reader.GetInt32(reader.GetOrdinal("CredentialID")); return machine; }
private EntCredential DataReaderToObject(SqlCeDataReader reader) { EntCredential credential = new EntCredential(); credential.CredentialID = reader.GetInt32(reader.GetOrdinal("CredentialID")); credential.Username = reader.GetString(reader.GetOrdinal("Username")); credential.Password = reader.GetString(reader.GetOrdinal("Password")); credential.CredentialName = reader.GetString(reader.GetOrdinal("CredentialName")); return credential; }
private object DataReaderToObject(SqlCeDataReader reader, EntityType entity) { object entityObject = null; switch (entity) { case EntityType.Processor: entityObject = new EntProcessor(); break; case EntityType.OS: entityObject = new EntOS(); break; case EntityType.Bios: entityObject = new EntBios(); break; case EntityType.MotherBoard: entityObject = new EntMotherBoard(); break; case EntityType.Disk: entityObject = new EntDisk(); break; case EntityType.Memory: entityObject = new EntMemory(); break; case EntityType.LogicalDrive: entityObject = new EntLogicalDrive(); break; case EntityType.CDRom: entityObject = new EntCDRom(); break; case EntityType.Video: entityObject = new EntVideo(); break; case EntityType.Multimedia: entityObject = new EntMultimedia(); break; case EntityType.Monitor: entityObject = new EntMonitor(); break; case EntityType.Share: entityObject = new EntShare(); break; case EntityType.StartUp: entityObject = new EntStartUp(); break; case EntityType.Hotfix: entityObject = new EntHotfixes(); break; case EntityType.Processes: entityObject = new EntProcesses(); break; case EntityType.Softwares: entityObject = new EntSoftwares(); break; case EntityType.Services: entityObject = new EntServices(); break; case EntityType.IPRoutes: entityObject = new EntIPRoutes(); break; case EntityType.EnvironmentVar: entityObject = new EntEnvironmentVars(); break; case EntityType.Computer: entityObject = new EntComputer(); break; case EntityType.Printer: entityObject = new EntPrinter(); break; case EntityType.UserGroup: entityObject = new EntUserGroups(); break; case EntityType.NetworkAdapter: entityObject = new EntNetworkAdapter(); break; } Type t = entityObject.GetType(); PropertyInfo[] pi = t.GetProperties(); foreach (PropertyInfo prop in pi) { if (prop.Name == "ClassName" || prop.Name == "Icon" || prop.Name == "NodeName") continue; switch (prop.PropertyType.Name) { case "String": string strValue = reader.GetString(reader.GetOrdinal(prop.Name)); prop.SetValue(entityObject, strValue, null); break; case "Int32": int intValue = reader.GetInt32(reader.GetOrdinal(prop.Name)); prop.SetValue(entityObject, intValue, null); break; case "Double": double dValue = reader.GetDouble(reader.GetOrdinal(prop.Name)); prop.SetValue(entityObject, dValue, null); break; case "DateTime": DateTime dtValue = DateTime.MinValue; if ( reader.GetValue(reader.GetOrdinal(prop.Name))== DBNull.Value) { dtValue = DateTime.MinValue; } else { dtValue = reader.GetDateTime(reader.GetOrdinal(prop.Name)); } prop.SetValue(entityObject, dtValue, null); break; case "Boolean": bool bValue = reader.GetBoolean(reader.GetOrdinal(prop.Name)); prop.SetValue(entityObject, bValue, null); break; } } return entityObject; }
private String GetExampleText(SqlCeDataReader reader) { return reader.GetString(reader.GetOrdinal("Example")); }
static JournalRecord ReadOneJournalRecord(SqlCeDataReader reader) { var journalRecord = new JournalRecord(); if (!reader.IsDBNull(reader.GetOrdinal("Description"))) journalRecord.Description = reader.GetString(reader.GetOrdinal("Description")); if (!reader.IsDBNull(reader.GetOrdinal("Detalization"))) journalRecord.Detalization = reader.GetString(reader.GetOrdinal("Detalization")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceCategory"))) journalRecord.DeviceCategory = reader.GetInt32(reader.GetOrdinal("DeviceCategory")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceDatabaseId"))) journalRecord.DeviceDatabaseId = reader.GetString(reader.GetOrdinal("DeviceDatabaseId")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceName"))) journalRecord.DeviceName = reader.GetString(reader.GetOrdinal("DeviceName")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceTime"))) journalRecord.DeviceTime = reader.GetDateTime(reader.GetOrdinal("DeviceTime")); if (!reader.IsDBNull(reader.GetOrdinal("OldId"))) journalRecord.OldId = reader.GetInt32(reader.GetOrdinal("OldId")); if (!reader.IsDBNull(reader.GetOrdinal("PanelDatabaseId"))) journalRecord.PanelDatabaseId = reader.GetString(reader.GetOrdinal("PanelDatabaseId")); if (!reader.IsDBNull(reader.GetOrdinal("PanelName"))) journalRecord.PanelName = reader.GetString(reader.GetOrdinal("PanelName")); if (!reader.IsDBNull(reader.GetOrdinal("StateType"))) journalRecord.StateType = (StateType)reader.GetInt32(reader.GetOrdinal("StateType")); if (!reader.IsDBNull(reader.GetOrdinal("SubsystemType"))) journalRecord.SubsystemType = (SubsystemType)reader.GetInt32(reader.GetOrdinal("SubsystemType")); if (!reader.IsDBNull(reader.GetOrdinal("SystemTime"))) journalRecord.SystemTime = reader.GetDateTime(reader.GetOrdinal("SystemTime")); if (!reader.IsDBNull(reader.GetOrdinal("UserName"))) journalRecord.User = reader.GetString(reader.GetOrdinal("UserName")); if (!reader.IsDBNull(reader.GetOrdinal("ZoneName"))) journalRecord.ZoneName = reader.GetString(reader.GetOrdinal("ZoneName")); if (!reader.IsDBNull(reader.GetOrdinal("Id"))) journalRecord.No = reader.GetInt32(reader.GetOrdinal("Id")); return journalRecord; }