Exemplo n.º 1
0
        public override void Delete()
        {
            LongTimeAbsence absence = FocusedEntity;

            if (absence != null)
            {
                if (QuestionMessageYes(GetLocalized("QuestionDeleteLongTimeAbsence")))
                {
                    try
                    {
                        ClientEnvironment.LongTimeAbsenceService.DeleteByID(absence.ID);
                        m_absenceList.RemoveEntityById(absence.ID);
                    }
                    catch (ValidationException)
                    {
                        ErrorMessage(GetLocalized("CantDeleteLongTimeAbsence"));
                        return;
                    }
                    catch (EntityException ex)
                    {
                        ProcessEntityException(ex);
                        return;
                    }
                }
                UpdateButtonState();
            }
        }
Exemplo n.º 2
0
        public LongTimeAbsence GetById(long id)
        {
            LongTimeAbsence absence = null;

            _diction.TryGetValue(id, out absence);
            return(absence);
        }
Exemplo n.º 3
0
        private void UpdateButtonState()
        {
            LongTimeAbsence absence = FocusedEntity;

            bi_EditLongTimeAbsence.Enabled   = absence != null;
            bi_DeleteLongTimeAbsence.Enabled = absence != null;
        }
Exemplo n.º 4
0
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            LongTimeAbsence absence = FocusedEntity;

            mi_EditLongtimeAbsence.Enabled   = absence != null;;
            mi_DeleteLongtimeAbsence.Enabled = absence != null;;
        }
Exemplo n.º 5
0
        public override bool Commit()
        {
            if (IsModified() && IsValid())
            {
                LongTimeAbsence copyAbsence = new LongTimeAbsence();

                CopyAbsence(EntityAbsence, copyAbsence);

                copyAbsence.CodeName = AbsenceName;

//                if (copyAbsence.IsNew)
//                    copyAbsence = ClientEnvironment.LongTimeAbsenceService.Save(copyAbsence);
//                else
                try
                {
                    copyAbsence = ClientEnvironment.LongTimeAbsenceService.SaveOrUpdate(copyAbsence);

                    CopyAbsence(copyAbsence, EntityAbsence);
                    Modified = true;
                    return(base.Commit());
                }
                catch (DBDuplicateKeyException)
                {
                    ErrorMessage(GetLocalized("LongTimeAbsenceNameExists"));
                    teAbsenceName.Focus();
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        LongTimeAbsence GetEntityByRowHandle(int rowHandle)
        {
            LongTimeAbsence absence = null;

            if (gridViewEntities.IsDataRow(rowHandle))
            {
                absence = (LongTimeAbsence)gridViewEntities.GetRow(rowHandle);
            }
            return(absence);
        }
Exemplo n.º 7
0
        public string GetLongTimeAbbreviation(long id)
        {
            LongTimeAbsence absence = LongAbsences.GetById(id);;
            string          result  = String.Empty;

            if (absence != null)
            {
                result = (absence.CharID != null) ? absence.CharID : String.Empty;
            }
            return(result);
        }
Exemplo n.º 8
0
        private void CopyAbsence(LongTimeAbsence source, LongTimeAbsence dest)
        {
            Debug.Assert(source != null);
            Debug.Assert(dest != null);
            Debug.Assert(!source.Equals(dest));

            dest.ID       = source.ID;
            dest.Code     = source.Code;
            dest.CodeName = source.CodeName;
            dest.Import   = source.Import;
        }
Exemplo n.º 9
0
        public string GetAbbreviation(long id)
        {
            LongTimeAbsence a = GetById(id);
            String          s = String.Empty;

            if (a != null)
            {
                s = a.CharID;
            }

            return(s);
        }
Exemplo n.º 10
0
        public int?GetColor(long id)
        {
            LongTimeAbsence a = GetById(id);
            int?            s = null;

            if (a != null)
            {
                s = a.Color;
            }

            return(s);
        }
Exemplo n.º 11
0
        private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            GridHitInfo info = gridViewEntities.CalcHitInfo(e.X, e.Y);

            if (info.InRowCell && gridViewEntities.IsDataRow(info.RowHandle))
            {
                LongTimeAbsence entity = GetEntityByRowHandle(info.RowHandle);
                if (entity != null)
                {
                    Edit();
                }
            }
        }
Exemplo n.º 12
0
        public override void Add()
        {
            using (FormLongTimeAbsence newAbsenceForm = new FormLongTimeAbsence())
            {
                LongTimeAbsence newAbsence = new LongTimeAbsence();
                newAbsenceForm.Entity = newAbsence;

                if (newAbsenceForm.ShowDialog() == DialogResult.OK)
                {
                    m_absenceList.Add(newAbsence);
                }
                UpdateButtonState();
            }
        }
Exemplo n.º 13
0
        public override void Edit()
        {
            LongTimeAbsence absence = FocusedEntity;

            if (absence != null)
            {
                using (FormLongTimeAbsence newAbsenceForm = new FormLongTimeAbsence())
                {
                    newAbsenceForm.Entity = absence;

                    if (newAbsenceForm.ShowDialog() == DialogResult.OK)
                    {
                        m_absenceList.SetEntity(absence);
                    }
                }
                UpdateButtonState();
            }
        }
Exemplo n.º 14
0
        public override bool Commit()
        {
            if (!IsModified())
            {
                return(base.Commit());
            }
            else
            if (IsValid())
            {
                if (!isChecked && ((AbsenceColor < lightWhite && AbsenceColor > darkWhite) || (AbsenceColor < lightBlack && AbsenceColor > darkBlack)))
                {
                    InfoMessage(GetLocalized("err_enter_absence_colour"));
                    cbLongTimeColor.Focus();
                    isChecked = true;
                    return(false);
                }
                LongTimeAbsence copyAbsence = new LongTimeAbsence();
                LongTimeAbsence.CopyTo(EntityAbsence, copyAbsence);     //CopyAbsence();

                copyAbsence.CodeName = AbsenceName;
                copyAbsence.CharID   = AbsenceAbbreviation;
                copyAbsence.Color    = AbsenceColor;
                try
                {
                    Debug.Assert(copyAbsence.CountryID > 0);

                    copyAbsence = ClientEnvironment.LongTimeAbsenceService.SaveOrUpdate(copyAbsence);

                    LongTimeAbsence.CopyTo(copyAbsence, EntityAbsence);
                    Modified = true;
                    return(base.Commit());
                }
                catch (DBDuplicateKeyException)
                {
                    ErrorMessage(GetLocalized("ErrorLongTimeAbsenceNameExists"));
                    teAbsenceName.Focus();
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }