using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.BaseMethod; using Core.StlMes.Client.Mcp.CollarMaterial; using Core.StlMes.Client.Mcp.Common; using Core.StlMes.Client.Mcp.Control; using Core.StlMes.Client.Mcp.Entity; using CoreFS.CA06; using Infragistics.Win; 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.Threading; using System.Windows.Forms; namespace Core.StlMes.Client.Mcp.CollarLibrary { public partial class FrmCollarOutBound : FrmBase { private string strOutbound = "800803";//出库类型编码 private string strOutname = "";//出库类型名称 private TalentICTGXControl.TalentICTGXClass icClass; private string[] storageArr = null; private string departId = ""; private string departMent = ""; public FrmCollarOutBound() { InitializeComponent(); try { string[] portnames = System.IO.Ports.SerialPort.GetPortNames(); //获取计算机串口数组 if (portnames is Infragistics.Win.UltraWinGrid.Nullable || portnames.Length < 1) { portnames = new string[10] { "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM10" }; } txtCom.DataSource = portnames; this.txtCom.SelectedIndex = 0; } catch (Exception eex3) { MessageBox.Show(eex3.Message); } } private void FrmCollarOutBound_Load(object sender, EventArgs e) { RegStartTime.Value = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00:00"); RegEndTime.Value = DateTime.Parse(DateTime.Today.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd") + " 23:59:59"); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getKepNo", null, this.ob); cmbMaterial.DataSource = dt; cmbMaterial.DisplayMember = "KEP_NO"; PipeManageClass.SetComboItemHeight(cmbMaterial); cmbKenNo.DataSource = dt; cmbKenNo.DisplayMember = "KEP_NO"; PipeManageClass.SetComboItemHeight(cmbKenNo); PipeManageClass.setUltraGridColumnInput(ultraGrid2, new string[] { "DealNum" });//支数 PipeManageClass.setUltraGridColumnMaxInput(ultraGrid2, new string[] { "DealWt" });//重量 storageArr = BaseHelper.WarehousePermissionsStore1(this.ValidDataPurviewIds, ob); departId = BaseHelper.GetDepartIdBySectionId1(this.UserInfo.GetDeptid(), this.ob); departMent = BaseHelper.GetDepartBySectionId1(this.UserInfo.GetDeptid(), this.ob); StorInfo(); getStoreAll(); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Add": doAdd(); break; case "Delete": doDelete(); break; //case "Refresh": // doRefresh(); // break; case "Export": if (ultraTabControl1.SelectedTab.Key.Equals("Library1")) { GridHelper.ulGridToExcel(ultraGrid1, "库存实绩表"); } else { GridHelper.ulGridToExcel(ultraGrid2, "倒库实绩表"); } break; case "Close": this.Close(); break; case "addWriteCard": addWriteCard(); break; } } private void doQuery() { string strRegStart = ""; string strRegEnd = ""; string strWare = "";//仓库号 string strMat = "";//框号 string strFurnace = ""; ArrayList pram = new ArrayList(); if (!CheckQuery()) return; if (chkWarehous.Checked) { strWare = cmbWarehous.Value.ToString(); } if (chkMaterial.Checked) { strMat = cmbMaterial.Value.ToString(); } if (chkRegTime.Checked) { strRegStart = RegStartTime.Value.ToString(); strRegEnd = RegEndTime.Value.ToString(); } if (chkFurnace.Checked) { strFurnace = txtFurnace.Text.Trim(); } pram.Clear(); pram.Add(strWare); pram.Add(strMat); pram.Add(strFurnace); pram.Add(strRegStart); pram.Add(strRegStart); pram.Add(strRegStart); pram.Add(strRegEnd); pram.Add(strRegEnd); string[] str = this.ValidDataPurviewIds; //获取用户对应科室ID string User = this.UserInfo.GetDeptid(); string StorageType = "";//根据传递的参数获取仓库类别 string StorageAttr = "";////根据传递的参数获取仓库类型 if (CustomInfo != "") { string[] strflg = CustomInfo.ToString().Split(new char[] { ',' }); StorageType = strflg[0]; StorageAttr = strflg[1]; } string[] arr = null; DataTable ds = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getStoreNo", new object[] { StorageType, StorageAttr, str }, this.ob); if (ds.Rows.Count > 0) { arr = new string[ds.Rows.Count]; for (int i = 0; i < ds.Rows.Count; i++) { arr[i] = ds.Rows[i][0].ToString(); } } if (arr == null) { MessageUtil.ShowTips("无仓库权限!"); return; } if (arr.Length < 1) { return; } if (ultraTabControl1.SelectedTab.Key.Equals("Library1")) { DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.CollarLibrary.FrmCollarOutBound.doQueryInfoResult", new object[] { pram, arr }, ob); GridHelper.CopyDataToDatatable(dt, this.dataStorage, true); } else { pram.Add(strOutbound); List listSource = EntityHelper.GetData ("com.steering.mes.mcp.CollarLibrary.FrmCollarOutBound.queryOutPerfo", new object[] { pram, arr }, this.ob); couplingMatDealEntityBindingSource.DataSource = listSource; GridHelper.RefreshAndAutoSize(ultraGrid2); } } /// /// 获取仓库 /// private void StorInfo() { string[] str = this.ValidDataPurviewIds; ArrayList arList = new ArrayList(); //获取用户对应科室ID string User = this.UserInfo.GetDeptid(); string StorageType = "";//根据传递的参数获取仓库类别 string StorageAttr = "";////根据传递的参数获取仓库类型 if (CustomInfo != "") { string[] strflg = CustomInfo.ToString().Split(new char[] { ',' }); StorageType = strflg[0]; StorageAttr = strflg[1]; } DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getStoreNo", new object[] { StorageType, StorageAttr, str }, this.ob); cmbWarehous.DataSource = dt; cmbWarehous.DisplayMember = "STORAGE_NAME"; cmbWarehous.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(cmbWarehous); CKstorage.DataSource = dt; CKstorage.DisplayMember = "STORAGE_NAME"; CKstorage.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(CKstorage); } /// /// 获取所有的目标库 /// private void getStoreAll() { //string StorageType = "";//根据传递的参数获取仓库类别 //string StorageAttr = "";////根据传递的参数获取仓库类型 //if (CustomInfo != "") //{ // string[] strflg = CustomInfo.ToString().Split(new char[] { ',' }); // StorageType = strflg[0]; // StorageAttr = strflg[1]; //} //string[] arr = McpBaseHelper.WarehousePermissions(this.CustomInfo, this.ValidDataPurviewIds, this.ob); string[] arr = { "XJG8", "TJG1", "XJG1" }; DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getStoreAll", new object[] { arr }, this.ob); cmbWareEdi.DataSource = dt; cmbWareEdi.DisplayMember = "STORAGE_NAME"; cmbWareEdi.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(cmbWareEdi); mbStorage.DataSource = dt; mbStorage.DisplayMember = "STORAGE_NAME"; mbStorage.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(mbStorage); } ///查询时验证必填项 private bool CheckQuery() { if (chkRegTime.Checked&&DataTimeUtil.JudgeTime(DateTime.Parse(RegStartTime.Value.ToString()), DateTime.Parse(RegEndTime.Value.ToString())) == 0) { MessageUtil.ShowTips("开始时间不能大于结束时间!"); return false; } if (chkWarehous.Checked && string.IsNullOrEmpty(cmbWarehous.Text.Trim())) { MessageBox.Show("请选择仓库号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } //if (chkMaterial.Checked && string.IsNullOrEmpty(cmbMaterial.Text.Trim())) //{ // MessageBox.Show("请选择框号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return false; //} if (chkFurnace.Checked && string.IsNullOrEmpty(txtFurnace.Text.Trim())) { MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } return true; } /// /// 验证Checked是否勾选,显示控件可编辑 打勾表示可编辑,不打勾表示不可编辑 /// /// /// private void chk_CheckedChanged(object sender, EventArgs e) { if (chkWarehous.Checked) { cmbWarehous.Enabled = true; } else { cmbWarehous.Enabled = false; } if (chkMaterial.Checked) { cmbMaterial.Enabled = true; } else { cmbMaterial.Enabled = false; } if (chkFurnace.Checked) { txtFurnace.Enabled = true; } else { txtFurnace.Enabled = false; } if (chkRegTime.Checked) { RegStartTime.Enabled = true; RegEndTime.Enabled = true; } else { RegStartTime.Enabled = false; RegEndTime.Enabled = false; } } private void FrmCollarOutBound_Shown(object sender, EventArgs e) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False; } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null) return; if (ultraTabControl1.SelectedTab.Key.Equals("Library1")) { this.chkRegTime.Text = "入库时间"; toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False; toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.True; //chkMaterial.Visible = true; //cmbMaterial.Visible = true; chkWarehous.Visible = true; cmbWarehous.Visible = true; label1.Visible = true; txtCom.Visible = true; } else { this.chkRegTime.Text = "倒库时间"; toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True; toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.False; //chkMaterial.Visible = false; //cmbMaterial.Visible = false; chkWarehous.Visible = false; cmbWarehous.Visible = false; chkWarehous.Checked = false; label1.Visible = false; txtCom.Visible = false; } } /// /// 回车键查询 /// /// /// private void txtFurnace_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { doQuery(); } } 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["CHOOSE"].Value = true; } } } /// /// 新增 /// private void doAdd() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); //查询出库类型 DataTable dt = PipeManageClass.getComTypeInfo(strOutbound, ob); if (dt.Rows.Count >= 1) { strOutname = dt.Rows[0]["BASENAME"].ToString(); } else { MessageUtil.ShowTips("出库类型不能为空,请确认基础信息是否有对应出库类型信息!"); return; } int num = 0; if (cmbWareEdi.SelectedIndex == -1) { MessageUtil.ShowTips("请选择目标库号!"); return; } ArrayList List = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid1.Rows) { if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { num++; if (uRow.Cells["PLA_COUNT"].Text.Trim() == "") { MessageUtil.ShowTips("请输入个数!"); return; } if (double.Parse(uRow.Cells["PLA_COUNT"].Value.ToString()) > double.Parse(uRow.Cells["PRO_NUM"].Value.ToString())) { MessageUtil.ShowTips("倒库出库个数不能大于库存个数!"); return; } ArrayList matList = new ArrayList(); matList.Add(uRow.Cells["JUDGE_STOVE_NO"].Text); matList.Add(uRow.Cells["BATCH_NO"].Text); //DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMoveOut.getMatStaus", new object[] { matList }, this.ob); //if (int.Parse(ds.Rows[0]["ACOUNT"].ToString())>0) //{ // MessageUtil.ShowTips("此炉【" + uRow.Cells["JUDGE_STOVE_NO"].Text + "】已被做计划,不允许进行倒库!"); // return; //} ArrayList pram = new ArrayList(); pram.Add(uRow.Cells["JUDGE_STOVE_NO"].Text.Trim()); pram.Add(uRow.Cells["BATCH_NO"].Text.Trim()); pram.Add(uRow.Cells["RESULT_NO"].Text.Trim()); pram.Add(uRow.Cells["ZY_PLAN_ID"].Text.Trim()); pram.Add(uRow.Cells["STORAGE_NO"].Text.Trim()); pram.Add(uRow.Cells["KEP_NO"].Text.Trim()); pram.Add(cmbWareEdi.Value.ToString()); pram.Add(this.UserInfo.GetUserOrder()); pram.Add(this.UserInfo.GetUserGroup()); pram.Add(this.UserInfo.GetUserName()); pram.Add(uRow.Cells["PLA_COUNT"].Value.ToString()); pram.Add(strOutbound); pram.Add(strOutname); pram.Add(cmbKenNo.Text.ToString()); pram.Add(uRow.Cells["WO_ID"].Value.ToString()); pram.Add(uRow.Cells["MAT_NO"].Value.ToString()); pram.Add(uRow.Cells["MAT_NO_XH"].Value.ToString()); pram.Add(uRow.Cells["PLA_WEIGHT"].Value.ToString()); List.Add(pram); } } if (num == 0) { MessageUtil.ShowTips("请选择需要操作的数据!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认倒库?") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); ccp.ServerName = "com.steering.mes.mcp.CollarLibrary.FrmCollarOutBound"; ccp.MethodName = "addOutLibResult"; ccp.ServerParams = new object[] { List }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("倒库出库成功!")) { cmbKenNo.Text = ""; cmbWareEdi.Text = ""; doQuery(); } } /// /// 作废 /// private void doDelete() { UltraGridRow ugr = this.ultraGrid2.ActiveRow; int count = 0; if (ugr == null) return; ArrayList list = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows) { if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { count += 1; ArrayList pram = new ArrayList(); pram.Add(uRow.Cells["dealTypeCode"].Text.Trim()); pram.Add(uRow.Cells["resultNo"].Text.Trim()); pram.Add(uRow.Cells["zyPlanId"].Text.Trim()); pram.Add(uRow.Cells["matNo"].Text.Trim()); pram.Add(uRow.Cells["kepNo"].Value.ToString()); pram.Add(uRow.Cells["storageNo"].Value.ToString()); pram.Add(uRow.Cells["tarKepNo"].Value.ToString()); pram.Add(uRow.Cells["tarStorageNo"].Value.ToString()); pram.Add(uRow.Cells["dealNum"].Value.ToString()); pram.Add(uRow.Cells["dealWt"].Value.ToString()); pram.Add(this.UserInfo.GetUserName()); pram.Add(uRow.Cells["dealOrde"].Text.ToString()); list.Add(pram); } } if (count == 0) { MessageUtil.ShowTips("请选择要撤销的数据"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销?") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); ccp.ServerName = "com.steering.mes.mcp.CollarLibrary.FrmCollarOutBound"; ccp.MethodName = "deleteOutLibResult"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("撤销成功!")) { doQuery(); } } /// /// 写卡倒库 /// private void addWriteCard() { this.ultraGrid1.UpdateData(); string dateTim = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string outdoc = ""; string matTarStorageNo = "";//计划去向 //查询出库类型 DataTable dt = PipeManageClass.getComTypeInfo(strOutbound, ob); if (dt.Rows.Count >= 1) { strOutname = dt.Rows[0]["BASENAME"].ToString(); } else { MessageUtil.ShowTips("出库类型不能为空,请确认基础信息是否有对应出库类型信息!"); return; } IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHOOSE = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请勾选需要倒库的物料!"); return; } string tarStoreNo = this.cmbWareEdi.Value.ToString2(); string tarStoreName = this.cmbWareEdi.Text; if (tarStoreNo.Equals("")) { MessageUtil.ShowTips("请选择目标仓库!"); return; } //生成交易单号 DataTable dsDoc = ServerHelper.GetData("com.steering.mes.mcp.CollarLibrary.FrmCollarOutBound.getOutDoc", new object[] { tarStoreNo }, ob); if (dsDoc.Rows.Count > 0) { outdoc = dsDoc.Rows[0]["OUTSTOCK_DOC"].ToString(); } ArrayList parmlist = new ArrayList(); ArrayList list = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid1.Rows) { if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { if (!StringUtil.IsInt(uRow.Cells["PLA_COUNT"].Text.ToString3()) || uRow.Cells["PLA_COUNT"].Text.Equals("")) { MessageUtil.ShowTips(uRow.Cells["JUDGE_STOVE_NO"].Text + "倒库个数请输入整数!"); return; } if (double.Parse(uRow.Cells["PLA_COUNT"].Value.ToString()) > double.Parse(uRow.Cells["PRO_NUM"].Value.ToString())) { MessageUtil.ShowTips("倒库出库个数不能大于库存个数!"); return; } ArrayList childlist = new ArrayList(); childlist.Add(uRow.Cells["MAT_NO"].Text.ToString3()); childlist.Add(uRow.Cells["RESULT_NO"].Text.ToString3()); childlist.Add(uRow.Cells["ZY_PLAN_ID"].Text.ToString3()); childlist.Add(uRow.Cells["PLA_COUNT"].Text.ToString3()); childlist.Add(uRow.Cells["PLA_WEIGHT"].Text.ToString3()); childlist.Add(uRow.Cells["WO_ID"].Text.ToString3()); childlist.Add(uRow.Cells["STORAGE_NO"].Text.ToString3()); childlist.Add(uRow.Cells["MAT_NO_XH"].Text.ToString3()); childlist.Add(uRow.Cells["PRO_NUM"].Text.ToString3()); childlist.Add(uRow.Cells["PRO_WT"].Text.ToString3()); parmlist.Add(childlist); } } list.Add(this.cmbWareEdi.Value.ToString()); list.Add(UserInfo.GetUserName()); list.Add(UserInfo.GetUserOrder()); list.Add(UserInfo.GetUserGroup()); list.Add(UserInfo.GetDeptid()); list.Add(UserInfo.GetDepartment()); list.Add(this.cmbWareEdi.Text.ToString()); list.Add(outdoc); list.Add(strOutbound); list.Add(strOutname); list.Add(cmbKenNo.Text.ToString()); if (!WriteCard(outdoc)) { disConnect(); return; } if (MessageUtil.ShowYesNoAndQuestion("是否倒库?") == DialogResult.No) { clearCard(); return; } list.Add(departId); list.Add(departMent); list.Add(carNo); list.Add(cardNo); list.Add(diver); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.CollarLibrary.FrmCollarOutBound"; ccp.MethodName = "doAdd"; ccp.ServerParams = new object[] { parmlist, list, storageArr, outdoc}; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("倒库成功!")) { doQuery(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { clearCard(); MessageUtil.ShowTips(ccp.ReturnInfo); } } else { clearCard(); MessageUtil.ShowTips(ccp.ReturnInfo); } } /// /// 写IC卡信息 /// /// /// /// private bool WriteCard(string outdoc) { WaitingForm2 wf = new WaitingForm2("正在加载,请稍候...."); try { cardNo = ""; carNo = ""; diver = ""; this.ultraGrid1.UpdateData(); int n = 0; int tolCount = 0; double tolWgt = 0.0; string tarDepart = ""; string tarDepartM = ""; IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where("CHOOSE = 'True'"); //foreach (UltraGridRow uRow in checkMagRows) //{ // tolCount = tolCount + int.Parse(uRow.Cells["PRO_NUM"].Text.Replace("_", "").ToString3()); // n++; //} //if (n > 1) //{ // if (!checkMagRows.ToArray()[0].Cells["StorageNo"].Text.Trim().Equals(checkMagRows.ToArray()[1].Cells["StorageNo"].Text.Trim())) // { // MessageUtil.ShowTips("倒运炉信息必须在同一仓库里!"); // return false; // } //} //else if (n > 2) //{ // if (!(checkMagRows.ToArray()[0].Cells["StorageNo"].Text.Trim().Equals(checkMagRows.ToArray()[1].Cells["StorageNo"].Text.Trim()) && checkMagRows.ToArray()[0].Cells["StorageNo"].Text.Trim().Equals(checkMagRows.ToArray()[2].Cells["StorageNo"].Text.Trim()))) // { // MessageUtil.ShowTips("倒运炉信息必须在同一仓库里!"); // return false; // } //} string storeNo = checkMagRows.ToArray()[0].Cells["STORAGE_NO"].Value.ToString(); //DataTable ds = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.doQueryTarDepart", new object[] { this.ultraComboEditor2.Value.ToString() }, ob); //DataTable ds = ServerHelper.GetData("com.steering.mes.SendRecive.FrmFilpOutStorage.doQueryTarDepart", new object[] { this.cmbWareEdi.Value.ToString() }, ob); //if (ds.Rows.Count > 0) //{ // tarDepart = ds.Rows[0]["MANAGEMENT_NO"].ToString(); // tarDepartM = ds.Rows[0]["MANAGEMENT_NAME"].ToString(); //} if (!ConnectCard(wf)) { return false; } if (!ReadCard(wf)) { return false; } if (icClass == null) { wf.Close(); MessageUtil.ShowTips("请放IC卡!"); return false; } else { if (icClass.Active) { icClass.measureid = outdoc; icClass.taskid = outdoc;//物流任务ID(出库单号) icClass.sourceunitcode = storeNo; icClass.sourceunit = checkMagRows.ToArray()[0].Cells["STORAGE_NAME"].Value.ToString(); icClass.sourcecode = storeNo; icClass.source = checkMagRows.ToArray()[0].Cells["STORAGE_NAME"].Value.ToString(); icClass.targetcode = this.cmbWareEdi.Value.ToString(); icClass.target = this.cmbWareEdi.Text; icClass.targetunitcode = this.cmbWareEdi.Value.ToString(); ; icClass.targetunit = this.cmbWareEdi.Text; ; icClass.RecordCount = 3; icClass.operatype = "0"; if (!icClass.DoWriteTemp()) { wf.Close(); MessageUtil.ShowTips("写卡失败!"); return false; } if (icClass.Errored == true) { wf.Close(); MessageUtil.ShowTips("写卡出现错误,请重写IC卡!"); return false; } if (icClass.Active) { icClass.AlarmBeep(3); disConnect(); wf.Close(); return true; } } else { wf.Close(); MessageUtil.ShowTips("读卡器失去连接"); return false; } } } catch { return false; } finally { wf.Close(); } return true; } private string carNo = "";//车号 private string cardNo = "";//卡号 private string diver = "";//司机 /// /// 读IC卡信息 /// public bool ReadCard(WaitingForm2 wf) { icClass.PrepareReadTemp(); if (icClass.DoReadTemp(1, 39)) { int count = icClass.RecordCount; if (icClass.carno == null || icClass.driver == null) { MessageUtil.ShowTips("IC卡中车号/司机不能为空!"); return false; } carNo = icClass.carno.ToString(); cardNo = icClass.ICNo.ToString(); diver = icClass.driver.ToString(); if (count > 0) { wf.Close(); MessageUtil.ShowTips("IC卡上已有记录,不允许写卡!"); return false; } } else { wf.Close(); MessageUtil.ShowTips("读取IC卡出现错误,请联系相关部门!"); return false; } return true; } /// /// 清卡 /// private void clearCard() { string dealOrde = ""; WaitingForm2 wf = new WaitingForm2("正在加载,请稍候...."); try { if (ConnectCard(wf) == false) { disConnect(); return; } else { icClass.PrepareReadTemp(); if (icClass.DoReadTemp(1, 39)) { dealOrde = icClass.taskid.ToString2(); carNo = icClass.carno.ToString2(); if (dealOrde != "") { //DataTable ds = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.doQueryCount", new object[] { outDoc }, ob); DataTable ds = ServerHelper.GetData("com.steering.mes.mcp.CollarLibrary.FrmCollarOutBound.doQueryCount", new object[] { dealOrde }, ob); if (int.Parse(ds.Rows[0][0].ToString2()) > 0) { MessageUtil.ShowTips("此卡有未接收倒运记录,不允许清卡!"); return; } } } else { wf.Close(); MessageUtil.ShowTips("读取IC卡出现错误,请联系相关部门!"); } } icClass.ClearCard(); icClass.AlarmBeep(1); } catch { } finally { wf.Close(); disConnect(); } } void icClass_OnFindCard() { icClass.OnFindCard -= new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard); icClass.OnDropCard += new TalentICTGXControl.ITalentICTGXEvents_OnDropCardEventHandler(icClass_OnDropCard); } void icClass_OnDropCard() { //将OnDropCard事件从委托链中删除,并加入OnFindCard事件到委托链中。 //这样就实现了程序中自动寻卡的功能。 icClass.OnDropCard -= new TalentICTGXControl.ITalentICTGXEvents_OnDropCardEventHandler(icClass_OnDropCard); icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard); } /// /// 连接读卡器 /// /// private bool ConnectCard(WaitingForm2 wf) { //if (icClass == null) //{ // icClass = new TalentICTGXControl.TalentICTGXClass(); // //委托OnFindCard事件,icClass_OnFindCard是该事件要执行的方法。 // //此事件在当IC卡放到读卡器上时触发。 // icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard); //} icClass = IcReadWrite.getIcClass(); int comNum = (short)(short.Parse(txtCom.Text.Replace("COM", "")) - 1); icClass.CommPort = comNum; if (!icClass.Active) { //利用ToFindCard属性连接读卡器,启动OnFindCard事件。 icClass.ToFindCard = true; if (icClass.Active) { //AlarmBeep(int times)方法实现了让IC卡读卡器发出警示音, //参数为发出几次警示音。 icClass.AlarmBeep(2); Thread.Sleep(500); return true; } else { wf.Close(); MessageUtil.ShowTips("读卡器连接失败!或请切换端口尝试!"); return false; } } return true; } /// /// 关闭连接 /// /// private bool disConnect() { //return true; if (icClass.Active) { //icClass.AlarmBeep(1); //设置Active属性为false,则断开与读卡器的连接。 icClass.ToFindCard = false; icClass.Active = false; return true; } else { return 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["CHOOSE"].Value = true; } } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); if (e.Cell.Column.Key.Equals("PLA_COUNT")) { if (e.Cell.Row.Cells["PLA_COUNT"].Text.ToString().Trim() == "") { e.Cell.Row.Cells["PLA_COUNT"].Value = "0"; } e.Cell.Row.Cells["PLA_WEIGHT"].Value = double.Parse(e.Cell.Row.Cells["PLA_COUNT"].Value.ToString()) * (double.Parse(e.Cell.Row.Cells["SINGLEWEIGHT"].Value.ToString())/1000); } } } }