using Core.Mes.Client.Comm.Format;
using Core.Mes.Client.Comm.Tool;
using CoreFS.CA06;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Core.StlMes.Client.YdmBase
{
public partial class FrmBelong : FrmBase
{
public FrmBelong()
{
InitializeComponent();
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.doQuery();
break;
case "Add":
this.doAdd();
break;
case "Update":
this.doUpdate();
break;
case "Close":
this.Close();
break;
}
}
///
/// 查询
///
private void doQuery()
{
string txtRoleId = "";
if (this.txtRoleName.Text.Trim() != "")
{
txtRoleId = this.txtRoleName.Value.ToString();
}
List listSource = EntityHelper.GetData(
"com.steering.pss.ydm.base.FrmBelong.doQueryRoleData", new object[] { txtRoleId }, this.ob);
YdmBsPurviewMEntitybindingSource.DataSource = listSource;
}
///
/// 新增
///
private void doAdd()
{
this.ultraGrid1.UpdateData();
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
if (uRow == null) return;
IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
ArrayList parm = new ArrayList();
foreach (UltraGridRow row in checkMagRows)
{
YdmBsPurviewMEntity ydmBsPu = (YdmBsPurviewMEntity)row.ListObject;
ydmBsPu.Roleid = row.Cells["Roleid"].Value.ToString();
ydmBsPu.IsBelongPurview = row.Cells["IsBelongPurview"].Value.ToString();
ydmBsPu.CreateName = UserInfo.GetUserName();
string ydmBsPuTity = JSONFormat.Format(ydmBsPu);
parm.Add(ydmBsPuTity);
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.base.FrmBelong";
ccp.MethodName = "addYdmBsPu";
ccp.ServerParams = new object[] { parm };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("新增成功!"))
{
doQuery();
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 修改
///
private void doUpdate()
{
this.ultraGrid1.UpdateData();
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
if (uRow == null) return;
IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
ArrayList parm = new ArrayList();
foreach (UltraGridRow row in checkMagRows)
{
YdmBsPurviewMEntity ydmBsPu = (YdmBsPurviewMEntity)row.ListObject;
ydmBsPu.Roleid = row.Cells["Roleid"].Value.ToString();
ydmBsPu.IsBelongPurview = row.Cells["IsBelongPurview"].Value.ToString();
ydmBsPu.UpdateName = UserInfo.GetUserName();
string ydmBsPuTity = JSONFormat.Format(ydmBsPu);
parm.Add(ydmBsPuTity);
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.base.FrmBelong";
ccp.MethodName = "updateYdmBsPu";
ccp.ServerParams = new object[] { parm };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("修改成功!"))
{
doQuery();
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
private void FrmBelong_Load(object sender, EventArgs e)
{
EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]);
YdmBaseClass.InitComboEditor(comRole, "com.steering.pss.ydm.base.FrmBelong.doQueryRole", "ID", ob, true);
YdmBaseClass.InitComboEditor(txtRoleName, "com.steering.pss.ydm.base.FrmBelong.doQueryRole", "ID", ob, true);
}
}
}