Beispiel #1
0
        internal static String Save(DB.SYS_Module entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntitySystemContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntitySystemContext.SYS_Module.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
Beispiel #2
0
        private void wcModule_FinishClick(object sender, CancelEventArgs e)
        {
            try
            {
                //DataContext.EntitySystemContext.BeginTransaction();
                //TODO : Add some code that verifies the code before saving to database
                if (true)
                {
                    try
                    {
                        using (TransactionScope transaction = DataContext.GetTransactionScope())
                        {
                            DB.SYS_Module module = BL.SYS.SYS_Module.Load(selectedModule.Id, DataContext);
                            module.Code = txtAccessCode.Text;
                            BL.EntityController.SaveSYS_Module(module, DataContext);
                            DataContext.SaveChangesEntitySystemContext();
                            DataContext.CompleteTransaction(transaction);
                        }
                        DataContext.EntitySystemContext.AcceptAllChanges();
                        Essential.BaseAlert.ShowAlert("Module Active", "You have succesfully activated the selected module, please log out and back in for changes to take effect.", Essential.BaseAlert.Buttons.Ok, Essential.BaseAlert.Icons.Information);
                    }
                    catch (Exception ex)
                    {
                        DataContext.EntitySystemContext.RejectChanges();
                        //HasErrors = true;
                        if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                        {
                            throw ex;
                        }
                    }
                }
                else
                {
                    Essential.BaseAlert.ShowAlert("Module Activation", "Unfortunately you code could not be verified please check the code you entered or contact our support team.", Essential.BaseAlert.Buttons.Ok, Essential.BaseAlert.Icons.Error);
                }

                this.Close();
            }
            catch (Exception ex)
            {
                //DataContext.EntitySystemContext.RollBackTransaction();
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
        }
Beispiel #3
0
        private void btnDeActivate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var row = (((DevExpress.Data.Async.Helpers.ReadonlyThreadSafeProxyForObjectFromAnotherThread)(GridView.GetFocusedRow())).OriginalRow as CDS.Client.DataAccessLayer.DB.VW_Module);

            if (row == null)
            {
                return;
            }

            if (row.Access.Value)
            {
                if (Essential.BaseAlert.ShowAlert("De-Activate Module", String.Format("You are about to De-Active the selected module {0} - {1}.\nDo you want to continue ?", row.Module, row.Description), Essential.BaseAlert.Buttons.OkCancel, Essential.BaseAlert.Icons.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        using (TransactionScope transaction = DataContext.GetTransactionScope())
                        {
                            DB.SYS_Module module = BL.SYS.SYS_Module.Deactivate(row.Id, DataContext);
                            BL.EntityController.SaveSYS_Module(module, DataContext);
                            DataContext.SaveChangesEntitySystemContext();
                            DataContext.CompleteTransaction(transaction);
                        }
                        DataContext.EntitySystemContext.AcceptAllChanges();
                    }
                    catch (Exception ex)
                    {
                        DataContext.EntitySystemContext.RejectChanges();
                        //HasErrors = true;
                        if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                        {
                            throw ex;
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public static DB.SYS_Module Deactivate(Int32 id, DataContext dataContext)
 {
     DB.SYS_Module module = Load(id, dataContext);
     module.Code = String.Empty;
     return(module);
 }
Beispiel #5
0
 public static DB.SYS_Module GetPreviousItem(DB.SYS_Module SYS_Module, DataContext dataContext)
 {
     return(dataContext.EntitySystemContext.SYS_Module.OrderByDescending(o => o.Id).FirstOrDefault(n => n.Id < SYS_Module.Id));
 }
Beispiel #6
0
 public static DB.SYS_Module GetNextItem(DB.SYS_Module SYS_Module, DataContext dataContext)
 {
     return(dataContext.EntitySystemContext.SYS_Module.OrderBy(o => o.Id).FirstOrDefault(n => n.Id > SYS_Module.Id));
 }