| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.YdmBcPipeManage.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.YdmBcPipeManage
- {
- public partial class FrmGateFrim1 : FrmBase
- {
- public FrmGateFrim1()
- {
- 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;
- }
- catch (Exception eex3)
- {
- MessageBox.Show(eex3.Message);
- }
- }
- private string[] arr = null;
- private TalentICTGXControl.TalentICTGXClass icClass;
- private void FrmGateFrim1_Load(object sender, EventArgs e)
- {
- DateTime now = DateTime.Now;
- DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
- DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
- this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
- this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
- //BaseMethod.InitCellPosition(ultraGrid1, new string[] { "ActWeight", "ActCount", "ActDimater", "ActHeight", "ActLenMin", "ActLenMax", "ActLen" });
- //BaseMethod.InitCellPosition(ultraGrid2, new string[] { "ActWeight", "ActCount", "ActDimater", "ActHeight", "ActLenMin", "ActLenMax", "ActLen" });
- EntityHelper.ShowGridCaption<CouplingMatDealEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<CouplingMatDealEntity>(ultraGrid2.DisplayLayout.Bands[0]);
- arr = this.ValidDataPurviewIds;
- this.txtCom.SelectedIndex = 0;
- }
- private void chkDk_CheckedChanged(object sender, EventArgs e)
- {
- this.txtOutList.Enabled = chkDk.Checked;
- }
- private void chkFurnace_CheckedChanged(object sender, EventArgs e)
- {
- this.txtFurnace.Enabled = chkFurnace.Checked;
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "ReadCard":
- ReadData();
- break;
- case "Query":
- Query();
- break;
- case "Confirm":
- Confirm();
- break;
- case "CancelConfirm":
- CancelConfirm();
- break;
- case "Close":
- Close();
- break;
-
- }
- }
- /// <summary>
- /// 读卡查询出库信息
- /// </summary>
- /// <param name="dealOrde"></param>
- public void doQueryOutList(string dealOrde){
- List<CouplingMatDealEntity> listSource = EntityHelper.GetData<CouplingMatDealEntity>(
- "com.steering.ydm.bc.FrmGateFrim1.doQueryOutList", new object[] { dealOrde }, this.ob);
- couplingMatDealEntityBindingSource.DataSource = listSource;
- }
- /// <summary>
- /// 读卡
- /// </summary>
- public void ReadData()
- {
- WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
- try
- {
- string outdoc = "";
- if (!ConnectCard(wf))
- {
- disConnect();
- return;
- }
- icClass.PrepareReadTemp();
- //bool b = icClass.DoReadTemp(1, 39);
- if (icClass.DoReadTemp(1, 39))
- {
- int count = icClass.RecordCount;
- if (count == 0) //判断卡上的记录数
- {
- wf.Close();
- MessageUtil.ShowTips("IC卡无记录,请核实!");
- disConnect();
- return;
- }
- else
- {
- outdoc = icClass.taskid;
- }
- //disConnect();
- }
- else
- {
- wf.Close();
- MessageUtil.ShowTips("读取IC卡出现错误!");
- disConnect();
- return;
- }
- doQueryOutList(outdoc);
- }
- finally
- {
- disConnect();
- wf.Close();
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- public void Query()
- {
- string strRegStart = "";
- string strRegEnd = "";
- string judgeNo = "";
- string dealOrde = "";
- ArrayList parm = new ArrayList();
- if (chkRegTime.Checked)
- {
- strRegStart = RegStartTime.Value.ToString();
- strRegEnd = RegEndTime.Value.ToString();
- }
- if (chkFurnace.Checked)
- {
- judgeNo = this.txtFurnace.Text.Trim();
- }
- if (chkDk.Checked)
- {
- dealOrde = this.txtOutList.Text.Trim();
- }
- parm.Add(strRegStart);
- parm.Add(strRegEnd);
- parm.Add(judgeNo);
- parm.Add(dealOrde);
- if (ultraTabControl1.SelectedTab.Index == 0)
- {
- List<CouplingMatDealEntity> listSource = EntityHelper.GetData<CouplingMatDealEntity>(
- "com.steering.ydm.bc.FrmGateFrim1.QueryBefore", new object[] { parm }, this.ob);
- couplingMatDealEntityBindingSource.DataSource = listSource;
- }
- else
- {
- List<CouplingMatDealEntity> listSource = EntityHelper.GetData<CouplingMatDealEntity>(
- "com.steering.ydm.bc.FrmGateFrim1.QueryDone", new object[] { parm }, this.ob);
- couplingMatDealEntityBindingSource1.DataSource = listSource;
- }
- }
- /// <summary>
- /// 确认出厂
- /// </summary>
- public void Confirm()
- {
- this.ultraGrid1.UpdateData();
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (uRow == null)
- {
- return;
- }
- string dealOrde = uRow.Cells["DealOrde"].Text.ToString();
- if (MessageUtil.ShowYesNoAndQuestion("是否确认出厂?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.ydm.bc.FrmGateFrim1";
- ccp.MethodName = "Confirm";
- ccp.ServerParams = new object[] { dealOrde , UserInfo.GetUserName() };
- ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("确认出厂成功!"))
- {
- Query();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- /// <summary>
- /// 撤销确认出厂
- /// </summary>
- public void CancelConfirm()
- {
- this.ultraGrid2.UpdateData();
- UltraGridRow uRow = this.ultraGrid2.ActiveRow;
- if (uRow == null)
- {
- return;
- }
- string dealOrde = uRow.Cells["DealOrde"].Text.ToString();
- if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销出厂?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.ydm.bc.FrmGateFrim1";
- ccp.MethodName = "CancelConfirm";
- ccp.ServerParams = new object[] { dealOrde };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("撤销确认出厂成功!"))
- {
- Query();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- ///<summary>
- /// 关闭连接
- /// </summary>
- /// <returns></returns>
- private bool disConnect()
- {
- if (icClass.Active)
- {
- icClass.AlarmBeep(1);
- //设置Active属性为false,则断开与读卡器的连接。
- icClass.ToFindCard = false;
- icClass.Active = false;
- return true;
- }
- else
- {
- return true;
- }
- }
- 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);
- }
- /// <summary>
- /// 连接读卡器
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 清卡
- /// </summary>
- private void clearCard()
- {
- WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
- try
- {
- if (ConnectCard(wf) == false)
- {
- return;
- }
- icClass.ClearCard();
- icClass.AlarmBeep(1);
- }
- catch
- {
- }
- finally
- {
- disConnect();
- wf.Close();
- }
- }
- private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- if (toolMenu == null || toolMenu.Toolbars == null) return;
- if (toolMenu.Toolbars[0].Tools.Exists("ReadCard")) { toolMenu.Toolbars[0].Tools["ReadCard"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
- if (toolMenu.Toolbars[0].Tools.Exists("Confirm")) { toolMenu.Toolbars[0].Tools["Confirm"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
- if (toolMenu.Toolbars[0].Tools.Exists("CancelConfirm")) { toolMenu.Toolbars[0].Tools["CancelConfirm"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 1 ? DefaultableBoolean.True : DefaultableBoolean.False; }
- }
-
- }
- }
|