using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreFS.CA06;
using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Tool;
using Infragistics.Win.UltraWinGrid;
using Core.StlMes.Client.Mcp.Mch.Entity;
using com.steering.mes.mcp.entity;
using Core.Mes.Client.Comm.Server;
using Core.StlMes.Client.Mcp.Control;
namespace Core.StlMes.Client.Mcp.Mch.MchResult
{
public partial class FrmMchPerson : FrmBase
{
public FrmMchPerson()
{
InitializeComponent();
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "doQuery":
get_PurUoms();
break;
case "doAdd":
add_PurUoms();
break;
case "doModify":
upd_PurUoms();
break;
case "doDelete":
del_PurUoms();
break;
case "Close":
this.Close();
break;
}
}
///
/// 查询人员
///
///
public void get_PurUoms()
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchPerson.doQuery", new object[] { banci.Text.Trim(), pline.Text.Trim() }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
}
///
/// 增加人员
/////
/////
public void add_PurUoms()
{
string name = "";
string pline = "";
string banci = "";
if (txt_name.Text != "" && txt_name.Text != null)
{
name = txt_name.Text;
}
else
{
MessageUtil.ShowTips("请输入人员名称!");
return;
}
if (txt_pline.Text != "" && txt_pline.Text != null)
{
pline = txt_pline.Text;
}
else
{
MessageUtil.ShowTips("请输入生产产线!");
return;
}
if (txt_banci.Text != "" && txt_banci.Text != null)
{
banci = txt_banci.Text;
}
else
{
MessageUtil.ShowTips("请输入生产班组!");
return;
}
if (!same()) return;
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchPerson";
ccp.MethodName = "addPerson";
ccp.ServerParams = new Object[] { name, pline, banci };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("新增成功!"))
{
get_PurUoms();
}
}
//ConfigureClassCommon.doActiveSelRow(ultraGrid1, "UomCode", UomsEntity.UomCode);//激活当前行
}
/////
///// 修改人员
/////
/////
public void upd_PurUoms()
{
UltraGridRow urg = ultraGrid1.ActiveRow;
FrmMchPersonentity result = new FrmMchPersonentity();
result.ManName = urg.Cells["MAN_NAME"].Text.ToString();
result.ManCode = urg.Cells["MAN_CODE"].Text.ToString();
result.PlineCode = txt_pline.Text;
result.ProBc = txt_banci.Text;
if (txt_name.Text == "" || txt_name.Text == null)
{
MessageUtil.ShowTips("人员名称不能为空!");
return;
}
if (!same()) return;
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchPerson";
ccp.MethodName = "updatePerson";
ccp.ServerParams = new Object[] { result, txt_name.Text };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("修改成功!"))
{
get_PurUoms();
}
}
}
private void FrmMchPerson_Load(object sender, EventArgs e)
{
//产线
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchPerson.doQuerypline", null, this.ob);//如果是“”里面添加的是条件
pline.DataSource = dt;
pline.DisplayMember = "PLINE_NAME";
pline.ValueMember = "PLINE_CODE";
YdmBaseClass.SetComboItemHeight(pline);
txt_pline.DataSource = dt;
txt_pline.DisplayMember = "PLINE_NAME";
txt_pline.ValueMember = "PLINE_CODE";
YdmBaseClass.SetComboItemHeight(txt_pline);
}
/////
///// 删除人员
/////
/////
public void del_PurUoms()
{
if (ultraGrid1.ActiveRow != null)
{
UltraGridRow urg = ultraGrid1.ActiveRow;
if (urg != null)
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchPerson";
ccp.MethodName = "deletePerson";
ccp.ServerParams = new Object[] { urg.Cells["MAN_NAME"].Value.ToString(), urg.Cells["MAN_CODE"].Value.ToString() };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("删除成功!"))
{
get_PurUoms();
}
}
}
else
{
MessageUtil.ShowTips("请选择一条数据");
return;
}
}
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow urg = ultraGrid1.ActiveRow;
if(urg!=null)
{
txt_name.Text = urg.Cells["MAN_NAME"].Text.ToString();
txt_banci.Text = urg.Cells["PRO_BZ"].Text.ToString();
txt_pline.Text = urg.Cells["PLINE_CODE"].Text.ToString();
}
}
private bool same()
{
UltraGridRow urg = ultraGrid1.ActiveRow;
if (urg != null)
{
if (txt_name.Text == urg.Cells["MAN_NAME"].Text.ToString() && txt_banci.Text == urg.Cells["PRO_BZ"].Text.ToString() && txt_pline.Text == urg.Cells["PLINE_CODE"].Text.ToString())
{
MessageUtil.ShowTips("有相同的人员信息!");
return false;
}
else
{
return true;
}
}
return true;
}
}
}