public override async void DeleteAction()
 {
     try
     {
         if (Model.IsValid)
         {
             Model.UpdatedBy = EasyApp.Current.User.Login;
             CONSQLParameter data = ((CONSQLParameter)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, Actions.Remove, Options.Me, EasyApp.Current.DefaultDatabaseSettingName, ""));
             if (data != null)
             {
                 Model.Details.Remove(data);
             }
             PostDeleteAction("");
             MessageBoxResult result = MessageBox.Show("Registro eliminado correctamente", "Eliminando", MessageBoxButton.OK, MessageBoxImage.Question);
             OnNewCommand(new object());
         }
         else
         {
             MessageBox.Show("Hay validaciones pendientes por favor verifique.", "Información", MessageBoxButton.OK, MessageBoxImage.Information);
             PostDeleteAction("Hay validaciones pendientes por favor verifique.");
         }
     }
     catch (FaultException ex)
     {
         MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK);
         PostDeleteAction(new BusinessException(ex).GetExceptionMessage());
     }
     catch (Exception ex)
     {
         MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK);
         PostDeleteAction(new BusinessException(ex).GetExceptionMessage());
     }
 }
Exemple #2
0
        public override String GetQuery(CONSQLParameter data, Boolean byId)
        {
            String dml = base.GetQuery(data, byId);

            if (byId)
            {
                //add more parameters to method for query by id
            }
            else
            {
                //Determine if the boolean values ​​are taken included as part of the consultation
                //dml += "             AND a.IsDate = :IsDate \n" ;
                //dml += "             AND a.IsInt = :IsInt \n" ;
                //dml += "             AND a.IsString = :IsString \n" ;

                //add more parameters to method for query by any field

                if (data.SQL != null && data.SQL.Id != 0)
                {
                    dml += "             AND a.SQL.Id = :SQL \n";
                }

                dml += " order by a.Id asc ";
            }
            return(dml);
        }
Exemple #3
0
 public override CONSQLParameter Execute(CONSQLParameter data, Actions action, Options option, string token)
 {
     try
     {
         if (action == Actions.Add || action == Actions.Modify || action == Actions.Remove || (action == Actions.Find && (option == Options.Me || option == Options.Exist)))
         {
             if ((action == Actions.Add || action == Actions.Modify) && option == Options.All)
             {
                 BenginTransaction();
             }
             data = base.Execute(data, action, option, token);
             if (action == Actions.Find && option == Options.Me)
             {
             }
             if ((action == Actions.Add || action == Actions.Modify) && option == Options.All)
             {
                 AddDetails(data);
             }
             //if (option == Options.All)
             //    Work.Commit();
             return(data);
         }
         else if (action == Actions.Find && (option == Options.All || option == Options.Light))
         {
             if (option == Options.All)
             {
                 data.Entities = FindAll(data, Options.All);
             }
             else if (option == Options.Light)
             {
                 data.Entities = FindAll(data, Options.Light);
             }
             return(data);
         }
         else if (action == Actions.Process && (option == Options.All || option == Options.Light))
         {
             data.Entities = GenerateSettings(data);
             return(data);
         }
         else
         {
             throw new NotImplementedException(GetLocalizedMessage(Language.DLACTIONNOTIMPLEMENT, action.ToString(), option.ToString()));
         }
     }
     catch (FaultException <BusinessException> f)
     {
         Rollback();
         throw f;
     }
     catch (Exception e)
     {
         Rollback();
         throw new BusinessException(e).GetFaultException();
     }
     finally
     {
         Commit();
     }
 }
