|
@ -28,6 +28,9 @@ using NPOI.XSSF.UserModel; |
|
|
using NPOI.SS.Util; |
|
|
using NPOI.SS.Util; |
|
|
using static CK.SCP.Controller.SCP_COM_CONTROLLER; |
|
|
using static CK.SCP.Controller.SCP_COM_CONTROLLER; |
|
|
using CK.SCP.Models.Enums; |
|
|
using CK.SCP.Models.Enums; |
|
|
|
|
|
using SCP.Common; |
|
|
|
|
|
using System.Drawing.Imaging; |
|
|
|
|
|
using System.Drawing; |
|
|
|
|
|
|
|
|
namespace SCP |
|
|
namespace SCP |
|
|
{ |
|
|
{ |
|
@ -151,7 +154,7 @@ namespace SCP |
|
|
protected void BindVender(DropDownList p_dl) |
|
|
protected void BindVender(DropDownList p_dl) |
|
|
{ |
|
|
{ |
|
|
var _entity = CurrentUser.FactoryList.FirstOrDefault(); |
|
|
var _entity = CurrentUser.FactoryList.FirstOrDefault(); |
|
|
var ls= SCP_TB_VENDER_CONTROLLER.Getlist(_entity); |
|
|
var ls = SCP_TB_VENDER_CONTROLLER.Getlist(_entity); |
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_entity)) |
|
|
if (!string.IsNullOrEmpty(_entity)) |
|
|
{ |
|
|
{ |
|
@ -198,11 +201,11 @@ namespace SCP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 表格相关
|
|
|
#region 表格相关
|
|
|
|
|
|
|
|
|
protected int GetSelectedDataKeyID(Grid grid) |
|
|
protected int GetSelectedDataKeyID(Grid grid) |
|
|
{ |
|
|
{ |
|
|
int id = -1; |
|
|
int id = -1; |
|
|
int rowIndex = grid.SelectedRowIndex; |
|
|
int rowIndex = grid.SelectedRowIndex; |
|
@ -440,9 +443,9 @@ namespace SCP |
|
|
{ |
|
|
{ |
|
|
return q.SortBy(grid.SortField + " " + grid.SortDirection); |
|
|
return q.SortBy(grid.SortField + " " + grid.SortDirection); |
|
|
} |
|
|
} |
|
|
protected IQueryable<T> Sort<T>(IQueryable<T> q, FineUI.Grid grid,string p_asc) |
|
|
protected IQueryable<T> Sort<T>(IQueryable<T> q, FineUI.Grid grid, string p_asc) |
|
|
{ |
|
|
{ |
|
|
return q.SortBy(grid.SortField,p_asc); |
|
|
return q.SortBy(grid.SortField, p_asc); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 排序后分页
|
|
|
// 排序后分页
|
|
@ -457,14 +460,14 @@ namespace SCP |
|
|
return Sort(q, grid).Skip(grid.PageIndex * grid.PageSize).Take(grid.PageSize); |
|
|
return Sort(q, grid).Skip(grid.PageIndex * grid.PageSize).Take(grid.PageSize); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected IQueryable<T> SortAndPage<T>(IQueryable<T> q, FineUI.Grid grid,string p_asc) |
|
|
protected IQueryable<T> SortAndPage<T>(IQueryable<T> q, FineUI.Grid grid, string p_asc) |
|
|
{ |
|
|
{ |
|
|
if (grid.PageIndex >= grid.PageCount && grid.PageCount >= 1) |
|
|
if (grid.PageIndex >= grid.PageCount && grid.PageCount >= 1) |
|
|
{ |
|
|
{ |
|
|
grid.PageIndex = grid.PageCount - 1; |
|
|
grid.PageIndex = grid.PageCount - 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return Sort(q, grid,p_asc).Skip(grid.PageIndex * grid.PageSize).Take(grid.PageSize); |
|
|
return Sort(q, grid, p_asc).Skip(grid.PageIndex * grid.PageSize).Take(grid.PageSize); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected DataSet SortAndPage(GridPageSearch p_search, FineUI.Grid grid) |
|
|
protected DataSet SortAndPage(GridPageSearch p_search, FineUI.Grid grid) |
|
@ -635,7 +638,7 @@ namespace SCP |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Session["CurrentUser"] = _currentUser; |
|
|
Session["CurrentUser"] = _currentUser; |
|
|
} |
|
|
} |
|
|
return (User)Session["CurrentUser"]; |
|
|
return (User)Session["CurrentUser"]; |
|
@ -1334,7 +1337,7 @@ namespace SCP |
|
|
itm.Text = GetResourceKey(itm.Text); |
|
|
itm.Text = GetResourceKey(itm.Text); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(p_crtl is RadioButtonList) |
|
|
if (p_crtl is RadioButtonList) |
|
|
{ |
|
|
{ |
|
|
RadioButtonList _rb = p_crtl as RadioButtonList; |
|
|
RadioButtonList _rb = p_crtl as RadioButtonList; |
|
|
_rb.Label = GetResourceKey(_rb.Label); |
|
|
_rb.Label = GetResourceKey(_rb.Label); |
|
@ -1348,19 +1351,19 @@ namespace SCP |
|
|
DatePicker _date = p_crtl as DatePicker; |
|
|
DatePicker _date = p_crtl as DatePicker; |
|
|
_date.Label = GetResourceKey(_date.Label); |
|
|
_date.Label = GetResourceKey(_date.Label); |
|
|
} |
|
|
} |
|
|
if(p_crtl is CheckBoxList) |
|
|
if (p_crtl is CheckBoxList) |
|
|
{ |
|
|
{ |
|
|
CheckBoxList _cbl= p_crtl as CheckBoxList; |
|
|
CheckBoxList _cbl = p_crtl as CheckBoxList; |
|
|
_cbl.Label = GetResourceKey(_cbl.Label); |
|
|
_cbl.Label = GetResourceKey(_cbl.Label); |
|
|
} |
|
|
} |
|
|
if (p_crtl is FineUI.Region) |
|
|
if (p_crtl is FineUI.Region) |
|
|
{ |
|
|
{ |
|
|
FineUI.Region _region = p_crtl as FineUI.Region; |
|
|
FineUI.Region _region = p_crtl as FineUI.Region; |
|
|
_region.Title = GetResourceKey(_region.Title); |
|
|
_region.Title = GetResourceKey(_region.Title); |
|
|
} |
|
|
} |
|
|
if (p_crtl is Tab) |
|
|
if (p_crtl is Tab) |
|
|
{ |
|
|
{ |
|
|
Tab _tab= p_crtl as Tab; |
|
|
Tab _tab = p_crtl as Tab; |
|
|
_tab.Title = GetResourceKey(_tab.Title); |
|
|
_tab.Title = GetResourceKey(_tab.Title); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1376,7 +1379,7 @@ namespace SCP |
|
|
FormRow _formrow = p_crtl as FormRow; |
|
|
FormRow _formrow = p_crtl as FormRow; |
|
|
foreach (var item in _formrow.Items) |
|
|
foreach (var item in _formrow.Items) |
|
|
{ |
|
|
{ |
|
|
TranslatorAgent(item); |
|
|
TranslatorAgent(item); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (p_crtl is Toolbar) |
|
|
if (p_crtl is Toolbar) |
|
@ -1390,7 +1393,7 @@ namespace SCP |
|
|
if (p_crtl is Panel) |
|
|
if (p_crtl is Panel) |
|
|
{ |
|
|
{ |
|
|
var _toolbar = p_crtl as Panel; |
|
|
var _toolbar = p_crtl as Panel; |
|
|
_toolbar.Title= GetResourceKey(_toolbar.Title); |
|
|
_toolbar.Title = GetResourceKey(_toolbar.Title); |
|
|
foreach (var item in _toolbar.Items) |
|
|
foreach (var item in _toolbar.Items) |
|
|
{ |
|
|
{ |
|
|
TranslatorAgent(item); |
|
|
TranslatorAgent(item); |
|
@ -1543,7 +1546,7 @@ namespace SCP |
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
public static string EntityListToExcel2003(Dictionary<string, string> cellHeard, IList enList, string sheetName,string title=null) |
|
|
public static string EntityListToExcel2003(Dictionary<string, string> cellHeard, IList enList, string sheetName, string title = null) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -1582,7 +1585,7 @@ namespace SCP |
|
|
row1.CreateCell(i).SetCellValue(cellHeard[keys[i]]); // 列名为Key的值
|
|
|
row1.CreateCell(i).SetCellValue(cellHeard[keys[i]]); // 列名为Key的值
|
|
|
} |
|
|
} |
|
|
// 3.List对象的值赋值到Excel的单元格里
|
|
|
// 3.List对象的值赋值到Excel的单元格里
|
|
|
int rowIndex = _index+1; // 从第二行开始赋值(第一行已设置为单元头)
|
|
|
int rowIndex = _index + 1; // 从第二行开始赋值(第一行已设置为单元头)
|
|
|
foreach (var en in enList) |
|
|
foreach (var en in enList) |
|
|
{ |
|
|
{ |
|
|
IRow rowTmp = sheet.CreateRow(rowIndex); |
|
|
IRow rowTmp = sheet.CreateRow(rowIndex); |
|
@ -1707,12 +1710,13 @@ namespace SCP |
|
|
throw ex; |
|
|
throw ex; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
public static void DataSetToExcel(DataSet p_dataset, string sheetName,string title = null) |
|
|
public static void DataSetToExcel(DataSet p_dataset, string sheetName, string title = null) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
EpPlusHelper _helper = new EpPlusHelper(); |
|
|
EpPlusHelper _helper = new EpPlusHelper(); |
|
|
_helper.ExportExcelCompleted += (filePath,fileName) => { |
|
|
_helper.ExportExcelCompleted += (filePath, fileName) => |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
Alert.Show($"<a href=\'/exportfiles/{fileName}\'>{fileName}</a>", "文件导出成功,请点击文件名下载", MessageBoxIcon.Information); |
|
|
Alert.Show($"<a href=\'/exportfiles/{fileName}\'>{fileName}</a>", "文件导出成功,请点击文件名下载", MessageBoxIcon.Information); |
|
|
|
|
|
|
|
@ -1724,7 +1728,7 @@ namespace SCP |
|
|
throw ex; |
|
|
throw ex; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
protected void DisplayColumn(Grid p_grid,bool p_visible, params string[] p_header) |
|
|
protected void DisplayColumn(Grid p_grid, bool p_visible, params string[] p_header) |
|
|
{ |
|
|
{ |
|
|
foreach (var itm in p_grid.Columns) |
|
|
foreach (var itm in p_grid.Columns) |
|
|
{ |
|
|
{ |
|
@ -1735,5 +1739,99 @@ namespace SCP |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前账号页面列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static List<string> GetMenus(int Id) |
|
|
|
|
|
{ |
|
|
|
|
|
List<string> Menus = new List<string>(); |
|
|
|
|
|
using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance()) |
|
|
|
|
|
{ |
|
|
|
|
|
StringBuilder _buffer = new StringBuilder(); |
|
|
|
|
|
_buffer.Append(" select Name from Menus where ViewPowerID in( "); |
|
|
|
|
|
_buffer.Append(" select powerID from RolePowers where RoleID in( "); |
|
|
|
|
|
_buffer.AppendFormat(" select RoleID from RoleUsers where UserID = '{0}' )) ", Id); |
|
|
|
|
|
Menus = db.Database.SqlQuery<string>(_buffer.ToString()).ToList(); |
|
|
|
|
|
} |
|
|
|
|
|
return Menus; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 生成验证码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="lengths">长度</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string RandomVerificationCode(int lengths) |
|
|
|
|
|
{ |
|
|
|
|
|
string[] chars = new string[] { "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "P", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; |
|
|
|
|
|
string code = ""; |
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
for (int i = 0; i < lengths; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
code += chars[random.Next(chars.Length)]; |
|
|
|
|
|
} |
|
|
|
|
|
return code; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 绘制验证码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="code"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static Bitmap DrawImage(string code) |
|
|
|
|
|
{ |
|
|
|
|
|
Color[] colors = { |
|
|
|
|
|
Color.Red, Color.OrangeRed,Color.SaddleBrown, |
|
|
|
|
|
Color.LimeGreen,Color.Green,Color.MediumAquamarine, |
|
|
|
|
|
Color.Blue,Color.MediumOrchid,Color.Black, |
|
|
|
|
|
Color.DarkBlue,Color.Orange,Color.Brown, |
|
|
|
|
|
Color.DarkCyan,Color.Purple |
|
|
|
|
|
}; |
|
|
|
|
|
string[] fonts = { "Verdana", "Microsoft Sans Serif", "Comic Sans MS", "Arial", "宋体" }; |
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
// 创建一个 Bitmap 图片类型对象
|
|
|
|
|
|
Bitmap bitmap = new Bitmap(code.Length * 18, 32); |
|
|
|
|
|
// 创建一个图形画笔
|
|
|
|
|
|
Graphics graphics = Graphics.FromImage(bitmap); |
|
|
|
|
|
// 将图片背景填充成白色
|
|
|
|
|
|
graphics.Clear(Color.White); |
|
|
|
|
|
// 绘制验证码噪点
|
|
|
|
|
|
for (int i = 0; i < random.Next(60, 80); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
int pointX = random.Next(bitmap.Width); |
|
|
|
|
|
int pointY = random.Next(bitmap.Height); |
|
|
|
|
|
graphics.DrawLine(new Pen(Color.LightGray, 1), pointX, pointY, pointX + 1, pointY); |
|
|
|
|
|
} |
|
|
|
|
|
// 绘制验证码
|
|
|
|
|
|
for (int i = 0; i < code.Length; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
graphics.DrawString( |
|
|
|
|
|
code.Substring(i, 1), |
|
|
|
|
|
new Font(fonts[random.Next(fonts.Length)], 15, FontStyle.Bold), |
|
|
|
|
|
new SolidBrush(colors[random.Next(colors.Length)]), |
|
|
|
|
|
16 * i + 1, |
|
|
|
|
|
random.Next(0, 5) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
return bitmap; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 返回图片
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="bitmap"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string BitmapToBase64Str(Bitmap bitmap) |
|
|
|
|
|
{ |
|
|
|
|
|
using (MemoryStream memoryStream = new MemoryStream()) |
|
|
|
|
|
{ |
|
|
|
|
|
bitmap.Save(memoryStream, ImageFormat.Jpeg); |
|
|
|
|
|
byte[] bytes = memoryStream.ToArray(); |
|
|
|
|
|
return Convert.ToBase64String(memoryStream.ToArray()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |