private void executeQuery() { this.Cursor = Cursors.WaitCursor; string colName = GridViewCruise.FocusedColumn.FieldName; string value = String.Empty; if (!string.IsNullOrWhiteSpace(GridViewCruise.GetFocusedDisplayText())) { value = GridViewCruise.GetFocusedDisplayText(); } if (!string.IsNullOrWhiteSpace(value)) { string query = String.Format("it.NAME like '{0}%'", GridViewCruise.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "NAME")); var special = context.CRU.Where(query); if (!string.IsNullOrWhiteSpace(GridViewCruise.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE"))) { query = String.Format("it.{0} like '{1}%'", "CODE", GridViewCruise.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE")); special = special.Where(query); } int count = special.Count(); if (count > 0) { CruBindingSource.DataSource = special; GridViewCruise.ClearColumnsFilter(); } else { MessageBox.Show("No records in database."); GridViewCruise.ClearColumnsFilter(); } } this.Cursor = Cursors.Default; }
private void cRUBindingNavigatorSaveItem_Click(object sender, EventArgs e) { typeTextEdit.Text = "CRU"; if (CruBindingSource.Current == null) { return; } GridViewCruise.CloseEditor(); //bindingNavigatorPositionItem.Focus();//trigger field leave event ImageComboBoxEditCode.Focus(); bool temp = newRec; if (checkForms()) { errorProvider1.Clear(); setReadOnly(true); panelControlStatus.Visible = true; LabelStatus.Text = "Record Saved"; rowStatusSave = new Timer(); rowStatusSave.Interval = 3000; rowStatusSave.Start(); rowStatusSave.Tick += TimedEventSave; } if (!temp && !modified) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (CRU)CruBindingSource.Current); } }
private void CruiseShipForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && GridViewCruise.IsFilterRow(GridViewCruise.FocusedRowHandle)) { executeQuery(); } }
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (CruBindingSource.Current == null) { return; } GridViewCruise.CloseEditor(); if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes) { modified = false; newRec = false; CruBindingSource.RemoveCurrent(); errorProvider1.Clear(); context.SaveChanges(); GridViewCruise.Columns.ColumnByName(colName).OptionsColumn.AllowEdit = false; panelControlStatus.Visible = true; LabelStatus.Text = "Record Deleted"; rowStatusDelete = new Timer(); rowStatusDelete.Interval = 3000; rowStatusDelete.Start(); rowStatusDelete.Tick += new EventHandler(TimedEventDelete); } currentVal = ImageComboBoxEditCode.Text; }
private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (!GridViewCruise.IsFilterRow(e.RowHandle)) { modified = true; } labelControlLastUpd.Text = DateTime.Today.ToShortDateString(); labelControlUpdBy.Text = username; }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { GridViewCruise.ClearColumnsFilter(); if (CruBindingSource.Current == null) { //fake query in order to create a link between the database table and the binding source CruBindingSource.DataSource = from opt in context.CRU where opt.CODE == "KJM9" select opt; CruBindingSource.AddNew(); if (GridViewCruise.FocusedRowHandle == GridControl.AutoFilterRowHandle) { GridViewCruise.FocusedRowHandle = GridViewCruise.RowCount - 1; } setValues(); ImageComboBoxEditCode.Focus(); setReadOnly(false); newRec = true; return; } ImageComboBoxEditCode.Focus(); //bindingNavigatorPositionItem.Focus(); //trigger field leave event GridViewCruise.CloseEditor(); temp = newRec; if (checkForms()) { errorProvider1.Clear(); if (!temp) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (CRU)CruBindingSource.Current); } CruBindingSource.AddNew(); if (GridViewCruise.FocusedRowHandle == GridControl.AutoFilterRowHandle) { GridViewCruise.FocusedRowHandle = GridViewCruise.RowCount - 1; } setValues(); setReadOnly(false); newRec = true; } }
private bool move() { GridViewCruise.CloseEditor(); ImageComboBoxEditCode.Focus(); //bindingNavigatorPositionItem.Focus();//trigger field leave event temp = newRec; if (checkForms()) { errorProvider1.Clear(); if (!temp) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (CRU)CruBindingSource.Current); } setReadOnly(true); newRec = false; modified = false; return(true); } return(false); }
private void setValues() { GridViewCruise.SetFocusedRowCellValue("CODE", string.Empty); GridViewCruise.SetFocusedRowCellValue("NAME", string.Empty); GridViewCruise.SetFocusedRowCellValue("AP", string.Empty); GridViewCruise.SetFocusedRowCellValue("AR", string.Empty); GridViewCruise.SetFocusedRowCellValue("BUILT", string.Empty); GridViewCruise.SetFocusedRowCellValue("ELECT", string.Empty); GridViewCruise.SetFocusedRowCellValue("TONNAGE", string.Empty); GridViewCruise.SetFocusedRowCellValue("REGISTRY", string.Empty); GridViewCruise.SetFocusedRowCellValue("CREW", string.Empty); GridViewCruise.SetFocusedRowCellValue("FACILITIES", string.Empty); GridViewCruise.SetFocusedRowCellValue("COMMENT1", string.Empty); GridViewCruise.SetFocusedRowCellValue("COMMENT2", string.Empty); GridViewCruise.SetFocusedRowCellValue("COMMENT3", string.Empty); GridViewCruise.SetFocusedRowCellValue("COMMENT4", string.Empty); GridViewCruise.SetFocusedRowCellValue("OPER", string.Empty); GridViewCruise.SetFocusedRowCellValue("NON", string.Empty); GridViewCruise.SetFocusedRowCellValue("RESTR_CDE", string.Empty); GridViewCruise.SetFocusedRowCellValue("DEF_CABIN", string.Empty); GridViewCruise.SetFocusedRowCellValue("Due_Days", 0); GridViewCruise.SetFocusedRowCellValue("Type", string.Empty); }