diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index c7146e53..fbd3fc78 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -148,7 +148,7 @@ - + @@ -172,8 +172,6 @@ - - Global.asax @@ -182,15 +180,12 @@ - - + - - diff --git a/Bootstrap.Admin/Content/js/Longbow.Common.js b/Bootstrap.Admin/Content/js/Longbow.Common.js index 32b401d6..cbd4c014 100644 --- a/Bootstrap.Admin/Content/js/Longbow.Common.js +++ b/Bootstrap.Admin/Content/js/Longbow.Common.js @@ -1,6 +1,4 @@ -/// - -(function ($) { +(function ($) { // 增加Array扩展 if (!$.isFunction(Array.prototype.filter)) { Array.prototype.filter = function (callback, thisObject) { @@ -94,6 +92,32 @@ that.animate({ marginTop: "+=" + getHeight() }); } }); + + $.fn.extend({ + autoValidate: function (options) { + // validate + $("#dataForm").validate({ + ignore: "ignore", + rules: $.extend({}, options), + unhighlight: function (element, errorClass, validClass) { + $.validator.defaults.unhighlight(element, errorClass, validClass); + $(element).popover('destroy'); + }, + errorPlacement: function (label, element) { + $(element).popover('destroy'); + $(element).popover({ + animation: true, + delay: { "show": 100, "hide": 100 }, + container: 'form', + trigger: 'manual', + content: $(label).text(), + placement: 'auto' + }); + $(element).popover('show'); + } + }); + } + }); })(jQuery); $(function () { diff --git a/Bootstrap.Admin/Content/js/_references.js b/Bootstrap.Admin/Content/js/_references.js index 5b9881dd..85847050 100644 Binary files a/Bootstrap.Admin/Content/js/_references.js and b/Bootstrap.Admin/Content/js/_references.js differ diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js index 6efb4e16..8d4b152e 100644 --- a/Bootstrap.Admin/Content/js/framework.js +++ b/Bootstrap.Admin/Content/js/framework.js @@ -1,153 +1,153 @@ -(function ($) { - ExtenderChecker = function (options) { - var that = this; - this.options = $.extend({}, ExtenderChecker.settings, options); - - this.dataEntity = options.dataEntity; - if (!(this.dataEntity instanceof DataEntity) && window.console) { - window.console.log('初始化参数中没有DataEntity实例'); - } - - // handler click event - for (name in this.options.click) { - var source = $("#" + this.options.click[name]); - source.data('click', name); - $("#" + this.options.click[name]).click(function () { - var method = $(this).data('click'); - ExtenderChecker.prototype[method].apply(that); - }); - } - - // handler modal window show event - if (this.options.modal.constructor === String) { - $('#' + this.options.modal).on('show.bs.modal', function (e) { - if (that.options.validateForm.constructor === String) { - var v = $('#' + that.options.validateForm).validate(); - v.currentElements.each(function () { $(this).popover('destroy'); }) - v.resetForm(); - } - }); - } - }; - - ExtenderChecker.VERSION = "1.0"; - ExtenderChecker.Author = "Argo Zhang"; - ExtenderChecker.Email = "argo@163.com"; - - ExtenderChecker.settings = { - url: undefined, - bootstrapTable: 'table', - validateForm: 'dataForm', - modal: 'dialogNew', - click: {} - } - - ExtenderChecker.idFormatter = function (value, row, index) { - return "" + value + ""; - }; - - ExtenderChecker.prototype = { - constructor: ExtenderChecker, - - query: function () { - if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('refresh'); - }, - - create: function () { - this.dataEntity.reset(); - if (this.options.modal.constructor === String) $('#' + this.options.modal).modal("show"); - if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('uncheckAll'); - }, - - edit: function () { - options = this.options; - if (options.bootstrapTable.constructor !== String) return; - var arrselections = $(options.bootstrapTable).bootstrapTable('getSelections'); - if (arrselections.length == 0) { - swal('请选择要编辑的条目', "编辑操作", "warning"); - } - else if (arrselections.length > 1) { - swal('请选择一个要编辑的条目', "编辑操作", "warning"); - } - else { - this.dataEntity.load(arrselections[0]); - if (options.modal.constructor === String) $('#' + options.modal).modal("show"); - } - }, - - del: function () { - var options = this.options; - if (options.bootstrapTable.constructor !== String) return; - var arrselections = $(options.bootstrapTable).bootstrapTable('getSelections'); - if (arrselections.length == 0) { - swal('请选择要删除的条目', "删除操作", "warning"); - return; - } - else { - swal({ - title: "您确定要删除吗?", - text: "删除操作", - type: "warning", - showCancelButton: true, - closeOnConfirm: true, - confirmButtonText: "是的,我要删除", - confirmButtonColor: "#d9534f", - cancelButtonText: "取消" - }, function () { - var iDs = arrselections.map(function (element, index) { return element.ID }).join(","); - $.ajax({ - url: options.url, - data: { "": iDs }, - type: 'DELETE', - success: function (result) { - if (result) setTimeout(function () { swal("成功!", "删除数据", "success"); $(options.bootstrapTable).bootstrapTable('refresh'); }, 100); - else setTimeout(function () { swal("失败", "删除数据", "error"); }, 200); - }, - error: function (XMLHttpRequest, textStatus, errorThrown) { - swal("失败", "删除数据", "error"); - } - }); - }); - } - }, - - save: function () { - var options = $.extend({}, this.options, { data: this.dataEntity.get() }); - if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return; - $.ajax({ - url: options.url, - data: options.data, - type: 'POST', - success: function (result) { - if (result) { - if ($.isFunction(options.success)) options.success(options.data); - if (options.bootstrapTable.constructor === String && options.data.ID.constructor === String) { - // 更新表格 - if (options.data.ID > 0) { - var allTableData = $(options.bootstrapTable).bootstrapTable('getData'); - for (index = 0; index < allTableData.length; index++) { - var temp = allTableData[index]; - if (temp.ID == options.data.ID) { - $(options.bootstrapTable).bootstrapTable('updateRow', { index: index, row: $.extend(temp, options.data) }); - break; - } - } - } - else { - $(options.bootstrapTable).bootstrapTable('refresh'); - } - } - if (options.modal.constructor === String) $('#' + options.modal).modal("hide"); - swal("成功", "保存数据", "success"); - } - else { - swal("失败", "保存数据", "error"); - } - }, - error: function (XMLHttpRequest, textStatus, errorThrown) { - swal("失败", "保存数据失败", "error"); - } - }); - } - }; +(function ($) { + BootstrapAdmin = function (options) { + var that = this; + this.options = $.extend({}, BootstrapAdmin.settings, options); + + this.dataEntity = options.dataEntity; + if (!(this.dataEntity instanceof DataEntity) && window.console) { + window.console.log('初始化参数中没有DataEntity实例'); + } + + // handler click event + for (name in this.options.click) { + var source = $("#" + this.options.click[name]); + source.data('click', name); + $("#" + this.options.click[name]).click(function () { + var method = $(this).data('click'); + BootstrapAdmin.prototype[method].apply(that); + }); + } + + // handler modal window show event + if (this.options.modal.constructor === String) { + $('#' + this.options.modal).on('show.bs.modal', function (e) { + if (that.options.validateForm.constructor === String) { + var v = $('#' + that.options.validateForm).validate(); + v.currentElements.each(function () { $(this).popover('destroy'); }) + v.resetForm(); + } + }); + } + }; + + BootstrapAdmin.VERSION = "1.0"; + BootstrapAdmin.Author = "Argo Zhang"; + BootstrapAdmin.Email = "argo@163.com"; + + BootstrapAdmin.settings = { + url: undefined, + bootstrapTable: 'table', + validateForm: 'dataForm', + modal: 'dialogNew', + click: {} + } + + BootstrapAdmin.idFormatter = function (value, row, index) { + return "" + value + ""; + }; + + BootstrapAdmin.prototype = { + constructor: BootstrapAdmin, + + query: function () { + if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('refresh'); + }, + + create: function () { + this.dataEntity.reset(); + if (this.options.modal.constructor === String) $('#' + this.options.modal).modal("show"); + if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('uncheckAll'); + }, + + edit: function () { + options = this.options; + if (options.bootstrapTable.constructor !== String) return; + var arrselections = $(options.bootstrapTable).bootstrapTable('getSelections'); + if (arrselections.length == 0) { + swal('请选择要编辑的条目', "编辑操作", "warning"); + } + else if (arrselections.length > 1) { + swal('请选择一个要编辑的条目', "编辑操作", "warning"); + } + else { + this.dataEntity.load(arrselections[0]); + if (options.modal.constructor === String) $('#' + options.modal).modal("show"); + } + }, + + del: function () { + var options = this.options; + if (options.bootstrapTable.constructor !== String) return; + var arrselections = $(options.bootstrapTable).bootstrapTable('getSelections'); + if (arrselections.length == 0) { + swal('请选择要删除的条目', "删除操作", "warning"); + return; + } + else { + swal({ + title: "您确定要删除吗?", + text: "删除操作", + type: "warning", + showCancelButton: true, + closeOnConfirm: true, + confirmButtonText: "是的,我要删除", + confirmButtonColor: "#d9534f", + cancelButtonText: "取消" + }, function () { + var iDs = arrselections.map(function (element, index) { return element.ID }).join(","); + $.ajax({ + url: options.url, + data: { "": iDs }, + type: 'DELETE', + success: function (result) { + if (result) setTimeout(function () { swal("成功!", "删除数据", "success"); $(options.bootstrapTable).bootstrapTable('refresh'); }, 100); + else setTimeout(function () { swal("失败", "删除数据", "error"); }, 200); + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + swal("失败", "删除数据", "error"); + } + }); + }); + } + }, + + save: function () { + var options = $.extend({}, this.options, { data: this.dataEntity.get() }); + if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return; + $.ajax({ + url: options.url, + data: options.data, + type: 'POST', + success: function (result) { + if (result) { + if ($.isFunction(options.success)) options.success(options.data); + if (options.bootstrapTable.constructor === String && options.data.ID.constructor === String) { + // 更新表格 + if (options.data.ID > 0) { + var allTableData = $(options.bootstrapTable).bootstrapTable('getData'); + for (index = 0; index < allTableData.length; index++) { + var temp = allTableData[index]; + if (temp.ID == options.data.ID) { + $(options.bootstrapTable).bootstrapTable('updateRow', { index: index, row: $.extend(temp, options.data) }); + break; + } + } + } + else { + $(options.bootstrapTable).bootstrapTable('refresh'); + } + } + if (options.modal.constructor === String) $('#' + options.modal).modal("hide"); + swal("成功", "保存数据", "success"); + } + else { + swal("失败", "保存数据", "error"); + } + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + swal("失败", "保存数据失败", "error"); + } + }); + } + }; })(jQuery); \ No newline at end of file diff --git a/Bootstrap.Admin/Controllers/HomeController.cs b/Bootstrap.Admin/Controllers/HomeController.cs index 07af0a16..3d46d086 100644 --- a/Bootstrap.Admin/Controllers/HomeController.cs +++ b/Bootstrap.Admin/Controllers/HomeController.cs @@ -16,26 +16,7 @@ namespace Bootstrap.Admin.Controllers public ActionResult Index() { var v = new HeaderBarModel(); - return View(v); - } - /// - /// - /// - /// - public ActionResult Rules() - { - var v = new HeaderBarModel(); - v.BreadcrumbName = "规则设置"; - return View(v); - } - /// - /// - /// - /// - public ActionResult Terminals() - { - var v = new HeaderBarModel(); - v.BreadcrumbName = "输入口设置"; + v.ShowMenu = "hide"; return View(v); } /// diff --git a/Bootstrap.Admin/Controllers/RulesController.cs b/Bootstrap.Admin/Controllers/RulesController.cs deleted file mode 100644 index da4c0ed5..00000000 --- a/Bootstrap.Admin/Controllers/RulesController.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using System.Web.Http; - -namespace Bootstrap.Admin.Controllers -{ - public class RulesController : ApiController - { - // GET api/ - public IEnumerable Get() - { - return new string[] { "value1", "value2" }; - } - - // GET api//5 - public string Get(int id) - { - return "value"; - } - - // POST api/ - public void Post([FromBody]string value) - { - } - - // PUT api//5 - public void Put(int id, [FromBody]string value) - { - } - - // DELETE api//5 - public void Delete(int id) - { - } - } -} \ No newline at end of file diff --git a/Bootstrap.Admin/Controllers/TerminalsController.cs b/Bootstrap.Admin/Controllers/TerminalsController.cs deleted file mode 100644 index ff6829b3..00000000 --- a/Bootstrap.Admin/Controllers/TerminalsController.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Bootstrap.Admin.Models; -using Bootstrap.DataAccess; -using System.Linq; -using System.Web.Http; - -namespace Bootstrap.Admin.Controllers -{ - public class TerminalsController : ApiController - { - // GET api/ - [HttpGet] - public TerminalsModel Get([FromUri]TerminalsPageOption value) - { - var ret = new TerminalsModel(); - ret.RetrieveTerminals(value); - return ret; - } - - // GET api//5 - [HttpGet] - public Terminal Get(int id) - { - return TerminalHelper.RetrieveTerminals(string.Empty).FirstOrDefault(t => t.ID == id); - } - - // POST api/ - [HttpPost] - public bool Post([FromBody]Terminal value) - { - return TerminalHelper.SaveTerminal(value); - } - - // PUT api//5 - [HttpPut] - public bool Put(int id, [FromBody]Terminal value) - { - return TerminalHelper.SaveTerminal(value); - } - - // DELETE api//5 - [HttpDelete] - public bool Delete([FromBody]string value) - { - TerminalHelper.DeleteTerminal(value); - return true; - } - } -} \ No newline at end of file diff --git a/Bootstrap.Admin/Controllers/UsersController.cs b/Bootstrap.Admin/Controllers/UsersController.cs index 5c54473d..93462da1 100644 --- a/Bootstrap.Admin/Controllers/UsersController.cs +++ b/Bootstrap.Admin/Controllers/UsersController.cs @@ -1,38 +1,55 @@ -using Bootstrap.Admin.Models; -using System.Web.Http; - -namespace Bootstrap.Admin.Controllers -{ - public class UsersController : ApiController - { - // GET api/ - [HttpGet] - public UserModel Get() - { - return new UserModel() - { - }; - } - - // GET api//5 - public string Get(int id) - { - return "value"; - } - - // POST api/ - public void Post([FromBody]string value) - { - } - - // PUT api//5 - public void Put(int id, [FromBody]string value) - { - } - - // DELETE api//5 - public void Delete(int id) - { - } - } +using Bootstrap.Admin.Models; +using Bootstrap.DataAccess; +using System.Web.Http; +using System.Linq; + +namespace Bootstrap.Admin.Controllers +{ + /// + /// + /// + public class UsersController : ApiController + { + /// + /// + /// + /// + /// + [HttpGet] + public UserEntity Get([FromUri]TerminalsPageOption value) + { + var ret = new UserEntity(); + ret.RetrieveUsers(value); + return ret; + + } + /// + /// + /// + /// + /// + [HttpGet] + public User Get(int id) + { + return UserHelper.RetrieveUsers().FirstOrDefault(t => t.ID == id); + } + /// + /// + /// + /// + [HttpPost] + public bool Post([FromBody]User value) + { + return UserHelper.SaveUser(value); + } + /// + /// + /// + /// + [HttpDelete] + public bool Delete([FromBody]string value) + { + return UserHelper.DeleteUser(value); + } + } } \ No newline at end of file diff --git a/Bootstrap.Admin/Models/TerminalsModel.cs b/Bootstrap.Admin/Models/UserEntity.cs similarity index 53% rename from Bootstrap.Admin/Models/TerminalsModel.cs rename to Bootstrap.Admin/Models/UserEntity.cs index dd3196d6..60f6651b 100644 --- a/Bootstrap.Admin/Models/TerminalsModel.cs +++ b/Bootstrap.Admin/Models/UserEntity.cs @@ -4,27 +4,23 @@ using System.Linq; namespace Bootstrap.Admin.Models { - public class TerminalsModel + public class UserEntity { public int total { get; private set; } - public IEnumerable rows { get; private set; } + public IEnumerable rows { get; private set; } - public void RetrieveTerminals(TerminalsPageOption option) + public void RetrieveUsers(TerminalsPageOption option) { // int limit, int offset, string name, string price, string sort, string order - var data = TerminalHelper.RetrieveTerminals(string.Empty); + var data = UserHelper.RetrieveUsers(string.Empty); if (!string.IsNullOrEmpty(option.Name)) { - data = data.Where(t => t.Name.Contains(option.Name)); - } - if (!string.IsNullOrEmpty(option.Ip)) - { - data = data.Where(t => t.ServerIP.Contains(option.Ip)); + data = data.Where(t => t.UserName.Contains(option.Name)); } total = data.Count(); // TODO: 通过option.Sort属性判断对那列进行排序,现在统一对名称列排序 - data = option.Order == "asc" ? data.OrderBy(t => t.Name) : data.OrderByDescending(t => t.Name); + data = option.Order == "asc" ? data.OrderBy(t => t.UserName) : data.OrderByDescending(t => t.UserName); rows = data.Skip(option.Offset).Take(option.Limit); } } @@ -34,7 +30,5 @@ namespace Bootstrap.Admin.Models public class TerminalsPageOption : PaginationOption { public string Name { get; set; } - - public string Ip { get; set; } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Models/UserModel.cs b/Bootstrap.Admin/Models/UserModel.cs deleted file mode 100644 index 1bad06b0..00000000 --- a/Bootstrap.Admin/Models/UserModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Bootstrap.Admin.Models -{ - public class UserModel : HeaderBarModel - { - - } -} \ No newline at end of file diff --git a/Bootstrap.Admin/Scripts/Terminals.js b/Bootstrap.Admin/Scripts/Terminals.js deleted file mode 100644 index a1b83298..00000000 --- a/Bootstrap.Admin/Scripts/Terminals.js +++ /dev/null @@ -1,150 +0,0 @@ -$(function () { - var dataEntity = new DataEntity({ - map: { - ID: "terminalId", - Name: "terminalName", - ClientIP: "clientIP", - ClientPort: "clientPort", - ServerIP: "serverIP", - ServerPort: "serverPort", - DeviceIP: "deviceIP", - DevicePort: "devicePort", - DatabaseName: "databaseName", - DatabaseUserName: "databaseUserName", - DatabasePassword: "databasePassword" - } - }); - - var extender = new ExtenderChecker({ - url: '../api/Terminals', - dataEntity: dataEntity, - click: { - query: 'btn_query', - create: 'btn_add', - edit: 'btn_edit', - del: 'btn_delete', - save: 'btnSubmit' - } - }); - - idEvents = { - 'click .edit': function (e, value, row, index) { - dataEntity.load(row); - $('table').bootstrapTable('uncheckAll'); - $('table').bootstrapTable('check', index); - $("#dialogNew").modal("show"); - } - }; - - $('table').bootstrapTable({ - url: '../api/Terminals', //请求后台的URL(*) - method: 'get', //请求方式(*) - toolbar: '#toolbar', //工具按钮用哪个容器 - striped: true, //是否显示行间隔色 - cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*) - pagination: true, //是否显示分页(*) - sortable: true, //是否启用排序 - sortName: 'Name', - sortOrder: "asc", //排序方式 - queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val(), ip: $("#txt_search_ip").val() }); }, //传递参数(*) - sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*) - pageNumber: 1, //初始化加载第一页,默认第一页 - pageSize: 10, //每页的记录行数(*) - pageList: [10, 25, 50, 100], //可供选择的每页的行数(*) - search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大 - strictSearch: false, - showColumns: true, //是否显示所有的列 - showRefresh: true, //是否显示刷新按钮 - minimumCountColumns: 2, //最少允许的列数 - clickToSelect: false, //是否启用点击选中行 - //height: 500, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度 - idField: "Id", - uniqueId: "Id", //每一行的唯一标识,一般为主键列 - showToggle: true, //是否显示详细视图和列表视图的切换按钮 - cardView: false, //是否显示详细视图 - detailView: false, //是否显示父子表 - clickToSelect: false, - columns: [{ checkbox: true }, - { title: "Id", field: "ID", events: idEvents, formatter: ExtenderChecker.idFormatter }, - { title: "输入口名称", field: "Name", sortable: true }, - { title: "工控机IP", field: "ClientIP", sortable: false }, - { title: "工控机Port", field: "ClientPort", sortable: false }, - { title: "服务器IP", field: "ServerIP", sortable: false }, - { title: "服务器Port", field: "ServerPort", sortable: false }, - { title: "比对设备IP", field: "DeviceIP", sortable: false }, - { title: "比对设备Port", field: "DevicePort", sortable: false }, - { title: "数据库名称", field: "DatabaseName", sortable: false }, - { title: "数据库用户名", field: "DatabaseUserName", sortable: false }, - { title: "数据库密码", field: "DatabasePassword", sortable: false } - ] - }); - - // validate - $("#dataForm").validate({ - ignore: "ignore", - rules: { - terminalName: { - required: true, - maxlength: 50 - }, - clientIP: { - required: true, - ip: true, - maxlength: 15 - }, - clientPort: { - required: true, - digits: true, - range: [0, 65535], - maxlength: 5 - }, - serverIP: { - required: true, - ip: true, - maxlength: 15 - }, - serverPort: { - required: true, - digits: true, - range: [1000, 65535], - minlength: 4 - }, - deviceIP: { - required: true, - ip: true, - maxlength: 15 - }, - devicePort: { - required: true, - digits: true, - range: [1000, 65535], - minlength: 4 - }, - databaseName: { - maxlength: 50 - }, - databaseUserName: { - maxlength: 50 - }, - databasePassword: { - maxlength: 50 - } - }, - unhighlight: function (element, errorClass, validClass) { - $.validator.defaults.unhighlight(element, errorClass, validClass); - $(element).popover('destroy'); - }, - errorPlacement: function (label, element) { - $(element).popover('destroy'); - $(element).popover({ - animation: true, - delay: { "show": 100, "hide": 100 }, - container: 'form', - trigger: 'manual', - content: $(label).text(), - placement: 'auto' - }); - $(element).popover('show'); - } - }); -}); \ No newline at end of file diff --git a/Bootstrap.Admin/Scripts/Users.js b/Bootstrap.Admin/Scripts/Users.js new file mode 100644 index 00000000..efd9accd --- /dev/null +++ b/Bootstrap.Admin/Scripts/Users.js @@ -0,0 +1,80 @@ +$(function () { + var dataEntity = new DataEntity({ + map: { + ID: "userID", + UserName: "userName", + Password: "password" + } + }); + + var extender = new BootstrapAdmin({ + url: '../api/Users', + dataEntity: dataEntity, + click: { + query: 'btn_query', + create: 'btn_add', + edit: 'btn_edit', + del: 'btn_delete', + save: 'btnSubmit' + } + }); + + idEvents = { + 'click .edit': function (e, value, row, index) { + dataEntity.load(row); + $('table').bootstrapTable('uncheckAll'); + $('table').bootstrapTable('check', index); + $("#dialogNew").modal("show"); + } + }; + + $('table').bootstrapTable({ + url: '../api/Users', //请求后台的URL(*) + method: 'get', //请求方式(*) + toolbar: '#toolbar', //工具按钮用哪个容器 + striped: true, //是否显示行间隔色 + cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*) + pagination: true, //是否显示分页(*) + sortable: true, //是否启用排序 + sortName: 'UserName', + sortOrder: "asc", //排序方式 + queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val() }); }, //传递参数(*) + sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*) + pageNumber: 1, //初始化加载第一页,默认第一页 + pageSize: 10, //每页的记录行数(*) + pageList: [10, 25, 50, 100], //可供选择的每页的行数(*) + search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大 + strictSearch: false, + showColumns: true, //是否显示所有的列 + showRefresh: true, //是否显示刷新按钮 + minimumCountColumns: 2, //最少允许的列数 + clickToSelect: false, //是否启用点击选中行 + //height: 500, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度 + idField: "Id", + uniqueId: "Id", //每一行的唯一标识,一般为主键列 + showToggle: true, //是否显示详细视图和列表视图的切换按钮 + cardView: false, //是否显示详细视图 + detailView: false, //是否显示父子表 + clickToSelect: false, + columns: [{ checkbox: true }, + { title: "Id", field: "ID", events: idEvents, formatter: BootstrapAdmin.idFormatter }, + { title: "用户名称", field: "UserName", sortable: true } + ] + }); + + // validate + $('#dataForm').autoValidate({ + userName: { + required: true, + maxlength: 50 + }, + password: { + required: true, + maxlength: 50 + }, + confirm: { + required: true, + equalTo: "#password" + } + }); +}); \ No newline at end of file diff --git a/Bootstrap.Admin/Views/Admin/Users.cshtml b/Bootstrap.Admin/Views/Admin/Users.cshtml index 04ae574e..2e9737b7 100644 --- a/Bootstrap.Admin/Views/Admin/Users.cshtml +++ b/Bootstrap.Admin/Views/Admin/Users.cshtml @@ -5,7 +5,6 @@ } @section Javascript { - } @section header { @Html.Partial("Header", Model) @@ -16,9 +15,9 @@ @section query {
- +
- +
@@ -35,58 +34,22 @@
/// - public static void DeleteUser(string ids) + public static bool DeleteUser(string ids) { - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return; - string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Users where ID in ({0})", ids); - using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) + bool ret = false; + if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret; + try { - DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); + string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Users where ID in ({0})", ids); + using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) + { + DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); + } ClearCache(); + ret = true; } + catch (Exception ex) + { + ExceptionManager.Publish(ex); + } + return ret; } /// /// 保存新建/更新的用户信息 @@ -71,11 +79,11 @@ namespace Bootstrap.DataAccess /// public static bool SaveUser(User p) { + //TODO: 这里这样处理明显不行,需要用非对称加密算法进行混淆加密后存储到数据库中 if (p == null) throw new ArgumentNullException("p"); bool ret = false; if (p.UserName.Length > 50) p.UserName.Substring(0, 50); if (p.Password.Length > 50) p.Password.Substring(0, 50); - if (p.PassSalt.Length > 50) p.PassSalt.Substring(0, 50); string sql = p.ID == 0 ? "Insert Into Users (UserName, Password, PassSalt) Values (@UserName, @Password, @PassSalt)" : "Update Users set UserName = @UserName, Password = @Password, PassSalt = @PassSalt where ID = @ID"; @@ -86,7 +94,7 @@ namespace Bootstrap.DataAccess cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.ID, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", p.UserName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Password", p.Password, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@PassSalt", p.PassSalt, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@PassSalt", DBNull.Value, ParameterDirection.Input)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); } ret = true; diff --git a/Bootstrap.DataAccessTests/App.config b/Bootstrap.DataAccessTests/App.config index df96ee28..dabe6101 100644 --- a/Bootstrap.DataAccessTests/App.config +++ b/Bootstrap.DataAccessTests/App.config @@ -9,7 +9,7 @@ - + diff --git a/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj b/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj index aaa90f16..13377adc 100644 --- a/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj +++ b/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj @@ -52,13 +52,9 @@ - - - - diff --git a/Bootstrap.DataAccessTests/TerminalHelperTests.cs b/Bootstrap.DataAccessTests/TerminalHelperTests.cs deleted file mode 100644 index dfd350b2..00000000 --- a/Bootstrap.DataAccessTests/TerminalHelperTests.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Linq; - -namespace Bootstrap.DataAccess.Tests -{ - [TestClass()] - public class MenuTests - { - [TestMethod()] - public void RetrieveMenusTest() - { - var result = TerminalHelper.RetrieveTerminals("1"); - Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的TerminalHelper.RetrieveTerminals方法调用失败,请检查数据库连接或者数据库SQL语句"); - result = TerminalHelper.RetrieveTerminals(); - Assert.IsTrue(result.Count() >= 0, "不带参数的TerminalHelper.RetrieveTerminals方法调用失败,请检查数据库连接或者数据库SQL语句"); - } - } -} \ No newline at end of file diff --git a/Bootstrap.DataAccessTests/UserHelperTests.cs b/Bootstrap.DataAccessTests/UserHelperTests.cs index 1fd8760a..214eff46 100644 --- a/Bootstrap.DataAccessTests/UserHelperTests.cs +++ b/Bootstrap.DataAccessTests/UserHelperTests.cs @@ -1,55 +1,47 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Linq; - -namespace Bootstrap.DataAccess.Tests -{ - [TestClass] - public class UserHelperTests - { - [TestMethod] - public void RetrieveUsersTest() - { - var result = UserHelper.RetrieveUsers("1"); - Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句"); - result = UserHelper.RetrieveUsers(); - Assert.IsTrue(result.Count() >= 0, "不带参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句"); - } - - [TestMethod] - public void DeleteUserTest() - { - string ids = "2"; - try - { - UserHelper.DeleteUser(ids); - Assert.IsTrue(true); - } - catch - { - Assert.IsTrue(false,"带有参数的UserHelper.DeleteUserTest方法调用失败,请检查数据库连接或者数据库SQL语句"); - } - - } - - [TestMethod] - public void SaveUserTest() - { - User users = new User(); - users.ID = 0; - users.UserName = "liqi"; - users.Password = "123"; - users.PassSalt = "123"; - var result = UserHelper.SaveUser(users); - Assert.IsTrue(result == true, "带有参数的UserHelper.SaveUser方法中新建用户信息失败,请检查数据库连接或者数据库SQL语句"); - - User users1 = new User(); - users1.ID = 1; - users1.UserName = "Lily"; - users1.Password = "123456"; - users1.PassSalt = "123456"; - result = UserHelper.SaveUser(users1); - Assert.IsTrue(result == true, "带有参数的UserHelper.SaveUser方法中更新用户信息失败,请检查数据库连接或者数据库SQL语句"); - } - - } -} +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; + +namespace Bootstrap.DataAccess.Tests +{ + [TestClass] + public class UserHelperTests + { + [TestMethod] + public void RetrieveUsersTest() + { + var result = UserHelper.RetrieveUsers("1"); + Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句"); + result = UserHelper.RetrieveUsers(); + Assert.IsTrue(result.Count() >= 0, "不带参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句"); + } + + [TestMethod] + public void DeleteUserTest() + { + //TODO: Delete方法没有返回值,自己想想做一个返回值即可 + Assert.IsTrue(UserHelper.DeleteUser("1,2"), "带有参数的UserHelper.DeleteUserTest方法调用失败,请检查数据库连接或者数据库SQL语句"); + Assert.IsFalse(UserHelper.DeleteUser(string.Empty), "参数为空字符串的UserHelper.DeleteUserTest方法调用失败,请检查数据库连接或者数据库SQL语句"); + } + + [TestMethod] + public void SaveUserTest() + { + //TODO: 两个提示一模一样完全不知道哪里出了问题,本单元测试未通过 + User users = new User(); + users.ID = 0; + users.UserName = "liqi"; + users.Password = "123"; + users.PassSalt = "123"; + var result = UserHelper.SaveUser(users); + Assert.IsTrue(result == true, "带有参数的UserHelper.SaveUser方法中新建用户信息失败,请检查数据库连接或者数据库SQL语句"); + + User users1 = new User(); + users1.ID = 1; + users1.UserName = "Lily"; + users1.Password = "123456"; + users1.PassSalt = "123456"; + result = UserHelper.SaveUser(users1); + Assert.IsTrue(result == true, "带有参数的UserHelper.SaveUser方法中更新用户信息失败,请检查数据库连接或者数据库SQL语句"); + } + } +} diff --git a/BootstrapAdmin.sln b/BootstrapAdmin.sln index 7903d1af..c5fd0e69 100644 --- a/BootstrapAdmin.sln +++ b/BootstrapAdmin.sln @@ -7,10 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bootstrap.DataAccess", "Boo EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sql", "sql", "{87319AF5-7C40-4362-B67C-35F9DD737DB4}" ProjectSection(SolutionItems) = preProject - DatabaseScripts\ExtendedChecker.sql = DatabaseScripts\ExtendedChecker.sql DatabaseScripts\Install.sql = DatabaseScripts\Install.sql - DatabaseScripts\Proc_StartTerminal.sql = DatabaseScripts\Proc_StartTerminal.sql - DatabaseScripts\Proc_StopTerminal.sql = DatabaseScripts\Proc_StopTerminal.sql DatabaseScripts\Readme.txt = DatabaseScripts\Readme.txt EndProjectSection EndProject diff --git a/DatabaseScripts/Install.sql b/DatabaseScripts/Install.sql index e7e9a36d..9937d98f 100644 --- a/DatabaseScripts/Install.sql +++ b/DatabaseScripts/Install.sql @@ -1,147 +1,144 @@ USE [master] GO -Create database [ExtendedChecker] +Create database [BootstrapAdmin] GO -ALTER DATABASE [ExtendedChecker] SET RECOVERY SIMPLE +ALTER DATABASE [BootstrapAdmin] SET RECOVERY SIMPLE GO -ALTER DATABASE [ExtendedChecker] SET AUTO_SHRINK ON +ALTER DATABASE [BootstrapAdmin] SET AUTO_SHRINK ON GO -USE [ExtendedChecker] +USE [BootstrapAdmin] GO -/****** Object: Table [dbo].[Rules] Script Date: 9/1/2016 7:44:10 PM ******/ +/****** Object: Table [dbo].[Users] Script Date: 10/22/2016 09:44:03 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -CREATE TABLE [dbo].[Terminals]( +CREATE TABLE [dbo].[Users]( [ID] [int] IDENTITY(1,1) NOT NULL, - [Name] [nvarchar](50) NOT NULL, - [ClientIP] [varchar](15) NOT NULL, - [ClientPort] [int] NOT NULL, - [ServerIP] [varchar](15) NOT NULL, - [ServerPort] [int] NOT NULL, - [DeviceIP] [varchar](15) NOT NULL, - [DevicePort] [int] NOT NULL, - [DatabaseName] [varchar](50) NULL, - [DatabaseUserName] [varchar](50) NULL, - [DatabasePassword] [varchar](50) NULL, - [Status] [bit] NOT NULL, - CONSTRAINT [PK_Terminal] PRIMARY KEY CLUSTERED + [UserName] [nvarchar](50) NULL, + [Password] [nvarchar](50) NULL, + [PassSalt] [nvarchar](50) NULL, + CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO -SET ANSI_PADDING OFF +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'ID' GO -/****** Object: Table [dbo].[TerminalRuleConfig] Script Date: 09/06/2016 14:31:10 ******/ +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserName' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'Password' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'֤' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'PassSalt' +GO +/****** Object: Table [dbo].[UserRole] Script Date: 10/22/2016 09:44:03 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -CREATE TABLE [dbo].[TerminalRuleConfig]( - [TerminalID] [int] NOT NULL, - [RuleID] [int] NOT NULL -) ON [PRIMARY] -GO -/****** Object: Table [dbo].[ScanInventory] Script Date: 09/06/2016 14:31:10 ******/ -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -SET ANSI_PADDING ON -GO -CREATE TABLE [dbo].[ScanInventory]( +CREATE TABLE [dbo].[UserRole]( [ID] [int] IDENTITY(1,1) NOT NULL, - [BarCode] [varchar](32) NOT NULL, - [TerminalID] [int] NOT NULL, - [ScanTime] [datetime] NOT NULL, - [BarCodeType] [int] NOT NULL, - CONSTRAINT [PK_ScanInventory] PRIMARY KEY CLUSTERED + [UserID] [int] NOT NULL, + [RoleID] [int] NOT NULL, + CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO -SET ANSI_PADDING OFF +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'ID' GO -/****** Object: Table [dbo].[Rules] Script Date: 09/06/2016 14:31:10 ******/ +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ûID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'UserID' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ɫID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'RoleID' +GO +/****** Object: Table [dbo].[UserGroup] Script Date: 10/22/2016 09:44:03 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -CREATE TABLE [dbo].[Rules]( +CREATE TABLE [dbo].[UserGroup]( [ID] [int] IDENTITY(1,1) NOT NULL, - [Name] [nvarchar](200) NOT NULL, - [Memo] [nvarchar](2000) NULL, - [Interval] [int] NOT NULL, - [Enabled] [bit] NOT NULL, - CONSTRAINT [PK_Rules] PRIMARY KEY CLUSTERED + [UserID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + CONSTRAINT [PK_UserGroup] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO -/****** Object: Default [DF_Rules_Enabled] Script Date: 09/06/2016 14:31:10 ******/ -ALTER TABLE [dbo].[Rules] ADD CONSTRAINT [DF_Rules_Enabled] DEFAULT ((1)) FOR [Enabled] +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserGroup', @level2type=N'COLUMN',@level2name=N'ID' GO -/****** Object: Default [DF_Terminals_Satus] Script Date: 09/06/2016 14:31:10 ******/ -ALTER TABLE [dbo].[Terminals] ADD CONSTRAINT [DF_Terminals_Satus] DEFAULT ((0)) FOR [Status] +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ûID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserGroup', @level2type=N'COLUMN',@level2name=N'UserID' GO - +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserGroup', @level2type=N'COLUMN',@level2name=N'GroupID' +GO +/****** Object: Table [dbo].[Roles] Script Date: 10/22/2016 09:44:03 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO --- ============================================= --- Author: Argo Zhang --- Create date: 2016-09-06 --- Description: --- ============================================= -CREATE PROCEDURE Proc_StartTerminal - -- Add the parameters for the stored procedure here - @tId int, - @rId int - WITH ENCRYPTION -AS -BEGIN - -- SET NOCOUNT ON added to prevent extra result sets from - -- interfering with SELECT statements. - SET NOCOUNT ON; - SET XACT_ABORT ON; - -- Insert statements for procedure here - delete from TerminalRuleConfig where TerminalID = @tId; - insert into TerminalRuleConfig (TerminalID, RuleID) values (@tId, @rId); - update Terminals set Status = 1 where Id = @tId; -END +CREATE TABLE [dbo].[Roles]( + [ID] [int] IDENTITY(1,1) NOT NULL, + [RoleName] [nvarchar](50) NULL, + [Description] [nvarchar](500) NULL, + CONSTRAINT [PK_Roles] PRIMARY KEY CLUSTERED +( + [ID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] GO - +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Roles', @level2type=N'COLUMN',@level2name=N'ID' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ɫ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Roles', @level2type=N'COLUMN',@level2name=N'RoleName' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Roles', @level2type=N'COLUMN',@level2name=N'Description' +GO +/****** Object: Table [dbo].[RoleGroup] Script Date: 10/22/2016 09:44:03 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO --- ============================================= --- Author: Argo Zhang --- Create date: 2016-09-06 --- Description: --- ============================================= -CREATE PROCEDURE Proc_StopTerminal - -- Add the parameters for the stored procedure here - @tId int - WITH ENCRYPTION -AS -BEGIN - -- SET NOCOUNT ON added to prevent extra result sets from - -- interfering with SELECT statements. - SET NOCOUNT ON; - SET XACT_ABORT ON; - -- Insert statements for procedure here - delete from TerminalRuleConfig where TerminalID = @tId; - update Terminals set Status = 0 where Id = @tId; -END +CREATE TABLE [dbo].[RoleGroup]( + [ID] [int] IDENTITY(1,1) NOT NULL, + [RoleID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + CONSTRAINT [PK_RoleGroup] PRIMARY KEY CLUSTERED +( + [ID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleGroup', @level2type=N'COLUMN',@level2name=N'ID' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ɫID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleGroup', @level2type=N'COLUMN',@level2name=N'RoleID' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleGroup', @level2type=N'COLUMN',@level2name=N'GroupID' +GO +/****** Object: Table [dbo].[Groups] Script Date: 10/22/2016 09:44:03 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Groups]( + [ID] [int] IDENTITY(1,1) NOT NULL, + [GroupName] [nvarchar](50) NULL, + [Description] [nvarchar](500) NULL, + CONSTRAINT [PK_Groups] PRIMARY KEY CLUSTERED +( + [ID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Groups', @level2type=N'COLUMN',@level2name=N'ID' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Groups', @level2type=N'COLUMN',@level2name=N'GroupName' +GO +EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Groups', @level2type=N'COLUMN',@level2name=N'Description' GO