219 lines
8.7 KiB
C#
219 lines
8.7 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Configuration;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.Text;
|
|||
|
using System.Windows.Forms;
|
|||
|
using Microsoft.VisualBasic;
|
|||
|
using DBFactory;
|
|||
|
namespace ControlSystem
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Creator:Richard.liu
|
|||
|
/// ϵͳ<CFB5><CDB3>ʼ<EFBFBD><CABC>
|
|||
|
/// </summary>
|
|||
|
public partial class FrmSystemInit : Form
|
|||
|
{
|
|||
|
DBOperator dbo = CStaticClass.dbo;
|
|||
|
private static FrmSystemInit _formInstance;
|
|||
|
|
|||
|
public static FrmSystemInit FormInstance
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_formInstance == null)
|
|||
|
{
|
|||
|
_formInstance = new FrmSystemInit();
|
|||
|
}
|
|||
|
return _formInstance;
|
|||
|
}
|
|||
|
set { _formInstance = value; }
|
|||
|
}
|
|||
|
public FrmSystemInit()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
_formInstance = this;
|
|||
|
}
|
|||
|
|
|||
|
private void FrmSystemInit_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
DataTable tableWareHouse = dbo.ExceSQL("SELECT distinct F_WarehouseIndex,F_Description FROM T_WAREHOUSE").Tables[0];
|
|||
|
cmbWareHouse.DisplayMember = "F_Description";
|
|||
|
cmbWareHouse.ValueMember = "F_WarehouseIndex";
|
|||
|
|
|||
|
cmbWareHouse.DataSource = tableWareHouse.DefaultView;
|
|||
|
|
|||
|
DataTable laneway = dbo.ExceSQL("SELECT distinct F_LaneDeviceIndex,F_StackIndex FROM T_Base_LaneInfo").Tables[0];
|
|||
|
this.cbLaneway.DisplayMember = "F_LaneDeviceIndex";
|
|||
|
cbLaneway.ValueMember = "F_StackIndex";
|
|||
|
|
|||
|
cbLaneway.DataSource = laneway.DefaultView;
|
|||
|
}
|
|||
|
|
|||
|
private void button4_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (MessageBox.Show("<22><>ȷ<EFBFBD><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD>ɻ<EFBFBD>λ<EFBFBD><CEBB>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
if (this.cmbWareHouse.SelectedValue == null)
|
|||
|
{
|
|||
|
MessageBox.Show("<22>ⷿ<EFBFBD><E2B7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>ֵ<EFBFBD><D6B5>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|||
|
cmbWareHouse.Focus();
|
|||
|
return;
|
|||
|
}
|
|||
|
if (Information.IsNumeric(this.cbLaneway.SelectedValue ) == false)
|
|||
|
{
|
|||
|
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|||
|
this.cbLaneway.Focus();
|
|||
|
return;
|
|||
|
}
|
|||
|
string sql = string.Empty;
|
|||
|
string warehouse = this.cmbWareHouse.SelectedValue.ToString();
|
|||
|
int laneway =Convert.ToInt32( this.cbLaneway.Text);
|
|||
|
int stackindex =Convert.ToInt32(lblStackIndex.Text);
|
|||
|
int Z =Convert.ToInt32( nudZ.Value);
|
|||
|
int Z1 = Convert.ToInt32(nudZ1.Value);
|
|||
|
int startX = Convert.ToInt32(nudstartX.Value);
|
|||
|
int X = Convert.ToInt32(nudX.Value);
|
|||
|
int Y = Convert.ToInt32(nudY.Value);
|
|||
|
|
|||
|
int fid = 0;string cellcode=string.Empty;string cellname=string.Empty;
|
|||
|
for (int z = Z; z <= Z1; z++)
|
|||
|
{
|
|||
|
for (int x = startX; x <= X; x++)
|
|||
|
{
|
|||
|
for (int y = 1; y <= Y; y++)
|
|||
|
{
|
|||
|
string xstr =string.Empty;
|
|||
|
if (x.ToString().Length == 1)
|
|||
|
{
|
|||
|
|
|||
|
xstr = "0" + x.ToString();
|
|||
|
}
|
|||
|
|
|||
|
if (x.ToString().Length == 2)
|
|||
|
{
|
|||
|
xstr = x.ToString();
|
|||
|
}
|
|||
|
cellcode = (z.ToString().Length == 1 ? "0" + z.ToString() : z.ToString())
|
|||
|
+ "-" +xstr + "-" + (y.ToString().Length == 1 ? "0" + y.ToString() : y.ToString());
|
|||
|
|
|||
|
if (x>101)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
sql = "SELECT FID FROM ST_CELL WHERE (FWAREHOUSE = '"+warehouse+"') AND (FLaneWay = "+laneway +") AND (FCELLCODE = '"+cellcode+"')";
|
|||
|
if (dbo.Exists(sql) == false)
|
|||
|
{
|
|||
|
cellname = z.ToString() + "<22><>" + x.ToString() + "<22><>" + y.ToString() + "<22><>";
|
|||
|
fid = dbo.GetMaxID("FID", "ST_CELL");
|
|||
|
sql = "INSERT INTO ST_CELL(FID, FWAREHOUSE, FLaneWay, FCELLCODE, F_Z, F_X, F_Y, " +
|
|||
|
"FCELLNAME,FCELLSTATUS, FRUNSTATUS, FPALLETBARCODE, FStack)VALUES " +
|
|||
|
"(" + fid + ",'" + warehouse + "'," + laneway + ",'" + cellcode + "'," + z + "," + x + "," + y + ",'" + cellname +
|
|||
|
"',0,0,'-'," + stackindex + ")";
|
|||
|
dbo.ExecuteSql(sql);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void cbLaneway_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
lblStackIndex.Text = this.cbLaneway.SelectedValue.ToString();
|
|||
|
}
|
|||
|
|
|||
|
private void button5_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (MessageBox.Show("<22><>ȷ<EFBFBD><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD>ջ<EFBFBD>λ<EFBFBD><CEBB>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
dbo.ExceSQL("delete from st_cell");
|
|||
|
}
|
|||
|
|
|||
|
private void button2_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (MessageBox.Show("<22><>ȷ<EFBFBD><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PLC<4C><43>ͨѶ<CDA8><D1B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
OPCClient.CCommonOPCClient.ConnectCount = 0;
|
|||
|
FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "", false);
|
|||
|
}
|
|||
|
|
|||
|
private void button3_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (MessageBox.Show("<22><>ȷ<EFBFBD><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AGV<47><56>ͨѶ<CDA8><D1B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
SocketsTCPIP.CClientTCPIP.TcpIPInitCount = 0;
|
|||
|
FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "", false);
|
|||
|
}
|
|||
|
|
|||
|
private void button6_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.button6.Enabled = false;
|
|||
|
DataView dv = dbo.ExceSQL("select * from t_base_device where f_devicekindindex =2 OR f_devicekindindex =1").Tables[0].DefaultView;
|
|||
|
if (dv.Count > 0)
|
|||
|
{
|
|||
|
for (int i = 0; i < dv.Count; i++)
|
|||
|
{
|
|||
|
//if (dv[i]["F_DBW1Address"] != null)
|
|||
|
//{
|
|||
|
// int tempaddress=Convert.ToInt32 (dv[i]["F_DBW1Address"] );
|
|||
|
// int tempdeviceindex =Convert.ToInt32(dv[i]["F_DeviceIndex"]);
|
|||
|
// dbo.ExceSQL("update t_base_device set F_DBW2Address =" + tempaddress + "where f_deviceindex =" + tempdeviceindex);
|
|||
|
//}
|
|||
|
|
|||
|
//string tempdeviceindex = (dv[i]["F_DeviceIndex"].ToString());
|
|||
|
//if (tempdeviceindex.Length == 6)
|
|||
|
//{
|
|||
|
|
|||
|
// string tempdevicename = tempdeviceindex.Substring(0, 5) + "#<23><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>" + tempdeviceindex.Substring(5, 1) + "<22><>";
|
|||
|
// dbo.ExceSQL("update t_base_device set F_DeviceName ='" + tempdevicename + "' where f_deviceindex =" + Convert.ToInt32(tempdeviceindex));
|
|||
|
//}
|
|||
|
|
|||
|
//int deviceindex = Convert.ToInt32(dv[i]["F_DeviceIndex"]);
|
|||
|
//string ahead = "I" + deviceindex;
|
|||
|
//dbo.ExceSQL("update t_base_device set F_BeDetected ='" + ahead + "' where F_DeviceIndex =" + deviceindex);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//int F_SplitByte = 0;
|
|||
|
//int deviceindex = Convert.ToInt32(dv[i]["F_DeviceIndex"]);
|
|||
|
//if (Convert.ToInt32(dv[i]["f_devicekindindex"]) == 1)
|
|||
|
//{
|
|||
|
|
|||
|
// F_SplitByte = Convert.ToInt32(dv[i]["F_DBW2Address"]) + 12;
|
|||
|
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// F_SplitByte = Convert.ToInt32(dv[i]["F_DBW2Address"]) + 5;
|
|||
|
//}
|
|||
|
//dbo.ExceSQL("update t_base_device set F_SplitByte =" + F_SplitByte + "where F_DeviceIndex =" + deviceindex);
|
|||
|
|
|||
|
int deviceindex = Convert.ToInt32(dv[i]["F_DeviceIndex"]);
|
|||
|
string f_bindingdevice = deviceindex.ToString() + ".0";
|
|||
|
dbo.ExceSQL("update t_base_device set F_BindingDeviceOut =null where F_DeviceIndex =" + deviceindex);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
this.button6.Enabled = true;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|