Exemplo n.º 1
0
 public CardEventArgsRegist()
 {
     _value = new CardData();
 }
Exemplo n.º 2
0
 public CardEventArgsRegist(CardData value)
 {
     this._value = value;
 }
Exemplo n.º 3
0
 void HandleCardData(CardData data)
 {
     tbValue.Text = data.CarNo;
     tbID.Text = data.ID;
 }
Exemplo n.º 4
0
 public CardEventArgs()
 {
     _value = new CardData();
 }
Exemplo n.º 5
0
        private void ReadCard(CardData cardData)
        {
            if (!_isReadCard)
                return;
            _isReadCard = false;
            txtCardNo.Text = cardData.CardNo;
            this._dischargeflag = cardData.UnloadFlag;
            if (!string.IsNullOrEmpty(txtCardNo.Text.Trim()))
            {
                //由卡号带出绑定的车号
                string sql = "select t.fs_sequenceno,t.FS_BINDCARNO from BT_CARDMANAGE t where t.fs_sequenceno='" + cardData.CardNo + "'";

                DataTable dt = new DataTable();
                CoreClientParam ccp = new CoreClientParam();
                ccp.ServerName = "com.dbComm.DBComm";
                ccp.MethodName = "queryBySql";
                ccp.ServerParams = new object[] { sql, new ArrayList() };
                ccp.SourceDataTable = dt;
                this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("该卡还未注册,不能使用!");
                    return;
                }
                else
                {
                    txtCardNo.Text = cardData.CardNo;

                    //查找进厂记录
                    string sql2 = "select t.fs_carno from dt_enterfacrecord t where t.fs_cardnumber = '"+cardData.CardNo+"' and nvl(t.fn_enterfacflag,1) = 1";
                    DataTable dt2 = new DataTable();
                    CoreClientParam ccp2 = new CoreClientParam();
                    ccp2.ServerName = "com.dbComm.DBComm";
                    ccp2.MethodName = "queryBySql";
                    ccp2.ServerParams = new object[] { sql2, new ArrayList() };
                    ccp2.SourceDataTable = dt2;
                    this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal);
                    if (dt2.Rows.Count > 0)
                    {
                        string carNo = dt2.Rows[0]["FS_CARNO"].ToString();
                        if (!string.IsNullOrEmpty(carNo) && carNo.Length > 1)
                        {
                            if (carNo.Length == 7)
                            {
                                this.cbCH.Text = carNo.Substring(0, 2);
                                this.tbCarNo.Text = carNo.Substring(2);
                            }
                            else if (carNo.Length == 8)
                            {
                                this.cbCH.Text = carNo.Substring(0, 3);
                                this.tbCarNo.Text = carNo.Substring(3);
                            }
                            else
                            {
                                this.cbCH.Text = carNo.Substring(0, 1);
                                this.tbCarNo.Text = carNo.Substring(1);
                            }
                            //自动出厂
                         /*   if (ultraCheckEditor2.Checked)
                            {
                                LetGo();
                            }*/
                        }
                        //return;
                    }

                    string text = dt.Rows[0]["FS_BINDCARNO"].ToString();

                    if (!string.IsNullOrEmpty(text) && text.Length > 1)
                    {
                        if (text.Length == 7)
                        {
                            this.cbCH.Text = text.Substring(0, 2);
                            this.tbCarNo.Text = text.Substring(2);
                        }
                        else if (text.Length == 8)
                        {
                            this.cbCH.Text = text.Substring(0, 3);
                            this.tbCarNo.Text = text.Substring(3);
                        }
                        else
                        {
                            this.cbCH.Text = text.Substring(0, 1);
                            this.tbCarNo.Text = text.Substring(1);
                        }
                    }
                 /*   else
                    {
                        this.cbCH.Text = "";
                        this.tbCarNo.Text = "";
                    }*/
                    if (checkBox1.Checked)
                    {
                        LetGo();
                    }
                }
            }

            System.Threading.Thread th = new System.Threading.Thread(resetReadStatus);
            th.Start();
        }
