You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
4.2 KiB
C#
158 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using XGL.Data;
|
|
using XGL.Models;
|
|
|
|
namespace XGL
|
|
{
|
|
public class CommonHelper
|
|
{
|
|
|
|
|
|
public static string UserName = "";
|
|
public static string MyServerStr = "";
|
|
public static string workPostNo = "";
|
|
public static string lineId = "";
|
|
public static DateTime LoginDt;
|
|
|
|
public static string LocalIP = "";
|
|
public static string LocalPort = "";
|
|
|
|
public static string ThriftIp = "";
|
|
public static string ThriftPort = "";
|
|
|
|
public static string ComPort = "";
|
|
|
|
public static string IsStopLine = "";
|
|
|
|
public static string PortNamestop = "";
|
|
|
|
public static DataTable UserPermissions = null;
|
|
|
|
public static void CheckPermition(Button btn, string Permition)
|
|
{
|
|
DataRow[] drs = UserPermissions.Select("Code='" + Permition + "'");
|
|
if (drs.Length > 0)
|
|
{
|
|
btn.Visibility = System.Windows.Visibility.Visible;
|
|
}
|
|
}
|
|
|
|
public static bool IsHasRole(int userId)
|
|
{
|
|
bool ret = true;
|
|
using (common_auth_userroleDb userroleDB = new common_auth_userroleDb())
|
|
{
|
|
|
|
List<common_auth_userroleModel> Items = userroleDB.GetList(" UserId=" + userId + " AND RoleId=3");
|
|
if (Items.Count > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
ret = false;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
public static bool IsHasRole(int UserId, int RoleId)
|
|
{
|
|
bool ret = true;
|
|
using (common_auth_userroleDb userroleDB = new common_auth_userroleDb())
|
|
{
|
|
|
|
List<common_auth_userroleModel> Items = userroleDB.GetList(" UserId=" + UserId + " AND RoleId=" + RoleId);
|
|
if (Items.Count > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
ret = false;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
public static bool IsHavePermition(string Permition)
|
|
{
|
|
bool ret = true;
|
|
DataRow[] drs = UserPermissions.Select("Code='" + Permition + "'");
|
|
if (drs.Length > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
ret = false;
|
|
}
|
|
return ret;
|
|
}
|
|
public static void GetUserPermissions(string loginname)
|
|
{
|
|
using (common_auth_rolemodulepermissionDb rolemodulepermissionDB = new common_auth_rolemodulepermissionDb())
|
|
{
|
|
UserPermissions = rolemodulepermissionDB.GetUserPermissions(loginname).Tables[0];
|
|
}
|
|
|
|
}
|
|
|
|
public static bool IsHavePermition(string FormCode, string Permition)
|
|
{
|
|
bool ret = true;
|
|
DataRow[] drs = UserPermissions.Select("FormCode='" + FormCode + "' AND Code='" + Permition + "'");
|
|
if (drs.Length > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
ret = false;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取周次
|
|
/// </summary>
|
|
/// <param name="dt"></param>
|
|
/// <param name="ci"></param>
|
|
/// <returns></returns>
|
|
public static int WeekOfYear(DateTime dt, CultureInfo ci)
|
|
{
|
|
return ci.Calendar.GetWeekOfYear(dt, ci.DateTimeFormat.CalendarWeekRule, ci.DateTimeFormat.FirstDayOfWeek);
|
|
}
|
|
|
|
public static Color GetColor(double value)
|
|
{
|
|
if (value <= 50)
|
|
{
|
|
return Colors.Green;
|
|
}
|
|
else if (value <= 70)
|
|
{
|
|
return Colors.Yellow;
|
|
}
|
|
else
|
|
{
|
|
return Colors.Red;
|
|
}
|
|
}
|
|
|
|
public static string GetStoreType(int StoreType)
|
|
{
|
|
if (StoreType == 1)
|
|
return "(单一)";
|
|
else
|
|
return "(混合)";
|
|
}
|
|
}
|
|
}
|