Beispiel #1
0
        /// <summary>
        /// Pega o comando de atualização
        /// </summary>
        /// <returns>Um DbCOmmand</returns>
        protected Tuple <string, List <TableAdapterField> > GetUpdateCommand()
        {
            var fields = new StringBuilder();

            foreach (var column in Collumns.Where(p => !p.Key))
            {
                fields.Append(fields.Length > 0 ? "   , " : "     ");

                fields.AppendLine("" + SetQuote(column.Name) + " = @" + column.Name + "");
            }

            if (fields.Length == 0)
            {
                return(null);
            }

            var query = new StringBuilder();

            query.AppendLine(" Update " + MakeFullTableName(DBName, TableName) + " SET  ");
            query.AppendLine(fields.ToString());
            query.AppendLine("  ");
            query.AppendLine(GetWhereCommand());

            return(new Tuple <string, List <TableAdapterField> >(
                       query.ToString(),
                       GetParameters(Collumns)
                       ));
        }
 private void lvColumns_ItemChecked(object sender, ItemCheckedEventArgs e)
 {
     if (!IsBeforeShow)
     {
         Collumns col = ((Collumns)e.Item.Tag);
         //BrowserControl.SetColInView(col, !e.Item.Checked);
     }
 }
Beispiel #3
0
        private void AddUomEntryIfNeeded()
        {
            if (!SboVersion.EqualOrMoreThenSap9Pl4())
            {
                return;
            }

            Collumns.Add(new TableAdapterField(FieldsName.UomEntry, Description.UomEntry, DbType.Int32));
            Collumns.Add(new TableAdapterField(FieldsName.UomCode, Description.UomCode, 10));
        }
Beispiel #4
0
        /// <summary>
        /// PReenche as colunms da atbela de acordo com as Campos TableAdapterFields
        /// Instanciano na classe base
        /// </summary>
        private void FillCollumns()
        {
            Collumns = TableAdapterColumns.GetCollumns(this);

            foreach (var item in Collumns.Where(c => c.Key))
            {
                KeyFields.Add(item);
            }

            StateRecord = eState.eAdd;
        }
Beispiel #5
0
        /// <summary>
        /// Pega o camando delete
        /// </summary>
        /// <returns>Um DbComando com o camando para excluir</returns>
        protected Tuple <string, List <TableAdapterField> > GetDeleteCommand()
        {
            var columns = Collumns.Where(p => p.Key).ToList();

            var query = new StringBuilder();

            query.AppendLine(" DELETE FROM " + MakeFullTableName(DBName, TableName) + " ");
            query.AppendLine(GetWhereCommand());

            return(new Tuple <string, List <TableAdapterField> >(
                       query.ToString(),
                       GetParameters(columns)));
        }
        private void SetCollumns()
        {
            if (Collumns.Count == 0)
            {
                Collumns.AddRange(TableQuery.Fields);
            }

            foreach (TableAdapterField item in Collumns)
            {
                ViewResult.Columns.AddVisible(
                    String.IsNullOrEmpty(item.Alias) ? item.Name : item.Alias,
                    item.Description);
            }
        }
        private Dictionary <int, PropertyInfo> CreateDictionary()
        {
            var result = new Dictionary <int, PropertyInfo>();

            PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public);
            foreach (var prop in properties)
            {
                string invariant = prop.Name.ToLowerInvariant();

                int index = Collumns.IndexOfOrDefault(invariant);

                if (index != -1)
                {
                    result[index] = prop;
                }
            }
            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// Pega o comando de inserção
        /// </summary>
        /// <returns>Um Db command preenchiodo</returns>
        protected Tuple <string, List <TableAdapterField> > GetInsertCommand()
        {
            var fields = new StringBuilder();
            var values = new StringBuilder();

            var columns = Collumns.Where(p => !p.Identity && p.Value != null).ToList();

            foreach (var column in columns)
            {
                if (fields.Length > 0)
                {
                    fields.Append("   , ");
                    values.Append("   , ");
                }
                else
                {
                    fields.Append("     ");
                    values.Append("     ");
                }

                fields.AppendLine(SetQuote(column.Name));
                values.AppendFormat("@{0}", column.Name);
            }

            if (fields.Length == 0)
            {
                throw new Exception(string.Format("Não há campos definidos para o objeto [{0}]", this));
            }

            var query = new StringBuilder();

            query.AppendLine(" INSERT INTO  " + MakeFullTableName(DBName, TableName) + " ( ");
            query.AppendLine(fields.ToString());
            query.AppendLine(") VALUES (");
            query.AppendLine(values.ToString());
            query.AppendLine(") ");

            var parameters = GetParameters(columns);

            return(new Tuple <string, List <TableAdapterField> >(
                       query.ToString(),
                       parameters));
        }
Beispiel #9
0
 /// <summary>
 /// Pega um campo pelo nome ou retorna null
 /// </summary>
 /// <param name="pFieldName">Nome do campo</param>
 /// <returns>Um TableAdapterField</returns>
 public TableAdapterField GetTableField(string pFieldName)
 {
     return(Collumns.FirstOrDefault(p => p.Name == pFieldName));
 }