| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421 |
- 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 Pur.Entity;
- using Core.Mes.Client.Comm.Control;
- using Pur.Entity.ck;
- using Infragistics.Win.UltraWinGrid;
- using System.Collections;
- using Core.Mes.Client.Comm.Tool;
- using com.hnshituo.pur.vo;
- using Core.Mes.Client.Comm.Server;
- using com.hnshituo.ck;
- using Pur.Pop_upWindow;
- using Infragistics.Win.UltraWinEditors;
- using Pur.configure;
- namespace Pur.ck
- {
- public partial class ExcDeliveryManagNewJL : FrmPmsBase
- {
- String WMmatcode = "";
- String WMsuppCode = "";
- String WMdeliveryCode = "";
- public ExcDeliveryManagNewJL()
- {
- 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" };
- }
- txt_com.DataSource = portnames;
- this.txt_com.SelectedIndex = 0;
- }
- catch (Exception eex3)
- {
- MessageBox.Show(eex3.Message);
- }
- }
- private void ExcDeliveryManagNewJL_Load(object sender, EventArgs e)
- {
- ck_isAllMeter.Checked = true;
- ck_Ctime.Checked = false;
- txt_CreateTimeS.Value = DateTime.Now.AddMonths(-1);
- txt_CreateTimeS.Enabled = false;
- txt_CreateTimeE.Value = Convert.ToDateTime(DateTime.Now.ToShortDateString()).AddHours(23).AddMinutes(59);
- txt_CreateTimeE.Enabled = false;
- Ck_Etime.Checked = true;
- txt_PlanedShipDateS.Value = DateTime.Now.AddDays(-3);
- txt_PlanedShipDateS.Enabled = true;
- txt_PlanedShipDateE.Value = Convert.ToDateTime(DateTime.Now.AddDays(3));
- txt_PlanedShipDateE.Enabled = true;
- txt_length.SelectedIndex = 0;
- ultraTabControl1.SelectedTab= ultraTabControl1.Tabs[0];
- txt_QtyJL.ReadOnly = false;
- txt_status.SelectedIndex = 1;//默认待发送计量委托
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] {});
- GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] {});
- GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] {});
- GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new string[] {});
- ultraExpandableGroupBox4.Expanded = true;
- Get_ExcSubM();
- }
- #region toolbar工具栏
- /// <summary>
- /// 菜单栏
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- Get_ExcSubM();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void Get_ExcSubM()
- {
- try
- {
- //查询待计量的通知单头
- this.Cursor = Cursors.WaitCursor;
- clearSampleTabJL();
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
- {
- dataSet1.Clear();
- Hashtable map = new Hashtable();
- map.Add("deliverySubId", txt_deliverySubId.Text.Trim());
- map.Add("orderId", txt_OrderId.Text.Trim());
- map.Add("supperId", txt_suppCode.Text.Trim());
- map.Add("validDataPurviewIds", this.ValidDataPurviewIds);
- map.Add("itemCode", txt_itemCode.Text.ToString().Trim());
- map.Add("itemName", txt_itemName.Text.ToString().Trim());
- if (ck_Ctime.Checked && !string.IsNullOrEmpty(txt_CreateTimeS.Text))
- {
- map.Add("createTimeBegin", Convert.ToDateTime(txt_CreateTimeS.Value));
- }
- if (ck_Ctime.Checked && !string.IsNullOrEmpty(txt_CreateTimeE.Text))
- {
- map.Add("createTimeEnd", Convert.ToDateTime(txt_CreateTimeE.Value));
- }
- if (Ck_Etime.Checked && !string.IsNullOrEmpty(txt_PlanedShipDateS.Text))
- {
- map.Add("planedShipDate", Convert.ToDateTime(txt_PlanedShipDateS.Value));
- }
- if (Ck_Etime.Checked && !string.IsNullOrEmpty(txt_PlanedShipDateE.Text))
- {
- map.Add("planedDeliveryDate", Convert.ToDateTime(txt_PlanedShipDateE.Value));
- }
- if (txt_status.SelectedIndex != -1)
- {
- map.Add("statusJL", txt_status.Value.ToString().Trim());
- }
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doQueryDeliverySubMList", new object[] { map });
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- }
- else
- {
- dataSet2.Clear();
- //通知单头
- ExcDeliveryNoticeM EdnM = new ExcDeliveryNoticeM();
- EdnM.OrderId = txt_OrderId.Text.ToString().Trim();
- EdnM.NoticeId = txt_deliverySubId.Text.Trim();
- if (ck_Ctime.Checked)
- {
- if (txt_CreateTimeS.Text != "")
- {
- EdnM.CreateTime = Convert.ToDateTime(txt_CreateTimeS.Value);
- }
- if (txt_CreateTimeE.Text != "")
- {
- EdnM.DeleteTime = Convert.ToDateTime(txt_CreateTimeE.Value);
- }
- }
- if (Ck_Etime.Checked)
- {
- if (txt_PlanedShipDateS.Text != "")
- {
- EdnM.PlanedDeliveryDate = Convert.ToDateTime(txt_PlanedShipDateS.Value);
- }
- if (txt_PlanedShipDateE.Text != "")
- {
- EdnM.PlanedDeliveryDate = Convert.ToDateTime(txt_PlanedShipDateE.Value);
- }
- }
- EdnM.ValidDataPurviewIds = this.ValidDataPurviewIds;
- EdnM.SuppCode = txt_suppCode.Text.Trim();
- EdnM.UpdateName = txt_itemName.Text.Trim();
- EdnM.UpdateUserid = txt_itemCode.Text.Trim();
- if (txt_status.SelectedIndex != -1)
- {
- EdnM.DeleteUserid = txt_status.Value.ToString().Trim();//是否需要计量
- }
- DataTable dt10 = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "find_Exc", new object[] { EdnM });
- GridHelper.CopyDataToDatatable(dt10, dataTable3, true);
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("查询送货单主表数据失败:" + ex.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- #endregion
- #region 界面事件
- /// <summary>
- /// 加载待计量送货单行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- WMmatcode = "";
- WMsuppCode = "";
- WMdeliveryCode = "";
- txt_message.Text = "";
- queryDeliverySubC("");
- }
- /// <summary>
- /// 加载待计量通知单头
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
- {
- WMmatcode = "";
- WMsuppCode = "";
- WMdeliveryCode = "";
- txt_message.Text = "";
- queryNoticeC("");
- }
- /// <summary>
- /// 选择计量的送货单行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- //根据物送货单行不允许编辑数量
- try
- {
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
- {
- WMmatcode = "";
- WMsuppCode = "";
- WMdeliveryCode = "";
- txt_message.Text = "";
- String strDeliverySubLineSqe = ultraGrid2.ActiveRow.GetCellValue("deliverySubLineSqe").ToString().Trim();
- // String strDeliverySubId = ultraGrid2.ActiveRow.Cells["DeliverySubId"].Value.ToString().Trim();
- //if (String.IsNullOrEmpty(strDeliverySubId))
- //{
- // MessageUtil.ShowTips("送货单号为空");
- //}
- if (String.IsNullOrEmpty(strDeliverySubLineSqe))
- {
- MessageUtil.ShowTips("送货单行号为空");
- }
- ExcDeliverySubC dsc = this.execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
- ExcDeliverySubM dsm = this.execute<ExcDeliverySubM>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { dsc.DeliverySubId });
- //计量数据加载
- txt_QtyJL.Text = dsc.Qty + "";
- ck_meterFlag.Checked = dsc.MeteringFlag == null ? false : (dsc.MeteringFlag == "1" ? true : false);
- if (ck_meterFlag.Checked)
- {
- ck_meterFlag.Enabled = true;
- }
- else
- {
- ck_meterFlag.Enabled = true;
- }
- txt_carNumJL.Text = dsc.CarNum;
- txt_batchNo.Text = dsc.BatchNo;
- CoreResult crt = new CoreResult();
- if (dsc.ItemCode == "Y01010001")
- {
- crt.Resultcode = 0;
- crt.Resultmsg = "105";
- }
- else
- {
- crt = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMMatCode", new object[] { dsc.ItemCode });
- }
- CoreResult crt2 = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMSuppCode", new object[] { dsm.SuppCode });
- CoreResult crt3 = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMdeliveryCode", new object[] { dsm.DeliveryLocation });
- if (crt2.Resultcode != 0 || crt.Resultcode != 0 || crt3.Resultcode != 0)
- {
- if (crt.Resultcode != 0)
- {
- txt_message.Text = crt.Resultmsg + "\r\n";
- }
- else
- {
- WMmatcode = crt.Resultmsg;
- }
- if (crt2.Resultcode != 0)
- {
- txt_message.Text = txt_message.Text + crt2.Resultmsg + "\r\n";
- }
- else
- {
- WMsuppCode = crt2.Resultmsg;
- }
- if (crt3.Resultcode != 0)
- {
- txt_message.Text = txt_message.Text + crt3.Resultmsg + "\r\n";
- }
- else
- {
- WMdeliveryCode = crt3.Resultmsg;
- }
- return;
- }
- WMmatcode = crt.Resultmsg;
- WMsuppCode = crt2.Resultmsg;
- WMdeliveryCode = crt3.Resultmsg;
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips(ex.Message);
- }
- }
- /// <summary>
- /// 选择计量的通知单行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid4_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
- {
- WMmatcode = "";
- WMsuppCode = "";
- WMdeliveryCode = "";
- txt_message.Text = "";
- //通知单行允许编辑数量
- String strNoticeLineSqe = ultraGrid4.ActiveRow.GetCellValue("noticeLineSqe").ToString().Trim();
- if (String.IsNullOrEmpty(strNoticeLineSqe))
- {
- MessageUtil.ShowTips("通知单行号为空");
- }
- ExcDeliveryNoticeC dsc = this.execute<ExcDeliveryNoticeC>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "findById", new object[] { strNoticeLineSqe });
- ExcDeliveryNoticeM dsm = this.execute<ExcDeliveryNoticeM>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "findById", new object[] { dsc.NoticeId });
- double dbcreatedQty = (double)(dsc.CreatedQty == null ? 0 : dsc.CreatedQty);
- Double canJLQty = (double)dsc.Qty - dbcreatedQty;
- //计量数据加载
- txt_QtyJL.Text = canJLQty + "";
- ck_meterFlag.Checked = dsc.MeteringFlag == null ? false : (dsc.MeteringFlag == "1" ? true : false);
- if (ck_meterFlag.Checked)
- {
- ck_meterFlag.Enabled = false;
- }
- else
- {
- ck_meterFlag.Enabled = true;
- }
- txt_carNumJL.Text = "";
- CoreResult crt = new CoreResult();
- if (dsc.ItemCode == "Y01010001")
- {
- crt.Resultcode = 0;
- crt.Resultmsg = "105";
- }
- else
- {
- crt = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMMatCode", new object[] { dsc.ItemCode });
- }
- CoreResult crt2 = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMSuppCode", new object[] { dsm.SuppCode });
- CoreResult crt3 = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMdeliveryCode", new object[] { dsm.DeliveryLocation });
- if (crt2.Resultcode != 0 || crt.Resultcode != 0 || crt3.Resultcode != 0)
- {
- if (crt.Resultcode != 0)
- {
- txt_message.Text = crt.Resultmsg + "\r\n";
- }
- else
- {
- WMmatcode = crt.Resultmsg;
- }
- if (crt2.Resultcode != 0)
- {
- txt_message.Text = txt_message.Text + crt2.Resultmsg + "\r\n";
- }
- else
- {
- WMsuppCode = crt2.Resultmsg;
- }
- if (crt3.Resultcode != 0)
- {
- txt_message.Text = txt_message.Text + crt3.Resultmsg + "\r\n";
- }
- else
- {
- WMdeliveryCode = crt3.Resultmsg;
- }
- return;
- }
- WMmatcode = crt.Resultmsg;
- WMsuppCode = crt2.Resultmsg;
- WMdeliveryCode = crt3.Resultmsg;
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("获取通知单行计量数据失败:" + ex.Message);
- }
- }
- /// <summary>
- /// 创建时间
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ck_Ctime_CheckedChanged(object sender, EventArgs e)
- {
- txt_CreateTimeS.Enabled = ck_Ctime.Checked;
- txt_CreateTimeE.Enabled = ck_Ctime.Checked;
- }
- /// <summary>
- /// 交期控制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Ck_Etime_CheckedChanged(object sender, EventArgs e)
- {
- txt_PlanedShipDateS.Enabled = Ck_Etime.Checked;
- txt_PlanedShipDateE.Enabled = Ck_Etime.Checked;
- }
- /// <summary>
- /// 通知单还是送货单控制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- clearSampleTabJL();
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
- {
- txt_QtyJL.ReadOnly = false;
- clearJL();
- queryNoticeC("");
- }
- else
- {
- clearJL();
- txt_QtyJL.ReadOnly = false;
- queryDeliverySubC("");
- }
- }
- //清卡计量编辑区
- private void clearJL()
- {
- txt_carNumJL.Clear();
- txt_length.SelectedIndex = 0;
- txt_batchNo.Clear();
- }
- /// <summary>
- /// 点击写卡
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_addJL_Click(object sender, EventArgs e)
- {
- //if (ConnectCard() == false)
- //{
- // return;
- //}
-
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
- {
- if (Write1() == true)
- {
- queryDeliverySubC("");
- }
- }
- else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
- {
- if (Write() == true)
- {
- queryNoticeC("");
- }
- }
- else
- {
- MessageUtil.ShowTips("请选择送货单或者通知单");
- }
- testConnectCard();
- //ReadCard();
- }
- /// <summary>
- /// 测试连接
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_testConnectJL_Click(object sender, EventArgs e)
- {
- testConnectCard();
- }
- /// <summary>
- /// 读卡
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_testReadJL_Click(object sender, EventArgs e)
- {
- ReadCard();
- }
- /// <summary>
- /// 清卡
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_clearIC_Click(object sender, EventArgs e)
- {
- Clear_IC_ChuKuDaTa();
- }
- #endregion
- #region 读卡
- private TalentICTGXControl.TalentICTGXClass icClass;
- ///<summary>
- /// 连接
- /// </summary>
- /// <returns></returns>
- private bool getConnect()
- {
- try
- {
- txt_message.Text = "";
- if (icClass == null)
- {
- icClass = new TalentICTGXControl.TalentICTGXClass();
- //委托OnFindCard事件,icClass_OnFindCard是该事件要执行的方法。
- //此事件在当IC卡放到读卡器上时触发。
- icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
- }
- //icClass.AlarmBeep(2);
- string txtCom = txt_com.SelectedItem.ToString();
- int comNum = (short)(short.Parse(txtCom.Replace("COM", "")) - 1);
- icClass.CommPort = comNum;
- if (!icClass.Active)
- {
- icClass.ToFindCard = true;
- // MessageUtil.ShowTips("ConnectCard.icClass.Active: " + icClass.Active);
- if (icClass.Active)
- {
- //MessageUtil.ShowTips("IC卡连接成功!");
- txt_message.Text = "IC卡连接成功!" + "\r\n";
- //AlarmBeep(int times)方法实现了让IC卡读卡器发出警示音,
- //参数为发出几次警示音。
- icClass.AlarmBeep(2);
- return true;
- }
- else
- {
- txt_message.Text = "IC卡连接失败!或请切换端口尝试" + "\r\n";
- return false;
- }
- }
- else
- {
- return true;
- }
- }
- catch (Exception e)
- {
- txt_message.Text = "IC卡连接失败!" + e.Message+"\r\n";
- return false;
- }
- }
- ///<summary>
- /// 关闭连接
- /// </summary>
- /// <returns></returns>
- private bool disConnect()
- {
- if (icClass.Active)
- {
- icClass.AlarmBeep(1);
- //设置Active属性为false,则断开与读卡器的连接。
- icClass.ToFindCard = false;
- icClass.Active = false;
- txt_message.Text =txt_message.Text+ "IC卡已断开与读卡器连接!" + "\r\n";
- return true;
- }
- else
- {
- return true;
- }
- }
- //出库清卡
- private void Clear_IC_ChuKuDaTa()
- {
- if (getConnect() == false)
- {
- return;
- }
- //车辆已经计量完成或者不计量则清卡,车辆没有计量完成则不清卡
- //清卡函数为 icClass.ClearCard
- if ((icClass.grossA == 0) || ((icClass.grossA > 0) && (!string.IsNullOrEmpty(icClass.grosstime)) && (icClass.tareA > 0) && (!string.IsNullOrEmpty(icClass.taretime))))
- {
- if (MessageUtil.ShowYesNoAndQuestion("确定清卡?") != DialogResult.Yes)
- {
- return;
- }
- if (icClass.ClearCard() == true)
- {
- txt_message.Text = txt_message.Text + "IC卡已清卡!" + "\r\n";
- }
- else
- {
- txt_message.Text = txt_message.Text + "IC卡已清卡!" + "\r\n";
- }
- icClass.AlarmBeep(1);
- }
- }
- /// <summary>
- /// 连接读卡器string txtCom = ultraComboEditor1.SelectedItem.ToString();
- /// </summary>
- /// <returns></returns>
- private bool ConnectCard()
- {
- try
- {
- txt_message.Text = "";
- if (icClass == null)
- {
- icClass = new TalentICTGXControl.TalentICTGXClass();
- //委托OnFindCard事件,icClass_OnFindCard是该事件要执行的方法。
- //此事件在当IC卡放到读卡器上时触发。
- icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
- }
- //icClass.AlarmBeep(2);
- string txtCom = txt_com.SelectedItem.ToString();
- int comNum = (short)(short.Parse(txtCom.Replace("COM", "")) - 1);
- icClass.CommPort = comNum;
- if (icClass.Active)
- {
- icClass.Active = false;
- txt_message.Text = "初始连接中!" + "\r\n";
- }
- if (!icClass.Active)
- {
- icClass.ToFindCard = true;
- // MessageUtil.ShowTips("ConnectCard.icClass.Active: " + icClass.Active);
- if (icClass.Active)
- {
- //MessageUtil.ShowTips("IC卡连接成功!");
- txt_message.Text = "IC卡连接成功!" + "\r\n";
- //AlarmBeep(int times)方法实现了让IC卡读卡器发出警示音,
- //参数为发出几次警示音。
- icClass.AlarmBeep(2);
- return true;
- }
- else
- {
- txt_message.Text = "IC卡连接失败!或请切换端口尝试" + "\r\n";
- return false;
- }
- }
- else
- {
- txt_message.Text = "初始连接失败!" + "\r\n";
- return false;
- }
- }
- catch (Exception ex)
- {
-
- txt_message.Text = txt_message.Text+ex + "\r\n";
- return false;
- }
- }
- /// <summary>
- /// 测试连接读卡器string txtCom = ultraComboEditor1.SelectedItem.ToString();
- /// </summary>
- /// <returns></returns>
- private bool testConnectCard()
- {
- try
- {
- txt_message.Text = "";
- icClass = new TalentICTGXControl.TalentICTGXClass();
- //委托OnFindCard事件,icClass_OnFindCard是该事件要执行的方法。
- //此事件在当IC卡放到读卡器上时触发。
- icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
- //icClass.AlarmBeep(2);
- string txtCom = txt_com.SelectedItem.ToString();
- int comNum = (short)(short.Parse(txtCom.Replace("COM", "")) - 1);
- icClass.CommPort = comNum;
- if (!icClass.Active)
- {
- icClass.ToFindCard = true;
- // MessageUtil.ShowTips("ConnectCard.icClass.Active: " + icClass.Active);
- if (icClass.Active)
- {
- //MessageUtil.ShowTips("IC卡连接成功!");
- txt_message.Text = "IC卡连接成功!" + "\r\n";
- //AlarmBeep(int times)方法实现了让IC卡读卡器发出警示音,
- //参数为发出几次警示音。
- icClass.AlarmBeep(2);
- return true;
- }
- else
- {
- txt_message.Text = "IC卡连接失败!或请切换端口尝试" + "\r\n";
- return false;
- }
- }
- else
- {
- icClass.AlarmBeep(1);
- //设置Active属性为false,则断开与读卡器的连接。
- icClass.ToFindCard = false;
- icClass.Active = false;
- txt_message.Text = "IC卡已断开与读卡器连接!" + "\r\n";
- return false;
- }
- }
- catch (Exception ex)
- {
- txt_message.Text = txt_message.Text + ex + "\r\n";
- return false;
- }
- }
- 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);
- }
- //void icClass_OnConnect()
- //{
- // MessageUtil.ShowTips("icClass_OnConnect");
- //}
- //void icClass_OnError()
- //{
- // MessageUtil.ShowTips("icClass_OnError");
- //}
- /// <summary>
- /// 读卡
- /// </summary>
- /// <summary>
- /// 读IC卡信息
- /// </summary>
- private void ReadCard()
- {
- try
- {
- if (getConnect() == false)
- {
- return;
- }
- icClass.PrepareReadTemp();
- if (icClass.DoReadTemp(1, 39))
- {
- txt_message.Text = txt_message.Text+"读卡成功!" + "\r\n";
- }
- else
- {
- txt_message.Text = txt_message.Text + "读卡失败!" + "\r\n";
- }
- //if (icClass.DoReadTemp(1, 39))
- //{
- int count = icClass.RecordCount;
- //if (count == 0) //判断卡上的记录数
- //{
- // txt_message.Text = txt_message.Text + "读卡失败!" + "\r\n";
- // return "";
- //}
- //else
- //{
- // icCardNo = icClass.ICNo;
- //}
- string strDeliverySubLineSqe = icClass.poorder;//订单号(最好8位,现在计量表中没有8位的单号,避免单号重复)
- string suppCode=icClass.sourceunitcode;//供应商代码(计量系统)
- string suppName=icClass.sourceunit;//客户名称
- string itemCode=icClass.A_materialcode;//物料代码(计量系统)
- string itemName=icClass.A_material;//物料名称tg
- string deliveryLocationCode=icClass.targetunitcode ;//去向代码
- string deliveryLocation=icClass.targetunit;//去向名称
- string icCardNo = icClass.ICNo;
- string carNo = icClass.carno;
- String A_length = icClass.A_length;
- icClass.EndReadTemp();
- txt_message.Text = txt_message.Text + "卡号:" + icCardNo + "\r\n";
- txt_message.Text = txt_message.Text + "车号:" + carNo + "\r\n";
- disConnect();
- if (String.IsNullOrEmpty(icCardNo))
- {
- txt_message.Text =txt_message.Text+ "或请点击“连接”按钮重试" +"\r\n";
- return;
- }
- if (String.IsNullOrEmpty(carNo))
- {
- txt_message.Text = txt_message.Text + "若未读到信息请点击“连接”按钮重试" + "\r\n";
- }
- ExcDeliverySubC sub = new ExcDeliverySubC();
- sub.DeliverySubId = icCardNo;
- sub.DeliverySubLineSqe = strDeliverySubLineSqe;
- sub.CreateUserid = suppCode;
- sub.CreateName = suppName;
- sub.ItemCode = itemCode;
- sub.ItemName = itemName;
- sub.UpdateName = deliveryLocation;
- sub.UpdateUserid = deliveryLocationCode;
- sub.DeleteName = A_length;
- sub.CarNum = carNo;
- frmPopJLDaTaReview frm = new frmPopJLDaTaReview(this.ob, sub);
- frm.Text = "[" + icCardNo + "]" + "卡信息";
- frm.ShowDialog();
- // return icCardNo;
- }
- catch (Exception ex)
- {
-
- txt_message.Text = txt_message.Text+ex + "\r\n";
- //return "-1";
- }
- }
- /// <summary>
- /// 送货单写卡写IC卡信息
- /// </summary>
- /// <param name="doc"></param>
- /// <param name="carNo"></param>
- /// <returns></returns>
- ///
- private bool Write()
- {
- if (testCode() == false)
- {
- return false;
- }
- if (getConnect() == false)
- {
- return false;
- }
- if (icClass == null)
- {
- return false;
- }
- //if (icClass.IsIC == false)
- //{
- // MessageUtil.ShowTips("请放IC卡!" + icClass.IsIC);
- // return false;
- //}
- //else
- {
- if (ultraGrid2.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择发货单行进行操作!");
- return false;
- }
- String strDeliverySubLineSqe = ultraGrid2.ActiveRow.GetCellValue("deliverySubLineSqe").ToString().Trim();
- if (String.IsNullOrEmpty(strDeliverySubLineSqe))
- {
- MessageUtil.ShowTips("送货单行号为空");
- }
- ExcDeliverySubC dsc = this.execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
- if (dsc.MeteringFlag != "1")
- {
- if (MessageUtil.ShowYesNoAndQuestion("该物料不需要过磅,是否继续操作 ?") != DialogResult.Yes)
- {
- return false;
- }
- }
- if (dsc.Ismeter == "1")
- {
- if (MessageUtil.ShowYesNoAndQuestion("该物料已委托计量,确定再次写卡 ?") != DialogResult.Yes)
- {
- return false;
- }
- }
- String strDeliverySubId = dsc.DeliverySubId;
- if (String.IsNullOrEmpty(strDeliverySubId))
- {
- MessageUtil.ShowTips("送货单号为空");
- return false;
- }
- ExcDeliverySubM dsm = this.execute<ExcDeliverySubM>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { strDeliverySubId });
- String suppCode = dsm.SuppCode;
- String suppName = dsm.SuppName;
- String deliveryLocationCode = dsm.DeliveryLocationCode;
- String deliveryLocation = dsm.DeliveryLocation;
- String itemCode = dsc.ItemCode;
- String itemName = dsc.ItemName;
- if (txt_carNumJL.Text.Trim() == "")
- {
- MessageUtil.ShowTips("车号不能为空!");
- txt_carNumJL.Focus();
- return false;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定生成供方:" + suppName + " 的计量委托?") != DialogResult.Yes)
- {
- return false;
- }
- icClass.PrepareWriteTemp();
- icClass.taskcode = "9";
- icClass.operatype = "9";//
- icClass.card_initflag = "3";//
- //icClass.totalcount = int.Parse(strDeliverySubLineSqe.Replace(orderId, "")); //送货单行号的序号
- icClass.carno = txt_carNumJL.Text.Trim();//车号
- icClass.poorder = strDeliverySubLineSqe;//订单号(最好8位,现在计量表中没有8位的单号,避免单号重复)
- icClass.A_materialcode = WMmatcode;//物料代码(计量系统)
- icClass.sourceunitcode = WMsuppCode;//供应商代码(计量系统)
- icClass.sourceunit = suppName;//客户名称
- icClass.A_material = itemName;//物料名称tg
- icClass.targetunitcode = WMdeliveryCode;//去向代码
- icClass.targetunit = deliveryLocation;//去向名称
- icClass.A_length = txt_length.Value.ToString().Trim();//是否每车刷卡 1:是(每次都要刷卡)0:否(此车只刷一次卡,长期有效)
- icClass.DoWriteTemp();
- if (icClass.Errored == true)
- {
- txt_message.Text = txt_message.Text + "写IC卡错误,请重新点击确认" + "\r\n";
- // MessageUtil.ShowTips("写IC卡错误,请重新点击确认!");
- return false;
- }
- if (icClass.Active)
- {
- icClass.AlarmBeep(3);
- txt_message.Text = txt_message.Text + "写IC卡完成" + "\r\n";
- //MessageUtil.ShowTips("写IC卡完成。");
- disConnect();
- //修改送货单行状态
- ExcDeliverySubC EdnC = new ExcDeliverySubC();
- EdnC.DeliverySubLineSqe = strDeliverySubLineSqe;
- EdnC.Ismeter = "1";
- EdnC.MeteringFlag = "1";
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "doUpdate", new object[] { EdnC });
- }
- }
- return true;
- }
- /// <summary>
- /// 通知单行写卡写IC卡信息
- /// </summary>
- /// <param name="doc"></param>
- /// <param name="carNo"></param>
- /// <returns></returns>
- ///
- private bool Write1()
- {
- if (testCode() == false)
- {
- return false;
- }
- if (getConnect() == false)
- {
- return false;
- }
- if (icClass == null)
- {
- return false;
- }
- //if (icClass.IsIC == false)
- //{
- // MessageUtil.ShowTips("请放IC卡!" + icClass.IsIC);
- // return false;
- //}
- //else
- {
- if (ultraGrid4.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择通知单行进行操作!");
- return false;
- }
- String strNoticeLineSqe = ultraGrid4.ActiveRow.GetCellValue("noticeLineSqe").ToString().Trim();
- if (String.IsNullOrEmpty(strNoticeLineSqe))
- {
- MessageUtil.ShowTips("通知单行号为空");
- }
- ExcDeliveryNoticeC dsc = this.execute<ExcDeliveryNoticeC>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "findById", new object[] { strNoticeLineSqe });
- if (dsc.MeteringFlag != "1")
- {
- if (MessageUtil.ShowYesNoAndQuestion("该物料不需要过磅,是否继续操作 ?") != DialogResult.Yes)
- {
- return false;
- }
- }
- if (txt_QtyJL.Value == null)
- {
- MessageUtil.ShowTips("请输入计量重量");
- }
- double dbCreateQty = Convert.ToDouble(txt_QtyJL.Value);
- double dbcreatedQty=(double)(dsc.CreatedQty == null ? 0 :dsc.CreatedQty);
- Double canJLQty = (double)dsc.Qty - dbcreatedQty;
- if (canJLQty<=0)
- {
- MessageUtil.ShowTips("已经全部生成送货单,或请采用送货单进行发送计量委托");
- return false;
- }
- if (dbCreateQty > canJLQty)
- {
- MessageUtil.ShowTips("该通知单行最大可编制:" + canJLQty);
- return false;
- }
- String strNoticeId = dsc.NoticeId;
- ExcDeliveryNoticeM dsm = this.execute<ExcDeliveryNoticeM>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "findById", new object[] { strNoticeId });
- //准备数据写入
- ExcDeliverySubM sm = new ExcDeliverySubM();
- sm.NoticeId = strNoticeId;
- sm.Status = "1";
- sm.OrderId = dsm.OrderId;
- sm.DeliveryLocationCode = dsm.DeliveryLocationCode;
- sm.DeliveryLocation = dsm.DeliveryLocation;
- sm.SuppCode = dsm.SuppCode;
- sm.SuppName = dsm.SuppName;
- sm.PlanedDeliveryDate = DateTime.Now;
- sm.Validflag = "1";
- sm.CreateName = UserInfo.GetUserName();
- sm.CreateUserid = UserInfo.GetUserID();
- sm.CreateTime = DateTime.Now;
- sm.DeliveryCondition = dsm.DeliveryCondition;
- sm.BuyerDeptCode = UserInfo.GetDeptid();
- sm.DeliveryType = dsm.DeliveryType;
- sm.ReceiveType = dsc.ReceiveType;
- List<ExcDeliverySubC> list = new List<ExcDeliverySubC>();
- ExcDeliverySubC sc = new ExcDeliverySubC();
- sc.NoticeId = strNoticeId;
- sc.OrderId = dsc.OrderId;
- sc.OrderLineSqe = dsc.OrderLineSqe;
- sc.NoticeLineSqe = dsc.NoticeLineSqe;
- sc.ItemCode = dsc.ItemCode;
- sc.ItemDesc = dsc.ItemDesc;
- sc.ItemDescE = dsc.ItemDescE;
- sc.ItemName = dsc.ItemName;
- sc.ItemUom = dsc.ItemUom;
- sc.ItemUomId = dsc.ItemUomId;
- sc.WeightUnit = dsc.WeightUnit;
- sc.ItemUomConefficient = dsc.ItemUomConefficient;
- sc.ItemUseUom = dsc.ItemUseUom;
- sc.ItemAttr = dsc.ItemAttr;//物料属性
- sc.ItemAttrId = dsc.ItemAttrId;//属性编码
- sc.ItemStandardsCode = dsc.ItemStandardsCode;
- sc.ItemStandardsId = dsc.ItemStandardsId;
- sc.ItemUnique = dsc.ItemUnique;
- sc.Qty = dbCreateQty;//送货数量
- String strBatchNo = txt_batchNo.Text.Trim();
- if (dsc.BatchFlag == "1")//批次控制
- {
- if (String.IsNullOrEmpty(strBatchNo))
- {
- MessageUtil.ShowTips("物料:" + dsc.ItemName + "为批次控制物料,请输入生成批次号!");
- return false;
- }
- }
- sc.BatchNo = strBatchNo;
- if (String.IsNullOrEmpty(txt_carNumJL.Text.Trim()))
- {
- MessageUtil.ShowTips("请输入车号!");
- return false;
- }
- String strCarNumC = txt_carNumJL.Text.Trim();
- sc.CarNum = strCarNumC;
- sc.ReceiveType = dsc.ReceiveType;
- sc.BuyerName = dsc.BuyerName;
- sc.MeteringFlag ="1";
- sc.BatchFlag = dsc.BatchFlag;
- sc.PcFlag = dsc.PcFlag;
- sc.Ismeter = "1";
- sc.CreateName = UserInfo.GetUserName();
- sc.CreateUserid = UserInfo.GetUserID();
- sc.CreateTime = DateTime.Now;
- sc.Validflag = "1";
- sc.Status = "1";//待收货
- sc.ShippedQty = 0;
- sc.ShipQty = 0;
- sc.ReceivedQty = 0;
- sc.PackageType = dsc.PackageType;
- list.Add(sc);
- if (MessageUtil.ShowYesNoAndQuestion("确定生成供方:" + dsm.SuppName + "的计量委托?") != DialogResult.Yes)
- {
- return false;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "insert_PC", new object[] { sm, list });
- if (re.Resultcode != 0)
- {
- MessageUtil.ShowTips("发送计量委托失败:生成送货单失败" + re.Resultmsg);
- return false;
- }
- String suppCode = dsm.SuppCode;
- String suppName = dsm.SuppName;
- String deliveryLocationCode = dsm.DeliveryLocationCode;
- String deliveryLocation = dsm.DeliveryLocation;
- String itemCode = dsc.ItemCode;
- String itemName = dsc.ItemName;
- String strDeliverySubId = re.Resultmsg;
- String strDeliverySubLineSqe = re.Resultdata.ToString();
- if (String.IsNullOrEmpty(strDeliverySubId))
- {
- MessageUtil.ShowTips("送货单号为空");
- }
- if (String.IsNullOrEmpty(strDeliverySubLineSqe))
- {
- MessageUtil.ShowTips("送货单行号为空");
- }
- icClass.PrepareWriteTemp();
- icClass.taskcode = "9";
- icClass.operatype = "9";//
- icClass.card_initflag = "3";//
- //icClass.totalcount = int.Parse(strDeliverySubLineSqe.Replace(orderId, "")); //送货单行号的序号
- icClass.carno = txt_carNumJL.Text;//车号
- icClass.poorder = strDeliverySubLineSqe;//订单号(最好8位,现在计量表中没有8位的单号,避免单号重复)
- icClass.sourceunit = suppName;//客户名称
- icClass.A_materialcode = WMmatcode;//物料代码(计量系统)
- icClass.sourceunitcode = WMsuppCode;//供应商代码(计量系统)
- icClass.A_material = itemName;//物料名称tg
- icClass.targetunitcode = WMdeliveryCode;//去向代码
- icClass.targetunit = deliveryLocation;//去向名称
- icClass.A_length = txt_length.Value.ToString().Trim();//是否每车刷卡 1:是(每次都要刷卡)0:否(此车只刷一次卡,长期有效)
- icClass.B_memo = memo.Text;
- icClass.DoWriteTemp();
- if (icClass.Errored == true)
- {
- txt_message.Text = txt_message.Text + "写IC卡错误,请重新点击确认" + "\r\n";
- //MessageUtil.ShowTips("写IC卡错误,请重新点击确认!");
- return false;
- }
- if (icClass.Active)
- {
- icClass.AlarmBeep(3);
- txt_message.Text = txt_message.Text + "写IC卡完成,同时生成送货单:" +strDeliverySubId+ "\r\n";
- // MessageUtil.ShowTips("写IC卡完成。");
- disConnect();
- }
- }
- return true;
- }
- private bool testCode()
- {
- if (WMmatcode.Trim() == "" || WMsuppCode.Trim() == "" || WMdeliveryCode.Trim() == "")
- {
- if (WMmatcode.Trim() == "")
- {
- txt_message.Text = txt_message.Text + "该物料编码未在计量系统维护,请联系计控维护" + "\r\n";
- }
- if (WMsuppCode.Trim() == "")
- {
- txt_message.Text = txt_message.Text + "该供方编码未在计量系统维护,请联系计控维护" + "\r\n";
- }
- if (WMdeliveryCode.Trim() == "")
- {
- txt_message.Text = txt_message.Text + "该交付地址未在计量系统维护,请联系计控维护" + "\r\n";
- }
- return false;
- }
- return true;
- }
- #endregion
- #region 公共用函数
- private bool testSubC(string strDeliverySubLineSqe)
- {
- ExcDeliverySubC dsc = this.execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
- if (dsc == null)
- {
- MessageUtil.ShowTips("未发现送货单行:" + strDeliverySubLineSqe + "信息记录,可能已被删除,或请刷新界面重试");
- return false;
- }
- if (dsc.Validflag != "1")
- {
- MessageUtil.ShowTips("送货单行:" + strDeliverySubLineSqe + "信息记录可能已被删除,或请刷新界面重试");
- return false;
- }
- if (!String.IsNullOrEmpty(dsc.CheckNo))
- {
- MessageUtil.ShowTips("送货单行:" + strDeliverySubLineSqe + "已生成检化验委托,无需重复操作!");
- return false;
- }
- return true;
- }
- //清空jl编辑区
- private void clearSampleTabJL()
- {
- txt_QtyJL.Value = 0;
- ck_meterFlag.Checked = false;
- ck_meterFlag.Enabled = true;
- txt_carNumJL.Clear();
- }
- /// <summary>
- /// 校验检验号是否可以作废
- /// </summary>
- /// <param name="strCheckNo"></param>
- /// <returns></returns>
- private bool testSampleNo(string strCheckNo)
- {
- CheckconsignDetail detail = new CheckconsignDetail();
- detail.CheckNo = strCheckNo;
- List<CheckconsignDetail> list = this.execute<List<CheckconsignDetail>>("com.hnshituo.pur.ck.service.CheckconsignDetailService", "find", new object[] { detail, 0, 0 });
- if (list != null)
- {
- if (list.Count > 0)
- {
- foreach (CheckconsignDetail det in list)
- {
- if (det.Flag != "-1")
- {
- MessageUtil.ShowTips("该检化验项委托可能已发送,不能作废!");
- return false;
- }
- }
- }
- else
- {
- MessageUtil.ShowTips("未发现检化验号:" + strCheckNo + "检验项明细!");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("未发现检化验号:" + strCheckNo + "检验项明细!");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 初检或者取消初检校验
- /// </summary>
- /// <param name="deliverySubId"></param>
- /// <param name="p"></param>
- /// <returns></returns>
- private bool testDeliveryStatus(String deliverySubId, int p)
- {
- if (String.IsNullOrEmpty(deliverySubId))
- {
- MessageUtil.ShowTips("送货单行号为空,无法校验数据有效性");
- return false;
- }
- ExcDeliverySubC subc = this.execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { deliverySubId });
- if (subc == null)
- {
- MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + "信息记录,可能已作废,或请刷新界面重试");
- return false;
- }
- if (subc.Validflag != "1")
- {
- MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + "信息记录,可能已作废,或请刷新界面重试");
- return false;
- }
- String testStatus = subc.Status;
- if (String.IsNullOrEmpty(subc.DeliverySubId))
- {
- MessageUtil.ShowTips("未找到送货单行的头信息");
- return false;
- }
- ExcDeliverySubM subM = this.execute<ExcDeliverySubM>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { subc.DeliverySubId });
- if (subM == null)
- {
- MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + "信息记录,可能已作废,或请刷新界面重试");
- return false;
- }
- if (subM.Validflag != "1")
- {
- MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + "信息记录,可能已作废,或请刷新界面重试");
- return false;
- }
- if (subM.Status != "1")
- {
- MessageUtil.ShowTips("送货单:" + subc.DeliverySubId + "可能已经收货完成,或请刷新界面重试");
- return false;
- }
- //完成初检校验
- if (p == 1)
- {
- if (testStatus != "1")
- {
- MessageUtil.ShowTips("送货单行:" + deliverySubId + "可能已经初检完成,或请刷新界面重试");
- return false;
- }
- }
- //取消初检校验
- else if (p == 2)
- {
- if (testStatus != "2" && testStatus != "3")
- {
- MessageUtil.ShowTips("送货单行:" + deliverySubId + "可能还未完成初检或已经(待检)入库,或请刷新界面重试");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数:" + p);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 查询送货单行
- /// </summary>
- private void queryDeliverySubC(String tips)
- {
- try
- {
- dataTable2.Clear();
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- return;
- }
- String strDeliverySubId = uge.GetCellValue("deliverySubId").ToString().Trim();
- if (String.IsNullOrEmpty(strDeliverySubId))
- {
- MessageUtil.ShowTips("送货单号为空");
- }
- if (tips != "0")
- {
- dataTable2.Clear();
- ultraGrid2.Update();
- }
- ExcDeliverySubC EdSc = new ExcDeliverySubC();
- EdSc.DeliverySubId = strDeliverySubId;
- EdSc.Validflag = "1";
- if (ck_isAllMeter.Checked)
- {
- EdSc.MeteringFlag = "1";
- }
- if (txt_status.SelectedIndex == 1)//待计量
- {
- EdSc.Ismeter = "0";
- }
- else if (txt_status.SelectedIndex == 2)//已经计量
- {
- EdSc.Ismeter = "1";
- }
- else//全部
- {
- //
- }
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdSc });
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载送货单行信息失败:" + ex);
- }
- }
- /// <summary>
- /// 查询通知单行
- /// </summary>
- private void queryNoticeC(String tips)
- {
- try
- {
- dataTable4.Clear();
- UltraGridRow uge = ultraGrid3.ActiveRow;
- if (uge == null)
- {
- return;
- }
- String strNoticeId = uge.Cells["NoticeId"].Value.ToString();
- if (tips!= "0")
- {
- dataTable4.Clear();
- ultraGrid4.Update();
- }
- ExcDeliveryNoticeC EdnC = new ExcDeliveryNoticeC();
- EdnC.NoticeId = strNoticeId;
- EdnC.Validflag = "1";
- if (ck_isAllMeter.Checked)
- {
- EdnC.MeteringFlag = "1";
- }
- if (txt_status.SelectedIndex == 1)//待计量
- {
- EdnC.DeleteUserid = "0";
- }
- else if (txt_status.SelectedIndex == 2)//已经计量
- {
- EdnC.DeleteUserid = "1";
- }
- else//全部
- {
- //
- }
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "find_EdnC", new object[] { EdnC });
- GridHelper.CopyDataToDatatable(dt, dataTable4, true);
- GridHelper.RefreshAndAutoSize(ultraGrid4);
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载通知单行信息失败:" + ex);
- }
- }
- #endregion
- private void txt_length_TextChanged(object sender, EventArgs e)
- {
- if(txt_length.Text.ToString()=="每车刷卡")
- {
- txt_length.Value = "1";
- }
- else
- {
- txt_length.Value = "0";
- }
- }
-
- }
- }
|