public Form_AccountList() { InitializeComponent(); dataSet1 = arxDs.ds; accountsBindingSource.DataSource = arxDs.ds; dataGridView1.DataSource = accountsBindingSource; using (var remainingColumn = new DataGridViewTextBoxColumn { Width = 100, HeaderText = "Текущее состояние", ReadOnly = true }) { dataGridView1.Columns.Add(remainingColumn); } var view1 = new DataView(arxDs.ds.Tables["Accounts"], "", "", DataViewRowState.CurrentRows); if (!view1.Cast<DataRowView>() .Any(rv => rv.Row.Field<string>("Account") == "Основной")) { DataRowView newRow = view1.AddNew(); newRow["Account"] = "Основной"; newRow["StartSum"] = 0; newRow.EndEdit(); } }
private void fillComboBoxes() { var view1 = new DataView(arxDs.ds.Tables["Accounts"], "", "", DataViewRowState.CurrentRows); var view2 = new DataView(arxDs.ds.Tables["Accounts"], "", "", DataViewRowState.CurrentRows); if (!view1.Cast<DataRowView>() .Any(rv => rv.Row.Field<string>("Account") == "Основной")) { DataRowView newRow = view1.AddNew(); newRow["Account"] = "Основной"; newRow["StartSum"] = 0; newRow.EndEdit(); } comboBox1.DataSource = view1; comboBox1.DisplayMember = "Account"; comboBox2.DataSource = view2; comboBox2.DisplayMember = "Account"; }
public IEnumerable<KeyValuePair<string, CryptoKey>> GetKeys(string bucket) { // properly escape the URL to prevent injection attacks. string value = bucket.Replace("'", "''"); string filter = string.Format( CultureInfo.InvariantCulture, "{0} = '{1}'", dataSet.CryptoKey.BucketColumn.ColumnName, value); string sort = dataSet.CryptoKey.ExpiresUtcColumn.ColumnName + " DESC"; DataView view = new DataView(dataSet.CryptoKey, filter, sort, DataViewRowState.CurrentRows); if (view.Count == 0) { yield break; } foreach (CustomStoreDataSet.CryptoKeyRow row in view.Cast<DataRowView>().Select(rv => rv.Row)) { yield return new KeyValuePair<string, CryptoKey>(row.Handle, new CryptoKey(row.Secret, row.ExpiresUtc)); } }
private static IEnumerable<string> GetIndexNames(DataView indexes) { var list = new List<string>(); foreach (var indexName in indexes.Cast<DataRowView>().Select(row => row["INDEX_NAME"].ToString()).Where(indexName => !list.Contains(indexName))) { list.Add(indexName); } return list.OrderBy(n => n); }
static public void SaveRemarks(string ownerGUIDFieldName, string ownerGUID, string userMessagePrefix, DataView v) { if (v == null) return; string savefilter = v.RowFilter; v.RowFilter = ""; // ReSharper disable InconsistentNaming using (var Remark_u = new iTRAACProc("Remark_u")) // ReSharper restore InconsistentNaming foreach (var remark in v.Cast<DataRowView>().Where(remark => remark.IsDirty())) { Remark_u.AssignValues(remark); if (!Remark_u.ExecuteNonQuery(userMessagePrefix + " Save Remark: ")) continue; remark["RowGUID"] = Remark_u["@RowGUID"]; //for inserts remark.AcceptChanges(); } v.RowFilter = savefilter; }