コード例 #1
0
        private void cARINFOBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (CarInfoBindingSource.Current == null)
            {
                return;
            }
            GridViewCarInfo.CloseEditor();
            cODETextEdit.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, (CARINFO)CarInfoBindingSource.Current);
            }
        }
コード例 #2
0
 private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
 {
     if (CarInfoBindingSource.Current == null)
     {
         return;
     }
     GridViewCarInfo.CloseEditor();
     if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         modified = false;
         newRec   = false;
         CarInfoBindingSource.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);
     }
     cODETextEdit.Focus();
     currentVal = cODETextEdit.Text;
     modified   = false;
     newRec     = false;
 }
コード例 #3
0
 private bool move()
 {
     GridViewCarInfo.CloseEditor();
     cODETextEdit.Focus();
     //bindingNavigatorPositionItem.Focus();//trigger field leave event
     temp = newRec;
     if (checkForms())
     {
         errorProvider1.Clear();
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( CARINFO)CarInfoBindingSource.Current);
         }
         setReadOnly(true);
         newRec   = false;
         modified = false;
         return(true);
     }
     return(false);
 }
コード例 #4
0
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            GridViewCarInfo.ClearColumnsFilter();
            cODETextEdit.Focus();  //trigger field leave event
            if (CarInfoBindingSource.Current == null)
            {
                //fake query in order to create a link between the database table and the binding source
                CarInfoBindingSource.DataSource = from opt in context.CARINFO where opt.CODE == "KJM9" select opt;
                CarInfoBindingSource.AddNew();
                if (GridViewCarInfo.FocusedRowHandle == GridControl.AutoFilterRowHandle)
                {
                    GridViewCarInfo.FocusedRowHandle = GridViewCarInfo.RowCount - 1;
                }
                setValues();
                cODETextEdit.Focus();
                setReadOnly(false);
                newRec = true;
                return;
            }

            GridViewCarInfo.CloseEditor();
            temp = newRec;
            if (checkForms())
            {
                errorProvider1.Clear();
                if (!temp)
                {
                    context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( CARINFO)CarInfoBindingSource.Current);
                }
                CarInfoBindingSource.AddNew();
                if (GridViewCarInfo.FocusedRowHandle == GridControl.AutoFilterRowHandle)
                {
                    GridViewCarInfo.FocusedRowHandle = GridViewCarInfo.RowCount - 1;
                }
                setValues();
                cODETextEdit.Focus();
                setReadOnly(false);
                newRec = true;
            }
        }