private void sVCRESTR2BindingNavigatorSaveItem_Click(object sender, System.EventArgs e) { GridViewSvcRestr.ClearColumnsFilter(); if (SvcRestrBindingSource.Current == null) { return; } if (!checkRestrCode()) { MessageBox.Show("The restriction code for this property/service must be set to ‘A’ (agency) in order to save a record in the service restriction file."); return; } GridViewSvcRestr.CloseEditor(); ComboBoxEditType.Focus(); //bindingNavigatorPositionItem.Focus();//trigger field leave event bool temp = newRec; if (checkForms()) { ImageComboBoxEditCode.Focus(); panelControlStatus.Visible = true; LabelStatus.Text = "Record Saved"; rowStatusSave = new Timer(); rowStatusSave.Interval = 3000; rowStatusSave.Start(); rowStatusSave.Tick += TimedEventSave; setReadOnly(true); } if (!temp && !modified) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (SVCRESTR)SvcRestrBindingSource.Current); } }
private void executeQuery() { this.Cursor = Cursors.WaitCursor; string colName = GridViewSvcRestr.FocusedColumn.FieldName; string value = String.Empty; if (!string.IsNullOrWhiteSpace(GridViewSvcRestr.GetFocusedDisplayText())) { value = GridViewSvcRestr.GetFocusedDisplayText(); } if (!string.IsNullOrWhiteSpace(value)) { string query = String.Format("it.CODE like '{0}%'", GridViewSvcRestr.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE")); var special = context.SVCRESTR.Where(query); if (!string.IsNullOrWhiteSpace(GridViewSvcRestr.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "TYPE"))) { query = String.Format("it.{0} like '{1}%'", "TYPE", GridViewSvcRestr.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "TYPE")); special = special.Where(query); } if (!string.IsNullOrWhiteSpace(GridViewSvcRestr.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "AGENCY"))) { query = String.Format("it.{0} like '{1}%'", "AGENCY", GridViewSvcRestr.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "AGENCY")); special = special.Where(query); } int count = special.Count(); if (count > 0) { SvcRestrBindingSource.DataSource = special; GridViewSvcRestr.FocusedRowHandle = 0; GridViewSvcRestr.FocusedColumn.FieldName = colName; GridViewSvcRestr.ClearColumnsFilter(); } else { MessageBox.Show("No records in database."); GridViewSvcRestr.ClearColumnsFilter(); //this should be final } } this.Cursor = Cursors.Default; }
private void bindingNavigatorAddNewItem_Click(object sender, System.EventArgs e) { GridViewSvcRestr.ClearColumnsFilter(); if (SvcRestrBindingSource.Current == null) { SvcRestrBindingSource.DataSource = from packrec in context.SVCRESTR where packrec.CODE == "KJM987" select packrec; SvcRestrBindingSource.AddNew(); if (GridViewSvcRestr.FocusedRowHandle == GridControl.AutoFilterRowHandle) { GridViewSvcRestr.FocusedRowHandle = GridViewSvcRestr.RowCount - 1; } ComboBoxEditType.Focus(); newRec = true; setReadOnly(false); setValues(); return; } ComboBoxEditType.Focus(); //bindingNavigatorPositionItem.Focus(); //trigger field leave event GridViewSvcRestr.CloseEditor(); temp = newRec; if (checkForms()) { errorProvider1.Clear(); if (!temp) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (SVCRESTR)SvcRestrBindingSource.Current); } SvcRestrBindingSource.AddNew(); if (GridViewSvcRestr.FocusedRowHandle == GridControl.AutoFilterRowHandle) { GridViewSvcRestr.FocusedRowHandle = GridViewSvcRestr.RowCount - 1; } ComboBoxEditType.Focus(); newRec = true; setValues(); setReadOnly(false); } }