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 System.Collections;
using Infragistics.Win.UltraWinGrid;
using Core.StlMes.Client.LgCommon;
using CoreFS.CA06;
namespace Core.StlMes.Client.LgIntegrationQuery
{
public partial class FrmShiftConfig : Core.StlMes.Client.LgCommon.frmStyleBase
{
public FrmShiftConfig()
{
InitializeComponent();
}
private void FrmShiftConfig_Load(object sender, EventArgs e)
{
allProdLineQuery();
shiftConfigQuery();
prodLineConfigQuery();
SetColumnModeClass(ugdShift);
}
// 查询基础信息所有产线
///
/// 查询基础信息所有产线
///
private void allProdLineQuery()
{
try
{
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("frmBaseInfo_Children.select");
arry.Add("1011");
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (ds != null)
{
cboProdline.Items.Clear();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
this.cboProdline.Items.Add(ds.Tables[0].Rows[i]["BASECODE"].ToString(), ds.Tables[0].Rows[i]["BASENAME"].ToString());
}
}
}
catch (System.Exception exp)
{
MessageBox.Show(exp.Message);
}
}
// 查询产线的具体信息
///
/// 查询产线的具体信息
///
private void prodLineConfigQuery()
{
try
{
string strErr = "";
ArrayList arry = new ArrayList();
CommonClientToServer ccTos = new CommonClientToServer();
ccTos.ob = this.ob;
DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
"QueryWithParameter", "STL_CON0001", 5, arry, out strErr);
if (strErr == "" && ds != null)
{
udsProdline.Rows.Clear();
if (ds.Tables.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
udsProdline.Rows.Add(new object[] {
dr["PRODLINE"].ToString(),
dr["PRODLINENAME"].ToString(),
dr["SHIFTCODE"].ToString(),
dr["SHIFTNAME"].ToString(),
dr["SHIFTTYPE"].ToString(),
dr["SHIFTTYPENAME"].ToString(),
dr["CYCLES"].ToString(),
dr["OPTPERSONNEL"].ToString(),
dr["OPTPERDATE"].ToString()
}
);
}
}
PublicMethod.RefreshAndAutoSize(ugdProdline);
}
else
MessageBox.Show("信息查询失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
catch { }
}
// 查询班次配置的信息
///
/// 查询班次配置的信息
///
public void shiftConfigQuery()
{
try
{
string strErr = "";
ArrayList arry = new ArrayList();
CommonClientToServer ccTos = new CommonClientToServer();
ccTos.ob = this.ob;
DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
"QueryWithParameter", "STL_CON0002", 5, arry, out strErr);
if (strErr == "" && ds != null)
{
udsConfig.Rows.Clear();
if (ds.Tables.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
udsConfig.Rows.Add(new object[] {
dr["ID"].ToString(),
dr["SHIFTNAME"].ToString(),
dr["SHIFTTYPE"].ToString(),
dr["SHIFTTYPENAME"].ToString(),
dr["CYCLES"].ToString(),
dr["OPTPERSONNEL"].ToString(),
dr["OPTPERDATE"].ToString()
}
);
}
}
PublicMethod.RefreshAndAutoSize(ugdConfig);
}
else
MessageBox.Show("信息查询失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
catch { }
}
// 查询具体配置的信息
///
/// 查询具体配置的信息
///
private void DetailConfigQuery(String strID)
{
try
{
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add(strID);
CommonClientToServer ccTos = new CommonClientToServer();
ccTos.ob = this.ob;
DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
"QueryWithParameter", "STL_CON0003", 5, arry, out strErr);
if (strErr == "" && ds != null)
{
udsShift.Rows.Clear();
if (ds.Tables.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
udsShift.Rows.Add(new object[] {
dr["CURDATE"].ToString(),
dr["FUNC"].ToString(),
dr["NO1"].ToString(),
dr["NO2"].ToString(),
dr["NO3"].ToString(),
dr["NO4"].ToString()
}
);
}
}
//PublicMethod.RefreshAndAutoSize(ugdShift);
}
else
MessageBox.Show("信息查询失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
catch { }
}
// 新增配置产线
///
/// 新增配置产线
///
private void proc_Add()
{
try
{
if (ugdConfig.Rows.Count == 0)
{
MessageBox.Show("没有配置方案,请添加配置方案!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
if (cboProdline.SelectedIndex < 0 )
{
MessageBox.Show("产线不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
string strProdline = cboProdline.Value.ToString(); //产线ID
string strProdlineName = cboProdline.SelectedItem.DisplayText.ToString(); //产线名称
string strID = ugdConfig.ActiveRow.Cells["ID"].Value.ToString(); //ID
string strErr = "";
string strSqlID = "STL_CON0007"; //SQLID
object[] sArgs = new object[4];
sArgs[0] = strProdline; //产线ID
sArgs[1] = strProdlineName; //产线名称
sArgs[2] = strID; //ID
sArgs[3] = this.UserInfo.GetUserName(); //操作人
CommonClientToServer ccTs = new CommonClientToServer();
ccTs.ob = ob;
CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
"ExecProcWithCollParam", strSqlID, 5, sArgs, out strErr);
if (strErr == "")
{
prodLineConfigQuery();
MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
MessageBox.Show("保存失败!" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch { }
}
// 修改配置产线
///
/// 修改配置方案
///
private void proc_Edit()
{
try
{
if (ugdProdline.Rows.Count == 0)
{
MessageBox.Show("没有可以修改的产线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
if (ugdConfig.Rows.Count == 0)
{
MessageBox.Show("没有配置方案,请添加配置方案!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
if (cboProdline.SelectedIndex < 0)
{
MessageBox.Show("产线不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
string strProdline = cboProdline.Value.ToString(); //产线ID
string strID = ugdConfig.ActiveRow.Cells["ID"].Value.ToString(); //ID
string strErr = "";
string strSqlID = "STL_CON0008"; //SQLID
object[] sArgs = new object[3];
sArgs[0] = strProdline; //产线ID
sArgs[1] = strID; //ID
sArgs[2] = this.UserInfo.GetUserName(); //操作人
CommonClientToServer ccTs = new CommonClientToServer();
ccTs.ob = ob;
CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
"ExecProcWithCollParam", strSqlID, 5, sArgs, out strErr);
if (strErr == "")
{
prodLineConfigQuery();
MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
MessageBox.Show("保存失败!" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch { }
}
// 删除配置产线
///
/// 删除配置方案
///
private void proc_Del()
{
try
{
if (ugdProdline.Rows.Count == 0)
{
MessageBox.Show("没有可以删除的产线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
string strProdline = ugdProdline.ActiveRow.Cells["PRODLINE"].Value.ToString(); //产线ID
string strErr = "";
string strSqlID = "STL_CON0009"; //SQLID
object[] sArgs = new object[1];
sArgs[0] = strProdline; //产线ID
CommonClientToServer ccTs = new CommonClientToServer();
ccTs.ob = ob;
CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
"ExecProcWithCollParam", strSqlID, 5, sArgs, out strErr);
if (strErr == "")
{
prodLineConfigQuery();
MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
MessageBox.Show("删除失败!" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch { }
}
// 设置班组
///
/// 设置班组
///
///
private void SetColumnModeClass(Infragistics.Win.UltraWinGrid.UltraGridBase Grid)
{
DataTable dt = new DataTable();
dt.TableName = "CLASS";
DataColumn dc = new DataColumn("BCBM", Type.GetType("System.String"));
dt.Columns.Add(dc);
dc = new DataColumn("BCNA", Type.GetType("System.String"));
dt.Columns.Add(dc);
DataRow dr = dt.NewRow();
dr["BCBM"] = "0";
dr["BCNA"] = "无";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["BCBM"] = "1";
dr["BCNA"] = "白班";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["BCBM"] = "2";
dr["BCNA"] = "小夜";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["BCBM"] = "3";
dr["BCNA"] = "大夜";
dt.Rows.Add(dr);
ClsControlPack.SetGridDropDownListCell("NO1", 0, "甲班", 60, Grid, dt, "BCBM", "BCNA");
ClsControlPack.SetGridDropDownListCell("NO2", 0, "乙班", 60, Grid, dt, "BCBM", "BCNA");
ClsControlPack.SetGridDropDownListCell("NO3", 0, "丙班", 60, Grid, dt, "BCBM", "BCNA");
ClsControlPack.SetGridDropDownListCell("NO4", 0, "丁班", 60, Grid, dt, "BCBM", "BCNA");
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
shiftConfigQuery();
prodLineConfigQuery();
break;
case "Add":
proc_Add();
break;
case "Update":
proc_Edit();
break;
case "Delete":
proc_Del();
break;
case "Config":
FrmShiftItems frm = new FrmShiftItems(ob);
frm.Location = new Point(10000, 4000);
frm.Tag = this;
frm.ShowDialog();
break;
case "Close":
this.Close();
break;
}
}
private void ugdConfig_AfterRowActivate(object sender, EventArgs e)
{
try
{
UltraGridRow row = ugdConfig.ActiveRow;
string ID = row.Cells["ID"].Value.ToString();
DetailConfigQuery(ID);
textValue.Text = row.Cells["SHIFTNAME"].Value.ToString();
txtTypeName.Text = row.Cells["SHIFTTYPENAME"].Value.ToString();
}
catch { }
}
private void ugdProdline_AfterRowActivate(object sender, EventArgs e)
{
try
{
UltraGridRow row = ugdProdline.ActiveRow;
cboProdline.Value = row.Cells["PRODLINE"].Value.ToString();
textValue.Text = row.Cells["SHIFTNAME"].Value.ToString();
txtTypeName.Text = row.Cells["SHIFTTYPENAME"].Value.ToString();
}
catch { }
}
}
}