Exemplo n.º 6
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (_measApp != null && _measApp.Card != null)
            {
                DataTable dt = new DataTable();
                _carWeightDatamanage.GetCardData(weighEditorControl1.CardNo, weighEditorControl1.CarNo, dt);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    _cardData = new CardData();
                    _cardData.CarNo = dr["FS_CARNO"].ToString(); ;
                    _cardData.MateriaName = dr["FS_MATERIALNAME"].ToString();
                    _cardData.Receiver = dr["FS_SHDW"].ToString();
                    _cardData.Sender = dr["FS_FHDW"].ToString();
                    _cardData.PlanLoc = dr["FS_RECEIVERFACTORY"].ToString();
                    _cardData.UnloadFlag = " ";
                    _cardData.UnloadKZ = " ";
                    _cardData.WgtOpCd = dr["FS_WEIGHTNO"].ToString();
                    _cardData.FirLocNo = dr["FS_POUND"].ToString();
                    _cardData.FirWeight = dr["FN_WEIGHT"].ToString() + "t";
                    _cardData.SecLocNo = " ";
                    _cardData.SecWeight = " ";
                    if (_measApp.Card.WriteCard(_cardData))
                    {
                        MessageBox.Show("补写成功!");
                        weighEditorControl1.lblStatus.ForeColor = Color.Black;
                        weighEditorControl1.WeighStatus = "";
                    }
                    else
                    {
                        MessageBox.Show("补写失败!");
                    }
                }
                else
                {
                    _measApp.Card.ClearCard();
                }
            }
        }
