236 lines
7.6 KiB
C#
236 lines
7.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraBars;
|
|
using DeviceRepair.Models.Device;
|
|
using TsSFCDevice.Client.Biz.Base.Utils;
|
|
using DevExpress.XtraEditors;
|
|
using TsSFCDevice.Client.Biz.Impl;
|
|
using TsSFCDevice.Client.Launch.FormatProviderExtend;
|
|
|
|
namespace TsSFCDevice.Client.Launch.Device
|
|
{
|
|
public partial class pageDeviceTreeView : DevExpress.XtraBars.Ribbon.RibbonForm
|
|
{
|
|
#region 属性&字段
|
|
|
|
/// <summary>
|
|
/// 按钮图标
|
|
/// </summary>
|
|
Dictionary<string, Image> Icons = new Dictionary<string, Image>
|
|
{
|
|
{ "Lock",DevExpress.Images.ImageResourceCache.Default.GetImageById(DevExpress.Images.DXImages.Cancel,DevExpress.Utils.Design.ImageSize.Size32x32,DevExpress.Utils.Design.ImageType.Colored) },
|
|
{ "UnLock",DevExpress.Images.ImageResourceCache.Default.GetImageById(DevExpress.Images.DXImages.Apply,DevExpress.Utils.Design.ImageSize.Size32x32,DevExpress.Utils.Design.ImageType.Colored) },
|
|
};
|
|
|
|
public IList<DeviceInformationInfoTree> Datas { get; set; }
|
|
|
|
private DeviceInformationInfoTree m_CurrentModel;
|
|
|
|
private string parEquipmentID { get { return baripsEquipmentID.EditValue + ""; } }
|
|
|
|
|
|
#endregion
|
|
|
|
#region 函数
|
|
|
|
public pageDeviceTreeView()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 事件
|
|
|
|
/// <summary>
|
|
/// 窗体加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void pageDeviceTreeView_Load(object sender, EventArgs e)
|
|
{
|
|
ribbon.AllowCustomization = false;
|
|
ribbon.AllowMinimizeRibbon = false;
|
|
|
|
// 关闭列头右键菜单
|
|
treeList1.OptionsMenu.EnableColumnMenu = false;
|
|
treeList1.OptionsBehavior.Editable = false;
|
|
treeList1.OptionsBehavior.ReadOnly = true;
|
|
treeList1.OptionsSelection.EnableAppearanceFocusedCell = false;
|
|
treeList1.OptionsScrollAnnotations.ShowSelectedRows = DevExpress.Utils.DefaultBoolean.False;
|
|
|
|
#region 状态格式化
|
|
gcEquipmentStatus.Format.FormatType = DevExpress.Utils.FormatType.Custom;
|
|
gcEquipmentStatus.Format.Format = new StatusFormatter();
|
|
gcEquipmentStatus.Format.FormatString = "device";
|
|
#endregion
|
|
|
|
#region 根据权限隐藏按钮
|
|
if (!Utility.SystemRuntimeInfo.AuthValidate(OperationAuthConstValue.PM_Device_KH)
|
|
&& !Utility.SystemRuntimeInfo.AuthValidate(OperationAuthConstValue.PM_Device_OEM)
|
|
)
|
|
{
|
|
barSearch.Visibility = BarItemVisibility.Never;
|
|
barRefresh.Visibility = BarItemVisibility.Never;
|
|
}
|
|
|
|
|
|
if (!Utility.SystemRuntimeInfo.AuthValidate(OperationAuthConstValue.PM_Device_ADD))
|
|
{
|
|
barInsert.Visibility = BarItemVisibility.Never;
|
|
}
|
|
|
|
|
|
if (!Utility.SystemRuntimeInfo.AuthValidate(OperationAuthConstValue.PM_Device_Edit))
|
|
{
|
|
barEdit.Visibility = BarItemVisibility.Never;
|
|
}
|
|
|
|
|
|
if (!Utility.SystemRuntimeInfo.AuthValidate(OperationAuthConstValue.PM_Device_Status))
|
|
{
|
|
barEditStatus.Visibility = BarItemVisibility.Never;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// 搜索
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void barSearch_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
InitializeGridData();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBoxHelper.Error(ex.Message, "出错");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void barRefresh_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Utility.SystemRuntimeInfo.CurrentDeviceCaches = null;
|
|
Utility.SystemRuntimeInfo.CurrentUsersCaches = null;
|
|
InitializeGridData();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBoxHelper.Error(ex.Message, "出错");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void barInsert_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void barEdit_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改状态
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void barEditStatus_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击清空
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ipsEquipmentID_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
((sender as ButtonEdit)).EditValue = "";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 方法
|
|
|
|
/// <summary>
|
|
/// 数据查询
|
|
/// </summary>
|
|
public void InitializeGridData()
|
|
{
|
|
try
|
|
{
|
|
splashScreenManager1.ShowWaitForm();
|
|
m_CurrentModel = null;
|
|
|
|
List<string> auths = new List<string>();
|
|
if (Utility.SystemRuntimeInfo.AuthValidate(Utility.SystemRuntimeInfo.DEVICE_OEM))
|
|
auths.Add("OEM");
|
|
if (Utility.SystemRuntimeInfo.AuthValidate(Utility.SystemRuntimeInfo.DEVICE_KH))
|
|
auths.Add("KH");
|
|
|
|
DevRepository devDa = new DevRepository();
|
|
IList<DeviceInformationInfoTree> Datas = devDa.GetTreeDatas(auths, parEquipmentID);
|
|
Datas = Datas.ToList();
|
|
|
|
treeList1.DataSource = Datas;
|
|
treeList1.KeyFieldName = "RouteAutoId";
|
|
treeList1.ParentFieldName = "ParentRouteId";
|
|
treeList1.ExpandAll();
|
|
treeList1.BestFitColumns();
|
|
|
|
splashScreenManager1.CloseWaitForm();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
splashScreenManager1.CloseWaitForm();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void treeList1_RowCellClick(object sender, DevExpress.XtraTreeList.RowCellClickEventArgs e)
|
|
{
|
|
m_CurrentModel = treeList1.GetRow(e.Node.Id) as DeviceInformationInfoTree;
|
|
|
|
if (m_CurrentModel != null)
|
|
{
|
|
barEdit.Enabled = m_CurrentModel.EquipmentStatus > 0;
|
|
barEditStatus.Enabled = true;
|
|
|
|
barEditStatus.Caption = m_CurrentModel.EquipmentStatus > 0 ? "禁用" : "启用";
|
|
barEditStatus.ImageOptions.Image = m_CurrentModel.EquipmentStatus > 0 ? Icons["Lock"] : Icons["UnLock"];
|
|
barEditStatus.ImageOptions.LargeImage = m_CurrentModel.EquipmentStatus > 0 ? Icons["Lock"] : Icons["UnLock"];
|
|
}
|
|
}
|
|
}
|
|
} |