using DevExpress.XtraTreeList;
|
using DevExpress.XtraTreeList.Nodes;
|
using Gs.DevApp.DevFrm.QC;
|
using Gs.DevApp.Entity;
|
using Gs.DevApp.ToolBox;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Windows.Forms;
|
|
namespace Gs.DevApp.DevFrm
|
{
|
public partial class Frm_MesDefectCode : DevExpress.XtraEditors.XtraForm
|
{
|
string _webServiceName = "MesDefectCodeManager/";
|
List<FilterEntity> _filterList = new List<FilterEntity>();
|
public Frm_MesDefectCode()
|
{
|
InitializeComponent();
|
tlMenu.ContextMenuStrip = contextMenuStrip1;
|
toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
|
this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
|
this.toolBarMenu1.getXmlConfig();
|
tlMenu.IndicatorWidth = 50;
|
tlMenu.CustomDrawNodeIndicator += (s, ee) =>
|
{
|
if (ee.IsNodeIndicator)
|
{
|
var index = ee.Node.TreeList.GetVisibleIndexByNode(ee.Node);
|
ee.Info.DisplayText = (index + 1).ToString();
|
}
|
};
|
getPageList(1);
|
this.tlMenu.MouseDown += TlMenu_MouseDown;
|
this.toolStripMenuItemAdd.Click += (s, ee) =>
|
{
|
string strGuid = "";
|
string strUpGuid = "";
|
if (tlMenu.FocusedNode != null)
|
{
|
strUpGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
|
}
|
Frm_MesDefectCodeShow frm = new Frm_MesDefectCodeShow(strGuid, "增加子项", strUpGuid);
|
frm.UpdateParent += (s2, ee2) =>
|
{
|
getPageList(1);
|
};
|
frm.ShowDialog();
|
};
|
this.toolStripMenuItemRoot.Click += (s, ee) =>
|
{
|
string strGuid = "";
|
string strUpGuid = "";
|
Frm_MesDefectCodeShow frm = new Frm_MesDefectCodeShow(strGuid, "增加项目", strUpGuid);
|
frm.UpdateParent += (s2, ee2) =>
|
{
|
getPageList(1);
|
};
|
frm.ShowDialog();
|
};
|
this.toolStripMenuItemDel.Click += (s, ee) =>
|
{
|
if (tlMenu.FocusedNode != null)
|
{
|
string rowGuid = "";
|
string rowName = "";
|
rowGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
|
rowName = tlMenu.FocusedNode.GetValue("defectName").ToString();
|
if (string.IsNullOrEmpty(rowGuid))
|
{
|
ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
|
return;
|
}
|
if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?"))
|
return;
|
List<dynamic> lst = new List<dynamic>();
|
lst.Add(rowGuid);
|
var _obj = lst;
|
try
|
{
|
string strJson = UtilityHelper.HttpPost("", _webServiceName + "DeleteModel", JsonConvert.SerializeObject(_obj));
|
ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
|
if (_rtn.rtnCode > 0)
|
{
|
tlMenu.DeleteNode(tlMenu.FocusedNode);
|
}
|
else
|
ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
|
}
|
catch (Exception ex)
|
{
|
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
|
}
|
}
|
};
|
this.toolStripMenuItemEdt.Click += (s, ee) =>
|
{
|
string strGuid = "";
|
string strTitle = "";
|
string strUpGuid = "";
|
if (tlMenu.FocusedNode != null)
|
{
|
strGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
|
strTitle = tlMenu.FocusedNode.GetValue("defectName").ToString();
|
strUpGuid = tlMenu.FocusedNode.GetValue("pid").ToString();
|
}
|
Frm_MesDefectCodeShow frm = new Frm_MesDefectCodeShow(strGuid, strTitle, strUpGuid);
|
frm.UpdateParent += (s2, ee2) =>
|
{
|
getPageList(1);
|
};
|
frm.ShowDialog();
|
};
|
}
|
|
private void TlMenu_MouseDown(object sender, MouseEventArgs e)
|
{
|
if (e.Button == MouseButtons.Right)
|
{
|
tlMenu.ContextMenuStrip = null;
|
TreeListHitInfo hInfo = tlMenu.CalcHitInfo(new Point(e.X, e.Y));
|
TreeListNode node = hInfo.Node;
|
tlMenu.FocusedNode = node;
|
if (node != null)
|
{
|
toolStripMenuItemAdd.Visible = true;
|
toolStripMenuItemEdt.Visible = true;
|
toolStripMenuItemDel.Visible = true;
|
toolStripMenuItemRoot.Visible = false;
|
tlMenu.ContextMenuStrip = contextMenuStrip1;
|
}
|
else {
|
toolStripMenuItemAdd.Visible = false;
|
toolStripMenuItemEdt.Visible = false;
|
toolStripMenuItemDel.Visible = false;
|
toolStripMenuItemRoot.Visible = true;
|
tlMenu.ContextMenuStrip = contextMenuStrip1;
|
}
|
}
|
}
|
|
|
/// <summary>
|
/// 查询事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
|
{
|
Gs.DevApp.ToolBox.MsgHelper.ShowInformation("该窗体不支持查询,若想更新页面,请点击 刷新");
|
}
|
|
/// <summary>
|
/// 刷新事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
|
{
|
_filterList.Clear();
|
getPageList(1);
|
}
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="curPage">第几页</param>
|
/// <param name="pageSize">每页几条</param>
|
private void getPageList(int curPage)
|
{
|
var pgq = new PageQueryModel(1, 999999, "a.defect_name");
|
var json = JsonConvert.SerializeObject(pgq);
|
try
|
{
|
var strReturn =
|
UtilityHelper.HttpPost("", _webServiceName+"GetListPage", json);
|
var dd = UtilityHelper.ReturnToTablePage(strReturn);
|
var dt = dd.rtnData.list;
|
tlMenu.DataSource = dt;
|
tlMenu.KeyFieldName = "guid";
|
tlMenu.ParentFieldName = "pid";
|
tlMenu.EndUpdate();
|
this.tlMenu.CollapseAll();
|
}
|
catch (Exception ex)
|
{
|
MsgHelper.Warning("提示:" + ex.Message);
|
}
|
|
}
|
}
|
}
|