Exemple #1
0
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     if (OperatorBindingSource.Current == null)
     {
         OperatorBindingSource.DataSource = from opt in context.OPERATOR where opt.CODE == "KJM9" select opt;
         OperatorBindingSource.AddNew();
         TextEditCode.Focus();
         setReadOnly(false);
         setValues();
         newRec = true;
         return;
     }
     TextEditCode.Focus();
     //bindingNavigatorPositionItem.Focus();  //trigger field leave event
     GridViewOper.CloseEditor();
     temp = newRec;
     if (checkForms())
     {
         errorProvider1.Clear();
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( OPERATOR)OperatorBindingSource.Current);
         }
         OperatorBindingSource.AddNew();
         TextEditCode.Focus();
         setReadOnly(false);
         setValues();
         newRec = true;
     }
 }
Exemple #2
0
        private bool move()
        {
            if (contactNewRowRec == true)
            {
                MessageBox.Show("Please save or delete the new record being added in the grid on the Contacts tab before attempting to navigate to another record.");

                return(false);
            }

            GridViewOper.CloseEditor();
            TextEditCode.Focus();
            //bindingNavigatorPositionItem.Focus();//trigger field leave event
            temp = newRec;
            if (checkForms())
            {
                errorProvider1.Clear();

                if (!temp)
                {
                    context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( OPERATOR)OperatorBindingSource.Current);
                }

                setReadOnly(true);
                newRec   = false;
                modified = false;
                return(true);
            }
            return(false);
        }
Exemple #3
0
        private void BindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (RptTypeBindingSource.Current == null)
            {
                return;
            }

            GridViewReport.CloseEditor();
            TextEditCode.Focus();
            //bindingNavigatorPositionItem.Focus();//trigger field leave event
            bool temp = newRec;

            if (checkForms())
            {
                TextEditCode.Focus();
                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, (RPTTYPE)RptTypeBindingSource.Current);
            }
        }
Exemple #4
0
 private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
 {
     if (AirBindingSource.Current == null)
     {
         return;
     }
     GridViewAir.CloseEditor();
     if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         modified = false;
         newRec   = false;
         AirBindingSource.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);
         //bindingNavigatorPositionItem.Focus();
     }
     TextEditCode.Focus();
 }
Exemple #5
0
        private void oPERATORBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            TextEditCode.Focus();
            int contactID = 0;

            if (OperatorBindingSource.Current == null)
            {
                return;
            }
            GridViewOper.CloseEditor();
            if (GridViewAdditionalContacts.RowCount > 0)
            {
                contactID = (int)GridViewAdditionalContacts.GetFocusedRowCellValue("ID");
            }


            bool temp = newRec;

            if (checkForms())
            {
                contactNewRowRec = false;
                errorProvider1.Clear();
                setReadOnly(true);
                if (contactID == int.MaxValue)
                {
                    int newID   = (int)GridViewAdditionalContacts.GetFocusedRowCellValue("ID");
                    var values1 = from rec in context.RPTTYPE where rec.RecipientType == "Operator" select new { rec.CODE };
                    foreach (var result in values1)
                    {
                        if (globalRptType.Contains(result.CODE))
                        {
                            RptContact lol = new RptContact();
                            lol.Code       = TextEditCode.Text;
                            lol.RptType    = result.CODE;
                            lol.Contact_ID = newID;
                            context.RptContact.AddObject(lol);
                        }
                    }
                    globalRptType = string.Empty;
                    context.SaveChanges();
                }
                contactNewRowRec           = 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, (OPERATOR)OperatorBindingSource.Current);
            }
        }
Exemple #6
0
 private void BarButtonItemNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     _ignoreLeaveRow = true;       //so that when the grid row changes it doesn't try to save again
     if (SaveRecord(true)) {
         GridViewLookup.ClearColumnsFilter();    //so that the new record will show even if it doesn't match the filter
         BindingSource.AddNew();
         //if (GridViewRoute.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         GridViewLookup.FocusedRowHandle = GridViewLookup.RowCount - 1;
         SetReadOnlyKeyFields(false);
         TextEditCode.Focus();
         SetReadOnly(false);
     }
     ErrorProvider.Clear();
     _ignoreLeaveRow = false;
 }
