Пример #1
0
        public string BuildInsertSQL(PanelContext data, System.Data.IDataParameterCollection parameters)
        {
            StringBuilder fieldlist = new StringBuilder();
            StringBuilder paramlist = new StringBuilder();

            foreach (DataField field in data.Row)
            {
                string paramname = String.Format("@{0}", field.Column.Name);
                fieldlist.AppendFormat("[{0}],", field.Column.Name);
                paramlist.Append(paramname).Append(",");
                if (field.Column.DataType == TypeCode.DateTime)
                {
                    MySqlParameter param = new MySqlParameter(field.Column.Name, MySqlDbType.Datetime);
                    param.Value = field.Value;
                    parameters.Add(param);
                }
                else
                {
                    parameters.Add(new MySqlParameter(paramname, field.Value));
                }
            }
            Utils.TrimEndStringBuilder(fieldlist, ",");
            Utils.TrimEndStringBuilder(paramlist, ",");
            return(String.Format(SQLINSERT, data.Table.Name, fieldlist, paramlist));
        }
Пример #2
0
        public string BuildGetSQL(PanelContext data, System.Data.IDataParameterCollection parameters)
        {
            StringBuilder sqlwehre = BuilderWhereSqlByDataKey(data, parameters, "");
            string        sql      = String.Format(SQLLIST, data.Table.Name, sqlwehre, data.Panel.Context.Orders);

            return(sql);
        }
Пример #3
0
        public string BuildListSQL(PanelContext data, System.Data.IDataParameterCollection parameters, int startindex, int itemcount)
        {
            StringBuilder sqlwehre = BuildWhereSql(data, parameters);

            string sql = "";

            if (startindex > 0)
            {
                string revorders = regex.Replace(data.Orders, delegate(Match m)
                {
                    if (String.Compare(m.Value, "desc", true) == 0)
                    {
                        return("ASC");
                    }
                    else
                    {
                        return("DESC");
                    }
                });
                int firstcount = itemcount + startindex;
                sql = String.Format(SQLPAGELIST, firstcount, data.Table.Name, sqlwehre, data.Orders, itemcount, revorders, data.Orders);
            }
            else if (itemcount > 0)
            {
                sql = String.Format(SQLTOPLIST, itemcount, data.Table.Name, sqlwehre, data.Orders);
            }
            else
            {
                sql = String.Format(SQLLIST, data.Table.Name, sqlwehre, data.Orders);
            }
            return(sql);
        }
Пример #4
0
        public string BuildUpdateSQL(PanelContext data, System.Data.IDataParameterCollection parameters)
        {
            StringBuilder sqlupdatefield = new StringBuilder();

            foreach (DataField field in data.Row)
            {
                sqlupdatefield.AppendFormat("{0}=@{0},", field.Column.Name);
                if (field.Column.DataType == TypeCode.DateTime)
                {
                    MySqlParameter param = new MySqlParameter(field.Column.Name, MySqlDbType.Datetime);
                    param.Value = field.Value;
                    parameters.Add(param);
                }
                else
                {
                    parameters.Add(new MySqlParameter(field.Column.Name, field.Value));
                }
            }
            Utils.TrimEndStringBuilder(sqlupdatefield, ",");
            StringBuilder sqlwhere = BuilderWhereSqlByDataKey(data, parameters, "old");

            return(String.Format(SQLUPDATE, data.Table.Name, sqlupdatefield, sqlwhere));
        }
Пример #5
0
        public string BuildDeleteSQL(PanelContext data, System.Data.IDataParameterCollection parameters)
        {
            StringBuilder sqlwhere = BuilderWhereSqlByDataKey(data, parameters, "");

            return(String.Format(SQLDELETE, data.Table.Name, sqlwhere));
        }
Пример #6
0
        public string BuildCountSQL(PanelContext data, System.Data.IDataParameterCollection parameters)
        {
            StringBuilder sqlwehre = BuildWhereSql(data, parameters);

            return(String.Format(SQLCOUNT, data.Table.Name, sqlwehre));
        }
Пример #7
0
 protected internal ParameterCollectionWrapper(System.Data.IDataParameterCollection paramCollection)
     : base(paramCollection)
 {
 }