Пример #1
0
 private void dgvRestrictedCasePrefixes_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex == -1 && dgvRestrictedCasePrefixes.SelectedRows.Count > 0)
     {
         _GridViewState            = GridViewState.Sorting;
         _RestrictedCasePrefixTemp = ((RestrictedCasePrefix)dgvRestrictedCasePrefixes.SelectedRows[0].DataBoundItem);
     }
 }
Пример #2
0
        private bool CanChangeCurrentRestrictedCasePrefix()
        {
            bool rtnValue = true;

            if (bindingRestrictedCasePrefixes.Current != null)
            {
                RestrictedCasePrefix restrictedcaseprefix = (RestrictedCasePrefix)bindingRestrictedCasePrefixes.Current;

                switch (restrictedcaseprefix.MyState)
                {
                case MyObjectState.New:
                case MyObjectState.Modified:

                    switch (MyMessageBox.Show(this, "Restricted Case Prefixes", MyDisplayMessage.SaveConfirm))
                    {
                    case DialogResult.Yes:
                        dgvRestrictedCasePrefixes.EndEdit();
                        bindingRestrictedCasePrefixes.EndEdit();
                        try
                        {
                            restrictedcaseprefix.Save(true);
                            bindingRestrictedCasePrefixes.ResetCurrentItem();
                            rtnValue = true;
                        }
                        catch (MyException ex)
                        {
                            MyMessageBox.Show(this, "Restricted Case Prefixes", MyDisplayMessage.SaveError, ex);
                            rtnValue = false;
                        }
                        break;

                    case DialogResult.No:
                        if (restrictedcaseprefix.MyState == MyObjectState.New)
                        {
                            bindingRestrictedCasePrefixes.RemoveCurrent();
                            bindingRestrictedCasePrefixes.ResetBindings(false);
                        }
                        else
                        {
                            restrictedcaseprefix.Reset();
                        }
                        rtnValue = true;
                        break;

                    case DialogResult.Cancel:
                        rtnValue = false;
                        break;
                    }
                    break;
                }
            }

            return(rtnValue);
        }
Пример #3
0
 private void dgvRestrictedCasePrefixes_Sorted(object sender, EventArgs e)
 {
     if (_RestrictedCasePrefixTemp != null)
     {
         int row = bindingRestrictedCasePrefixes.IndexOf(_RestrictedCasePrefixTemp);
         dgvRestrictedCasePrefixes.BeginInvoke((MethodInvoker) delegate()
         {
             dgvRestrictedCasePrefixes.Rows[row].Selected = true;
             dgvRestrictedCasePrefixes.CurrentCell        = dgvRestrictedCasePrefixes[0, row];
         });
     }
     _RestrictedCasePrefixTemp = null;
     _GridViewState            = GridViewState.None;
 }
Пример #4
0
 private void ResetDataGridViewRestrictedCasePrefixes(RestrictedCasePrefix restrictedcaseprefix)
 {
     if (restrictedcaseprefix != null)
     {
         int row = bindingRestrictedCasePrefixes.IndexOf(restrictedcaseprefix);
         if (row >= 0)
         {
             dgvRestrictedCasePrefixes.BeginInvoke((MethodInvoker) delegate()
             {
                 dgvRestrictedCasePrefixes.Rows[row].Selected = true;
                 dgvRestrictedCasePrefixes.CurrentCell        = dgvRestrictedCasePrefixes[0, row];
             });
         }
     }
 }
        public static RestrictedCasePrefix CreateCasePrefix(SqlDataReader dr)
        {
            RestrictedCasePrefix prefix = new RestrictedCasePrefix();

            if (!dr.IsClosed && dr.HasRows)
            {
                // getting id that uniquely identifies the object
                int      id          = Convert.ToInt32(dr["prefixid"]);
                string   updatedby   = dr["updatedby"].ToString();
                DateTime?updateddate = Convert.ToDateTime(dr["updateddate"]);

                prefix = new RestrictedCasePrefix(id, updatedby, updateddate);

                prefix.RaiseChangedEvents = false;

                prefix.CasePrefix = dr["prefix"].ToString();
                prefix.Save(false);

                prefix.RaiseChangedEvents = true;
            }

            return(prefix);
        }