Exemplo n.º 7
0
        public void Save()
        {
            try
            {
                if (weighEditorControl1.CheckInput())
                {
                    this.Cursor = Cursors.WaitCursor;

                    //meterControl1.Weight = 15;
                    double weight = meterControl1.Weight;

                    if (_measApp != null && _measApp.Weight != null)
                    {
                        _measApp.Weight._receiveFlag = false;
                    }

                    string message = "";
                    bool isAffirm = true;

                    bool isNeedDischarge = weighEditorControl1.IsNeedDischarge;
                    if (weighEditorControl1.Flow.Equals("001"))
                    {
                        isNeedDischarge = true;
                    }

                    if (!_carWeightDatamanage.CheckWeighHistory(weighEditorControl1.CarNo, weight, weighEditorControl1.Flow, isNeedDischarge, weighEditorControl1.DischargeFlag,weighEditorControl1.AlowTareWeight, out message,out isAffirm))
                    {
                        if (!isAffirm)
                        {
                            MessageBox.Show(message, "提示");
                            Cursor = Cursors.Default;
                            if (_measApp != null && _measApp.Weight != null)
                            {
                                _measApp.Weight._receiveFlag = true;
                            }
                            return;
                        }
                        if (MessageBox.Show(message, "提示", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            Cursor = Cursors.Default;
                            if (_measApp != null && _measApp.Weight != null)
                            {
                                _measApp.Weight._receiveFlag = true;
                            }
                            return;
                        }
                    }

                    button1.Enabled = false;
                    messForm.SetMessage("正在计量,请稍候!");
                    //期限皮重更新上次扣渣量
                    if (weighEditorControl1.CardWeightNo.EndsWith("H") && weighEditorControl1.DischargeFlag.Equals("1"))
                    {
                        Hashtable ht = new Hashtable();
                        ht.Add("I1", weighEditorControl1.DischargeFlag);
                        ht.Add("I2", weighEditorControl1.Discharger);
                        ht.Add("I3", weighEditorControl1.DischargeTime);
                        ht.Add("I4", weighEditorControl1.CardDedution);
                        ht.Add("I5", weighEditorControl1.CardWeightNo);
                        ht.Add("I6", "");//预留
                        ht.Add("I7", "");//预留
                        ht.Add("O8", "");
                        ht.Add("O9", "");
                        string[] res = _carWeightDatamanage.SaveCardDischarge(ht);
                    }

                Hashtable param = new Hashtable();
                param.Add("I1", weighEditorControl1.CardNo);
                param.Add("I2", weighEditorControl1.CarNo);
                param.Add("I3", weighEditorControl1.StoveNo1);
                param.Add("I4", weighEditorControl1.StoveNo2);
                param.Add("I5", weighEditorControl1.StoveNo3);
                param.Add("I6", weighEditorControl1.OrderNo);
                param.Add("I7", weighEditorControl1.OrderSeq);
                param.Add("I8", weighEditorControl1.IsTermTare ? "1" : "0");
                param.Add("I9", weighEditorControl1.StoveCount1);
                param.Add("I10", weighEditorControl1.StoveCount2);
                param.Add("I11", weighEditorControl1.StoveCount3);
                param.Add("I12", weighEditorControl1.Material);
                param.Add("I13", weighEditorControl1.MaterialName);
                param.Add("I14", weighEditorControl1.Flow);
                param.Add("I15", weighEditorControl1.TransCompany);
                param.Add("I16", weighEditorControl1.SendCompany);
                param.Add("I17", weighEditorControl1.ReceiveCompany);
                param.Add("I18", weighEditorControl1.SendPlace);
                param.Add("I19", weighEditorControl1.DischargePlace);
                param.Add("I20", weighEditorControl1.WeightType);
                param.Add("I21", weighEditorControl1.Cost);
                param.Add("I22", weighEditorControl1.Deduction);
                param.Add("I23", weighEditorControl1.BillNo);
                param.Add("I24", weighEditorControl1.IsMultiMaterials ? "1" : "0");
                param.Add("I25", weighEditorControl1.SenderWeight);
                param.Add("I26", UserInfo.GetUserID());
                param.Add("I27", UserInfo.GetUserOrder());
                param.Add("I28", UserInfo.GetUserGroup());
                param.Add("I29", weighEditorControl1.PointCode);
                param.Add("I30", weighEditorControl1.PointName);
                param.Add("I31", weighEditorControl1.Remark);
                param.Add("I32", weight.ToString());
                param.Add("I33", weighEditorControl1.TransPlanNo);
                param.Add("I34", weighEditorControl1.DischargeFlag);
                param.Add("I35", !string.IsNullOrEmpty(weighEditorControl1.DischargeFlag) ? weighEditorControl1.Discharger : "");
                if (!string.IsNullOrEmpty(weighEditorControl1.DischargeFlag))
                {
                    try
                    {
                        DateTime.ParseExact(weighEditorControl1.DischargeTime, "yyyyMMddHHmmss", null).ToString("yyyyMMddHHmmss");
                        param.Add("I36", !string.IsNullOrEmpty(weighEditorControl1.DischargeFlag) ? weighEditorControl1.DischargeTime : "");

                    }
                    catch(Exception ee)
                    {
                        param.Add("I36", !string.IsNullOrEmpty(weighEditorControl1.DischargeFlag) ? System.DateTime.Now.ToString("yyyyMMddHHmmss") : "");
                        string p_UPDATER = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();

                        string strDate = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                        string strIP = _baseInfo.getIPAddress();
                        string strMAC = _baseInfo.getMACAddress();
                        //string p_UPDATER = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();

                        _baseInfo.insertLog(strDate, "汽车", p_UPDATER, strIP, strMAC, "", weighEditorControl1.CarNo, weighEditorControl1.TareWeight.ToString(), weighEditorControl1.DischargeTime, "", "", "DT_CARWEIGHT_WEIGHT", "汽车衡过磅/手持时间错误");

                    }
                }

                    if(string.IsNullOrEmpty(weighEditorControl1.DischargeFlag))
                    {
                        param.Add("I36","");
                    }
                ////param.Add("I36", !string.IsNullOrEmpty(weighEditorControl1.DischargeFlag) ? weighEditorControl1.DischargeTime : "");
                param.Add("I37", !string.IsNullOrEmpty(weighEditorControl1.DischargeFlag) ? weighEditorControl1.DischargeDepart : "");
                param.Add("I38", (int)weighEditorControl1.TermTareType);
                param.Add("I39", weighEditorControl1.SenderGrosssWeight);
                param.Add("I40", weighEditorControl1.SenderTareWeight);
                param.Add("O41", "");
                param.Add("O42", "");
                param.Add("O43", "");

                string[] result = _carWeightDatamanage.SaveWeightData(param);

                    //string debugInfo = "";
                    //for (int i = 1; i != 40;i++ )
                    //{
                    //    debugInfo += "I" + i + "=" + param["I" + i].ToString() + ",";
                    //}
                    //Log.Debug("SaveWeightData: point:"+weighEditorControl1.PointName+ ",params:" + debugInfo);

                    if (string.IsNullOrEmpty(result[0]) || result[0].Trim().Equals("0"))
                    {
                        _preWeightNo = result[1];
                        //MessageBox.Show("计量完成!");
                        //语音电铃截图LCD显示
                        if (_measApp != null)
                        {
                            if (_measApp.Rtu != null)
                            {
                                _measApp.Rtu.OpenRing();
                                Log.Debug("carweight.save() : RTU End!");
                            }
                            if (_measApp.Card != null && !string.IsNullOrEmpty(weighEditorControl1.CardNo))
                            {
                                _cardData = new CardData();
                                _cardData.CarNo = weighEditorControl1.CarNo;
                                _cardData.MateriaName = weighEditorControl1.MaterialName;
                                _cardData.Receiver = weighEditorControl1.ReceiveCompanyName;
                                _cardData.Sender = weighEditorControl1.SendCompanyName;
                                _cardData.PlanLoc = weighEditorControl1.DischargePlace;
                                _cardData.UnloadFlag = " ";
                                _cardData.UnloadKZ = " ";
                                _cardData.WgtOpCd = result[1];
                                if (!string.IsNullOrEmpty(result[1]) && result[1].EndsWith("H"))
                                {
                                    //_cardData.SecLocNo = weighEditorControl1.PointName;
                                    //_cardData.SecWeight = weight.ToString()+"t";
                                    _cardData.FirLocNo = " ";
                                    _cardData.FirWeight = " ";
                                    _cardData.CarNo = " ";
                                    _cardData.MateriaName = " ";
                                    _cardData.Receiver = " ";
                                    _cardData.Sender = " ";
                                    _cardData.PlanLoc = " ";
                                }
                                else
                                {
                                    _cardData.FirLocNo = weighEditorControl1.PointName;
                                    _cardData.FirWeight = weight.ToString() + "t";

                                    _cardData.SecLocNo = " ";
                                    _cardData.SecWeight = " ";
                                }
                                //Thread th = new Thread(ThreadWrite);
                                //th.Start();
                                try
                                {
                                    ThreadWrite();
                                }
                                catch (Exception e)
                                {

                                }

                                Log.Debug("carweight.save() : IcCard End!");
                            }
                            if (_measApp.Lcd != null)
                            {
                                ShowLcd();
                                Log.Debug("carweight.save() : Lcd End!");
                            }

                            if (_measApp.Dvr != null)
                            {
                                bool talked = false;
                                if (_isTalk)
                                {
                                    talked = true;
                                    _measApp.Dvr.StopTalk();
                                    _isTalk = false;
                                    ultraToolbarsManager1.Toolbars[0].Tools["YYDJ"].SharedProps.Caption = "打开对讲";
                                }
                                if (_isReWriteCard)
                                {
                                    _measApp.Dvr.SendVoiceData(_curPath + "\\sound\\刷卡失败 请重新刷卡.wav");
                                    weighEditorControl1.lblStatus.ForeColor = Color.Red;
                                    weighEditorControl1.WeighStatus = "写卡失败,请让司机插卡,然后点击界面上的“补写”按钮!";
                                }

                                else

                                _measApp.Dvr.SendVoiceData(_curPath + "\\qcsound\\计量完成.wav");
                                Log.Debug("carweight.save() : DVR Send Voice End!");
                                //if (talked)
                                //{
                                //    Thread.Sleep(200);
                                //    _isTalk = _measApp.Dvr.StartTalk();
                                //    if (_isTalk)
                                //    {
                                //        ultraToolbarsManager1.Toolbars[0].Tools["YYDJ"].SharedProps.Caption = "关闭对讲";
                                //    }
                                //}
                                Capture(weighEditorControl1.PointCode, result[1], weight);
                                Log.Debug("carweight.save() : DVR Capture End!");
                            }
                        }

                        //采购进厂或二次计量自动打印
                        if (ultraCheckEditor1.Checked && (weighEditorControl1.Flow.Equals("001") || _preWeightNo.EndsWith("H")))
                        {
                            Log.Debug("carweight.save() : Printer Begin!");
                            Print();
                            Log.Debug("carweight.save() : Printer End!");
                        }
                        string strStatus = weighEditorControl1.WeighStatus;

                        weighEditorControl1.Clear();
                        if (strStatus.Contains("补写"))
                        {
                            weighEditorControl1.WeighStatus = strStatus;
                        }
                        weighEditorControl1.CardNo = "";
                        weighEditorControl1.CarNo = "";
                        //_series[m_iSelectedPound].Points.Clear();
                        //NumericDataPoint np = new NumericDataPoint();
                        //np.Value = 0;
                        //_series[m_iSelectedPound].Points.Add(np);

                    //加载一次计量数据
                    _carWeightDatamanage.GetFirstWeighData(this.dataTable11, "", "");
                    _dtFirstWeighData = dataTable11.Copy();
                    ultraGrid3.DataSource = _dtFirstWeighData;

                    SetFirstPicVisible(false);
                    _measApp.IsSaved = true;//保存标识
                    button1.Enabled = false;
                    messForm.Visible = false;
                }
                    if (!string.IsNullOrEmpty(result[2]))
                    {
                        MessageBox.Show(_isReWriteCard ? (result[2] + "   请补写卡!") : result[2]);

                    }

                    weighEditorControl1.Focus();
                    Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                Log.Error("carweigh.save() : " + ex.Message);
            }
            catch
            {
                Log.Error("carweigh.save() Error!");
            }
            finally
            {
                if (_measApp != null && _measApp.Weight != null)
                {
                    _measApp.Weight._receiveFlag = true; ;
                }
            }
        }
Exemplo n.º 8
0
        private void HandleCardChange(CardData data)
        {
            weighEditorControl1.CardNo = data.CardNo.Trim();
            //weighEditorControl1.CarNo = data.CarNo.Trim();
            weighEditorControl1.DischargeFlag = data.UnloadFlag.Trim();
            if (!string.IsNullOrEmpty(weighEditorControl1.DischargeFlag))
            {
                weighEditorControl1.CardWeightNo = data.WgtOpCd.Trim();
                weighEditorControl1.Discharger = data.UnloadName.Trim();
                weighEditorControl1.DischargeTime = data.UnloadTime.Trim();
                weighEditorControl1.DischargeDepart = data.UnloadDepart.Trim();
                if (weighEditorControl1.DischargeFlag.Equals("1"))
                {
                    //历史记录不显示扣渣量
                    if (!weighEditorControl1.CardWeightNo.EndsWith("H"))
                    {
                        double kz = 0;
                        double.TryParse(data.UnloadKZ.Trim(), out kz);
                        weighEditorControl1.Deduction = kz;
                    }
                    else
                    {
                        weighEditorControl1.CardDedution = data.UnloadKZ.Trim();
                    }
                }
            }

            weighEditorControl1.CardWeightNo = data.WgtOpCd.Trim();
            _carWeightDatamanage.GetTransPlan(weighEditorControl1.DT_TransPlan, weighEditorControl1.CardNo, "", weighEditorControl1.IFYBFirst);
            weighEditorControl1.BandTransPlan();
            //DataRow dr = weighEditorControl1.DT_TransPlan.Rows.Count > 0 ? weighEditorControl1.DT_TransPlan.Rows[0] : null;
            //if (dr != null && !string.IsNullOrEmpty(dr["FS_CARNO"].ToString()) && string.IsNullOrEmpty(weighEditorControl1.CarNo))
            //{
            //    weighEditorControl1.CarNo = dr["FS_CARNO"].ToString();
            //}

            //显示车辆过磅信息
            weighEditorControl1.WeighStatus = _carWeightDatamanage.GetWeightStatus(weighEditorControl1.CarNo, (!string.IsNullOrEmpty(weighEditorControl1.DischargeFlag)) && weighEditorControl1.DischargeFlag.Equals("1"));
            SetFirstPicVisible(true);

            Log.Debug("CardInfo = cardNo:" + weighEditorControl1.CardNo + ",carNo:" + weighEditorControl1.CarNo + ",cardWeightNo:" + weighEditorControl1.CardWeightNo + ",dischargeFlag:" + weighEditorControl1.DischargeFlag + ",discharger:" + weighEditorControl1.Discharger + ",dischargeTime:" + weighEditorControl1.DischargeTime);
        }
Exemplo n.º 9
0
        private void RegistCard()
        {
            String czkh = textCZKH.Text; //车证卡芯片号
            String czkxlh = textCZKXLH.Text;//车证卡编号
            String fpr = textFPR.Text;      //分配人(分配给谁用)
            String fpdw = comboFPDW.Text;   //分配单位(对卸货身份卡而言,就是卸货点所属单位)
            //String yt = textYT.Text;
            String jb = ""; //车证卡级别(卸货卡,身份卡,临时卡)
            String strXb = comboSex.Text.Trim();
            String strGwei = comboGwei.Text.Trim();//岗位(对卸货身份卡而言,就是权限 卸货员/管理员)
            String strBmen = comboBmen.Text.Trim();
            String strSfzh = textSFZH.Text.Trim();//身份证号
            String strLxdh = textLXDH.Text.Trim();//联系电话

            try
            {
                jb = comboJB.SelectedValue.ToString();//车证卡级别
            }
            catch (Exception ee1)
            {

            }

            String jbname = comboJB.Text.ToString();
            String yt = ""; //用途
            String bz = textBZ.Text;//备注
            //卡号不可编辑
            //以下为注册车证卡确认时更新相关信息代码

            rowno = -1;//防止应该注册的操作,去操作其他按钮
            if (!textCZKXLH.Enabled)
            {
                MessageBox.Show("还未读卡,请先读卡!");//车证卡芯片序列号
                return;
            }
            czkh = textCZKH.Text.Trim();
            czkxlh = textCZKXLH.Text.Trim();
            if (czkh == null || czkh.Equals(""))
            {
                MessageBox.Show("没有车证卡芯片信息,请刷卡!");
                return;
            }
            if (czkxlh == null || czkxlh.Equals(""))
            {
                MessageBox.Show("请输入车证卡号!");
                return;
            }
            if (czkxlh.Length != 5)
            {
                MessageBox.Show("车证卡号必须为5位数字编号!");
                return;
            }
            try
            {
                int.Parse(czkxlh);
            }
            catch (Exception ee2)
            {
                MessageBox.Show("车证卡号必须为5位数字编号!");
                return;
            }

            if (!checkInputValue())
            {
                return;
            }
            DateTime zzsj = System.DateTime.Now;
            String sxbz_str = "1";//生效标志位

            DataTable testdatatable = new DataTable();//测试输入的卡号和芯片号是否已经存在
            String isExistsql = "select t.FS_SEQUENCENO from BT_CARDMANAGE t where t.FS_SEQUENCENO='" + czkxlh + "'";
            CoreClientParam selectccp = new CoreClientParam();
            selectccp.ServerName = "ygjzjl.carcard.CarCard";
            selectccp.MethodName = "queryByClientSql";
            selectccp.ServerParams = new object[] { isExistsql };
            selectccp.SourceDataTable = testdatatable;
            this.ExecuteQueryToDataTable(selectccp, CoreInvokeType.Internal);
            if (testdatatable.Rows.Count > 0)
            {
                MessageBox.Show("该序列号已经存在,不能注册!");
                return;
            }
            testdatatable.Clear();//若该卡号不存在,则清空临时表testdatatable,并继续用其验证芯片号是否存在
            isExistsql = "select t.FS_CARDNUMBER from BT_CARDMANAGE t where t.FS_CARDNUMBER='" + czkh + "'";
            //CoreClientParam selectccp = new CoreClientParam();
            selectccp.ServerName = "ygjzjl.carcard.CarCard";
            selectccp.MethodName = "queryByClientSql";
            selectccp.ServerParams = new object[] { isExistsql };
            selectccp.SourceDataTable = testdatatable;
            this.ExecuteQueryToDataTable(selectccp, CoreInvokeType.Internal);
            if (testdatatable.Rows.Count > 0)
            {
                if (DialogResult.No == MessageBox.Show("芯片号:" + czkh + "的车证卡已经注册,要更新吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                    textCZKXLH.Text = "";
                    textCZKH.Text = "";
                    textCZKXLH.Enabled = false;//设置为不可编辑
                    return;
                }
                else //如果确定要更新已经注册的车证卡(芯片号已经存在,允许修改车证卡编号)
                {
                    CardData cardData = new CardData();
                    cardData.CardNo = czkxlh;
                    if (checkBox1.Checked && _icCard.CardThread.ThreadState == System.Threading.ThreadState.Running)
                    {
                        _icCard.CardThread.Suspend();
                    }
                    switch (comboJB.Text.Trim())
                    {
                        case "身份卡":
                            cardData.CardType = "0";
                            if (string.IsNullOrEmpty(fpr.Trim()))
                            {
                                MessageBox.Show("请选择分配人!");
                                return;
                            }
                            cardData.FirLocNo = fpr.Trim();

                            if (string.IsNullOrEmpty(strGwei.Trim()))
                            {
                                MessageBox.Show("请选择岗位!");
                                return;
                            }
                            cardData.FirWeight = strGwei.Trim();

                            if (string.IsNullOrEmpty(fpdw.Trim()))
                            {
                                MessageBox.Show("请选择分配单位!");
                                return;
                            }
                            cardData.MateriaName = fpdw.Trim();
                            break;
                        case "计量卡":
                            cardData.CardType = "1";
                            break;
                        case "临时卡":
                            cardData.CardType = "2";
                            break;
                        default:
                            MessageBox.Show("请选择车证卡类型!");
                            return;
                    }
                    bool flag = _icCard.WriteCard(cardData);//写卡操作
                    if (checkBox1.Checked && _icCard.CardThread.ThreadState == System.Threading.ThreadState.Suspended)
                    {
                        _icCard.CardThread.Resume();
                    }
                    if (!flag)
                    {
                        MessageBox.Show("车证卡号没有成功写入卡内扇区,请确认卡放置正确!");
                        textCZKXLH.Text = "";
                        textCZKH.Text = "";
                        textCZKXLH.Enabled = false;
                        return;
                    }
                    //String manageinsertsql = "update BT_CARDMANAGE t set t.FS_SEQUENCENO='" + czkxlh + "',t.FS_INITDEPART='" + departmentcode + "',t.FS_INITUSER='******',t.FD_INITTIME=TO_DATE('" + zzsj + "','YYYY-MM-DD HH24:MI:SS'),t.FS_USEPURPOSE='" + yt + "',t.FS_MEMO='" + bz + "',t.FS_CARDLEVEL='" + jb + "',t.FS_ISVALID='" + sxbz_str + "' where t.FS_CARDNUMBER='" + czkh + "'";
                    String manageinsertsql = @"update BT_CARDMANAGE t
                                                set
                                                    t.FS_SEQUENCENO='" + czkxlh + @"',
                                                    t.FS_INITDEPART='" + departmentcode + @"',
                                                    t.FS_INITUSER='******',
                                                    t.FD_INITTIME=TO_DATE('" + zzsj + @"','YYYY-MM-DD HH24:MI:SS'),
                                                    t.FS_USEPURPOSE='" + yt + @"',
                                                    t.FS_MEMO='" + bz + @"',
                                                    t.FS_CARDLEVEL='" + jb + @"',
                                                    t.FS_ISVALID='" + sxbz_str + @"' ,

                                                    t.FS_ASSIGNDEPART ='" + fpdw + @"',
                                                    t.FS_ASSIGNUSER ='******'
                                                where
                                                    t.FS_CARDNUMBER='" + czkh + @"'";

                    CoreClientParam reccp = new CoreClientParam();
                    reccp.ServerName = "ygjzjl.carcard.CarCard";
                    reccp.MethodName = "updateByClientSql";
                    reccp.ServerParams = new object[] { manageinsertsql };
                    this.ExecuteNonQuery(reccp, CoreInvokeType.Internal);
                    if (reccp.ReturnCode == 0) //更新成功
                    {
                        MessageBox.Show("车证卡更新成功!");
                        DataRow newczkrow = this.dataSet1.Tables["车证卡基础表"].NewRow();
                        newczkrow["FS_CARDNUMBER"] = czkh;
                        newczkrow["FS_SEQUENCENO"] = czkxlh;
                        newczkrow["FS_INITDEPART"] = departmentcode;
                        newczkrow["FS_INITUSER"] = username;
                        newczkrow["FD_INITTIME"] = zzsj.ToString();
                        newczkrow["FS_USEPURPOSE"] = yt;
                        newczkrow["FS_MEMO"] = bz;
                        newczkrow["FS_CARDLEVEL"] = jb;
                        newczkrow["FS_CARDLEVELNAME"] = jbname;
                        newczkrow["FS_ISVALID"] = sxbz_str;
                        newczkrow["FS_ISVALIDNAME"] = "注册";

                        this.dataSet1.Tables["车证卡基础表"].Rows.Add(newczkrow);
                        dataSet1.AcceptChanges();
                        //以上为注册车证卡确认时更新相关信息代码

                        //车证卡操作表(车证卡操作日志)
                        String operationNO = Guid.NewGuid().ToString();
                        String insertsql = "insert into  DT_CARDOPERATION(FS_OPERATENO,FS_SEQUENCENO,FS_CARDNO,FS_APPLYDEPART,FS_APPLYUSER,FS_OPERATIONTYPE,FS_OPERATEDEPART,FS_OPERATOR,FD_OPERATIONTIME) values ('" + operationNO + "','" + czkxlh + "','" + czkh + "','','','更新','" + departmentcode + "','" + username + "',TO_DATE('" + zzsj + "','YYYY-MM-DD HH24:MI:SS'))";
                        CoreClientParam ccp = new CoreClientParam();
                        ccp.ServerName = "ygjzjl.carcard.CarCard";
                        ccp.MethodName = "insertByClientSql";
                        ccp.ServerParams = new object[] { insertsql };
                        this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
                        //车证卡操作表
                    }

                    textCZKXLH.Enabled = false;//注册完后,设置为不可编辑
                }
            }
            else//不存在,则插入(卡号和芯片号均不存在)
            {
                CardData cardData = new CardData();
                cardData.CardNo = czkxlh; //车证卡编号
                if (checkBox1.Checked && _icCard.CardThread.ThreadState == System.Threading.ThreadState.Running)
                {
                    _icCard.CardThread.Suspend(); //如果(自动读卡&&线程正在运行)则挂起ic卡线程,等待写卡操作
                }
                switch (comboJB.Text.Trim())
                {
                    case "身份卡":
                        cardData.CardType = "0";
                        if (string.IsNullOrEmpty(fpr.Trim()))
                        {
                            MessageBox.Show("请填写分配人!");
                            return;
                        }
                        cardData.FirLocNo = fpr.Trim();
                        if (string.IsNullOrEmpty(strGwei.Trim()))
                        {
                            MessageBox.Show("请选择岗位!");
                            return;
                        }
                        cardData.FirWeight = strGwei.Trim();

                        //在此处添加分配单位(卸货身份卡:卸货地点)
                        if (string.IsNullOrEmpty(fpdw.Trim()))
                        {
                            MessageBox.Show("请选择分配单位!");
                            return;
                        }
                        cardData.MateriaName = fpdw.Trim();//写卡到 Scetor2 扇区
                        break;
                    case "计量卡":
                        cardData.CardType = "1";
                        break;
                    case "临时卡":
                        cardData.CardType = "2";
                        break;
                    default:
                        MessageBox.Show("请选择车证卡类型!");
                        return;
                }
                bool flag = _icCard.WriteCard(cardData);//执行写卡操作,并返回写卡成功true(失败false)标志
                if (checkBox1.Checked && _icCard.CardThread.ThreadState == System.Threading.ThreadState.Suspended)
                {
                    _icCard.CardThread.Resume();  //继续已挂起的线程
                }
                if (!flag)
                {
                    MessageBox.Show("车证卡号没有成功写入卡内扇区,请确认卡放置正确或者是否同一张卡!");
                    textCZKXLH.Text = "";
                    textCZKH.Text = "";
                    textCZKXLH.Enabled = false;
                    return;
                }
                //String manageinsertsql = "insert into BT_CARDMANAGE t(t.FS_CARDNUMBER,t.FS_SEQUENCENO,t.FS_INITDEPART,t.FS_INITUSER,t.FD_INITTIME,t.FS_USEPURPOSE,t.FS_MEMO,t.FS_CARDLEVEL,t.FS_ISVALID) values ('" + czkh + "','" + czkxlh + "','" + departmentcode + "','" + username + "',TO_DATE('" + zzsj + "','YYYY-MM-DD HH24:MI:SS'),'" + yt + "','" + bz + "','" + jb + "','" + sxbz_str + "')";
                String manageinsertsql = @"insert into BT_CARDMANAGE t
                                                            (
                                                                 t.FS_CARDNUMBER,
                                                                 t.FS_SEQUENCENO,
                                                                 t.FS_INITDEPART,
                                                                 t.FS_INITUSER,
                                                                 t.FD_INITTIME,
                                                                 t.FS_USEPURPOSE,
                                                                 t.FS_MEMO,
                                                                 t.FS_CARDLEVEL,
                                                                 t.FS_ISVALID,
                                                                 t.FS_ASSIGNDEPART,
                                                                 t.FS_ASSIGNUSER
                                                            )
                                                        values
                                                            (
                                                                '" + czkh + @"',
                                                                '" + czkxlh + @"',
                                                                '" + departmentcode + @"',
                                                                '" + username + @"',
                                                                TO_DATE('" + zzsj + @"','YYYY-MM-DD HH24:MI:SS'),
                                                                '" + yt + @"',
                                                                '" + bz + @"',
                                                                '" + jb + @"',
                                                                '" + sxbz_str + @"',
                                                                '" + fpdw + @"',
                                                                '" + fpr + @"'
                                                            )";

                CoreClientParam reccp = new CoreClientParam();
                reccp.ServerName = "ygjzjl.carcard.CarCard";
                reccp.MethodName = "insertByClientSql";
                reccp.ServerParams = new object[] { manageinsertsql };
                this.ExecuteNonQuery(reccp, CoreInvokeType.Internal);
                if (reccp.ReturnCode == 0) //插入成功
                {
                    MessageBox.Show("车证卡注册成功!");
                    DataRow newczkrow = this.dataSet1.Tables["车证卡基础表"].NewRow();
                    newczkrow["FS_CARDNUMBER"] = czkh;
                    newczkrow["FS_SEQUENCENO"] = czkxlh;
                    newczkrow["FS_INITDEPART"] = departmentcode;
                    newczkrow["FS_INITUSER"] = username;
                    newczkrow["FD_INITTIME"] = zzsj.ToString();
                    newczkrow["FS_USEPURPOSE"] = yt;
                    newczkrow["FS_MEMO"] = bz;
                    newczkrow["FS_CARDLEVEL"] = jb;
                    newczkrow["FS_CARDLEVELNAME"] = jbname;
                    newczkrow["FS_ISVALID"] = sxbz_str;
                    newczkrow["FS_ISVALIDNAME"] = "注册";

                    //Ksh增加对分配人和分配单位字段的刷新
                    newczkrow["FS_ASSIGNDEPART"] = fpdw;
                    newczkrow["FS_ASSIGNUSER"] = fpr;

                    this.dataSet1.Tables["车证卡基础表"].Rows.Add(newczkrow);
                    dataSet1.AcceptChanges();

                    //以上为注册车证卡确认时更新相关信息代码

                    //车证卡操作表(车证卡操作日志)
                    String operationNO = Guid.NewGuid().ToString();
                    String insertsql = "insert into  DT_CARDOPERATION(FS_OPERATENO,FS_SEQUENCENO,FS_CARDNO,FS_APPLYDEPART,FS_APPLYUSER,FS_OPERATIONTYPE,FS_OPERATEDEPART,FS_OPERATOR,FD_OPERATIONTIME) values ('" + operationNO + "','" + czkxlh + "','" + czkh + "','','','注册','" + departmentcode + "','" + username + "',TO_DATE('" + zzsj + "','YYYY-MM-DD HH24:MI:SS'))";
                    CoreClientParam ccp = new CoreClientParam();
                    ccp.ServerName = "ygjzjl.carcard.CarCard";
                    ccp.MethodName = "insertByClientSql";
                    ccp.ServerParams = new object[] { insertsql };
                    this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
                    //车证卡操作表
                }

                textCZKXLH.Enabled = false;//注册完后,设置为不可编辑
            }
        }