public string GetNextCode()
 {
     return(CrudController.GetNextCode(tableName));
 }
 public string GetNextCode(string fieldName)
 {
     return(CrudController.GetNextCode(fieldName, tableName));
 }
 public SAPObjectBaseController(string tableName)
 {
     crudController = new CrudController(tableName);
     this.tableName = tableName;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Salva o model no BD de acordo com o tipo da operação
        /// </summary>
        /// <param name="enumCrudOperation">Operação - Create ou Update</param>
        /// <param name="tableName">Nome da tabela</param>
        /// <param name="model">Modelo</param>
        private void SaveNonObjectModel(EnumCrudOperation enumCrudOperation)
        {
            UserTable utbUser       = SBOApp.Company.UserTables.Item(TableName.Replace("@", ""));
            string    code          = Model.GetType().GetProperty("Code").GetValue(Model, null).ToString();
            bool      alreadyExists = utbUser.GetByKey(code);

            if (!String.IsNullOrEmpty(code))
            {
                utbUser.Code = code;
            }
            else
            {
                utbUser.Code = CrudController.GetNextCode(TableName);
            }

            utbUser.Name = utbUser.Code;

            ModelControllerAttribute modelController;

            // Percorre as propriedades do Model
            foreach (PropertyInfo property in Model.GetType().GetProperties())
            {
                if (property.Name == "Code" || property.Name == "Name")
                {
                    continue;
                }

                // Busca os Custom Attributes
                foreach (Attribute attribute in property.GetCustomAttributes(true))
                {
                    modelController = attribute as ModelControllerAttribute;

                    if (modelController != null)
                    {
                        // Se não for DataBaseField não seta nas properties
                        if (!modelController.DataBaseFieldYN)
                        {
                            break;
                        }
                        if (String.IsNullOrEmpty(modelController.ColumnName))
                        {
                            modelController.ColumnName = property.Name;
                        }
                        utbUser.UserFields.Fields.Item(modelController.ColumnName).Value = property.GetValue(Model, null);
                    }
                    break;
                }
            }
            switch (enumCrudOperation)
            {
            case EnumCrudOperation.Create:
                utbUser.Add();
                break;

            case EnumCrudOperation.Update:
                utbUser.Update();
                break;

            default:
                break;
            }

            Marshal.ReleaseComObject(utbUser);
            utbUser = null;
            GC.Collect();
        }
Exemplo n.º 5
0
 public BaseChildController(string parentTable, string tableName)
 {
     CrudController      = new CrudController(tableName);
     CrudChildController = new CrudChildController(parentTable, tableName);
     this.tableName      = tableName;
 }
 public BaseController(string tableName, BoUTBTableType userTableType)
 {
     crudController = new CrudController(tableName);
     this.tableName = tableName;
 }
 public string GetNextCode(string fieldName, string where)
 {
     return(CrudController.GetNextCode(tableName, fieldName, where));
 }