|
|
@ -28,6 +28,9 @@ using NPOI.XSSF.UserModel; |
|
|
|
using NPOI.SS.Util; |
|
|
|
using static CK.SCP.Controller.SCP_COM_CONTROLLER; |
|
|
|
using CK.SCP.Models.Enums; |
|
|
|
using SCP.Common; |
|
|
|
using System.Drawing.Imaging; |
|
|
|
using System.Drawing; |
|
|
|
|
|
|
|
namespace SCP |
|
|
|
{ |
|
|
@ -151,7 +154,7 @@ namespace SCP |
|
|
|
protected void BindVender(DropDownList p_dl) |
|
|
|
{ |
|
|
|
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)) |
|
|
|
{ |
|
|
@ -159,7 +162,7 @@ namespace SCP |
|
|
|
if (_entity == "CNS") |
|
|
|
{ |
|
|
|
lsVender = ls.Where(p => p.VendId.Substring(0, 1) == "R" || p.VendId.Substring(0, 1) == "E").ToList(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
lsVender.ForEach(p => |
|
|
|
{ |
|
|
@ -172,7 +175,7 @@ namespace SCP |
|
|
|
p_dl.Items.Insert(0, new FineUI.ListItem("--无供应商--", string.Empty)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -198,11 +201,11 @@ namespace SCP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 表格相关
|
|
|
|
|
|
|
|
protected int GetSelectedDataKeyID(Grid grid) |
|
|
|
protected int GetSelectedDataKeyID(Grid grid) |
|
|
|
{ |
|
|
|
int id = -1; |
|
|
|
int rowIndex = grid.SelectedRowIndex; |
|
|
@ -440,9 +443,9 @@ namespace SCP |
|
|
|
{ |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
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) |
|
|
|
{ |
|
|
|
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) |
|
|
@ -485,7 +488,7 @@ namespace SCP |
|
|
|
|
|
|
|
//return Sort(q, grid, p_asc).Skip(grid.PageIndex * grid.PageSize).Take(grid.PageSize);
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -635,7 +638,7 @@ namespace SCP |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Session["CurrentUser"] = _currentUser; |
|
|
|
} |
|
|
|
return (User)Session["CurrentUser"]; |
|
|
@ -1232,7 +1235,7 @@ namespace SCP |
|
|
|
/// <returns>返回实际语言翻译完成</returns>
|
|
|
|
protected string GetResourceKey(string p_key) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
string _content = p_key; |
|
|
|
if (!string.IsNullOrEmpty(p_key)) |
|
|
|
{ |
|
|
@ -1304,7 +1307,7 @@ namespace SCP |
|
|
|
itm.HeaderText = GetResourceKey(itm.HeaderText); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (p_crtl is Button) |
|
|
|
{ |
|
|
|
Button _btn = p_crtl as Button; |
|
|
@ -1334,7 +1337,7 @@ namespace SCP |
|
|
|
itm.Text = GetResourceKey(itm.Text); |
|
|
|
} |
|
|
|
} |
|
|
|
if(p_crtl is RadioButtonList) |
|
|
|
if (p_crtl is RadioButtonList) |
|
|
|
{ |
|
|
|
RadioButtonList _rb = p_crtl as RadioButtonList; |
|
|
|
_rb.Label = GetResourceKey(_rb.Label); |
|
|
@ -1348,22 +1351,22 @@ namespace SCP |
|
|
|
DatePicker _date = p_crtl as DatePicker; |
|
|
|
_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); |
|
|
|
} |
|
|
|
if (p_crtl is 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) |
|
|
|
{ |
|
|
|
Tab _tab= p_crtl as Tab; |
|
|
|
Tab _tab = p_crtl as Tab; |
|
|
|
_tab.Title = GetResourceKey(_tab.Title); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1375,8 +1378,8 @@ namespace SCP |
|
|
|
{ |
|
|
|
FormRow _formrow = p_crtl as FormRow; |
|
|
|
foreach (var item in _formrow.Items) |
|
|
|
{ |
|
|
|
TranslatorAgent(item); |
|
|
|
{ |
|
|
|
TranslatorAgent(item); |
|
|
|
} |
|
|
|
} |
|
|
|
if (p_crtl is Toolbar) |
|
|
@ -1390,7 +1393,7 @@ namespace SCP |
|
|
|
if (p_crtl is Panel) |
|
|
|
{ |
|
|
|
var _toolbar = p_crtl as Panel; |
|
|
|
_toolbar.Title= GetResourceKey(_toolbar.Title); |
|
|
|
_toolbar.Title = GetResourceKey(_toolbar.Title); |
|
|
|
foreach (var item in _toolbar.Items) |
|
|
|
{ |
|
|
|
TranslatorAgent(item); |
|
|
@ -1407,7 +1410,7 @@ namespace SCP |
|
|
|
string[] allowedExtensions = { ".jpg", ".gif", ".jpeg", ".png", ".rar", ".zip", ".flv", ".doc", ".docx", ".xls", ".xlsx", ".pdf", ".cad", ".txt" };//允许上传的文件类型
|
|
|
|
|
|
|
|
string filename = ""; //MyWebString.GetOrderNumber();
|
|
|
|
|
|
|
|
|
|
|
|
bool fileOK = false; |
|
|
|
string fileExtension = System.IO.Path.GetExtension(fUpload.FileName).ToLower(); |
|
|
|
for (int i = 0; i < allowedExtensions.Length; i++) |
|
|
@ -1543,7 +1546,7 @@ namespace SCP |
|
|
|
|
|
|
|
#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 |
|
|
|
{ |
|
|
@ -1561,7 +1564,7 @@ namespace SCP |
|
|
|
ISheet sheet = workbook.CreateSheet(sheetName); // 工作表
|
|
|
|
List<string> keys = cellHeard.Keys.ToList(); |
|
|
|
if (title != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IRow row = sheet.CreateRow(0); |
|
|
|
ICell cell = row.CreateCell(0); |
|
|
|
ICellStyle style = workbook.CreateCellStyle(); |
|
|
@ -1576,13 +1579,13 @@ namespace SCP |
|
|
|
_index++; |
|
|
|
} |
|
|
|
// 2.解析单元格头部,设置单元头的中文名称
|
|
|
|
IRow row1 = sheet.CreateRow(_index); |
|
|
|
IRow row1 = sheet.CreateRow(_index); |
|
|
|
for (int i = 0; i < keys.Count; i++) |
|
|
|
{ |
|
|
|
row1.CreateCell(i).SetCellValue(cellHeard[keys[i]]); // 列名为Key的值
|
|
|
|
} |
|
|
|
// 3.List对象的值赋值到Excel的单元格里
|
|
|
|
int rowIndex = _index+1; // 从第二行开始赋值(第一行已设置为单元头)
|
|
|
|
int rowIndex = _index + 1; // 从第二行开始赋值(第一行已设置为单元头)
|
|
|
|
foreach (var en in enList) |
|
|
|
{ |
|
|
|
IRow rowTmp = sheet.CreateRow(rowIndex); |
|
|
@ -1707,24 +1710,25 @@ namespace SCP |
|
|
|
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 |
|
|
|
{ |
|
|
|
EpPlusHelper _helper = new EpPlusHelper(); |
|
|
|
_helper.ExportExcelCompleted += (filePath,fileName) => { |
|
|
|
_helper.ExportExcelCompleted += (filePath, fileName) => |
|
|
|
{ |
|
|
|
|
|
|
|
Alert.Show($"<a href=\'/exportfiles/{fileName}\'>{fileName}</a>", "文件导出成功,请点击文件名下载", MessageBoxIcon.Information); |
|
|
|
|
|
|
|
}; |
|
|
|
_helper.WriteDsToExcel(sheetName, p_dataset, title); |
|
|
|
_helper.WriteDsToExcel(sheetName, p_dataset, title); |
|
|
|
} |
|
|
|
catch (Exception 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) |
|
|
|
{ |
|
|
@ -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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |