public UserEntity Validate(string userNm, string pwd) { UserEntity model = new UserEntity(); string sql = string.Format("SELECT * FROM [Users] where usernm='{0}' and pwd='{1}';", userNm, pwd); SqlCeConnection _Conn = new SqlCeConnection(conn); _Conn.Open(); SqlCeCommand cmd = new SqlCeCommand(sql, _Conn); SqlCeDataReader rdr = cmd.ExecuteReader(); if (rdr.Read()) { model.Id = rdr.GetInt32(0); model.UserNm = rdr.GetString(1); model.Pwd = rdr.GetString(2); model.IsConfigured = rdr.GetBoolean(3); if (!rdr.IsDBNull(4)) { model.InstallID = rdr.GetGuid(4); } model.Location = rdr.IsDBNull(5) == true ? "" : rdr.GetString(5); model.PinCode = rdr.IsDBNull(6) == true ? "" : rdr.GetString(6); } _Conn.Close(); return(model); }
protected Guid?getGuid(SqlCeDataReader reader, string columnName) { int index = reader.GetOrdinal(columnName); if (!reader.IsDBNull(index)) { return(reader.GetGuid(index)); } return(null); }
public List <Product> GetAllProducts() { List <Product> products = new List <Product>(); var query = $@"SELECT * FROM Products;"; SqlCeCommand cmd = new SqlCeCommand(query, _connection); SqlCeDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { products.Add(new Product() { Id = reader.GetGuid(0), Denomination = reader.GetString(1), Price = reader.GetInt32(2), Quantity = reader.GetInt32(3) }); } return(products); }
public Product GetProduct(Guid id) { var query = $@"SELECT * FROM Products WHERE ID = '{id}';"; SqlCeCommand cmd = new SqlCeCommand(query, _connection); SqlCeDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { var product = new Product() { Id = reader.GetGuid(0), Denomination = reader.GetString(1), Price = reader.GetInt32(2), Quantity = reader.GetInt32(3) }; return(product); } return(null); }
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; }
protected virtual Guid ReadGuid(SqlCeDataReader reader, string columnName) { return reader.GetGuid(reader.GetOrdinal(columnName)); }
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; }
public ObservableCollection <PatientEntity> GetAll(string column = null, string searchText = null) { string sql = "Select * from Patient"; if (!string.IsNullOrEmpty(searchText)) { if (column != null && column != "p_id") { sql = "select * from patient where " + column + " like '%" + searchText + "%';"; } else if (column != null && column == "p_id") { sql = "select * from patient where p_id=" + int.Parse(searchText); } } ObservableCollection <PatientEntity> list = new ObservableCollection <PatientEntity>(); SqlCeConnection _Conn = new SqlCeConnection(conn); _Conn.Open(); SqlCeCommand cmd = new SqlCeCommand(sql, _Conn); SqlCeDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { PatientEntity obj = new PatientEntity() { Id = rdr.GetInt32(0), Nm = rdr.GetString(1), MNm = rdr.IsDBNull(2) == true ? "" : rdr.GetString(2), LNm = rdr.GetString(3), NotResident = rdr.IsDBNull(4) == true ? "" : rdr.GetString(4), IfResidentOfM = rdr.GetString(5), IcNumber = rdr.IsDBNull(6) == true ? "" : rdr.GetString(6), OtherOption = rdr.IsDBNull(7) == true ? "" : rdr.GetString(7), OthersID = rdr.IsDBNull(8) == true ? "" : rdr.GetString(8), DocNm = rdr.IsDBNull(9) == true ? "" : rdr.GetString(9), HospitalNm = rdr.IsDBNull(10) == true ? "" : rdr.GetString(10), HospitalID = rdr.IsDBNull(11) == true ? "" : rdr.GetString(11), HospitalScreening = rdr.IsDBNull(12) == true ? "" : rdr.GetString(12), Email = rdr.GetString(13), MaritalStatus = rdr.GetString(14), Age = rdr.GetInt32(15), Sex = rdr.GetString(16), PerAdr = rdr.IsDBNull(17) == true ? "" : rdr.GetString(17), Area = rdr.IsDBNull(18) == true ? "" : rdr.GetString(18), ResidentPh = rdr.IsDBNull(19) == true ? "" : rdr.GetString(19), Mob = rdr.GetString(20), Occupation = rdr.IsDBNull(21) == true ? "" : rdr.GetString(21), WorkingAt = rdr.IsDBNull(22) == true ? "" : rdr.GetString(22), CurrentMedications = rdr.IsDBNull(23) == true ? "" : rdr.GetString(23), LaserTreatment = rdr.IsDBNull(24) == true ? "" : rdr.GetString(24), Cataract = rdr.IsDBNull(25) == true ? "" : rdr.GetString(25), Hypertension = rdr.IsDBNull(26) == true ? "" : rdr.GetString(26), AllergyDrugs = rdr.IsDBNull(27) == true ? "" : rdr.GetString(27), Diabetic = rdr.IsDBNull(28) == true ? "" : rdr.GetString(28), Info = rdr.IsDBNull(29) == true ? "" : rdr.GetString(29), EmergContactNm = rdr.IsDBNull(30) == true ? "" : rdr.GetString(30), EmergPh = rdr.IsDBNull(31) == true ? "" : rdr.GetString(31), StatedConsentPerson = rdr.IsDBNull(32) == true ? "" : rdr.GetString(32), Relation = rdr.IsDBNull(33) == true ? "" : rdr.GetString(33), TermsCondition = rdr.GetString(34), CollectionID = rdr.GetInt32(35), InstallID = rdr.GetGuid(36), MDt = rdr.GetDateTime(37), CDt = rdr.GetDateTime(38), UniqueID = rdr.GetGuid(39), AllergyDrugsDtl = rdr.IsDBNull(40) == true ? "" : rdr.GetString(40), MedicalInsurance = rdr.IsDBNull(41) == true ? "" : rdr.GetString(41), PatientId = rdr.GetInt32(42) }; list.Add(obj); } _Conn.Close(); return(list); }