using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using CoreFS.CA06;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Core.StlMes.Client.YdmBase
{
public partial class FrmBasePlineGroup : FrmBase
{
public FrmBasePlineGroup()
{
InitializeComponent();
}
private void FrmBasePlineGroup_Load(object sender, EventArgs e)
{
getGroupStoage();
getPlineCode();
getPlaceDelivery();
getStation();
getTransportation();
getBsStorage();
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
DoQuery();
break;
case "Add":
DoAdd();
break;
case "Update":
DoUpdate();
break;
case "Delete":
DoDelete();
break;
case "Export":
GridHelper.ulGridToExcel(GridStorage, "产线与仓库分组对于关系");
break;
case "Close":
this.Close();
break;
}
}
///
/// 查询
///
private void DoQuery()
{
string plineCode="";
string groupNo="";
if (chkPline.Checked)
{
if (cmbPlineQuery.Text.Equals(""))
{
MessageUtil.ShowTips("请选择产线!");
return;
}
else
{
plineCode = cmbPlineQuery.Value.ToString();
}
}
if (chkGroup.Checked)
{
if (cmbGroupQuery.Text.Equals(""))
{
MessageUtil.ShowTips("请选择仓库分组!");
return;
}
else
{
groupNo = cmbGroupQuery.Value.ToString();
}
}
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.doQuery", new Object[] { plineCode, groupNo }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
}
///
/// 新增
///
private void DoAdd()
{
string plineCode = "";
string plineName = "";
string adressNo = "";
string adressName = "";
string placeDelivNo = "";
string placeDelivName = "";
string stationNo = "";
string stationName = "";
string groupNo = "";
string groupName = "";
string storage_no = "";
string storage_name = "";
if (cmbPline.Text.Equals(""))
{
MessageUtil.ShowTips("主产线不能为空,请选择!");
return;
}
else
{
if (cmbPline.SelectedItem == null)
{
MessageUtil.ShowTips("请重新输入或选择下拉框存在的主产线!");
return;
}
plineCode = cmbPline.Value.ToString();
plineName = cmbPline.Text.Trim();
}
string cplineCode = "";
string cplineName = "";
//判定从表产线
if (txtPlineCode.Text.Equals(""))
{
if (cmbAdressNo.Text.Equals(""))
{
MessageUtil.ShowTips("运输方式不能为空,请选择!");
return;
}
else
{
adressNo = cmbAdressNo.Value.ToString();
adressName = cmbAdressNo.Text.Trim();
}
if (cmbAdressNo.Value.Equals("110501"))
{
if (!cmb_stoClass.Text.Equals(""))
{
//MessageUtil.ShowTips("交货地点不能为空,请选择!");
//return;
stationNo = cmb_stoClass.Value.ToString();
stationName = cmb_stoClass.Text.Trim();
}
}
else
{
if (!cmb_taskNo.Text.Equals(""))
{
//MessageUtil.ShowTips("到站不能为空,请选择!");
//return;
stationNo = cmb_taskNo.Value.ToString();
stationName = cmb_taskNo.Text.Trim();
}
}
}
else
{
if (txtPlineCode.SelectedItem == null)
{
MessageUtil.ShowTips("请重新输入或选择下拉框存在的从产线!");
return;
}
cplineCode = txtPlineCode.Value.ToString();
cplineName = txtPlineCode.Text.ToString();
}
if (txtPlineCode.Text.Equals(""))
{
placeDelivNo = adressNo + stationNo;
placeDelivName = adressName + " " + stationName;
}
else
{
placeDelivNo = cplineCode;
placeDelivName = cplineName;
}
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.storageRepeatCode", new Object[] { plineCode,placeDelivNo }, this.ob);
if (dt.Rows.Count > 0)
{
string repeat = dt.Rows[0][0].ToString();
if (repeat != "")
{
MessageUtil.ShowTips("你选择的从产线或运输方式+交货地点/到站有重复,请重新选择!");
return;
}
}
if (GroupName.Text.Equals(""))
{
MessageUtil.ShowTips("仓库分组不能为空,请选择!");
return;
}
else
{
groupNo = GroupName.Value.ToString();
groupName = GroupName.Text.Trim();
}
if (!ultraComboEditor1.Text.ToString().Equals(""))
{
if (ultraComboEditor1.SelectedItem == null)
{
MessageUtil.ShowTips("请重新输入或选择下拉框存在的仓库!");
return;
}
storage_no = ultraComboEditor1.Value.ToString();
storage_name = ultraComboEditor1.Text.ToString().Trim();
}
if (MessageBox.Show("是否新增数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return;
ArrayList parm = new ArrayList();
parm.Add(plineCode);
parm.Add(plineName);
parm.Add(placeDelivNo);
parm.Add(placeDelivName);
parm.Add(groupNo);
parm.Add(groupName);
parm.Add(this.UserInfo.GetUserName());
parm.Add(storage_no);
parm.Add(storage_name);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.base.FrmBasePlineGroup";
ccp.MethodName = "doAdd";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
MessageUtil.ShowTips("新增成功!");
DoQuery();
YdmBaseClass.Postioning(GridStorage, "PLINE_CODE_C", placeDelivNo);
}
///
/// 修改
///
private void DoUpdate()
{
UltraGridRow row = GridStorage.ActiveRow;
if (row == null) return;
string plineCode = "";
string plineName = "";
string adressNo = "";
string adressName = "";
string placeDelivNo = "";
string placeDelivName = "";
string stationNo = "";
string stationName = "";
string groupNo = "";
string groupName = "";
string storage_no = "";
string storage_name = "";
if (cmbPline.Text.Equals(""))
{
MessageUtil.ShowTips("产线不能为空,请选择!");
return;
}
else
{
plineCode = cmbPline.Value.ToString();
plineName = cmbPline.Text.Trim();
}
string cplineCode = "";
string cplineName = "";
//判定从表产线
if (txtPlineCode.Text.Equals(""))
{
if (cmbAdressNo.Text.Equals(""))
{
MessageUtil.ShowTips("运输方式不能为空,请选择!");
return;
}
else
{
adressNo = cmbAdressNo.Value.ToString();
adressName = cmbAdressNo.Text.Trim();
}
if (cmbAdressNo.Value.Equals("110501"))
{
if (!cmb_stoClass.Text.Equals(""))
{
//MessageUtil.ShowTips("交货地点不能为空,请选择!");
//return;
stationNo = cmb_stoClass.Value.ToString();
stationName = cmb_stoClass.Text.Trim();
}
}
else
{
if (!cmb_taskNo.Text.Equals(""))
{
//MessageUtil.ShowTips("到站不能为空,请选择!");
//return;
stationNo = cmb_taskNo.Value.ToString();
stationName = cmb_taskNo.Text.Trim();
}
}
}
else
{
cplineCode = txtPlineCode.Value.ToString();
cplineName = txtPlineCode.Text.ToString();
}
if (txtPlineCode.Text.Equals(""))
{
placeDelivNo = adressNo + stationNo;
placeDelivName = adressName + " " + stationName;
}
else
{
placeDelivNo = cplineCode;
placeDelivName = cplineName;
}
if (placeDelivNo != row.Cells["PLINE_CODE_C"].Value.ToString())
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.storageRepeatCode", new Object[] { plineCode, placeDelivNo }, this.ob);
if (dt.Rows.Count > 1)
{
string repeat = dt.Rows[0][0].ToString();
if (repeat != "")
{
MessageUtil.ShowTips("你选择的从产线或运输方式+交货地点/到站有重复,请重新选择!");
return;
}
}
}
if (GroupName.Text.Equals(""))
{
MessageUtil.ShowTips("仓库分组不能为空,请选择!");
return;
}
else
{
groupNo = GroupName.Value.ToString();
groupName = GroupName.Text.Trim();
}
if (!ultraComboEditor1.Text.ToString().Equals(""))
{
storage_no = ultraComboEditor1.Value.ToString();
storage_name = ultraComboEditor1.Text.ToString().Trim();
}
if (MessageBox.Show("是否修改选择数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return;
ArrayList parm = new ArrayList();
//parm.Add(plineCode);
//parm.Add(plineName);
//parm.Add(placeDelivNo);
//parm.Add(placeDelivName);
parm.Add(groupNo);
parm.Add(groupName);
parm.Add(this.UserInfo.GetUserName());
parm.Add(storage_no);
parm.Add(storage_name);
parm.Add(row.Cells["PLINE_CODE_M"].Value.ToString());
parm.Add(row.Cells["PLINE_CODE_C"].Value.ToString());
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.base.FrmBasePlineGroup";
ccp.MethodName = "doUpdate";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
MessageUtil.ShowTips("修改成功!");
DoQuery();
YdmBaseClass.Postioning(GridStorage, "PLINE_CODE_C", placeDelivNo);
}
///
/// 删除
///
private void DoDelete()
{
UltraGridRow row = GridStorage.ActiveRow;
if (row == null) return;
string plineCode = row.Cells["PLINE_CODE_M"].Value.ToString();
string placeDelivNo = row.Cells["PLINE_CODE_C"].Value.ToString();
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.storageRepeatCode", new Object[] { plineCode,placeDelivNo }, this.ob);
if (dt.Rows.Count <= 0)
{
MessageUtil.ShowTips("你选择数据已删除,请重新选择!");
return;
}
if (MessageBox.Show("是否删除选择数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return;
ArrayList parm = new ArrayList();
parm.Add(row.Cells["PLINE_CODE_M"].Value.ToString());
parm.Add(row.Cells["PLINE_CODE_C"].Value.ToString());
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.base.FrmBasePlineGroup";
ccp.MethodName = "doDelete";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
MessageUtil.ShowTips("删除成功!");
DoQuery();
YdmBaseClass.Postioning(GridStorage, "PLINE_CODE_C", placeDelivNo);
}
///
/// 仓库分组
///
private void getGroupStoage()
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.getGroupStoage", new object[] { "8019" }, this.ob);
GroupName.DataSource = dt;
GroupName.DisplayMember = "BASENAME";
GroupName.ValueMember = "BASECODE";
YdmBaseClass.SetComboItemHeight(GroupName);
cmbGroupQuery.DataSource = dt;
cmbGroupQuery.DisplayMember = "BASENAME";
cmbGroupQuery.ValueMember = "BASECODE";
YdmBaseClass.SetComboItemHeight(cmbGroupQuery);
}
///
///运输方式
///
private void getTransportation()
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.getGroupStoage", new object[] { "1105" }, this.ob);
cmbAdressNo.DataSource = dt;
cmbAdressNo.DisplayMember = "BASENAME";
cmbAdressNo.ValueMember = "BASECODE";
YdmBaseClass.SetComboItemHeight(cmbAdressNo);
}
///
/// 交货地点
///
private void getPlaceDelivery()
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.getGroupStoage", new object[] { "1106" }, this.ob);
Object[] obj = new Object[] { "", "" };
DataRow dr = dt.NewRow();
dr.ItemArray = obj;
dt.Rows.InsertAt(dr, 0);
cmb_stoClass.DataSource = dt;
cmb_stoClass.DisplayMember = "BASENAME";
cmb_stoClass.ValueMember = "BASECODE";
YdmBaseClass.SetComboItemHeight(cmb_stoClass);
}
///
/// 有效仓库
///
private void getBsStorage()
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.getBsStorage", null, this.ob);
ultraComboEditor1.DataSource = dt;
ultraComboEditor1.DisplayMember = "STORAGE_NAME";
ultraComboEditor1.ValueMember = "STORAGE_NO";
YdmBaseClass.SetComboItemHeight(ultraComboEditor1);
}
///
/// 到站
///
private void getStation()
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.getStationQuery", null, this.ob);
Object[] obj = new Object[] { "", "" };
DataRow dr = dt.NewRow();
dr.ItemArray = obj;
dt.Rows.InsertAt(dr, 0);
cmb_taskNo.DataSource = dt;
cmb_taskNo.DisplayMember = "STATION_NM";
cmb_taskNo.ValueMember = "STATION_NO";
YdmBaseClass.SetComboItemHeight(cmb_taskNo);
}
///
/// 产线查询
///
private void getPlineCode()
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.doPlineCodeQuery", null, this.ob);
cmbPlineQuery.DataSource = dt;
cmbPlineQuery.DisplayMember = "PLINE_NAME";
cmbPlineQuery.ValueMember = "PLINE_CODE";
YdmBaseClass.SetComboItemHeight(cmbPlineQuery);
cmbPline.DataSource = dt;
cmbPline.DisplayMember = "PLINE_NAME";
cmbPline.ValueMember = "PLINE_CODE";
YdmBaseClass.SetComboItemHeight(cmbPline);
DataTable dt1 = ServerHelper.GetData("com.steering.pss.ydm.base.FrmBasePlineGroup.doPlineCodeQuery", null, this.ob);
Object[] obj = new Object[] { "", "" };
DataRow dr = dt1.NewRow();
dr.ItemArray = obj;
dt1.Rows.InsertAt(dr, 0);
txtPlineCode.DataSource = dt1;
txtPlineCode.DisplayMember = "PLINE_NAME";
txtPlineCode.ValueMember = "PLINE_CODE";
YdmBaseClass.SetComboItemHeight(txtPlineCode);
}
private void chkPline_CheckedChanged(object sender, EventArgs e)
{
if (chkPline.Checked) { cmbPlineQuery.Enabled = true; } else { cmbPlineQuery.Enabled = false; }
if (chkGroup.Checked) { cmbGroupQuery.Enabled = true; } else { cmbGroupQuery.Enabled = false; }
}
private void cmbAdressNo_ValueChanged(object sender, EventArgs e)
{
if (cmbAdressNo.Text.Trim().Equals(""))
{
cmb_stoClass.Enabled = false;
cmb_taskNo.Enabled = false;
}
else
{
if (cmbAdressNo.Value.Equals("110501"))
{
cmb_stoClass.Enabled = true;
cmb_taskNo.Enabled = false;
cmb_taskNo.Text = "";
}
else
{
cmb_stoClass.Enabled = false;
cmb_taskNo.Enabled = true;
cmb_stoClass.Text = "";
}
}
}
private void GridStorage_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow row = GridStorage.ActiveRow;
if (row == null) return;
cmbPline.Value = row.Cells["PLINE_CODE_M"].Text.ToString();
string plincod=row.Cells["PLINE_CODE_C"].Value.ToString().Substring(0,4).ToString();
if (plincod.Equals("1105"))
{
//cmbAdressNo.Enabled = true;
cmbAdressNo.Value = row.Cells["PLINE_CODE_C"].Value.ToString().Substring(0, 6).ToString();
if (cmbAdressNo.Value.ToString().Equals("110501"))
{
cmb_stoClass.Value = row.Cells["PLINE_CODE_C"].Value.ToString().Substring(6).ToString();
}
else
{
cmb_taskNo.Value = row.Cells["PLINE_CODE_C"].Value.ToString().Substring(6).ToString();
}
txtPlineCode.Value = "";
}
else
{
txtPlineCode.Value = row.Cells["PLINE_CODE_C"].Value.ToString().Substring(0, 4).ToString();
}
GroupName.Value = row.Cells["STOCK_GROUP_CODE"].Text.ToString();
ultraComboEditor1.Value = row.Cells["STORAGE_NO"].Text.ToString();
}
private void txtPlineCode_ValueChanged(object sender, EventArgs e)
{
if (txtPlineCode.Text.Trim().Equals(""))
{
cmbAdressNo.Enabled = true;
cmbAdressNo.Value = "110501";
}
else
{
cmbAdressNo.Enabled = false;
cmbAdressNo.Text = "";
cmb_stoClass.Text = "";
cmb_taskNo.Text = "";
}
}
}
}