private void executeQuery() { this.Cursor = Cursors.WaitCursor; string colName = GridViewCarOff.FocusedColumn.FieldName; string value = String.Empty; if (!string.IsNullOrWhiteSpace(GridViewCarOff.GetFocusedDisplayText())) { value = GridViewCarOff.GetFocusedDisplayText(); } if (!string.IsNullOrWhiteSpace(value)) { string query = String.Format("it.NAME like '{0}%'", GridViewCarOff.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "NAME")); var special = context.CAROFF.Where(query); if (!string.IsNullOrWhiteSpace(GridViewCarOff.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE"))) { query = String.Format("it.{0} like '{1}%'", "CODE", GridViewCarOff.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE")); special = special.Where(query); } int count = special.Count(); if (count > 0) { CarOffBindingSource.DataSource = special; GridViewCarOff.ClearColumnsFilter(); } else { MessageBox.Show("No records in database."); GridViewCarOff.ClearColumnsFilter(); } } this.Cursor = Cursors.Default; }
private void cAROFFBindingNavigatorSaveItem_Click(object sender, EventArgs e) { if (CarOffBindingSource.Current == null) { return; } GridViewCarOff.CloseEditor(); ImageComboBoxEditCode.Focus(); // bindingNavigatorPositionItem.Focus();//trigger field leave event 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, (CAROFF)CarOffBindingSource.Current); } }
private void CarOffForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && GridViewCarOff.IsFilterRow(GridViewCarOff.FocusedRowHandle)) { executeQuery(); } }
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (CarOffBindingSource.Current == null) { return; } GridViewCarOff.CloseEditor(); if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes) { modified = false; newRec = false; CarOffBindingSource.RemoveCurrent(); errorProvider1.Clear(); context.SaveChanges(); setReadOnly(true); panelControlStatus.Visible = true; LabelStatus.Text = "Record Deleted"; rowStatusDelete = new Timer(); rowStatusDelete.Interval = 3000; rowStatusDelete.Start(); rowStatusDelete.Tick += new EventHandler(TimedEventDelete); } ImageComboBoxEditCode.Focus(); currentVal = ImageComboBoxEditCode.Text; modified = false; newRec = false; }
private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (!GridViewCarOff.IsFilterRow(e.RowHandle)) { modified = true; } labelControl4.Text = DateTime.Today.ToShortDateString(); labelControl5.Text = username; }
private bool move() { GridViewCarOff.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, ( CAROFF)CarOffBindingSource.Current); } setReadOnly(true); newRec = false; modified = false; return(true); } return(false); }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { GridViewCarOff.ClearColumnsFilter(); if (CarOffBindingSource.Current == null) { //fake query in order to create a link between the database table and the binding source CarOffBindingSource.DataSource = from opt in context.CAROFF where opt.CODE == "KJM9" select opt; CarOffBindingSource.AddNew(); if (GridViewCarOff.FocusedRowHandle == GridControl.AutoFilterRowHandle) { GridViewCarOff.FocusedRowHandle = GridViewCarOff.RowCount - 1; } setValues(); ImageComboBoxEditCode.Focus(); setReadOnly(false); newRec = true; return; } ImageComboBoxEditCode.Focus(); //bindingNavigatorPositionItem.Focus(); //trigger field leave event GridViewCarOff.CloseEditor(); temp = newRec; if (checkForms()) { errorProvider1.Clear(); if (!temp) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( CAROFF)CarOffBindingSource.Current); } CarOffBindingSource.AddNew(); if (GridViewCarOff.FocusedRowHandle == GridControl.AutoFilterRowHandle) { GridViewCarOff.FocusedRowHandle = GridViewCarOff.RowCount - 1; } setValues(); ImageComboBoxEditCode.Focus(); setReadOnly(false); newRec = true; } }
private void setValues() { GridViewCarOff.SetFocusedRowCellValue("OFF", string.Empty); GridViewCarOff.SetFocusedRowCellValue("CODE", string.Empty); GridViewCarOff.SetFocusedRowCellValue("NAME", string.Empty); GridViewCarOff.SetFocusedRowCellValue("AP", string.Empty); GridViewCarOff.SetFocusedRowCellValue("AR", string.Empty); GridViewCarOff.SetFocusedRowCellValue("CONTACT", string.Empty); GridViewCarOff.SetFocusedRowCellValue("PHONE1", string.Empty); GridViewCarOff.SetFocusedRowCellValue("PHONE1_NO", string.Empty); GridViewCarOff.SetFocusedRowCellValue("PHONE2", string.Empty); GridViewCarOff.SetFocusedRowCellValue("PHONE2_NO", string.Empty); GridViewCarOff.SetFocusedRowCellValue("ADDR1", string.Empty); GridViewCarOff.SetFocusedRowCellValue("ADDR2", string.Empty); GridViewCarOff.SetFocusedRowCellValue("ADDR3", string.Empty); GridViewCarOff.SetFocusedRowCellValue("AIRPORT", string.Empty); GridViewCarOff.SetFocusedRowCellValue("AIR_MI", 0); GridViewCarOff.SetFocusedRowCellValue("COUNTRY", string.Empty); GridViewCarOff.SetFocusedRowCellValue("CITY", string.Empty); GridViewCarOff.SetFocusedRowCellValue("CITY_MI", 0); GridViewCarOff.SetFocusedRowCellValue("MISC1", string.Empty); GridViewCarOff.SetFocusedRowCellValue("MISC2", string.Empty); GridViewCarOff.SetFocusedRowCellValue("MISC3", string.Empty); GridViewCarOff.SetFocusedRowCellValue("MISC4", string.Empty); GridViewCarOff.SetFocusedRowCellValue("REGION", string.Empty); GridViewCarOff.SetFocusedRowCellValue("LATITUDE", string.Empty); GridViewCarOff.SetFocusedRowCellValue("LONGITUDE", string.Empty); GridViewCarOff.SetFocusedRowCellValue("STATE", string.Empty); GridViewCarOff.SetFocusedRowCellValue("ZIP", string.Empty); GridViewCarOff.SetFocusedRowCellValue("TOWN", string.Empty); GridViewCarOff.SetFocusedRowCellValue("GMACCTNO", string.Empty); GridViewCarOff.SetFocusedRowCellValue("USER_DEC1", 0); GridViewCarOff.SetFocusedRowCellValue("USER_DEC2", 0); GridViewCarOff.SetFocusedRowCellValue("USER_INT1", 0); GridViewCarOff.SetFocusedRowCellValue("USER_INT2", 0); GridViewCarOff.SetFocusedRowCellValue("USER_TXT1", string.Empty); GridViewCarOff.SetFocusedRowCellValue("USER_TXT2", string.Empty); GridViewCarOff.SetFocusedRowCellValue("USER_TXT3", string.Empty); GridViewCarOff.SetFocusedRowCellValue("USER_TXT4", string.Empty); }