// Method ListDataByCoumn public Dictionary <string, object> ListDataByCoumn(string column) { List <string> data = UsersDao.Instance.ListDataByColumn(HelperBll.GetColumnNameInSQLByPropertyName <UsersModel>(column)); Dictionary <string, object> dics = new Dictionary <string, object>(); Type t = HelperBll.GetTypeOfProperty <UsersModel>(column); if (t != null && t == typeof(Boolean)) { switch (column) { case "Sex": foreach (string item in data) { if (item == "True") { dics.Add("Nam", 1); } else if (item == "False") { dics.Add("Nữ", 0); } } break; case "Status": foreach (string item in data) { if (item == "True") { dics.Add("Kích hoạt", 1); } else if (item == "False") { dics.Add("Khóa", 1); } } break; } return(dics); } else { foreach (string item in data) { dics.Add(item, item); } return(dics); } }
// Method ListDataByCoumn public Dictionary <string, object> ListDataByCoumn(string column) { List <string> data = StuffsDao.Instance.ListDataByColumn(HelperBll.GetColumnNameInSQLByPropertyName <StuffsModel>(column)); Dictionary <string, object> dics = new Dictionary <string, object>(); foreach (string item in data) { dics.Add(item, item); } return(dics); }
// Method ListForExcel public void ListForExcel(MetroGrid grid, string keyword, string sortColumn, string sortBy, string columnFilter, object filterValue) { grid.Rows.Clear(); grid.Columns.Clear(); List <StuffsModel> stuffs = StuffsDao.Instance.ListForExcel(keyword, !string.IsNullOrEmpty(sortColumn) ? HelperBll.GetColumnNameInSQLByPropertyName <StuffsModel>(sortColumn) : "", sortBy, !string.IsNullOrEmpty(columnFilter) ? HelperBll.GetColumnNameInSQLByPropertyName <StuffsModel>(columnFilter) : "", filterValue); StuffsModel nameOf = new StuffsModel(); grid.Columns.Add(nameof(nameOf.BQCode), nameof(nameOf.BQCode)); grid.Columns.Add(nameof(nameOf.Name), nameof(nameOf.Name)); grid.Columns.Add(nameof(nameOf.Category), nameof(nameOf.Category)); grid.Columns.Add(nameof(nameOf.PlaceStuff), nameof(nameOf.PlaceStuff)); grid.Columns.Add(nameof(nameOf.DateBuy), nameof(nameOf.DateBuy)); grid.Columns.Add(nameof(nameOf.DateUse), nameof(nameOf.DateUse)); grid.Columns.Add(nameof(nameOf.YearRelease), nameof(nameOf.YearRelease)); grid.Columns.Add(nameof(nameOf.ColorStuffs), nameof(nameOf.ColorStuffs)); grid.Columns.Add(nameof(nameOf.State), nameof(nameOf.State)); grid.Columns.Add(nameof(nameOf.PriceBuy), nameof(nameOf.PriceBuy)); grid.Columns.Add(nameof(nameOf.Warranty), nameof(nameOf.Warranty)); grid.Columns.Add(nameof(nameOf.CreatedDate), nameof(nameOf.CreatedDate)); grid.Columns.Add(nameof(nameOf.CreatedBy), nameof(nameOf.CreatedBy)); grid.Columns.Add(nameof(nameOf.ModifiedDate), nameof(nameOf.ModifiedDate)); grid.Columns.Add(nameof(nameOf.ModifiedBy), nameof(nameOf.ModifiedBy)); for (int i = 0; i < stuffs.Count; i++) { grid.Rows.Add(); grid[nameof(nameOf.BQCode), i].Value = stuffs[i].BQCode; grid[nameof(nameOf.Name), i].Value = stuffs[i].Name; grid[nameof(nameOf.Category), i].Value = stuffs[i].Category; grid[nameof(nameOf.PlaceStuff), i].Value = stuffs[i].PlaceStuff; grid[nameof(nameOf.DateBuy), i].Value = stuffs[i].DateBuy; grid[nameof(nameOf.DateUse), i].Value = stuffs[i].DateUse; grid[nameof(nameOf.YearRelease), i].Value = stuffs[i].YearRelease; grid[nameof(nameOf.ColorStuffs), i].Value = stuffs[i].ColorStuffs; grid[nameof(nameOf.State), i].Value = stuffs[i].State; grid[nameof(nameOf.PriceBuy), i].Value = stuffs[i].PriceBuy; grid[nameof(nameOf.Warranty), i].Value = stuffs[i].Warranty; grid[nameof(nameOf.CreatedDate), i].Value = stuffs[i].CreatedDate; grid[nameof(nameOf.CreatedBy), i].Value = stuffs[i].CreatedBy; grid[nameof(nameOf.ModifiedDate), i].Value = stuffs[i].ModifiedDate.ToString() == "01-Jan-01 12:00:00 AM" ? "" : stuffs[i].ModifiedDate.ToString(); grid[nameof(nameOf.ModifiedBy), i].Value = stuffs[i].ModifiedBy; } }
// Method ListForExcel public void ListForExcel(MetroGrid grid, string keyword, string sortColumn, string sortBy) { grid.Rows.Clear(); grid.Columns.Clear(); List <CategoriesModel> stuffs = CategoriesDao.Instance.ListForExcel(keyword, !string.IsNullOrEmpty(sortColumn) ? HelperBll.GetColumnNameInSQLByPropertyName <CategoriesModel>(sortColumn) : "", sortBy); CategoriesModel nameOf = new CategoriesModel(); grid.Columns.Add(nameof(nameOf.Name), nameof(nameOf.Name)); grid.Columns.Add(nameof(nameOf.CreatedDate), nameof(nameOf.CreatedDate)); grid.Columns.Add(nameof(nameOf.CreatedBy), nameof(nameOf.CreatedBy)); grid.Columns.Add(nameof(nameOf.ModifiedDate), nameof(nameOf.ModifiedDate)); grid.Columns.Add(nameof(nameOf.ModifiedBy), nameof(nameOf.ModifiedBy)); grid.Columns.Add(nameof(nameOf.CountStuffs), nameof(nameOf.CountStuffs)); for (int i = 0; i < stuffs.Count; i++) { grid.Rows.Add(); grid[nameof(nameOf.Name), i].Value = stuffs[i].Name; grid[nameof(nameOf.CreatedDate), i].Value = stuffs[i].CreatedDate; grid[nameof(nameOf.CreatedBy), i].Value = stuffs[i].CreatedBy; grid[nameof(nameOf.ModifiedDate), i].Value = stuffs[i].ModifiedDate.ToString() == "01-Jan-01 12:00:00 AM" ? "" : stuffs[i].ModifiedDate.ToString(); grid[nameof(nameOf.ModifiedBy), i].Value = stuffs[i].ModifiedBy; grid[nameof(nameOf.CountStuffs), i].Value = stuffs[i].CountStuffs; } }
// Method ListForExcel public void ListForExcel(MetroGrid grid, string keyword, string sortColumn, string sortBy) { grid.Rows.Clear(); grid.Columns.Clear(); List <PlaceStuffsModel> stuffs = PlaceStuffsDao.Instance.ListForExcel(keyword, !string.IsNullOrEmpty(sortColumn) ? HelperBll.GetColumnNameInSQLByPropertyName <PlaceStuffsModel>(sortColumn) : "", sortBy); PlaceStuffsModel nameOf = new PlaceStuffsModel(); grid.Columns.Add(nameof(nameOf.Name), nameof(nameOf.Name)); grid.Columns.Add(nameof(nameOf.CountStuffs), nameof(nameOf.CountStuffs)); for (int i = 0; i < stuffs.Count; i++) { grid.Rows.Add(); grid[nameof(nameOf.Name), i].Value = stuffs[i].Name; grid[nameof(nameOf.CountStuffs), i].Value = stuffs[i].CountStuffs; } }
// Method ListForExcel public void ListForExcel(MetroGrid grid, string keyword, string sortColumn, string sortBy, string columnFilter, object filterValue) { grid.Rows.Clear(); grid.Columns.Clear(); List <UsersModel> stuffs = UsersDao.Instance.ListForExcel(keyword, !string.IsNullOrEmpty(sortColumn) ? HelperBll.GetColumnNameInSQLByPropertyName <UsersModel>(sortColumn) : "", sortBy, !string.IsNullOrEmpty(columnFilter) ? HelperBll.GetColumnNameInSQLByPropertyName <UsersModel>(columnFilter) : "", filterValue); UsersModel nameOf = new UsersModel(); grid.Columns.Add(nameof(nameOf.Name), nameof(nameOf.Name)); grid.Columns.Add(nameof(nameOf.RoleName), nameof(nameOf.RoleName)); grid.Columns.Add(nameof(nameOf.Sex), nameof(nameOf.Sex)); grid.Columns.Add(nameof(nameOf.BirthOfDate), nameof(nameOf.BirthOfDate)); grid.Columns.Add(nameof(nameOf.Email), nameof(nameOf.Email)); grid.Columns.Add(nameof(nameOf.PhoneNumber), nameof(nameOf.PhoneNumber)); grid.Columns.Add(nameof(nameOf.Status), nameof(nameOf.Status)); grid.Columns.Add(nameof(nameOf.CreatedDate), nameof(nameOf.CreatedDate)); grid.Columns.Add(nameof(nameOf.CreatedBy), nameof(nameOf.CreatedBy)); grid.Columns.Add(nameof(nameOf.ModifiedDate), nameof(nameOf.ModifiedDate)); grid.Columns.Add(nameof(nameOf.ModifiedBy), nameof(nameOf.ModifiedBy)); for (int i = 0; i < stuffs.Count; i++) { grid.Rows.Add(); grid[nameof(nameOf.Name), i].Value = stuffs[i].Name; grid[nameof(nameOf.RoleName), i].Value = stuffs[i].RoleName; grid[nameof(nameOf.Sex), i].Value = stuffs[i].Sex ? "Nam" : "Nữ"; grid[nameof(nameOf.BirthOfDate), i].Value = stuffs[i].BirthOfDate; grid[nameof(nameOf.Email), i].Value = stuffs[i].Email; grid[nameof(nameOf.PhoneNumber), i].Value = stuffs[i].PhoneNumber; grid[nameof(nameOf.Status), i].Value = stuffs[i].Status ? "Kích hoạt" : "Khóa"; grid[nameof(nameOf.CreatedDate), i].Value = stuffs[i].CreatedDate; grid[nameof(nameOf.CreatedBy), i].Value = stuffs[i].CreatedBy; grid[nameof(nameOf.ModifiedDate), i].Value = stuffs[i].ModifiedDate.ToString() == "01-Jan-01 12:00:00 AM" ? "" : stuffs[i].ModifiedDate.ToString(); grid[nameof(nameOf.ModifiedBy), i].Value = stuffs[i].ModifiedBy; } }