Exemple #4
0
 public List <CONSQLParameter> GenerateSettings(CONSQLParameter data)
 {
     try
     {
         CONSQLBLL daoSQL = new CONSQLBLL(Work.Settings);
         //CONSQLParameterBLL daoParam = daoParam = new CONSQLParameterBLL(Work.Settings); ;
         CONSQL sql = daoSQL.Execute(new CONSQL {
             Id = data.SQL.Id
         }, Actions.Find, Options.Me, "");
         //if (sql.SQLParameters != null && sql.SQLParameters.Count > 0)
         //{
         //    foreach (CONSQLParameter item in sql.SQLParameters)
         //    {
         //        daoParam.Execute(item, Actions.Remove, Options.All, "");
         //    }
         //}
         List <CONSQLParameter> parameters = new List <CONSQLParameter>();
         parameters = GetParameters(sql.SQLSentence);
         if (!String.IsNullOrWhiteSpace(sql.ExecuteStoreProcedure))
         {
             parameters.AddRange(GetParameters(sql.ExecuteStoreProcedure));
         }
         foreach (CONSQL item in sql.ChildSQLs)
         {
             List <CONSQLParameter> parameterChilds = GetParameters(item.SQLSentence);
             if (!String.IsNullOrWhiteSpace(item.ExecuteStoreProcedure))
             {
                 parameterChilds.AddRange(GetParameters(sql.ExecuteStoreProcedure));
             }
             foreach (CONSQLParameter sparam in parameterChilds)
             {
                 if (parameters.Count(t => t.Name.ToUpper() == sparam.Name.ToUpper()) <= 0)
                 {
                     parameters.Add(sparam);
                 }
             }
         }
         return(parameters);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         //daoSQL.Work.Commit();
     }
 }
 public override async void SaveAction(bool createNew)
 {
     try
     {
         if (Model.IsValid)
         {
             Model.UpdatedBy = EasyApp.Current.User.Login;
             CONSQLParameter data = ((CONSQLParameter)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, (Model.Id == 0 ? Actions.Add : Actions.Modify), Options.Me, EasyApp.Current.DefaultDatabaseSettingName, ""));
             if (data != null)
             {
                 if (Model.Details.IndexOf(data) != -1)
                 {
                     Model.Details[Model.Details.IndexOf(data)] = data;
                 }
                 else
                 {
                     Model.Details.Add(data);
                 }
                 Model.Entity = data;
             }
             PostSaveAction("");
             if (createNew)
             {
                 MessageBoxResult result = MessageBox.Show("Registro guardado correctamente, desea crear un nuevo registro", "Nuevo Registro", MessageBoxButton.YesNo, MessageBoxImage.Question);
                 if (result == MessageBoxResult.Yes)
                 {
                     OnNewCommand(new object());
                 }
             }
         }
         else
         {
             MessageBox.Show("Hay validaciones pendientes por favor verifique.", "Información", MessageBoxButton.OK, MessageBoxImage.Information);
             PostSaveAction("Hay validaciones pendientes por favor verifique.");
         }
     }
     catch (FaultException ex)
     {
         MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK);
         PostSaveAction(new BusinessException(ex).GetExceptionMessage());
     }
     catch (Exception ex)
     {
         MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK);
         PostSaveAction(new BusinessException(ex).GetExceptionMessage());
     }
 }
 public override async void FindAction()
 {
     try
     {
         CONSQLParameter data = ((CONSQLParameter)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, Actions.Find, Options.All, EasyApp.Current.DefaultDatabaseSettingName, ""));
         //Model.Details = data.Entities;
         PostFindAction("CONSQLParameters", Model.Details.Count, "");
     }
     catch (FaultException ex)
     {
         MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK);
         FormIsBusy = false;
         PostFindAction("", 0, new BusinessException(ex).GetExceptionMessage());
     }
     catch (Exception ex)
     {
         MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK);
         FormIsBusy = false;
         PostFindAction("", 0, new BusinessException(ex).GetExceptionMessage());
     }
 }
Exemple #7
0
        public override void SetQueryParameters(IQuery query, CONSQLParameter data, Boolean byId)
        {
            base.SetQueryParameters(query, data, byId);
            if (byId)
            {
                //add more parameters to method for query by id
            }
            else
            {
                //Determine if the boolean values ​​are taken included as part of the consultation
                //query.SetBoolean("IsDate",  data.IsDate);
                //query.SetBoolean("IsInt",  data.IsInt);
                //query.SetBoolean("IsString",  data.IsString);

                //add more parameters to method for query by any field

                if (data.SQL != null && data.SQL.Id != 0)
                {
                    query.SetInt32("SQL", data.SQL.Id);
                }
            }
        }
Exemple #8
0
 public override List <CONSQLParameter> FindAll(CONSQLParameter data, Options option)
 {
     return(base.FindAll(data, option));
 }
Exemple #9
0
 public override CONSQLParameter FindById(CONSQLParameter data)
 {
     return(base.FindById(data));
 }
Exemple #10
0
 public override void AddMoreDetailFindById(CONSQLParameter data)
 {
 }
Exemple #11
0
 public override void SaveOrUpdateDetails(CONSQLParameter data)
 {
     base.SaveOrUpdateDetails(data);
 }
Exemple #12
0
 public override void AddRules(CONSQLParameter data)
 {
     base.AddRules(data);
     data.LastUpdate = DateTime.Now;
 }
Exemple #13
0
 public override void CommonRules(CONSQLParameter data)
 {
     base.CommonRules(data);
 }
Exemple #14
0
 public void AddDetails(CONSQLParameter data)
 {
 }
Exemple #15
0
 public override void FindByIdRules(CONSQLParameter data)
 {
     base.FindByIdRules(data);
 }
Exemple #16
0
 public override void RemoveRules(CONSQLParameter data)
 {
     base.RemoveRules(data);
 }