You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
251 lines
9.3 KiB
251 lines
9.3 KiB
10 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Data;
|
||
|
using System.Drawing;
|
||
|
using System.Text;
|
||
|
using System.Windows.Forms;
|
||
|
using DBFactory;
|
||
|
namespace wcfControlMonitorClient
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 20110906������������˫����������
|
||
|
/// </summary>
|
||
|
public partial class FrmRelativeIDSet : Form
|
||
|
{
|
||
|
DBOperator dbo = CStaticClass.dbo;
|
||
|
//DBOperator dboM = CStaticClass.dboM;
|
||
|
private static FrmRelativeIDSet _formInstance;
|
||
|
|
||
|
public static FrmRelativeIDSet FormInstance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (_formInstance == null)
|
||
|
{
|
||
|
_formInstance = new FrmRelativeIDSet();
|
||
|
}
|
||
|
return _formInstance;
|
||
|
}
|
||
|
set { _formInstance = value; }
|
||
|
}
|
||
|
public FrmRelativeIDSet()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
|
||
|
_formInstance = this;
|
||
|
|
||
|
}
|
||
|
|
||
|
private void button1_Click_1(object sender, EventArgs e)
|
||
|
{
|
||
|
int flag = 0;//0��ʾ˫��������������
|
||
|
if(rbnNearForkSet.Checked)//��ȡradiobuttonѡ��״̬
|
||
|
{
|
||
|
flag = 1;
|
||
|
|
||
|
}
|
||
|
else
|
||
|
if (rbnFarForkSet.Checked)
|
||
|
{
|
||
|
flag = 2;
|
||
|
|
||
|
}
|
||
|
|
||
|
if (cbBType.Text.Trim().Length <= 0)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ���������ͣ�", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
if (cbBFloor.Text.Trim().Length <= 0)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ����������¥�㣡", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
if (cbBLane.Text.Trim().Length <= 0)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ����������������", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
if(flag!=1)
|
||
|
{
|
||
|
if (cbBFarID.Text.Trim().Length <= 0)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ��Զ����������������", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (flag != 2)
|
||
|
{
|
||
|
if (cbBNearID.Text.Trim().Length <= 0)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ��������������������", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//����ʱ1.���������Ƿ����ڣ�2.���ܹ����Լ���3.��ʾ���ô����ĺ���
|
||
|
int FarID = 0, NearID = 0;
|
||
|
int Type = cbBType.SelectedIndex + 1;
|
||
|
int Floor = cbBFloor.SelectedIndex + 1;
|
||
|
string Lane = string.Format("1800{0}", cbBLane.SelectedIndex + 1);
|
||
|
|
||
|
string str1=string.Empty, str2=string.Empty;
|
||
|
if(flag!=1)
|
||
|
{
|
||
|
|
||
|
FarID = Convert.ToInt32(cbBFarID.Text.Trim());//Զ��������
|
||
|
str1 = string.Format("��������: {0} ����ΪԶ��ִ�� ", FarID);
|
||
|
}
|
||
|
if (flag != 2)
|
||
|
{
|
||
|
NearID = Convert.ToInt32(cbBNearID.Text.Trim());//����������
|
||
|
str2 = string.Format("��������: {0} ����Ϊ����ִ�� ", NearID);
|
||
|
}
|
||
|
|
||
|
string info = string.Format("ȷ�Ͻ�{0}{1}��?\r\n\r\n�������ã����ô�������������!!!", str1, str2);
|
||
|
|
||
|
|
||
|
//�жϽ�����������Զ���������Ƿ���ͬ
|
||
|
if(FarID==NearID)
|
||
|
{
|
||
|
MessageBox.Show("Զ��������������������������������������ͬ��", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
//�ж�Զ�������Ƿ�����
|
||
|
string sql = string.Format("select FID from T_Manage_Task where ( FCONTROLTASKTYPE = {0} ) And ((FCONTROLTASKTYPE=1 and FSTARTDEVICE like '{1}_%' and FENDDEVICE like '{2}' ) or (FCONTROLTASKTYPE=2 and FENDDEVICE like '{3}_%' and FSTARTDEVICE like '{4}' ) And ( FID = {5}))", Type, Floor, Lane, Floor, Lane,FarID);
|
||
|
|
||
|
// string sql = string.Format("select FID from T_Manage_Task where ( FCONTROLTASKTYPE = 1 ) and ( FSTARTDEVICE like '{0}_%' ) and ( FENDDEVICE like '{1}' ) and FID = {2}", Floor, Lane, FarID);
|
||
|
DataView dvs = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvs.Count <= 0)
|
||
|
{
|
||
|
MessageBox.Show("����������Զ�������������������ڣ�", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
|
||
|
}
|
||
|
//�жϽ��������Ƿ�����
|
||
|
sql = string.Format("select FID from T_Manage_Task where ( FCONTROLTASKTYPE = {0} ) And ((FCONTROLTASKTYPE=1 and FSTARTDEVICE like '{1}_%' and FENDDEVICE like '{2}' ) or (FCONTROLTASKTYPE=2 and FENDDEVICE like '{3}_%' and FSTARTDEVICE like '{4}' ) And ( FID = {5}))", Type, Floor, Lane, Floor, Lane, NearID);
|
||
|
dvs = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvs.Count <= 0)
|
||
|
{
|
||
|
MessageBox.Show("���������Ľ��������������������ڣ�", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
|
||
|
}
|
||
|
//CStaticClass.WcfControl.BeginModifyManageTaskFork(mti, fid, Model.CGeneralFunction.TASKFINISH, new AsyncCallback(ModifyManageTaskCallBack), null);
|
||
|
|
||
|
if (MessageBox.Show(info, "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
|
||
|
{
|
||
|
CStaticClass.WcfControl.BeginModifyManageTaskFork(flag, FarID, NearID, new AsyncCallback(ModifyManageTaskForkCallBack), null);
|
||
|
}
|
||
|
|
||
|
////��ʾ�����ù�������
|
||
|
// string info = string.Format("ȷ������Զ������: {0} �� ��������: {1} Ϊ˫������������?\r\n\r\n�������ã����ô�������������!!!",FarID,NearID);
|
||
|
// if (MessageBox.Show(info, "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
|
||
|
// {
|
||
|
// //���õ��������Ĺ�������ָ������
|
||
|
// //�����豸ָ�������еĻ���
|
||
|
// //ָ��Զ��
|
||
|
// string managesql = string.Format("update T_Manage_Task set FUseAwayFork='1',F_RELATIVECONTORLID={0} where FID ={1}",NearID,FarID);
|
||
|
// string monitorsql = string.Format("update T_Monitor_Task set F_UseAwayFork='1' where F_ManageTaskIndex= {0}", FarID);
|
||
|
// dbo.ExecuteSql(managesql);
|
||
|
// dbo.ExecuteSql(monitorsql);
|
||
|
|
||
|
|
||
|
// //ָ������
|
||
|
|
||
|
// managesql = string.Format("update T_Manage_Task set FUseAwayFork='0',F_RELATIVECONTORLID={0} where FID = {1}", FarID,NearID);
|
||
|
// monitorsql = string.Format("update T_Monitor_Task set F_UseAwayFork='0' where F_ManageTaskIndex= {0}", NearID);
|
||
|
// dbo.ExecuteSql(managesql);
|
||
|
// dbo.ExecuteSql(monitorsql);
|
||
|
|
||
|
// }
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
void ModifyManageTaskForkCallBack(IAsyncResult ar)
|
||
|
{
|
||
|
string errtext = string.Empty;
|
||
|
if (CStaticClass.WcfControl.EndModifyManageTaskFork(out errtext, ar) == false)
|
||
|
{
|
||
|
MessageBox.Show(errtext, "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
private void FrmRelativeIDSet_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
private void cbBLane_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
int Type = cbBType.SelectedIndex + 1;
|
||
|
int Floor=cbBFloor.SelectedIndex+1;
|
||
|
string Lane=string.Format("1800{0}",cbBLane.SelectedIndex+1);
|
||
|
|
||
|
string sql = string.Format("select FID from T_Manage_Task where ( FCONTROLTASKTYPE = {0} ) And ((FCONTROLTASKTYPE=1 and FSTARTDEVICE like '{1}_%' and FENDDEVICE like '{2}' ) or (FCONTROLTASKTYPE=2 and FENDDEVICE like '{3}_%' and FSTARTDEVICE like '{4}' ))", Type, Floor, Lane, Floor, Lane);
|
||
|
DataView dvs = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
|
||
|
cbBFarID.ValueMember = "FID";
|
||
|
cbBFarID.DisplayMember = "FID";
|
||
|
cbBFarID.DataSource = dvs;
|
||
|
|
||
|
|
||
|
DataView dvs1 = dvs.ToTable().DefaultView;
|
||
|
|
||
|
cbBNearID.ValueMember = "FID";
|
||
|
cbBNearID.DisplayMember = "FID";
|
||
|
cbBNearID.DataSource = dvs1;
|
||
|
|
||
|
}
|
||
|
|
||
|
private void button2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
cbBLane_SelectedIndexChanged(null, EventArgs.Empty);
|
||
|
}
|
||
|
|
||
|
private void cbBFloor_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
cbBLane.SelectedIndex = -1;
|
||
|
//cbBLane.Text = "";
|
||
|
//cbBFarID.Text = "";
|
||
|
//cbBNearID.Text = "";
|
||
|
}
|
||
|
|
||
|
private void rbnOneForkSet_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
gbFloor.Visible = false;
|
||
|
gbLane.Visible = false;
|
||
|
}
|
||
|
|
||
|
private void rbnTwoForkSet_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
gbNearFork.Visible = true;
|
||
|
gbFarFork.Visible = true;
|
||
|
}
|
||
|
|
||
|
private void rbnOneForkSet_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
private void rbnFarForkSet_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
gbNearFork.Visible = false;
|
||
|
gbFarFork.Visible = true;
|
||
|
}
|
||
|
|
||
|
private void rbnNearForkSet_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
gbNearFork.Visible = true;
|
||
|
gbFarFork.Visible = false; ;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|