Beispiel #1
0
        public static string CreateDeleteCommand(IDBConnectionStateGettable actualPage, string primaryKey, string nameOfPrimaryKey)
        {
            string commandToReturn = "DELETE FROM ";

            commandToReturn += actualPage.GetTableDescriptionToSql();
            commandToReturn += " WHERE " + nameOfPrimaryKey + " = '" + primaryKey + "'";
            return(commandToReturn);
        }
Beispiel #2
0
        public static string CreateCommand(IDBConnectionStateGettable actualPage, string searchIn,
                                           string searchedExpression, string sortBy = null, SortCriteria sortCriterium = SortCriteria.Ascending)
        {
            string commandToReturn = CreateCommand(actualPage);

            commandToReturn = AddWhereToCommandAndSort(commandToReturn, searchIn, searchedExpression, sortBy, sortCriterium);
            return(commandToReturn);
        }
Beispiel #3
0
        public static string CreateUpdateCommand(IDBConnectionStateGettable actualPage, string primaryKey, string nameOfPrimaryKey,
                                                 List <string> fieldsToUpdate, List <string> valueToSet)
        {
            string commandToReturn = "UPDATE " + actualPage.GetTableDescriptionToSql() + " SET " +
                                     fieldsToUpdate[0] + "='" + valueToSet[0] + "' WHERE " + nameOfPrimaryKey + " = '" + primaryKey + "'";

            if (commandToReturn.Contains(@"'NULL'"))
            {
                commandToReturn = commandToReturn.Replace(@"'NULL'", "NULL");
            }
            return(commandToReturn);
        }
Beispiel #4
0
        //Dziala!
        /// <summary>
        /// Creates a command string which show actual table and sort it.
        /// </summary>
        /// <param name="actualPage">Actual view</param>
        /// <param name="orderBy">order by (optional)</param>
        /// <param name="sortCriterium"></param>
        /// <returns></returns>
        public static string CreateCommand(IDBConnectionStateGettable actualPage, string orderBy = null,
                                           SortCriteria sortCriterium = SortCriteria.Ascending)
        {
            string actualTableSqlDescription = actualPage.GetTableDescriptionToSql();

            string commandToReturn = "SELECT * FROM ";

            commandToReturn += actualTableSqlDescription;
            if (!string.IsNullOrEmpty(orderBy))
            {
                commandToReturn = CreateCommand(commandToReturn, orderBy, sortCriterium);
            }
            return(commandToReturn);
        }
Beispiel #5
0
        public static string CreateNewRecordCommand(IDBConnectionStateGettable actualPage, List <string> valuesList, List <string> columnNames)
        {
            string commandToReturn = "INSERT INTO " + actualPage.GetTableDescriptionToSql() + " (";
            string lastColumn      = columnNames.Last();
            string lastValue       = valuesList.Last();

            foreach (string column in columnNames)
            {
                commandToReturn += column;
                if (column == lastColumn)
                {
                    commandToReturn += ") VALUES (";
                }
                else
                {
                    commandToReturn += ", ";
                }
            }
            foreach (object value in valuesList)
            {
                if (value.ToString() == "NULL")
                {
                    commandToReturn += value;
                }
                else
                {
                    commandToReturn += "'" + value + "'";
                }

                if (value.ToString() == lastValue)
                {
                    commandToReturn += ")";
                }
                else
                {
                    commandToReturn += ", ";
                }
            }
            return(commandToReturn);
        }
Beispiel #6
0
 public static string ResetCommand(IDBConnectionStateGettable actualTable)
 {
     return(CreateCommand(actualTable));
 }