示例#1
0
        private static string Save(DomainModel.UserPreferenceKey data, int auditId, string sqlcmd)
        {
            var sql = "EXEC ";

            switch (sqlcmd)
            {
            case "Create":
                sql += "dbo.UserPreferenceKeyInsert  " +
                       " " + ToSQLParameter(BaseModel.BaseDataColumns.AuditId, auditId) +
                       ", " + ToSQLParameter(BaseModel.BaseDataColumns.ApplicationId, ApplicationId);
                break;

            case "Update":
                sql += "dbo.UserPreferenceKeyUpdate  " +
                       " " + ToSQLParameter(BaseModel.BaseDataColumns.AuditId, auditId);
                break;

            default:
                break;
            }

            sql = sql + ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.UserPreferenceKeyId) +
                  ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.Name) +
                  ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.Value) +
                  ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.DataTypeId) +
                  ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.Description) +
                  ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.SortOrder);
            return(sql);
        }
示例#2
0
        public static int?GetUserTimeZone(int applicationUserId, int auditId)
        {
            var dataKey = new DomainModel.UserPreferenceKey();

            dataKey.Name = "UserTimeZone";

            var dtKeys = UserPreferenceKey.Search(dataKey, auditId);

            if (dtKeys != null && dtKeys.Rows.Count > 0)
            {
                var keyId = Convert.ToInt32(dtKeys.Rows[0][DomainModel.UserPreferenceKey.DataColumns.UserPreferenceKeyId]);

                var data = new Data();
                data.ApplicationUserId   = SetupConfiguration.ApplicationId;
                data.UserPreferenceKeyId = keyId;

                var dt = Search(data, auditId);

                if (dt.Rows.Count > 0)
                {
                    return(Convert.ToInt32(dt.Rows[0][DomainModel.UserPreferenceKey.DataColumns.Value]));
                }
            }

            return(null);
        }
示例#3
0
        public static List <DomainModel.UserPreferenceKey> GetEntityDetails(DomainModel.UserPreferenceKey data, int auditId)
        {
            var sql = "EXEC dbo.UserPreferenceKeyDetails " +
                      " " + ToSQLParameter(BaseModel.BaseDataColumns.AuditId, auditId) +
                      ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.UserPreferenceKeyId);

            var result = new List <DomainModel.UserPreferenceKey>();

            using (var reader = new DBDataReader("Get Details", sql, DataStoreKey))
            {
                var dbReader = reader.DBReader;

                while (dbReader.Read())
                {
                    var dataItem = new DomainModel.UserPreferenceKey();

                    dataItem.UserPreferenceKeyId = (int)dbReader[DomainModel.UserPreferenceKey.DataColumns.UserPreferenceKeyId];
                    dataItem.Name        = dbReader[DomainModel.UserPreferenceKey.DataColumns.Name].ToString();
                    dataItem.Description = dbReader[DomainModel.UserPreferenceKey.DataColumns.Description].ToString();
                    dataItem.SortOrder   = (int)dbReader[DomainModel.UserPreferenceKey.DataColumns.SortOrder];

                    SetBaseInfo(dataItem, dbReader);

                    result.Add(dataItem);
                }
            }

            return(result);
        }
示例#4
0
        public static void Delete(DomainModel.UserPreferenceKey data, int auditId)
        {
            var sql = "EXEC dbo.UserPreferenceKeyDelete " +
                      " " + ToSQLParameter(BaseModel.BaseDataColumns.AuditId, auditId) +
                      ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.UserPreferenceKeyId);

            DataAccess.DBDML.RunSQL("UserPreferenceKey.Delete", sql, DataStoreKey);
        }
示例#5
0
        public static DataTable GetDetails(DomainModel.UserPreferenceKey data, int auditId)
        {
            var sql = "EXEC dbo.UserPreferenceKeyDetails " +
                      " " + ToSQLParameter(BaseModel.BaseDataColumns.AuditId, auditId) +
                      ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.UserPreferenceKeyId);

            var oDT = new DataAccess.DBDataTable("UserPreferenceKey.Details", sql, DataStoreKey);

            return(oDT.DBTable);
        }
示例#6
0
        private static DataSet GetChildren(DomainModel.UserPreferenceKey data, int auditId)
        {
            var sql = "EXEC dbo.UserPreferenceKeyChildrenGet " +
                      " " + ToSQLParameter(BaseModel.BaseDataColumns.AuditId, auditId) +
                      ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.UserPreferenceKeyId);

            var oDT = new DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
示例#7
0
        public static DataTable Search(DomainModel.UserPreferenceKey data, int auditId)
        {
            // formulate SQL
            var sql = "EXEC dbo.UserPreferenceKeySearch " +
                      " " + ToSQLParameter(BaseModel.BaseDataColumns.AuditId, auditId) +
                      ", " + ToSQLParameter(BaseModel.BaseDataColumns.ApplicationId, ApplicationId) +
                      ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.UserPreferenceKeyId) +
                      ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.Name) +
                      ", " + ToSQLParameter(data, DomainModel.UserPreferenceKey.DataColumns.DataTypeId);

            var oDT = new DataAccess.DBDataTable("UserPreferenceKey.Search", sql, DataStoreKey);

            return(oDT.DBTable);
        }
示例#8
0
        public static bool IsDeletable(DomainModel.UserPreferenceKey data, int auditId)
        {
            var isDeletable = true;
            var ds          = GetChildren(data, auditId);

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataTable dt in ds.Tables)
                {
                    if (dt.Rows.Count > 0)
                    {
                        isDeletable = false;
                        break;
                    }
                }
            }
            return(isDeletable);
        }
示例#9
0
        public static void Update(DomainModel.UserPreferenceKey data, int auditId)
        {
            var sql = Save(data, auditId, "Update");

            DataAccess.DBDML.RunSQL("UserPreferenceKey.Update", sql, DataStoreKey);
        }