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.
227 lines
9.5 KiB
227 lines
9.5 KiB
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 wcfControlMonitorClient
|
|
{
|
|
/// <summary>
|
|
/// Creator:Richard.liu
|
|
/// 系统初始化
|
|
/// </summary>
|
|
public partial class FrmSystemInit : Form
|
|
{
|
|
DBFactory.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)
|
|
{
|
|
string errtext = string.Empty;
|
|
DataView tableWareHouse = CStaticClass.WcfControl.GetDataView(out errtext, "SELECT distinct F_WarehouseIndex,F_Description FROM T_WAREHOUSE").DefaultView;
|
|
cmbWareHouse.DisplayMember = "F_Description";
|
|
cmbWareHouse.ValueMember = "F_WarehouseIndex";
|
|
|
|
cmbWareHouse.DataSource = tableWareHouse;
|
|
|
|
DataView laneway = CStaticClass.WcfControl.GetDataView(out errtext, "SELECT distinct F_LaneDeviceIndex,F_StackIndex FROM T_Base_LaneInfo").DefaultView;
|
|
this.cbLaneway.DisplayMember = "F_LaneDeviceIndex";
|
|
cbLaneway.ValueMember = "F_StackIndex";
|
|
|
|
cbLaneway.DataSource = laneway;
|
|
}
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("您确认要生成货位信息吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
if (this.cmbWareHouse.SelectedValue == null)
|
|
{
|
|
MessageBox.Show("库房索引不能是空值!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
cmbWareHouse.Focus();
|
|
return;
|
|
}
|
|
int a = 0;
|
|
if (int.TryParse(this.cbLaneway.SelectedValue.ToString(),out a ) == false)
|
|
{
|
|
MessageBox.Show("巷道设备索引只能是数字类型!", "误操作提示:", 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);
|
|
|
|
string errtext=string.Empty;
|
|
int fid = 0;string cellcode=string.Empty;string cellname=string.Empty;
|
|
|
|
#region hwhx 海湾化学货位生成
|
|
int ii = 0;
|
|
for (int lane = 18001; lane <= 18024; lane++)
|
|
{
|
|
|
|
laneway = lane;
|
|
cbLaneway.SelectedItem = laneway;
|
|
Y = 8;
|
|
stackindex = Convert.ToInt32("110" + (laneway % 100).ToString().PadLeft(2, '0'));
|
|
//stackindex = Convert.ToInt32(this.cbLaneway.SelectedValue.ToString());
|
|
|
|
|
|
Z = ii + 1;
|
|
|
|
if (stackindex == 11001 || stackindex == 11007 || stackindex == 11013)
|
|
{
|
|
Z = Z + 1;
|
|
Z1 = Z;
|
|
}
|
|
else if (stackindex == 11024)
|
|
{
|
|
Z1 = Z;
|
|
}
|
|
else
|
|
Z1 = Z + 1;
|
|
startX = 1; X = 95;
|
|
for (int z = Z; z <= Z1; z++)
|
|
{
|
|
for (int x = startX; x <= X; x++)
|
|
{
|
|
int y = 1;
|
|
if (x == 1 || x == 95)
|
|
y = 3;
|
|
for (; y <= Y; y++)
|
|
{
|
|
cellcode = (z.ToString().Length == 1 ? "0" + z.ToString() : z.ToString())
|
|
+ "-" + (x.ToString().Length == 1 ? "0" + x.ToString() : x.ToString()) + "-" + (y.ToString().Length == 1 ? "0" + y.ToString() : y.ToString());
|
|
sql = "SELECT FID FROM ST_CELL WHERE (FWAREHOUSE = '" + warehouse + "') AND (FLaneWay = " + laneway + ") AND (FCELLCODE = '" + cellcode + "')";
|
|
if (dbo.ExceSQL(sql).Tables[0].DefaultView.Count <= 0)
|
|
{
|
|
cellname = z.ToString() + "排" + x.ToString() + "列" + y.ToString() + "层";
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ii = ii + 1;
|
|
}
|
|
return;
|
|
#endregion
|
|
|
|
|
|
for (int z = Z; z <= Z1; z++)
|
|
{
|
|
for (int x = startX; x <= X; x++)
|
|
{
|
|
for (int y = 1; y <= Y; y++)
|
|
{
|
|
cellcode = (z.ToString().Length == 1 ? "0" + z.ToString() : z.ToString())
|
|
+ "-" + (x.ToString().Length == 1 ? "0" + x.ToString() : x.ToString()) + "-" + (y.ToString().Length == 1 ? "0" + y.ToString() : y.ToString());
|
|
sql = "SELECT FID FROM ST_CELL WHERE (FWAREHOUSE = '"+warehouse+"') AND (FLaneWay = "+laneway +") AND (FCELLCODE = '"+cellcode+"')";
|
|
if (dbo.ExceSQL(sql).Tables[0].DefaultView.Count<=0)
|
|
{
|
|
cellname = z.ToString() + "排" + x.ToString() + "列" + y.ToString() + "层";
|
|
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("您确认要清空货位信息吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
dbo.ExceSQL("delete from st_cell");
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (MessageBox.Show("您确认要建立与PLC的通讯连接吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
string errtext=string.Empty;
|
|
if (CStaticClass.WcfControl.DeviceCommunicationInit("OPCClient", out errtext) == false)
|
|
{
|
|
MessageBox.Show(errtext, "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
CStaticClass.WcfControl.ReConnectOPCServer();//20130817richard
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
Button bt=(Button)sender;
|
|
if (MessageBox.Show("您确认要建立与AGV的通讯连接吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
DataView dv = dbo.ExceSQL(string.Format("SELECT F_RemoteIP, F_RemotePort FROM T_Base_Device WHERE (F_DeviceIndex = {0})",Convert.ToInt32( bt.Tag) )).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
string errtext = string.Empty;
|
|
if (CStaticClass.WcfControl.DeviceCommunicationInit("SocketsTCPIP:" + dv[0]["F_RemoteIP"].ToString() + "," + dv[0]["F_RemotePort"].ToString(), out errtext) == false)
|
|
{
|
|
MessageBox.Show(errtext, "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void FrmSystemInit_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
_formInstance = null;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|