Пример #6
0
        private void mnuRestrictedCasePrefixes_Click(object sender, EventArgs e)
        {
            RestrictedCasePrefix restrictedcaseprefix = (RestrictedCasePrefix)bindingRestrictedCasePrefixes.Current;

            /********************************************************************************
            *   New
            ********************************************************************************/
            if (sender.Equals(mnuRestrictedCasePrefixesNew))
            {
                if (CanChangeCurrentRestrictedCasePrefix())
                {
                    _GridViewState = GridViewState.Adding;
                    bindingRestrictedCasePrefixes.AddNew();
                    _GridViewState = GridViewState.None;
                }
            }

            /********************************************************************************
            *   Remove
            ********************************************************************************/
            else if (sender.Equals(mnuRestrictedCasePrefixesRemove))
            {
                if (DialogResult.OK == MyMessageBox.Show(this, "Restricted Case Prefixes", MyDisplayMessage.RemoveConfirm))
                {
                    try
                    {
                        bindingRestrictedCasePrefixes.RemoveCurrent();
                        bindingRestrictedCasePrefixes.ResetBindings(false);
                    }
                    catch (MyException ex)
                    {
                        MyMessageBox.Show(this, "Restricted Case Prefixes", MyDisplayMessage.RemoveError, ex);
                    }
                }
            }

            /********************************************************************************
            *   Refresh
            ********************************************************************************/
            else if (sender.Equals(mnuRestrictedCasePrefixesRefresh))
            {
                if (!restrictedcaseprefix.MyState.Equals(MyObjectState.Current))
                {
                    if (DialogResult.Cancel == MyMessageBox.Show(this, "Restricted Case Prefixes", MyDisplayMessage.RefreshConfirm))
                    {
                        return;
                    }
                }

                try
                {
                    restrictedcaseprefix.Refresh();
                    bindingRestrictedCasePrefixes.ResetBindings(false);
                }
                catch (MyException ex)
                {
                    MyMessageBox.Show(this, "Restricted Case Prefixes", MyDisplayMessage.RefreshError, ex);
                }
            }

            /********************************************************************************
            *   Save
            ********************************************************************************/
            else if (sender.Equals(mnuRestrictedCasePrefixesSave))
            {
                dgvRestrictedCasePrefixes.EndEdit();
                bindingRestrictedCasePrefixes.EndEdit();
                try
                {
                    restrictedcaseprefix.Save(true);
                    bindingRestrictedCasePrefixes.ResetBindings(false);


                    bindingRestrictedCasePrefixes.Sort = "";
                    if (dgvRestrictedCasePrefixes.SortOrder == SortOrder.Descending)
                    {
                        bindingRestrictedCasePrefixes.Sort = dgvRestrictedCasePrefixes.SortedColumn.DataPropertyName + " DESC";
                    }
                    else
                    {
                        bindingRestrictedCasePrefixes.Sort = dgvRestrictedCasePrefixes.SortedColumn.DataPropertyName + " ASC";
                    }

                    ResetDataGridViewRestrictedCasePrefixes(restrictedcaseprefix);
                }
                catch (MyException ex)
                {
                    MyMessageBox.Show(this, "Restricted Case Prefixes", MyDisplayMessage.SaveError, ex);
                }
            }

            /********************************************************************************
            *   Cancel
            ********************************************************************************/
            else if (sender.Equals(mnuRestrictedCasePrefixesCancel))
            {
                if (restrictedcaseprefix.MyState == MyObjectState.New)
                {
                    bindingRestrictedCasePrefixes.RemoveCurrent();
                }
                else
                {
                    restrictedcaseprefix.Reset();
                    bindingRestrictedCasePrefixes.ResetCurrentItem();
                }
            }
        }