Beispiel #1
0
        private void executeQuery()
        {
            this.Cursor = Cursors.WaitCursor;
            string colName = GridViewConsrt.FocusedColumn.FieldName;
            string value   = String.Empty;

            if (!string.IsNullOrWhiteSpace(GridViewConsrt.GetFocusedDisplayText()))
            {
                value = GridViewConsrt.GetFocusedDisplayText();
            }
            if (!string.IsNullOrWhiteSpace(value))
            {
                string query   = String.Format("it.NAME like '{0}%'", GridViewConsrt.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "NAME"));
                var    special = context.CONSRT.Where(query);

                if (!string.IsNullOrWhiteSpace(GridViewConsrt.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE")))
                {
                    query   = String.Format("it.{0} like '{1}%'", "CODE", GridViewConsrt.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE"));
                    special = special.Where(query);
                }

                int count = special.Count();
                if (count > 0)
                {
                    ConsrtBindingSource.DataSource = special;
                    GridViewConsrt.ClearColumnsFilter();
                }
                else
                {
                    MessageBox.Show("No records in database.");
                    GridViewConsrt.ClearColumnsFilter();
                }
            }
            this.Cursor = Cursors.Default;
        }
Beispiel #2
0
 private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
 {
     if (ConsrtBindingSource.Current == null)
     {
         return;
     }
     GridViewConsrt.CloseEditor();
     if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         modified = false;
         newRec   = false;
         ConsrtBindingSource.RemoveCurrent();
         errorProvider1.Clear();
         context.SaveChanges();
         cODETextEdit.Properties.ReadOnly = true;
         GridViewConsrt.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);
         //bindingNavigatorPositionItem.Focus();
     }
     currentVal = cODETextEdit.Text;
 }
Beispiel #3
0
 private void ConsrtForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && GridViewConsrt.IsFilterRow(GridViewConsrt.FocusedRowHandle))
     {
         executeQuery();
     }
 }
Beispiel #4
0
        private void cONSRTBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (ConsrtBindingSource.Current == null)
            {
                return;
            }
            GridViewConsrt.CloseEditor();
            cODETextEdit.Focus();
            // bindingNavigatorPositionItem.Focus();//trigger field leave event
            bool temp = newRec;

            if (checkForms())
            {
                errorProvider1.Clear();
                cODETextEdit.Properties.ReadOnly = true;
                GridViewConsrt.Columns.ColumnByName(colName).OptionsColumn.AllowEdit = false;
                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, (CONSRT)ConsrtBindingSource.Current);
            }
        }
Beispiel #5
0
        private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (!GridViewConsrt.IsFilterRow(e.RowHandle))
            {
                modified = true;
            }

            labelControl1.Text = DateTime.Today.ToShortDateString();
            labelControl2.Text = username;
        }
Beispiel #6
0
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     GridViewConsrt.ClearColumnsFilter();
     if (ConsrtBindingSource.Current == null)
     {
         //fake query in order to create a link between the database table and the binding source
         ConsrtBindingSource.DataSource = from opt in context.CONSRT where opt.CODE == "KJM9" select opt;
         ConsrtBindingSource.AddNew();
         if (GridViewConsrt.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewConsrt.FocusedRowHandle = GridViewConsrt.RowCount - 1;
         }
         cODETextEdit.Focus();
         cODETextEdit.Properties.ReadOnly = false;
         GridViewConsrt.Columns.ColumnByName(colName).OptionsColumn.AllowEdit = true;
         newRec = true;
         return;
     }
     cODETextEdit.Focus();
     // bindingNavigatorPositionItem.Focus();  //trigger field leave event
     GridViewConsrt.CloseEditor();
     temp = newRec;
     //if (validCheck.saveRoutine(cONSRTBindingSource, cONSRTBindingNavigator, context, errorProvider1, ref newRec, ref modified, (( CONSRT)cONSRTBindingSource.Current).checkAll, splitContainerControl1.Panel2.Controls, validCheck.dummy))
     if (checkForms())
     {
         errorProvider1.Clear();
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( CONSRT)ConsrtBindingSource.Current);
         }
         ConsrtBindingSource.AddNew();
         if (GridViewConsrt.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewConsrt.FocusedRowHandle = GridViewConsrt.RowCount - 1;
         }
         cODETextEdit.Focus();
         cODETextEdit.Properties.ReadOnly = false;
         GridViewConsrt.Columns.ColumnByName(colName).OptionsColumn.AllowEdit = true;
         newRec = true;
     }
 }
Beispiel #7
0
        private bool move()
        {
            GridViewConsrt.CloseEditor();
            cODETextEdit.Focus();
            // bindingNavigatorPositionItem.Focus();//trigger field leave event
            temp = newRec;
            //if (validCheck.saveRoutine(cONSRTBindingSource, cONSRTBindingNavigator, context, errorProvider1, ref newRec, ref modified, (( CONSRT)cONSRTBindingSource.Current).checkAll, splitContainerControl1.Panel2.Controls, validCheck.dummy))
            if (checkForms())
            {
                errorProvider1.Clear();

                if (!temp)
                {
                    context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( CONSRT)ConsrtBindingSource.Current);
                }
                cODETextEdit.Properties.ReadOnly = true;
                GridViewConsrt.Columns.ColumnByName(colName).OptionsColumn.AllowEdit = false;
                newRec   = false;
                modified = false;
                return(true);
            }
            return(false);
        }