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 System.Collections;
namespace Core.LZMes.Client.UIF
{
public partial class UIF052030 : FrmBase
{
public UIF052030()
{
InitializeComponent();
}
#region "ToolBar Event"
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.DoQuery();
break;
case "Query2":
this.DoQuery2();
break;
case "Save":
this.Save();
break;
case "Delete":
Delete();
break;
case "Send":
Send();
break;
case "UnSend":
UnSend();
break;
case "Exit":
this.dataSet1.Dispose();
this.dataSet2.Dispose();
this.dataSet1 = null;
this.dataSet2 = null;
this.Close();
break;
}
}
///
/// 查询轧辊单元计划信息
///
private void DoQuery()
{
try
{
this.dataSet1.Tables[0].Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIF.UIF05.UIF052030";
ccp.MethodName = "QueryCalPlan";
ccp.ServerParams = new object[] { };
ccp.SourceDataTable = this.dataSet1.Tables[0];
CoreClientParam obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
if (obj.ReturnInfo.Length == 0)
{
System.Data.DataTable tab0 = Common.FixDBManager.ConvertToDataTable(obj.ReturnObject as System.Collections.ArrayList, this.dataSet1.Tables["L_TBF03_SPEC_ROLL"]);
tab0.TableName = "L_TBF03_SPEC_ROLL";
this.dataSet1.Tables["L_TBF03_SPEC_ROLL"].Merge(tab0);
this.dataSet1.AcceptChanges();
};
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 查询轧辊单元计划信息
///
private void DoQuery2()
{
try
{
this.dataSet1.Tables[0].Clear();
DataTable dt = new DataTable();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIB.COM.ComDBQuery";
ccp.MethodName = "doSimpleQuery";
ArrayList paramArray = new ArrayList();
paramArray.Add("UIF052030.Query_CALPlan_List_02");
ccp.ServerParams = new object[] { paramArray };
ccp.SourceDataTable = this.dataSet1.Tables[0];
//this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
CoreClientParam obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
/*
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIF.UIF05.UIF052030";
ccp.MethodName = "UIF052030.Query_CALPlan_List_02";
ccp.ServerParams = new object[] { };
ccp.SourceDataTable = this.dataSet1.Tables[0];
CoreClientParam obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
*/
if (obj.ReturnInfo.Length == 0)
{
System.Data.DataTable tab0 = Common.FixDBManager.ConvertToDataTable(obj.ReturnObject as System.Collections.ArrayList, this.dataSet1.Tables["L_TBF03_SPEC_ROLL"]);
tab0.TableName = "L_TBF03_SPEC_ROLL";
this.dataSet1.Tables["L_TBF03_SPEC_ROLL"].Merge(tab0);
this.dataSet1.AcceptChanges();
};
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 保存轧辊单元计划的顺序调整
///
private void Save()
{
try
{
string rollNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.textTarget.Text));
string pos = Convert.ToString(Common.FixDBManager.CheckNullStr(this.comboPosition.Value));
string type = Convert.ToString(Common.FixDBManager.CheckNullStr(this.optionBF.Value));
if (rollNO == "" || pos == "" || type == "")
{
MessageBox.Show(" 条件不能为空! ");
}
string ex = "";
Hashtable paramHsmp = new Hashtable();
paramHsmp.Add("i1", rollNO);
paramHsmp.Add("i2", pos);
paramHsmp.Add("i3", type);
paramHsmp.Add("o4", ex);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIB.COM.ComDBProcedure";
ccp.MethodName = "doXmlProcedure";
ccp.ServerParams = new Object[] { "UIF052030.Adj_RollUnit", paramHsmp };
CoreClientParam obj = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
System.Collections.ArrayList err = obj.ReturnObject as System.Collections.ArrayList;
if (err != null && err.Count > 0 && Common.FixDBManager.CheckNullStr(err[0]) != "1")
{
MessageBox.Show(err[0].ToString(), Common.FixDBManager.MsgCaption);
}
else
{
//DoQuery();
}
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 删除轧辊单元计划
///
private void Delete()
{
try
{
this.ugrd_CalInfo.UpdateData();
System.Data.DataRow[] rows = this.dataSet1.Tables[0].Select("CHK='TRUE'");
if (rows.Length == 0)
{
MessageBox.Show("请选择你要下发的计划", Common.FixDBManager.MsgCaption);
return;
}
string RollNO = rows[0]["CAL_NO"].ToString();
System.Windows.Forms.DialogResult rt = MessageBox.Show("是否确认删除所选轧制单元计划?", Common.FixDBManager.MsgCaption, MessageBoxButtons.YesNo);
if (rt == DialogResult.No)
{
return;
}
string Ex = "";
Hashtable paramHsmp = new Hashtable();
paramHsmp.Add("i1", RollNO);
paramHsmp.Add("i2", CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName());
paramHsmp.Add("o3", Ex);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIB.COM.ComDBProcedure";
ccp.MethodName = "doXmlProcedure";
ccp.ServerParams = new Object[] { "UIF052030.Del_CalUnit", paramHsmp };
CoreClientParam obj = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
System.Collections.ArrayList err = obj.ReturnObject as System.Collections.ArrayList;
if (err != null && err.Count > 0 && Common.FixDBManager.CheckNullStr(err[0]) != "1")
{
MessageBox.Show(err[0].ToString(), Common.FixDBManager.MsgCaption);
}
else
{
//DoQuery();
}
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
///
/// 轧辊单元计划指令下发(二级)
/// 支持≤2调计划指令下发
///
private void Send()
{
try
{
this.ugrd_CalInfo.UpdateData();
System.Data.DataRow[] rows = this.dataSet1.Tables[0].Select("CHK='TRUE'");
if (rows.Length == 0)
{
MessageBox.Show("请选择你要下发的计划", Common.FixDBManager.MsgCaption);
return;
}
string RollNO = rows[0]["CAL_NO"].ToString();
string ex = "";
#region "校验下发可行性"
Hashtable paramHsmp = new Hashtable();
paramHsmp.Add("i1", RollNO);
paramHsmp.Add("o2", ex);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIB.COM.ComDBProcedure";
ccp.MethodName = "doXmlProcedure";
ccp.ServerParams = new Object[] { "UIF052030.Sed_RollUnit", paramHsmp };
CoreClientParam obj = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
System.Collections.ArrayList err = obj.ReturnObject as System.Collections.ArrayList;
if (err != null && err.Count > 0 && Common.FixDBManager.CheckNullStr(err[0]) != "1")
{
MessageBox.Show(err[0].ToString(), Common.FixDBManager.MsgCaption);
return;
}
#endregion
//#region "执行下发"
//paramHsmp = new Hashtable();
//paramHsmp.Add("i1", RollNO);
//paramHsmp.Add("o2", ex);
//ccp = new CoreClientParam();
//ccp.ServerName = "com.core.sip.xinyu.service.CalSendTelegramService";
//ccp.MethodName = "sendPlanByPlanNo";
//ccp.ServerParams = new Object[] { RollNO };
//obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
//if (Common.FixDBManager.CheckNullInt(obj.ReturnObject)<=0)
//{
// MessageBox.Show("下发失败", Common.FixDBManager.MsgCaption);
//}
//else
//{
//DoQuery();
//}
//#endregion
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
///
/// 对已下发(二级)的轧辊单元计划进行撤销
///
private void UnSend()
{
try
{
this.ugrd_CalInfo.UpdateData();
System.Data.DataRow[] rows = this.dataSet1.Tables[0].Select("CHK='TRUE'");
if (rows.Length == 0)
{
MessageBox.Show("请选择你要下发的计划", Common.FixDBManager.MsgCaption);
return;
}
string RollNO = rows[0]["CAL_NO"].ToString();
string ex = "";
#region "校验下发可行性"
Hashtable paramHsmp = new Hashtable();
paramHsmp.Add("i1", RollNO);
paramHsmp.Add("i2", UserInfo.GetUserID());
paramHsmp.Add("o3", ex);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIB.COM.ComDBProcedure";
ccp.MethodName = "doXmlProcedure";
ccp.ServerParams = new Object[] { "UIF052030.Usd_RollUnit", paramHsmp };
CoreClientParam obj = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
System.Collections.ArrayList err = obj.ReturnObject as System.Collections.ArrayList;
if (err != null && err.Count > 0 && Common.FixDBManager.CheckNullStr(err[0]) != "1")
{
MessageBox.Show(err[0].ToString(), Common.FixDBManager.MsgCaption);
return;
}
#endregion
//#region "执行下发"
//paramHsmp = new Hashtable();
//paramHsmp.Add("i1", RollNO);
//paramHsmp.Add("o2", ex);
//ccp = new CoreClientParam();
//ccp.ServerName = "com.core.sip.xinyu.service.CalSendTelegramService";
//ccp.MethodName = "canclePlanByPlanNo";
//ccp.ServerParams = new Object[] { RollNO };
//obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
//if (Common.FixDBManager.CheckNullInt(obj.ReturnObject) <= 0)
//{
// MessageBox.Show("下发失败", Common.FixDBManager.MsgCaption);
//}
//else
//{
//DoQuery();
//}
//#endregion
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
#endregion
#region "Init"
private void UIF052030_Load(object sender, EventArgs e)
{
try
{
GetInitData();
Init_Grid();
Common.FixDBManager.Init_ComboControl(this.comboPosition, "SCM_BASE_INFO", "NAME_", "ID_", ref dataSet2);
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
private void GetInitData()
{
try
{
this.dataSet2.Tables[0].Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIF.UIF05.UIF052030";
ccp.MethodName = "queryInitdata";
ccp.ServerParams = new object[] { };
ccp.SourceDataTable = this.dataSet2.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
dataSet2.Tables[0].TableName = "SCM_BASE_INFO";
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
private void Init_Grid()
{
try
{
Common.FixDBManager.SetGridCheckBox("CHK", "L_TBF03_SPEC_ROLL", 0, this.ugrd_CalInfo);
foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn col in this.ugrd_CalInfo.DisplayLayout.Bands[0].Columns)
{
if (col.Key == "CHK")
{
Common.FixDBManager.SetCellActivation(col.Key, "L_TBF03_SPEC_ROLL", this.ugrd_CalInfo, "ALLOWEDIT");
}
else
{
Common.FixDBManager.SetCellActivation(col.Key, "L_TBF03_SPEC_ROLL", this.ugrd_CalInfo, "ALLOWEDIT");
}
}
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
#endregion
#region "Grid Event"
private void ugrd_CalInfo_AfterRowActivate(object sender, EventArgs e)
{
try
{
this.textTarget.Text = Convert.ToString(this.ugrd_CalInfo.ActiveRow.Cells["CAL_NO"].Value);
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
private void ugrd_CalInfo_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
try
{
this.ugrd_CalInfo.UpdateData();
if (e.Cell.Column.Key == "CHK")
{
if (e.Cell.Value.ToString().ToUpper() == "TRUE")
{
string RollNO = e.Cell.Row.Cells["CAL_NO"].Value.ToString();
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.ugrd_CalInfo.Rows)
{
if (row.Cells["CAL_NO"].Value.ToString() != RollNO)
{
row.Cells["CHK"].Value = "FALSE";
}
}
this.ugrd_CalInfo.UpdateData();
}
}
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
#endregion
}
}