Ejemplo n.º 1
0
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            if (modified || newRec)
            {
                DialogResult select = DevExpress.XtraEditors.XtraMessageBox.Show("Do you want to confirm these changes?", Text, MessageBoxButtons.YesNoCancel);
                if (select == DialogResult.Cancel)
                {
                    return;
                }
                if (select == DialogResult.Yes)
                {
                    if (!SaveRecord())
                    {
                        return;
                    }
                }
                if (select == DialogResult.No)
                {
                    if (newRec)
                    {
                        RemoveRecord();
                    }
                    else
                    {
                        RefreshRecord();
                    }
                }
            }

            GridViewUsers.ClearColumnsFilter();
            if (UsersBindingSource.Current == null)
            {
                //fake query in order to create a link between the database table and the binding source
                UsersBindingSource.DataSource = from opt in context.ExtranetUser where opt.UserID == "KJM9" select opt;
            }
            CheckEditAgent.Focus();
            GridViewUsers.CloseEditor();
            newRec         = true;
            ignoreLeaveRow = true;       //so that when the grid row changes it doesn't try to save again
            UsersBindingSource.AddNew();
            if (GridViewUsers.FocusedRowHandle == GridControl.AutoFilterRowHandle)
            {
                GridViewUsers.FocusedRowHandle = GridViewUsers.RowCount - 1;
            }
            CheckEditAgent.Focus();
            setReadOnly(false);
            ignoreLeaveRow = false;
        }
Ejemplo n.º 2
0
 private bool move()
 {
     GridViewUsers.CloseEditor();
     CheckEditAgent.Focus();
     //bindingNavigatorPositionItem.Focus();//trigger field leave event
     temp = newRec;
     if (checkForms(true))
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (ExtranetUser)UsersBindingSource.Current);
         }
         setReadOnly(true);
         newRec   = false;
         modified = false;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
        private bool SaveRecord()
        {
            if (UsersBindingSource.Current == null)     //user is not editing a record and has never clicked Add button
            {
                return(true);
            }

            GridViewUsers.CloseEditor();
            GridViewPermissions.CloseEditor();
            if (GridViewPermissions.UpdateCurrentRow())
            {
                PermissionsBindingSource.EndEdit();
                foreach (ExtranetPermission permission in PermissionsBindingSource)
                {
                    permission.UserID      = GetUserID();
                    permission.ProductType = "HTL";
                }
            }
            CheckEditAgent.Focus();
            temp = newRec;
            //bindingNavigatorPositionItem.Focus();//trigger field leave event
            if (checkForms(false))
            {
                CheckEditAgent.Focus();
                setReadOnly(true);
                panelControlStatus.Visible = true;
                LabelStatus.Text           = "Record Saved";
                rowStatusSave          = new Timer();
                rowStatusSave.Interval = 3000;
                rowStatusSave.Start();
                rowStatusSave.Tick += TimedEventSave;
                return(true);
            }
            else
            {
                return(false);
            }
        }