Beispiel #1
0
        /// <summary>
        /// checks whether the current record is being edited or inserted
        /// </summary>
        /// <param name="oViewEditing">editing state of the Form</param>
        /// <returns>returns true if the record is being edited, false vice versa</returns>
        public static bool CheckInEditMode(object caller, ViewEditing oViewEditing)
        {
            bool    bRet   = false;
            dynamic sTrace = caller.ToString();

            try
            {
                if (oViewEditing.actualStatus != state.view)
                {
                    string sMessage = oViewEditing.actualStatus == state.insert ? AlertOnInserting : AlertOnEditing;
                    Display.ShowWarning(sMessage);
                    sTrace += sMessage;
                    bRet    = true;
                }
                else
                {
                    bRet = false;
                }
            }
            catch (Exception ex)
            {
                Display.ShowError(ex.Message);
            }
            return(bRet);
        }
Beispiel #2
0
        /// <summary>
        /// It manages the repositioning of the record on a GridView
        /// </summary>
        /// <param name="oViewEditing">editing state of the Form</param>
        /// <param name="BindingSource">BindingSource on the data list</param>
        /// <param name="buttonCaller">Button that calls the move</param>
        /// <remarks></remarks>
        public static void MoveTo(ViewEditing oViewEditing, BindingSource bs, Button buttonCaller, Control ControlToFocus = null)
        {
            try
            {
                if (bs == null || bs.Count == 0)
                {
                    return;
                }

                if (ControlToFocus != null)
                {
                    ControlToFocus.Focus();
                }

                if (oViewEditing.actualStatus != state.view)
                {
                    Display.ShowMessage("You are in " + (oViewEditing.actualStatus == state.edit ? "edit!" : "insert!" + Environment.NewLine + "Save or Cancel " + "before proceeding with the update"));
                    return;
                }

                if (buttonCaller.Name.ToLower().Contains("first"))
                {
                    bs.MoveFirst();
                }
                if (buttonCaller.Name.ToLower().Contains("prev"))
                {
                    bs.MovePrevious();
                }
                if (buttonCaller.Name.ToLower().Contains("next"))
                {
                    bs.MoveNext();
                }
                if (buttonCaller.Name.ToLower().Contains("last"))
                {
                    bs.MoveLast();
                }
            }
            catch (Exception ex)
            {
                Display.ShowError(ex.Message);
            }
        }
Beispiel #3
0
        /// <summary>
        /// checks whether the change of a current tab control is performed during an edit
        /// </summary>
        /// <param name="oViewEditing">editing state of the Form</param>
        /// <returns>Returns true if try change tab during en editing, false vice versa</returns>
        public static bool IsTabChangingOnEdit(EventArgs e, ViewEditing oViewEditing)
        {
            bool bRet = false;

            try
            {
                if (oViewEditing.actualStatus != state.view)
                {
                    Display.ShowWarning(AlertOnEditing);
                    bRet = true;
                }
                else
                {
                    bRet = false;
                }
            }
            catch (Exception ex)
            {
                Display.ShowError(ex.Message);
            }
            return(bRet);
        }
Beispiel #4
0
 public static void CheckCloseWithoutSaving(object sender, FormClosingEventArgs e, ViewEditing oViewEditing)
 {
     try
     {
         if (oViewEditing.actualStatus != state.view)
         {
             e.Cancel = (Display.ShowMessageWithConferm(AlertOnClosing, "Warning") == System.Windows.Forms.DialogResult.No);
         }
     }
     catch (Exception ex)
     {
         Display.ShowError(ex.Message);
     }
 }
Beispiel #5
0
        /// <summary>
        /// check the data presence, and in this case prevents a tab change
        /// </summary>
        /// <param name="BindingSourceObject">BindingSource to check</param>
        /// <param name="oViewEditing">editing state of the Form</param>
        /// <returns>returns true if there are no data to be changed</returns>
        public static bool CheckNoDataToShow(EventArgs e, BindingSource BindingSourceObject, ViewEditing oViewEditing)
        {
            bool bRet = false;

            try
            {
                if ((BindingSourceObject.DataSource == null || BindingSourceObject.Count == 0) && oViewEditing.actualStatus != state.insert)
                {
                    Display.ShowMessage(MessageNoData);
                    bRet = true;
                }
            }
            catch (Exception ex)
            {
                Display.ShowError(ex.Message);
            }
            return(bRet);
        }