using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Core.Mes.Client.Common;
using CoreFS.CA06;
namespace Core.LgMes.Client.LgDeviceManager
{
public partial class FrmCLPluginInfo : Core.Mes.Client.Common.frmStyleBase//frmModelFormStyle
{
public FrmCLPluginInfo(OpeBase oba)
{
InitializeComponent();
ob = oba;
}
private void FrmCLPluginInfo_Load(object sender, EventArgs e)
{
udteBuyTime.DateTime = DateTime.Today;
proc_LoadPluginID();
proc_Query("", "", "");
}
private void cbCCM_CheckedChanged(object sender, EventArgs e)
{
cmbCCM.Enabled = chkCCM.Checked;
}
private void cbType_CheckedChanged(object sender, EventArgs e)
{
cmbType.Enabled = chkType.Checked;
}
private void cbID_CheckedChanged(object sender, EventArgs e)
{
cmbID.Enabled = chkID.Checked;
}
private void cbbCCM_SelectedIndexChanged(object sender, EventArgs e)
{
proc_LoadPluginID();
}
private void cbbType_SelectedIndexChanged(object sender, EventArgs e)
{
proc_LoadPluginID();
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
try
{
if (ultraGrid1.Rows.Count == 0) return;
if (ultraGrid1.ActiveRow == null) return;
cmbZJH.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["铸机号"].Value);
txtNO.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["编号"].Value);
cmbLB.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["类别"].Value);
txtCS.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["使用炉数"].Value);
udteBuyTime.DateTime = Convert.ToDateTime(ultraGrid1.ActiveRow.Cells["购买日期"].Value);
txtMemo.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["备注"].Value);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void proc_ExecuteCommand_Return(object[] obj, out DataSet ds, out string strErr)
{
//CallingMessage par = new CallingMessage();
//par.ServerName = "LgDeviceManager";
//par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
//par.ClassName = "Core.LgMes.Server.LgDeviceManager.jjqmanager";
//par.MethodName = "ExecuteCommand_Return";
//par.args = obj;
strErr = "";
ds =null;// ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
}
///
/// 删除 不用
///
///
///
private void proc_ExecuteCommand_NonReturn(object[] obj, out string strErr)
{
//CallingMessage par = new CallingMessage();
//par.ServerName = "LgDeviceManager";
//par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
//par.ClassName = "Core.LgMes.Server.LgDeviceManager.jjqmanager";
//par.MethodName = "ExecuteCommand_NonReturn";
//par.args = obj;
//ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr);
strErr = "";
}
private void proc_ResetControl()
{
try
{
cmbZJH.SelectedIndex = -1;
txtNO.Clear();
cmbLB.SelectedIndex = -1;
txtCS.Clear();
txtMemo.Clear();
}
catch { }
}
/// <铜板水箱编号查询>
/// 铜板水箱编号查询
///
private void proc_LoadPluginID()
{
try
{
string srtCCM_ID = "";
string srtTYPE = "";
if (cmbCCM.SelectedIndex > -1)
{
srtCCM_ID = cmbCCM.Text.Trim();//铸机号
}
if (cmbType.SelectedIndex > -1)
{
srtTYPE = cmbType.SelectedIndex.ToString();//类型
}
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("proc_LoadPluginID.Select");
arry.Add(srtCCM_ID);
arry.Add(srtCCM_ID);
arry.Add(srtTYPE);
arry.Add(srtTYPE);
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
{
MessageBox.Show("铜板水箱编号加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (MessageBox.Show("是否重新加载铜板水箱编号?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
proc_LoadPluginID();
return;
}
cmbID.ResetText();
cmbID.DataSource = ds.Tables[0];
cmbID.DisplayMember = "PLUGINNO";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
///
/// 铜板水箱编号信息查询
///
/// 铸机号>
/// 类型>
/// 铜板水箱编号>
private void proc_Query(string strCCM, string strType, string strID)
{
try
{
string strCCM_ID = "";
string strTYPE = "";
string strcbID = "";
if (chkCCM.Checked && cmbCCM.SelectedIndex > -1)
{
strCCM_ID = cmbCCM.SelectedItem.ToString();
}
if (chkType.Checked && cmbType.SelectedIndex > -1)
{
strTYPE = cmbType.SelectedIndex.ToString();
}
if (chkID.Checked && cmbID.SelectedIndex > -1)
{
strcbID = cmbID.Text.Trim();
}
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("proc_Query.Select");
arry.Add(strCCM_ID);
arry.Add(strCCM_ID);
arry.Add(strTYPE);
arry.Add(strTYPE);
arry.Add(strcbID);
arry.Add(strcbID);
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
{
MessageBox.Show("铜板水箱信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
ultraGrid1.DataSource = ds.Tables[0];
if (ds.Tables[0].Rows.Count == 0)
{
proc_ResetControl();
return;
}
if (strCCM.Length > 0) //定位记录
{
for (int i = 0; i < ultraGrid1.Rows.Count; i++)
{
if (Convert.ToString(ultraGrid1.Rows[i].Cells["铸机号"].Value) == strCCM)
{
if (strType.Length > 0)
{
if (Convert.ToString(ultraGrid1.Rows[i].Cells["类别"].Value) == strType)
{
if (strID.Length > 0)
{
if (Convert.ToString(ultraGrid1.Rows[i].Cells["编号"].Value) == strID)
{
ultraGrid1.ActiveRow = ultraGrid1.Rows[i];
ultraGrid1.Rows[i].Selected = true;
return;
}
}
else
{
ultraGrid1.ActiveRow = ultraGrid1.Rows[i];
ultraGrid1.Rows[i].Selected = true;
return;
}
}
}
else
{
ultraGrid1.ActiveRow = ultraGrid1.Rows[i];
ultraGrid1.Rows[i].Selected = true;
return;
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
///
/// 结晶器铜板水箱信息增加
///
private void proc_Add()
{
try
{
if (cmbZJH.SelectedIndex < 0)
{
MessageBox.Show("请选择铸机号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
cmbZJH.Focus();
return;
}
if (txtNO.Text.Trim().Length == 0)
{
MessageBox.Show("请录入编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtNO.Focus();
return;
}
if (cmbLB.SelectedIndex < 0)
{
MessageBox.Show("请选择类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
cmbLB.Focus();
return;
}
string strCCM = cmbZJH.Text.Trim();
string strNO = txtNO.Text.Trim();
string strType = cmbLB.SelectedIndex.ToString();
string strUseTimes = (txtCS.Text.Trim().Length == 0 ? "0" : txtCS.Text.Trim());
string strDate = udteBuyTime.DateTime.ToString("yyyy-MM-dd");
string strMemo = txtMemo.Text.Trim();
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("proc_Add.Select");
arry.Add(strCCM);
arry.Add(strType);
arry.Add(strNO);
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
{
MessageBox.Show("新增[" + strCCM + "][" + cmbLB.Text.Trim() + "][" + strNO + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
if (iCnt > 0)
{
MessageBox.Show("[" + strCCM + "]已存在[" + cmbLB.Text.Trim() + "][" + strNO + "],不能重复录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtNO.Focus();
return;
}
strErr = "";
arry.Clear();
arry.Add("proc_Add.Add");
arry.Add(strNO);
arry.Add(strCCM);
arry.Add(strType );
arry.Add(strUseTimes);
arry.Add(strDate);
arry.Add(strMemo );
string strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
if (!(strErr == null || strErr == ""))
{
MessageBox.Show("新增[" + strCCM + "][" + cmbLB.Text.Trim() + "][" + strNO + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
strType = cmbLB.Text.Trim();
proc_Query(strCCM, strType, strNO);
MessageBox.Show("新增[" + strCCM + "][" + strType + "][" + strNO + "]成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
///
/// 铜板水箱编号信息修改
///
private void proc_Edit()
{
try
{
if (ultraGrid1.Rows.Count == 0)
return;
if (ultraGrid1.ActiveRow == null)
{
MessageBox.Show("请选择您要修改的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (cmbZJH.SelectedIndex < 0)
{
MessageBox.Show("请选择铸机号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
cmbZJH.Focus();
return;
}
if (txtNO.Text.Trim().Length == 0)
{
MessageBox.Show("请录入编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtNO.Focus();
return;
}
if (cmbLB.SelectedIndex < 0)
{
MessageBox.Show("请选择类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
cmbLB.Focus();
return;
}
string strCCM = cmbZJH.Text.Trim();
string strNO = txtNO.Text.Trim();
string strType = cmbLB.SelectedIndex.ToString();
string strUseTimes = (txtCS.Text.Trim().Length == 0 ? "0" : txtCS.Text.Trim());
string strDate = udteBuyTime.DateTime.ToString("yyyy-MM-dd");
string strMemo = txtMemo.Text.Trim();
if (MessageBox.Show("确定要修改[" + strCCM + "][" + cmbLB.Text.Trim() + "][" + strNO + "]相关信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("proc_Edit.Select");
arry.Add(strCCM);
arry.Add(strType);
arry.Add(strNO);
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
{
MessageBox.Show("[" + strCCM + "][" + cmbLB.Text.Trim() + "][" + strNO + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
if (iCnt == 0)
{
MessageBox.Show("[" + strCCM + "]不存在[" + cmbLB.Text.Trim() + "][" + strNO + "],无法修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtNO.Focus();
return;
}
strErr = "";
arry.Clear();
arry.Add("proc_Edit.Edit");
arry.Add(strUseTimes);//状态
arry.Add(strDate);//购买时间
arry.Add(strMemo);//备注
arry.Add(strCCM);//铸机号
arry.Add(strType);//类别
arry.Add(strNO);//编号
string strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
if (!(strErr == null || strErr == ""))
{
MessageBox.Show("[" + strCCM + "][" + cmbLB.Text.Trim() + "][" + strNO + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
strType = cmbLB.Text.Trim();
proc_Query(strCCM, strType, strNO);
MessageBox.Show("[" + strCCM + "][" + strType + "][" + strNO + "]信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
///
/// 铜板水箱编号信息删除
///
private void proc_Del()
{
try
{
if (ultraGrid1.Rows.Count == 0)
return;
if (ultraGrid1.ActiveRow == null)
{
MessageBox.Show("请选择您要删除的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string strID = Convert.ToString(ultraGrid1.ActiveRow.Cells["ID"].Value);
string strNO = Convert.ToString(ultraGrid1.ActiveRow.Cells["编号"].Value);
string strCCM = Convert.ToString(ultraGrid1.ActiveRow.Cells["铸机号"].Value);
string strType = Convert.ToString(ultraGrid1.ActiveRow.Cells["类别"].Value);
if (MessageBox.Show("确定要删除[" + strCCM + "][" + strType + "][" + strNO + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("proc_Del.Select.Count");
arry.Add(strID);
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
{
MessageBox.Show("[" + strCCM + "][" + strType + "][" + strNO + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
if (iCnt == 0)
{
MessageBox.Show("[" + strCCM + "]不存在[" + strType + "][" + strNO + "],无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtNO.Focus();
return;
}
strErr = "";
arry.Clear();
ds.Clear();
arry.Add("proc_D.Select");
arry.Add(strID);
arry.Add(strID);
arry.Add(strID);
arry.Add(strID);
arry.Add(strID);
arry.Add(strID);
ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
{
MessageBox.Show("[" + strCCM + "][" + strType + "][" + strNO + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
if (iCnt > 0)
{
MessageBox.Show("[" + strCCM + "][" + strType + "][" + strNO + "]存在使用记录,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtNO.Focus();
return;
}
strErr = "";
arry.Clear();
ds.Clear();
arry.Add("proc_.Select");
arry.Add(strID);
arry.Add(strID);
arry.Add(strID);
arry.Add(strID);
arry.Add(strID);
arry.Add(strID);
ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
{
MessageBox.Show("[" + strCCM + "][" + strType + "][" + strNO + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
if (iCnt > 0)
{
MessageBox.Show("[" + strCCM + "][" + strType + "][" + strNO + "]存在使用记录,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtNO.Focus();
return;
}
strErr = "";
arry.Clear();
arry.Add("proc_Del.Delect");
arry.Add(strID);
string strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
if (!(strErr == null || strErr == ""))
{
MessageBox.Show("[" + strCCM + "][" + strType + "][" + strNO + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
proc_Query(strCCM, cmbLB.Text.Trim(), strNO);
MessageBox.Show("[" + strCCM + "][" + strType + "][" + strNO + "]信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
///
/// 菜单
///
///
///
private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
if (e.ClickedItem == null) return;
switch (e.ClickedItem.Name)
{
case "QUERY":
{
proc_Query("", "", "");
break;
}
case "ADD":
{
proc_Add();
break;
}
case "EDIT":
{
proc_Edit();
break;
}
case "DEL":
{
proc_Del();
break;
}
case "CLOSE":
{
this.Close();
break;
}
}
}
private void tbCS_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.') || (((TextBox)(sender)).Text.Trim().Contains(".") && e.KeyChar == '.'))
{
e.Handled = true;
}
}
}
}