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 Core.StlMes.Client.YdmBase;
using Core.StlMes.Client.YdmPipeManage.Entity;
using Core.Mes.Client.Comm.Tool;
using System.Collections;
using Infragistics.Win.UltraWinGrid;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Control;
namespace Core.StlMes.Client.YdmPipeManage
{
public partial class frmPipeManualIn : FrmBase
{
public frmPipeManualIn()
{
this.IsLoadUserView = true;
InitializeComponent();
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
QueryManualIn();
break;
case "Add":
Add();
break;
case "Update":
break;
case "Delete":
break;
case"Export":
exportDat();
break;
case "Close":
this.Close();
break;
}
}
private void exportDat()
{
GridHelper.ulGridToExcel(ultraGrid2, "钢管起初总汇");
}
private void Add()
{
if (ultraTabControl1.SelectedTab.Key == "0")
{
AddMatZc();
}else
{
updateMat();
}
}
private void frmPipeManualIn_Load(object sender, EventArgs e)
{
dteInStartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01" + " 00:00:00");
//YdmBaseClass.InitComboEditor(cmbBelog, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getStorageDetail", "STORAGE_NO", this.ob, false);
EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]);
EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]);
this.txtHeatNo.Enabled = false;
this.txtBatchNo.Enabled = false;
this.cmbBelog.Enabled = false;
//this.checkBox1.Visible = false;
this.ultraTabControl1.Tabs["0"].Visible = false;
}
///
/// 查询期初数据
///
private void QueryManualIn()
{
string time = dteInStartTime.Value.ToString("yyyyMM");
string heatNo = "";
string batchNo = "";
string storeNo = "";
string ss = "";
string supplyUnit = this.CustomInfo;
ArrayList parm = new ArrayList();
if(chkHeatNo.Checked)
{
heatNo = this.txtHeatNo.Text.Trim();
}
if (chkBacthNo.Checked)
{
batchNo = this.txtBatchNo.Text.Trim();
}
if (chkStoreNo.Checked)
{
storeNo = this.cmbBelog.Value.ToString();
}
parm.Add(time);
parm.Add(heatNo);
parm.Add(batchNo);
parm.Add(storeNo);
if (ultraTabControl1.SelectedTab.Key == "0")
{
ss = "0";
List listSource = EntityHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeManualIn.queryManualIn", new object[] { parm, ss, supplyUnit }, this.ob);
YdmZcInitialEntitybindingSource.DataSource = listSource;
}
if (ultraTabControl1.SelectedTab.Key == "1")
{
ss = "1";
List listSource = EntityHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeManualIn.queryManualIn", new object[] { parm,ss, supplyUnit }, this.ob);
bindingSource1.DataSource = listSource;
}
}
///
/// 增加库存
///
private void AddMatZc()
{
int m = 0;
ArrayList parm = new ArrayList();
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
{
m++;
}
}
if (m < 1)
{
MessageUtil.ShowTips("请勾选你需要操作的数据!");
return;
}
foreach (UltraGridRow uRow in ultraGrid1.Rows)
{
if (Convert.ToBoolean(uRow.Cells["CHK"].Text) == true)
{
ArrayList list = new ArrayList();
list.Add(uRow.Cells["judgeStoveNo"].Text.ToString());
list.Add(uRow.Cells["batchNo"].Value.ToString());
list.Add(uRow.Cells["batchGroudNo"].Value.ToString());
list.Add(uRow.Cells["produccode"].Value.ToString());
list.Add(uRow.Cells["producname"].Value.ToString());
list.Add(uRow.Cells["STEELCODE"].Value.ToString());
list.Add(uRow.Cells["STEELNAME"].Value.ToString());
list.Add(uRow.Cells["specCode"].Value.ToString());
list.Add(uRow.Cells["specName"].Value.ToString());
list.Add(uRow.Cells["modelCode"].Value.ToString());
list.Add(uRow.Cells["modelDesc"].Value.ToString());//10
list.Add(uRow.Cells["stdCode"].Value.ToString());
list.Add(uRow.Cells["stdName"].Value.ToString());
list.Add(uRow.Cells["stdStyle"].Value.ToString());
list.Add(uRow.Cells["stdStyleDesc"].Value.ToString());
list.Add(uRow.Cells["DIMATER"].Value.ToString()); //15
list.Add(uRow.Cells["HEIGHT"].Value.ToString());
list.Add(uRow.Cells["LEN"].Value.ToString());
list.Add(uRow.Cells["lenMin"].Value.ToString());
list.Add(uRow.Cells["lenMax"].Value.ToString());
list.Add(uRow.Cells["actCount"].Value.ToString());//20
list.Add(uRow.Cells["actWeight"].Value.ToString());
list.Add(uRow.Cells["actTheoryWeight"].Value.ToString());
list.Add(uRow.Cells["judgeResultCode"].Value.ToString());
list.Add(uRow.Cells["judgeResult"].Value.ToString());
list.Add(uRow.Cells["storageNo"].Value.ToString());
list.Add(uRow.Cells["storageName"].Value.ToString());
list.Add(uRow.Cells["locationNo"].Value.ToString());
list.Add(uRow.Cells["orderNo"].Value.ToString());//28
list.Add(uRow.Cells["orderSeq"].Value.ToString().PadLeft(3,'0'));
//if (uRow.Cells["OrderSeqNo"].Value.ToString() == "")
//{
// list.Add("001");
//}
//else
//{
// list.Add(uRow.Cells["OrderSeqNo"].Value.ToString().PadLeft(3,'0'));
//}
list.Add(uRow.Cells["OrderSeqNo"].Value.ToString());
list.Add(uRow.Cells["MEMO"].Value.ToString());
list.Add(dteInStartTime.Value.ToString("yyyyMM"));
list.Add(uRow.Cells["GRADECODE"].Value.ToString());
list.Add(uRow.Cells["GRADENAME"].Value.ToString());
list.Add(uRow.Cells["plineCode"].Value.ToString());
list.Add(uRow.Cells["plineName"].Value.ToString());
list.Add(this.UserInfo.GetUserName());//37
list.Add(uRow.Cells["initialId"].Value.ToString());
list.Add(this.UserInfo.GetDeptid());
list.Add(this.UserInfo.GetDepartment());
list.Add(ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob));
list.Add(ClsBaseInfo.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob));
list.Add(uRow.Cells["JUDGEGRADE"].Value.ToString());
list.Add(uRow.Cells["instockTime"].Value.ToString());
list.Add(uRow.Cells["belongCode"].Value.ToString());
list.Add(uRow.Cells["belongName"].Value.ToString());
parm.Add(list);
}
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.pipemanage.FrmPipeManualIn";
ccp.MethodName = "addMatZc";
ccp.ServerParams = new object[] { parm };
ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("期初库存维护成功!"))
{
QueryManualIn();
}
}
}
///
/// 修改材料表
///
private void updateMat()
{
int m = 0;
ArrayList parm = new ArrayList();
foreach (UltraGridRow row in ultraGrid2.Rows)
{
if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
{
m++;
}
}
if (m < 1)
{
MessageUtil.ShowTips("请勾选你需要操作的数据!");
return;
}
foreach (UltraGridRow uRow in ultraGrid2.Rows)
{
if (Convert.ToBoolean(uRow.Cells["CHK"].Text) == true)
{
ArrayList list = new ArrayList();
list.Add(uRow.Cells["judgeStoveNo"].Text.ToString());
list.Add(uRow.Cells["batchNo"].Value.ToString());
list.Add(uRow.Cells["batchGroudNo"].Value.ToString());
list.Add(uRow.Cells["orderNo"].Value.ToString());
list.Add(uRow.Cells["orderSeq"].Value.ToString().PadLeft(3, '0'));
list.Add(uRow.Cells["OrderSeqNo"].Value.ToString());
list.Add(uRow.Cells["initialId"].Value.ToString());
parm.Add(list);
}
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.pipemanage.FrmPipeManualIn";
ccp.MethodName = "updateMat";
ccp.ServerParams = new object[] { parm };
ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("修改成功!"))
{
QueryManualIn();
//this.checkBox1.Checked = false;
}
}
}
private void chkHeatNo_CheckedChanged(object sender, EventArgs e)
{
this.txtHeatNo.Enabled = this.chkHeatNo.Checked;
}
private void chkBacthNo_CheckedChanged(object sender, EventArgs e)
{
this.txtBatchNo.Enabled = this.chkBacthNo.Checked;
}
private void chkStoreNo_CheckedChanged(object sender, EventArgs e)
{
this.cmbBelog.Enabled = this.chkStoreNo.Checked;
}
///
/// ultraGrid1拖选
///
///
///
private void ultraGrid1_AfterSelectChange(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e)
{
foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows)
{
if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
{
uRow.Cells["CHK"].Value = true;
}
}
}
private void ultraGrid2_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
{
foreach (UltraGridRow uRow in ultraGrid2.Selected.Rows)
{
if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
{
uRow.Cells["CHK"].Value = true;
}
}
}
//private void checkBox1_CheckedChanged(object sender, EventArgs e)
//{
// int chkint = 0;
// if (this.checkBox1.Checked)
// {
// foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows)
// {
// //if (uRow.Cells["CXSTUPP"].Value.ToString().Equals(""))
// //{
// chkint += 1;
// if (chkint > 500) return;
// uRow.Cells["CHK"].Value = true;
// //}
// }
// }
// else
// {
// foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows)
// {
// uRow.Cells["CHK"].Value = false;
// }
// }
//}
}
}