Exemple #7
0
 private void BarButtonItemNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     _ignoreLeaveRow = true;                   //so that when the grid row changes it doesn't try to save again
     if (SaveRecord(true))
     {
         //For some reason when there is no existing record in the binding source the Add method does not
         //trigger the CurrentChanged event, but AddNew does so use that instead
         _selectedRecord = (REGION)BindingSource.AddNew();
         //With the instant feedback data source, the new row is not immediately added to the grid, so move
         //the focused row to the filter row just so that no other existing row is visually highlighted
         GridViewLookup.FocusedRowHandle = DevExpress.Data.BaseListSourceDataController.FilterRow;
         SetReadOnlyKeyFields(false);
         TextEditCode.Focus();
         SetReadOnly(false);
     }
     ErrorProvider.Clear();
     _ignoreLeaveRow = false;
 }
Exemple #8
0
 private bool move()
 {
     GridViewReport.CloseEditor();
     //bindingNavigatorPositionItem.Focus();//trigger field leave event
     TextEditCode.Focus();
     temp = newRec;
     if (checkForms())
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( RPTTYPE)RptTypeBindingSource.Current);
         }
         setReadOnly(true);
         newRec   = false;
         modified = false;
         return(true);
     }
     return(false);
 }
Exemple #9
0
        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (OperatorBindingSource.Current == null)
            {
                return;
            }
            GridViewOper.CloseEditor();
            if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                modified = false;
                newRec   = false;

                IEnumerable <CONTACT> contactRecs = from contact in context.CONTACT where contact.LINK_VALUE == TextEditCode.Text select contact;
                foreach (CONTACT rec in contactRecs)
                {
                    context.DeleteObject(rec);
                }

                IEnumerable <RptContact> rptContactRecs = from contact in context.RptContact where contact.Code == TextEditCode.Text select contact;
                foreach (RptContact rec in rptContactRecs)
                {
                    context.DeleteObject(rec);
                }


                OperatorBindingSource.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);
            }
            TextEditCode.Focus();
            currentVal = TextEditCode.Text;
            modified   = false;
            newRec     = false;
        }
Exemple #10
0
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     GridViewAir.ClearColumnsFilter();
     if (AirBindingSource.Current == null)
     {
         //fake query in order to create a link between the database table and the binding source
         AirBindingSource.DataSource = from opt in context.AIR where opt.CODE == "KJM9" select opt;
         AirBindingSource.AddNew();
         if (GridViewAir.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewAir.FocusedRowHandle = GridViewAir.RowCount - 1;
         }
         setValues();
         TextEditCode.Focus();
         setReadOnly(false);
         newRec = true;
         return;
     }
     TextEditCode.Focus();
     // bindingNavigatorPositionItem.Focus();  //trigger field leave event
     GridViewAir.CloseEditor();
     temp = newRec;
     if (checkForms())
     {
         errorProvider1.Clear();
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( AIR)AirBindingSource.Current);
         }
         AirBindingSource.AddNew();
         if (GridViewAir.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewAir.FocusedRowHandle = GridViewAir.RowCount - 1;
         }
         setValues();
         TextEditCode.Focus();
         setReadOnly(false);
         newRec = true;
     }
 }
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     GridViewTrain.ClearColumnsFilter();
     if (TrainStationBindingSource.Current == null)
     {
         TrainStationBindingSource.DataSource = from opt in context.TrainStation where opt.Code == "KJM9" select opt;
         TrainStationBindingSource.AddNew();
         if (GridViewTrain.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewTrain.FocusedRowHandle = GridViewTrain.RowCount - 1;
         }
         TextEditCode.Focus();
         setReadOnly(false);
         setValues();
         newRec = true;
         return;
     }
     TextEditCode.Focus();
     //bindingNavigatorPositionItem.Focus();  //trigger field leave event
     GridViewTrain.CloseEditor();
     temp = newRec;
     if (checkForms())
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (TrainStation)TrainStationBindingSource.Current);
         }
         TrainStationBindingSource.AddNew();
         if (GridViewTrain.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewTrain.FocusedRowHandle = GridViewTrain.RowCount - 1;
         }
         TextEditCode.Focus();
         setReadOnly(false);
         setValues();
         newRec = true;
     }
 }