using DevExpress.XtraTreeList.Nodes;
|
using DevExpress.XtraTreeList;
|
using Gs.DevApp.Entity;
|
using Gs.DevApp.ToolBox;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace Gs.DevApp.DevFrm.QC
|
{
|
public partial class DefectCode : DevExpress.XtraEditors.XtraUserControl
|
{
|
string _webServiceName = "MesDefectCodeManager/";
|
List<FilterEntity> _filterList = new List<FilterEntity>();
|
|
public string strType = "";//类别(普通信息,认证信息)
|
public DefectCode(string _strType)
|
{
|
InitializeComponent();
|
strType = _strType;
|
toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
|
this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
|
|
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,strType);
|
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, strType);
|
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 strUpGuid = "";
|
if (tlMenu.FocusedNode != null)
|
{
|
strGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
|
strUpGuid = tlMenu.FocusedNode.GetValue("pid").ToString();
|
}
|
Frm_MesDefectCodeShow frm = new Frm_MesDefectCodeShow(strGuid, strUpGuid, strType);
|
frm.UpdateParent += (s2, ee2) =>
|
{
|
getPageList(1);
|
};
|
frm.ShowDialog();
|
};
|
}
|
|
/// <summary>
|
/// 右键弹出菜单,如果是行,增加子项目,否则增加主项
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void TlMenu_MouseDown(object sender, MouseEventArgs e)
|
{
|
if (e.Button == MouseButtons.Right)
|
{
|
TreeListHitInfo hInfo = tlMenu.CalcHitInfo(new Point(e.X, e.Y));
|
TreeListNode node = hInfo.Node;
|
tlMenu.FocusedNode = node;
|
if (hInfo.HitInfoType == HitInfoType.Cell ||
|
hInfo.HitInfoType == HitInfoType.Row ||
|
hInfo.HitInfoType == HitInfoType.RowIndent ||
|
hInfo.HitInfoType == HitInfoType.RowIndicator
|
)
|
{
|
if (node != null)
|
{
|
toolStripMenuItemAdd.Visible = true;
|
toolStripMenuItemEdt.Visible = true;
|
toolStripMenuItemDel.Visible = true;
|
toolStripMenuItemRoot.Visible = false;
|
cms1.Show(tlMenu, e.Location);
|
}
|
}
|
else
|
{
|
toolStripMenuItemAdd.Visible = false;
|
toolStripMenuItemEdt.Visible = false;
|
toolStripMenuItemDel.Visible = false;
|
toolStripMenuItemRoot.Visible = true;
|
cms1.Show(tlMenu, e.Location);
|
}
|
}
|
}
|
|
|
/// <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)
|
{
|
System.Text.StringBuilder sbWhere = new StringBuilder();
|
sbWhere.Append(" and a.defect_sort='" + strType + "'");
|
var pgq = new PageQueryModel(1, 999999, "a.defect_code ", "asc","", sbWhere.ToString());
|
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();
|
this.tlMenu.ExpandAll();
|
}
|
catch (Exception ex)
|
{
|
MsgHelper.Warning("提示:" + ex.Message);
|
}
|
}
|
}
|
}
|