internal static SupplierBE Get(DbDataRecord row) { var supplier = new SupplierBE(); supplier.SupplierID = DataUtilities.GetInt32(row["SupplierID"]).Value; supplier.CompanyName = DataUtilities.GetString(row["CompanyName"]); supplier.ContactName = DataUtilities.GetString(row["ContactName"]); supplier.ContactTitle = DataUtilities.GetString(row["ContactTitle"]); supplier.Address = DataUtilities.GetString(row["Address"]); supplier.City = DataUtilities.GetString(row["City"]); supplier.Region = DataUtilities.GetString(row["Region"]); supplier.PostalCode = DataUtilities.GetString(row["PostalCode"]); supplier.Country = DataUtilities.GetString(row["Country"]); supplier.Phone = DataUtilities.GetString(row["Phone"]); supplier.Fax = DataUtilities.GetString(row["Fax"]); supplier.HomePage = DataUtilities.GetString(row["HomePage"]); return(supplier); }
//BUILD THE SHIRT'S TAG LIST public void ShirtTags_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DbDataRecord dbrd = (DbDataRecord)e.Item.DataItem; var ShirtTagCloud = e.Item.FindControl("ShirtTags") as Literal; string Tag = myFunctionsInstance.Stripper(dbrd["Tag"].ToString()); int TagID = Convert.ToInt32(dbrd["TagID"]); if (varConst.cSiteName == "damptshirts") { ShirtTagCloud.Text = "<li><a class=\"btn\" href='/" + varConst.cSEODirectory + "/tag/" + TagID + "/" + Tag + "/'>" + dbrd["Tag"] + "</a></li>"; } else { ShirtTagCloud.Text = "<li><a class=\"btn\" href='/" + Tag + "/tag/" + TagID + "/'>" + dbrd["Tag"] + "</a></li>"; } } }
protected void ButtonSave_Click(object sender, EventArgs e) { // save the object access settings for this role if (GridViewRoleObjectAccess.Rows.Count != 0) { // get the IDs of the security objects String[] IDResultSet = LabelIDResultSet.Text.Split(','); int RowCounter = 0; // loop through all rows foreach (GridViewRow gvr in GridViewRoleObjectAccess.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { DbDataRecord dbdr = gvr.DataItem as DbDataRecord; // get the row id //Guid RowID = new Guid(dbdr.GetValue(0).ToString()); Guid RowID = new Guid(IDResultSet[RowCounter]); RowCounter++; // update the row with the new settings Boolean Create, Read, Update, Delete, Execute; Create = (gvr.FindControl("CheckBoxCreate") as CheckBox).Checked; Read = (gvr.FindControl("CheckBoxRead") as CheckBox).Checked; Update = (gvr.FindControl("CheckBoxUpdate") as CheckBox).Checked; Delete = (gvr.FindControl("CheckBoxDelete") as CheckBox).Checked; Execute = (gvr.FindControl("CheckBoxExecute") as CheckBox).Checked; // locate the object access & update SecurityRoleObjectAccess sroa = ControlObjectContext.GetObjectByKey(new System.Data.EntityKey("ModelTMSContainer.SecurityRoleObjectAccessSet", "Id", RowID)) as SecurityRoleObjectAccess; sroa.HasCreateAccess = Create; sroa.HasReadAccess = Read; sroa.HasUpdateAccess = Update; sroa.HasDeleteAccess = Delete; sroa.HasExecuteAccess = Execute; } } } StandardButtonSaveClickHandler(sender, e); }
public void DisplayProducts(DataTable table) { student stu; Microsoft.EntityFrameworkCore.DbSet <student> j; DbDataRecord d = table; d.as // table Enumerable.AsEnumerable <student>(stu); //var productNames = from products in table.AsEnumerable() select products.Field<string>("ProductName"); //Console.WriteLine("Product Names: "); //foreach (string productName in productNames) //{ // Console.WriteLine(productName); //} }
public PatientHistory(DbDataRecord rec) { Id = Convert.ToInt32(rec["patient_id"]); SurnameNow = rec["patient_surname_now"].ToString(); NameNow = rec["patient_name_now"].ToString(); PatronymicNow = rec["patient_patronymic_now"].ToString(); StreetNow = Convert.ToInt32(rec["street_now"]); HouseNow = Convert.ToInt32(rec["house_now"]); RoomNow = Convert.ToInt32(rec["room_now"]); AccountNow = Convert.ToInt32(rec["account_now"]); SurnameLast = rec["patient_surname_last"].ToString(); NameLast = rec["patient_name_last"].ToString(); PatronymicLast = rec["patient_patronymic_last"].ToString(); StreetLast = Convert.ToInt32(rec["street_last"]); HouseLast = Convert.ToInt32(rec["house_last"]); RoomLast = Convert.ToInt32(rec["room_last"]); AccountLast = Convert.ToInt32(rec["account_last"]); OperationDate = Convert.ToDateTime(rec["operation_time"]); Operation = rec["operation"].ToString(); }
/// <summary> /// Popula Grupo, conforme DataRecord passado /// </summary> /// <autor>Fabio Senziani</autor> /// <param name="dtrDados">Registro a ser percorrido.</param> /// <returns><list type="EntGrupo">EntGrupo</list></returns> private EntTurmaEmpresa PopularRow(DbDataRecord dtrDados) { EntTurmaEmpresa entReturn; try { entReturn = new EntTurmaEmpresa(); entReturn = this.PopularRowSimples(dtrDados); entReturn.NumeroEndereco = ObjectUtils.ToString(dtrDados["TX_NUMERO"]); entReturn.NumeroEnderecoContato = ObjectUtils.ToString(dtrDados["TX_NUMERO_CONTATO"]); entReturn.ComplementoContato = ObjectUtils.ToString(dtrDados["TX_COMPLEMENTO_CONTATO"]); } catch (Exception ex) { throw ex; } return(entReturn); }
//***************************************************************************** // Method: ShowSubmissionDetails // // Purpose: Set textbox text's of the selected submission object //***************************************************************************** private void ShowSubmissionDetails(DbDataRecord record) { // Setup the SQL command string sql = "SELECT * FROM Submission WHERE AssignmentName = '" + record.GetString(0) + "';"; SqlCommand command = new SqlCommand(sql, sqlConn); // Retrieve the data from the database SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { // set text fields assignmentTextBox.Text = reader.GetString(0); categoryTextBox.Text = reader.GetString(1); gradeTextBox.Text = reader.GetDouble(2).ToString(); } } }
private EntQuestionarioPontuacao PopularRowListPontuacao(DbDataRecord dtrDados) { EntQuestionarioPontuacao entReturn; try { entReturn = new EntQuestionarioPontuacao(); entReturn.Avaliador = ObjectUtils.ToBoolean(dtrDados["FL_AVALIADOR"]); entReturn.Criterio.IdCriterio = DeParaCriterio(ObjectUtils.ToInt(dtrDados["CEA_CRITERIO"]), ObjectUtils.ToInt(dtrDados["CEA_PROGRAMA"])); entReturn.Ponto = ObjectUtils.ToDecimal(dtrDados["NU_PERCENTUAL"]); entReturn.Questionario.IdQuestionario = DeParaQuestionarioPorCriterio(ObjectUtils.ToInt(dtrDados["CEA_CRITERIO"]), ObjectUtils.ToInt(dtrDados["CEA_PROGRAMA"])); entReturn.QuestionarioEmpresa.IdQuestionarioEmpresa = ObjectUtils.ToInt(dtrDados["CDA_QUESTIONARIO_EMPRESA"]); } catch (Exception ex) { throw ex; } return(entReturn); }
public static ProducerSynonym CreateSynonym(DbDataRecord record) { if (record == null) { return(null); } if (record["CatalogId"] is DBNull && !(record["ProducerId"] is DBNull)) { return(new ProducerSynonym { Loaded = true, Id = Convert.ToUInt32(record["SynonymFirmCrCode"]), ProducerId = Convert.ToUInt32(record["ProducerId"]), Name = record["Synonym"].ToString() }); } else { return(new Exclude(record)); } }
// social_network_link_repeater_ItemCreated protected void social_network_link_repeater_ItemCreated(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { DbDataRecord currentRecord = e.Item.DataItem as DbDataRecord; if (currentRecord != null) { _socialNetworkId = Utils.getDbIntegerValue(currentRecord[(int)SocialNetworkLinkReaderFields.SocialNetworkId], 0); _socialNetworkName = Utils.getDbStringValue(currentRecord[(int)SocialNetworkLinkReaderFields.Name], string.Empty); _socialNetworkUrl = Utils.getDbStringValue(currentRecord[(int)SocialNetworkLinkReaderFields.NetworkURL], string.Empty); _socialNetworkIcon = Utils.getDbStringValue(currentRecord[(int)SocialNetworkLinkReaderFields.Icon], string.Empty); if (_socialNetworkName == "LinkedIn" & !IsPostBack) //get Linkedin Group Id for request { Uri url = new Uri(_socialNetworkUrl); _linkedinGroupId = HttpUtility.ParseQueryString(url.Query).Get("gid"); } if (_socialNetworkName == "FaceBook" & !IsPostBack) //get Facebook Page for request { Uri uri = new Uri(_socialNetworkUrl); string cleanUrl = uri.GetLeftPart(UriPartial.Path); //removes any query string user might have saved in their facebook settings cleanUrl = cleanUrl.TrimEnd(new[] { '/' }); int LastIndex = cleanUrl.LastIndexOf("/"); _facebookId = cleanUrl.Substring(LastIndex + 1, (cleanUrl.Length - LastIndex - 1)); if (_socialNetworkUrl.Contains("groups")) { _isFacebookGroup = "true"; } else { _isFacebookGroup = "false"; } } } } }
//// END GENERAL ///// //// BEGIN REPEATER EVENTS //// protected void Link_Repeater_OnItemDataBound(Object sender, RepeaterItemEventArgs e) { // Trim text to set number of characters and add "..." DbDataRecord rec = (DbDataRecord)e.Item.DataItem; // Make sure that you have the data if (rec != null) { Label lblname = (Label)e.Item.FindControl("lbl_LinkName"); string sLinkName = rec["LinkName"].ToString(); int stringLengthName = sLinkName.Length; Label lbldesc = (Label)e.Item.FindControl("lbl_LinkDescription"); string sLinkDesc = rec["LinkDescription"].ToString(); int stringLengthDesc = sLinkDesc.Length; // Check Name if (stringLengthName > 37) { lblname.Text = sLinkName.Substring(0, Math.Min(37, sLinkName.ToString().Length)) + "..."; } else { // List Name is Under 37 Char lblname.Text = sLinkName; } // Check Description if (stringLengthDesc > 230) { lbldesc.Text = sLinkDesc.Substring(0, Math.Min(230, sLinkDesc.ToString().Length)) + "..."; } else { // List Description is Under 230 Char lbldesc.Text = sLinkDesc; } } }
/// <summary> /// Popula Grupo, conforme DataRecord passado /// </summary> /// <autor>Fabio Senziani</autor> /// <param name="dtrDados">Registro a ser percorrido.</param> /// <returns><list type="EntGrupo">EntGrupo</list></returns> private EntGrupoEmpresa PopularRow(DbDataRecord dtrDados) { EntGrupoEmpresa entReturn; try { entReturn = new EntGrupoEmpresa(); entReturn.IdGrupoEmpresa = ObjectUtils.ToInt(dtrDados["CDA_GRUPO_EMPRESA"]); entReturn.DtCadastro = ObjectUtils.ToDate(dtrDados["DT_CADASTRO"]); entReturn.EmpresaCadastro.IdEmpresaCadastro = ObjectUtils.ToInt(dtrDados["CEA_EMP_CADASTRO"]); entReturn.Grupo.IdGrupo = ObjectUtils.ToInt(dtrDados["CEA_GRUPO"]); entReturn.Grupo.Ativo = ObjectUtils.ToBoolean(dtrDados["FL_ATIVO"]); } catch (Exception ex) { throw ex; } return(entReturn); }
/// <summary> /// Popula Questionario Empresa Pontuacao, conforme DataReader passado /// </summary> /// <autor>Fabio Moraes</autor> /// <param name="dtrDados">DataReader a ser percorrido.</param> /// <returns><list type="EntQuestionarioEmpresa">EntQuestionarioEmpresa</list></returns> private EntQuestionarioPontuacao PopularRow(DbDataRecord DataRecord) { EntQuestionarioPontuacao entReturn; try { entReturn = new EntQuestionarioPontuacao(); entReturn.QuestionarioEmpresa.IdQuestionarioEmpresa = ObjectUtils.ToInt(DataRecord["CEA_QUESTIONARIO_EMPRESA"]); entReturn.Questionario.IdQuestionario = ObjectUtils.ToInt(DataRecord["CEA_QUESTIONARIO"]); entReturn.Avaliador = ObjectUtils.ToBoolean(DataRecord["FL_AVALIADOR"]); entReturn.Criterio.IdCriterio = ObjectUtils.ToInt(DataRecord["CEA_CRITERIO"]); entReturn.Ponto = ObjectUtils.ToDecimal(DataRecord["NU_PONTO"]); } catch (Exception ex) { throw ex; } return(entReturn); }
public Film ConvertRecordToFilm(DbDataRecord rec) { if (rec == null || rec.FieldCount < filmRecFieldCount) { return(null); } var film = new Film { Id = rec.GetInt32((int)FilmColumns.Id), Picture = GetImageFromDbRec(rec.GetString((int)FilmColumns.Picture)), Name = rec.GetString((int)FilmColumns.Name), Country = rec.GetString((int)FilmColumns.Country), Year = rec.GetInt32((int)FilmColumns.Year), Producer = new Producer(rec.GetString((int)FilmColumns.Producer)), MainActors = new List <Actor>() }; return(film); }
internal bool LoadData(DbDataRecord dbData) { if (dbData == null) { return(false); } PropertyInfo[] plist = PropertyList; if (plist == null) { return(false); } foreach (PropertyInfo p in plist) { string fname = DObjectHelper.GetFieldName(p); SetProperty(p, dbData[fname]); } return(true); }
public void EnumeratorTest () { DataTable table = new DataTable (); table.Columns.Add ("col1", typeof(int)); table.Rows.Add (new object[] {0}); table.Rows.Add (new object[] {1}); DataTableReader rdr = table.CreateDataReader (); IEnumerator enmr = rdr.GetEnumerator (); table.Rows.Add (new object[] {2}); table.Rows.RemoveAt (0); //Test if the Enumerator is stable int i = 1; while (enmr.MoveNext ()) { DbDataRecord rec = (DbDataRecord)enmr.Current; Assert.AreEqual (i, rec.GetInt32 (0), "#2_" + i); i++; } }
private void SearchRoomsByCategory() { if (lsbxCategories.SelectedIndex == -1) { return; } listRooms = DataLayer.GetAllRooms(); for (int i = 0; i < listRooms.Count; i++) { DbDataRecord room = listRooms[i] as DbDataRecord; if ((int)room["IdCategory"] != (int)(lsbxCategories.SelectedItem as DbDataRecord)["ID"]) { listRooms.Remove(room); i--; } } dgRooms.ItemsSource = listRooms; }
internal IEnumerator <T> ExecuteReader <T>(string sql) { Type TypeT = typeof(T); ConstructorInfo ctor = TypeT.GetConstructor(Type.EmptyTypes); if (ctor == null) { throw new InvalidOperationException($"Type {TypeT.Name} does not have a default constructor."); } _sqlConnection.Open(); IEnumerator data = new SqlCommand(sql, _sqlConnection).ExecuteReader().GetEnumerator(); while (data.MoveNext()) { T newInst = (T)ctor.Invoke(null); DbDataRecord record = (DbDataRecord)data.Current; int fieldCount = Properties.GetFieldCount((DbDataRecord)data.Current); for (int i = 0; i < fieldCount; i++) { string propertyName = record.GetName(i); PropertyInfo propertyInfo = TypeT.GetProperty(propertyName); if (propertyInfo != null) { object value = record[i]; if (value == DBNull.Value) { propertyInfo.SetValue(newInst, null); } else { propertyInfo.SetValue(newInst, value); } } } yield return(newInst); } }
private EntQuestionarioEmpresaAvaliador PopularRowListAvaliador(DbDataRecord dtrDados, Boolean isPrimario) { EntQuestionarioEmpresaAvaliador entReturn; try { entReturn = new EntQuestionarioEmpresaAvaliador(); entReturn.Avaliado = ObjectUtils.ToBoolean(dtrDados["FL_AVALIADO"]); entReturn.Banca = ObjectUtils.ToString(dtrDados["TX_BANCA"]); entReturn.MelhorPratica = ObjectUtils.ToString(dtrDados["TX_MELHOR_PRATICA"]); entReturn.MotivoDevolucao = ObjectUtils.ToString(dtrDados["TX_MOTIVO_DEVOLUCAO"]); entReturn.Primario = isPrimario; entReturn.QuestionarioEmpresa.IdQuestionarioEmpresa = ObjectUtils.ToInt(dtrDados["CDA_QUESTIONARIO_EMPRESA"]); entReturn.Usuario.Email = ObjectUtils.ToString(dtrDados["TX_EMAIL"]); } catch (Exception ex) { throw ex; } return(entReturn); }
protected void GridViewRoleObjectAccess_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DbDataRecord sroa = e.Row.DataItem as DbDataRecord; e.Row.FindControl("CheckBoxCreate").Visible = sroa.GetValue(8).ToString().IndexOf("C") >= 0; e.Row.FindControl("CheckBoxRead").Visible = sroa.GetValue(8).ToString().IndexOf("R") >= 0; e.Row.FindControl("CheckBoxUpdate").Visible = sroa.GetValue(8).ToString().IndexOf("U") >= 0; e.Row.FindControl("CheckBoxDelete").Visible = sroa.GetValue(8).ToString().IndexOf("D") >= 0; e.Row.FindControl("CheckBoxExecute").Visible = sroa.GetValue(8).ToString().IndexOf("X") >= 0; /* * (e.Row.FindControl("CheckBoxCreate") as CheckBox).Checked = Convert.ToBoolean(sroa.GetValue(3)); * (e.Row.FindControl("CheckBoxRead") as CheckBox).Checked = Convert.ToBoolean( sroa.GetValue(4)); * (e.Row.FindControl("CheckBoxUpdate") as CheckBox).Checked = Convert.ToBoolean(sroa.GetValue(5)); * (e.Row.FindControl("CheckBoxDelete") as CheckBox).Checked = Convert.ToBoolean(sroa.GetValue(6)); * (e.Row.FindControl("CheckBoxExecute") as CheckBox).Checked = Convert.ToBoolean(sroa.GetValue(7)); * */ LabelIDResultSet.Text = LabelIDResultSet.Text + sroa.GetValue(0).ToString() + ","; } }
public static void AuditEntityModified(Audit audit, AuditEntry entry, DbDataRecord orginalRecord, DbUpdatableDataRecord currentRecord, string prefix = "") { for (var i = 0; i < orginalRecord.FieldCount; i++) { var name = orginalRecord.GetName(i); var originalValue = orginalRecord.GetValue(i); var currentValue = currentRecord.GetValue(i); var valueRecord = originalValue as DbDataRecord; if (valueRecord != null) { // Complex Type AuditEntityModified(audit, entry, valueRecord, currentValue as DbUpdatableDataRecord, string.Concat(prefix, name, ".")); } else { if (audit.Configuration.IncludePropertyUnchanged || !Equals(currentValue, originalValue)) { entry.Properties.Add(new AuditEntryProperty(string.Concat(prefix, name), originalValue, currentValue)); } } } }
private IEnumerable <Reporting.Failure> GetFailuresIfAny(DbDataRecord record) { //Get the primary key of the current row string[] primaryKey = _factory.PrimaryKeys.Select(k => record[k.GetRuntimeName()].ToString()).ToArray(); //For each column in the table for (var i = 0; i < _columnsNames.Length; i++) { //If it is a string column if (_stringColumns[i]) { var asString = record[i] as string; if (string.IsNullOrWhiteSpace(asString)) { continue; } var parts = new List <FailurePart>(); foreach (string part in asString.Split('\\')) { // Some strings contain null characters?! Remove them all. // XXX hopefully this won't break any special character encoding (eg. UTF) string partCleaned = part.Replace("\0", ""); parts.AddRange(Validate(_columnsNames[i], partCleaned)); } if (parts.Any()) { yield return(_factory.Create(_columnsNames[i], asString, parts, primaryKey)); } } } DoneRows(1); }
public override object GetValue(object item) { EntityUtil.CheckArgumentNull(item, "item"); if (!_itemType.IsAssignableFrom(item.GetType())) { throw EntityUtil.IncompatibleArgument(); } object propertyValue; DbDataRecord dbDataRecord = item as DbDataRecord; if (dbDataRecord != null) { propertyValue = (dbDataRecord.GetValue(dbDataRecord.GetOrdinal(_property.Name))); } else { propertyValue = LightweightCodeGenerator.GetValue(_property, item); } return(propertyValue); }
public void CopyTask(ref SQLiteDataAdapter adapter, Int32 _idTask) { const string idTask = "idTask"; const string idTaskParam = "@" + idTask; const string idNewTaskParam = "@idNewTask"; SQLiteParameter pidTask = new SQLiteParameter(); pidTask.ParameterName = idTaskParam; pidTask.DbType = DbType.Int32; pidTask.Size = 4; pidTask.Value = _idTask; const string copyTaskQuery = "insert into tblTasks (idSource, TaskNumber, TaskName, idLanguage, SubtaskCount, SubtaskNumber, TaskReceiveDate, TaskDeadlineDate, FirstDoneVersionDate, Cost, idStatus, Remark, isArchived) select idSource, TaskNumber, TaskName, idLanguage, SubtaskCount, SubtaskNumber, date('now'), null, null, Cost, 1, Remark, 0 from tblTasks where idTask = @idTask;"; Dictionary <string, SQLiteParameter> copyTaskQueryParams = new Dictionary <string, SQLiteParameter>(); copyTaskQueryParams[pidTask.ParameterName] = pidTask; const string CopyRecordLinks = "insert into tblTasksLinks (idTask, Link, LinkName) select @idNewTask, Link, LinkName from tblTasksLinks where idTask = @idTask;"; SQLiteParameter pNewTask = new SQLiteParameter(); pNewTask.ParameterName = idNewTaskParam; pNewTask.DbType = DbType.Int32; pNewTask.Size = 4; Dictionary <string, SQLiteParameter> CopyRecordLinksParams = new Dictionary <string, SQLiteParameter>(); const string getLastInsertIDQuery = "select last_insert_rowid();"; ExecuteNonQuery(copyTaskQuery, copyTaskQueryParams); DbDataRecord getLastInsertIDRecord = ExecuteCommand(ref adapter, getLastInsertIDQuery); pNewTask.Value = getLastInsertIDRecord == null?Convert.ToInt32(getLastInsertIDRecord[0].ToString()) : 1; CopyRecordLinksParams[pNewTask.ParameterName] = pNewTask; CopyRecordLinksParams[pidTask.ParameterName] = pidTask; ExecuteNonQuery(CopyRecordLinks, CopyRecordLinksParams); }
public void GetEnumeratorTest() { this.fixture.ExecuteCommand(command => { command.CommandText = "SELECT * FROM ORDERS"; using (var reader = command.ExecuteReader()) { IEnumerator enumerator = reader.GetEnumerator(); while (enumerator.MoveNext()) { DbDataRecord record = (DbDataRecord)enumerator.Current; Assert.Equal(reader.FieldCount, record.FieldCount); Assert.Equal(reader.GetInt32(0), record.GetInt32(0)); Assert.Equal(reader.GetString(1), record.GetString(1)); Assert.Equal(reader.GetInt32(2), record.GetInt32(2)); Assert.Equal(reader.GetDateTime(3), record.GetDateTime(3)); Assert.Equal(reader.GetDateTime(4), record.GetDateTime(4)); Assert.Equal(reader.GetValue(5), record.GetValue(5)); Assert.Equal(reader.GetInt32(6), record.GetInt32(6)); Assert.Equal(reader.GetDecimal(7), record.GetDecimal(7)); reader.Read(); } } }); }
public static void WriteBoolFromRecord(Worksheet ws, int row, int col, string fieldName, DbDataRecord reader, bool bordered, bool bolded) { Object value = reader[fieldName]; if (value != null && value != DBNull.Value) { ws.Cells[row, col] = new Cell( (Convert.ToInt64(value) == 1) ? "Да" : "Нет"); } if (bordered) { BorderCell(ws.Cells[row, col], bolded); } else if (bolded) { if (ws.Cells[row, col] == null) { ws.Cells[row, col] = new Cell(String.Empty); } ws.Cells[row, col].Style = BoldCell; } }
//private static string GetForeignKey(NavigationProperty navigationProperty) //{ // var association = navigationProperty.RelationshipType as AssociationType; // if (association == null) // return null; // // only support first constraint // var referentialConstraint = association.ReferentialConstraints.FirstOrDefault(); // if (referentialConstraint == null) // return null; // var toProperties = referentialConstraint // .ToProperties // .Select(p => p.Name) // .ToArray(); // return string.Join(",", toProperties); //} private static object GetDisplayValue(AuditEntryState state, NavigationProperty navigationProperty, IMemberAccessor displayMember, DbDataRecord values) { if (values == null) { return(null); } var association = navigationProperty.RelationshipType as AssociationType; if (association == null) { return(null); } // only support first constraint var referentialConstraint = association.ReferentialConstraints.FirstOrDefault(); if (referentialConstraint == null) { return(null); } var toProperties = referentialConstraint .ToProperties .Select(p => p.Name) .ToList(); var fromProperties = referentialConstraint .FromProperties .Select(p => p.Name) .ToList(); // make sure key columns match if (fromProperties.Count != toProperties.Count) { return(null); } var edmType = referentialConstraint .FromProperties .Select(p => p.DeclaringType) .FirstOrDefault(); if (edmType == null) { return(null); } var entitySet = GetEntitySet(state.ObjectContext, edmType.FullName); var sql = new StringBuilder(); sql.Append("SELECT VALUE t.") .Append(displayMember.Name) .Append(" FROM ") .Append(entitySet.Name) .Append(" as t") .Append(" WHERE "); var parameters = new List <ObjectParameter>(); for (int index = 0; index < fromProperties.Count; index++) { if (index > 0) { sql.Append(" AND "); } string fromProperty = fromProperties[index]; string toProperty = toProperties[index]; var value = GetValue(values, toProperty); var name = "@" + fromProperty; sql.Append(" t.").Append(fromProperty); if (value != null) { sql.Append(" == ").Append(name); parameters.Add(new ObjectParameter(fromProperty, value)); } else { sql.Append(" is null"); } } var q = state.ObjectContext.CreateQuery <object>( sql.ToString(), parameters.ToArray()); return(q.FirstOrDefault()); }
private static DataTable ObtainDataTableFromIEnumerable(IEnumerable ien, JQGrid grid) { DataTable table = new DataTable(); foreach (object obj2 in ien) { if (obj2 is DbDataRecord) { DbDataRecord record = obj2 as DbDataRecord; if (table.Columns.Count == 0) { foreach (JQGridColumn column in grid.Columns) { table.Columns.Add(column.DataField); } } DataRow row = table.NewRow(); foreach (JQGridColumn column2 in grid.Columns) { row[column2.DataField] = record[column2.DataField]; } table.Rows.Add(row); continue; } if (obj2 is DataRow) { DataRow row2 = obj2 as DataRow; if (table.Columns.Count == 0) { foreach (JQGridColumn column3 in grid.Columns) { table.Columns.Add(column3.DataField); } } DataRow row3 = table.NewRow(); foreach (JQGridColumn column4 in grid.Columns) { row3[column4.DataField] = row2[column4.DataField]; } table.Rows.Add(row3); continue; } PropertyInfo[] properties = obj2.GetType().GetProperties(); if (table.Columns.Count == 0) { foreach (PropertyInfo info in properties) { Type propertyType = info.PropertyType; if (propertyType.IsGenericType && (propertyType.GetGenericTypeDefinition() == typeof(Nullable <>))) { propertyType = Nullable.GetUnderlyingType(propertyType); } table.Columns.Add(info.Name, propertyType); } } DataRow row4 = table.NewRow(); foreach (PropertyInfo info2 in properties) { object obj3 = info2.GetValue(obj2, null); if (obj3 != null) { row4[info2.Name] = obj3; } else { row4[info2.Name] = DBNull.Value; } } table.Rows.Add(row4); } return(table); }
public DoctorComposite(DbDataRecord rec) { Doctor = new Doctor(rec); Speciality = new Speciality(rec); User = new User(rec); }
/// <summary>Audit entity modified.</summary> /// <param name="audit">The audit to use to add changes made to the context.</param> /// <param name="entry">The entry.</param> /// <param name="objectStateEntry">The object state entry.</param> /// <param name="orginalRecord">The orginal record.</param> /// <param name="currentRecord">The current record.</param> /// <param name="prefix">The prefix.</param> public static void AuditEntityModified(Audit audit, AuditEntry entry, ObjectStateEntry objectStateEntry, DbDataRecord orginalRecord, DbUpdatableDataRecord currentRecord, string prefix = "") { for (var i = 0; i < orginalRecord.FieldCount; i++) { var name = orginalRecord.GetName(i); var originalValue = orginalRecord.GetValue(i); var currentValue = currentRecord.GetValue(i); var valueRecord = originalValue as DbDataRecord; if (valueRecord != null) { // Complex Type AuditEntityModified(audit, entry, objectStateEntry, valueRecord, currentValue as DbUpdatableDataRecord, string.Concat(prefix, name, ".")); } else if (objectStateEntry.EntityKey.EntityKeyValues.Any(x => x.Key == name) || entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, name)) { if (!audit.Configuration.IgnorePropertyUnchanged || objectStateEntry.EntityKey.EntityKeyValues.Any(x => x.Key == name) || !Equals(currentValue, originalValue)) { var auditEntryProperty = entry.Parent.Configuration.AuditEntryPropertyFactory != null? entry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(entry, objectStateEntry, string.Concat(prefix, name), originalValue, currentValue)) : new AuditEntryProperty(); auditEntryProperty.Build(entry, string.Concat(prefix, name), originalValue, currentValue); entry.Properties.Add(auditEntryProperty); } } } }