/// <summary>
        /// -补卡的方法
        /// </summary>
        public void Send()
        {
            string strError = "";
            if (txtBEmptyCode.Text.Trim() == "" || txtBCarNo.Text.Trim() == "")
                strError += "请选择车辆登记信息";
            if (IsHaveRemote == "1")
            {
                if (strReadRemoteCode == "")
                    strError += "没有读到电子标签,请刷电子标签!";
                else
                {
                    if (strReadRemoteCode.Split(',').Length > 1)
                    {
                        strError += "读到了多个电子标签,请确认周围是否只有一个电子标签";
                        txtBRemoteCard.Clear();
                    }
                }
            }
            if (strError != "")
            {
                alarmSound.Alarm(strError);
                MessageBox.Show(strError, "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (txtBNavicertCode.Text.Trim() == "")
            {
                alarmSound.Alarm("请刷准运卡");
                MessageBox.Show("请刷准运卡", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string sSQL = "select NavicertCode from TT_Navicert where NavicertCode='" + txtBNavicertCode.Text.Trim() + "'and NavicertState='1'";
            object OResult = DbHelperSQL.GetSingle(sSQL);
            if (OResult != null)
            {
                alarmSound.Alarm("此卡已经和其它车辆绑定请另外刷卡");
                MessageBox.Show("此卡已经和其它车辆绑定请另外刷卡", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            strNavicertCode = txtBNavicertCode.Text.Trim();

            CoalTraffic.BLL.TT_Navicert bll = new CoalTraffic.BLL.TT_Navicert();
            DataSet ds = new DataSet();
            ds = bll.GetList("CarCode='" + this.txtBEmptyCode.Text.Trim() + "'");

            if (ds.Tables[0].Rows.Count > 0)
            {
                //注销准运卡表里该条记录
                SendCard.Public.SWPublic dal = new SendCard.Public.SWPublic();
                CoalTraffic.Model.TT_Navicert model = new CoalTraffic.Model.TT_Navicert();
                model.CarCode = this.txtBEmptyCode.Text;
                model.NavicertState = "3";

                dal.Add(model);//将现有的数据注销

                //增加一条新准运卡记录
                CoalTraffic.Model.TT_Navicert model2 = new CoalTraffic.Model.TT_Navicert();
                CoalTraffic.Model.TT_CarInfo modelCarInfo = new CoalTraffic.BLL.TT_CarInfo().GetModel(txtBEmptyCode.Text.Trim().Replace("'", "''"));
                if (model2 != null)
                {
                    model2.NavicertCode = strNavicertCode;
                    model2.RoomCode = modelCarInfo.RoomCode;
                    model2.CarCode = txtBEmptyCode.Text.Trim();
                    model2.CarNo = modelCarInfo.CarNo;
                    model2.CarType = modelCarInfo.CarType;
                    model2.CarOwnerName = modelCarInfo.CarOwnerName;
                    model2.CarOwnerPhone = modelCarInfo.CarOwnerPhone;
                    model2.CarOwnerIDCard = modelCarInfo.CarOwnerIDCard;
                    model2.MostWeight = modelCarInfo.MostWeight;
                    model2.EmptyWeight = modelCarInfo.EmptyWeight;
                    model2.NavicertState = "1";
                    model2.CardType = "1";
                    model2.StartTime = DateTime.Now;
                    model2.EndTime = DateTime.MaxValue;
                    model2.SendPerson = StaticParameter.UserName;
                    model2.ClaimPersonName = txtBClaimPerson.Text.Trim();
                    model2.IsForbid = "0";
                    model2.Remark = txtBRemark.Text.Trim();
                    model2.NavicertNo = strNavicertCode;

                    #region 判断是否更新电子标签
                    if (IsHaveRemote == "1")
                    {
                        string sql = "select RemoteCardCode FROM [CoalTraffic].[dbo].[TT_CarInfo] where  CarCode='" + txtBEmptyCode.Text.Trim() + "'";
                        string result = (string)DbHelperSQL.GetSingle(sql);
                        if (!string.IsNullOrEmpty(result))
                        {
                            DialogResult refYN = MessageBox.Show("该车辆已有电子标签,是否更换该车辆的电子标签?", "天大天科", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (refYN == DialogResult.Yes)
                            {
                                model2.RemoteCardCode = strReadRemoteCode.TrimEnd(',');
                            }
                            else
                            {
                                model2.RemoteCardCode = "";
                            }
                        }
                    }
                    #endregion

                }

                string strSuccess = "";
                strSuccess = dal.AddNewNcard(model2);//更新后的方法,此方法避免了将原有的电子标签更改为空
                //strSuccess = bll.Add(model2);

                if (strSuccess != "")
                {
                    //发送消息到磅房
                    //发送修改信息到队列和增加的队列。
                    StringBuilder sbInsert = new StringBuilder();
                    sbInsert.Append("insert into TT_Navicert(NavicertCode,RoomCode,CarCode,CarNo,CarType,CarOwnerName,NavicertState,");
                    sbInsert.Append("CardType,StartTime,EndTime,SendPerson,ClaimPersonName,CarOwnerPhone,CarOwnerIDCard,MostWeight,");
                    sbInsert.Append("EmptyWeight,IsForbid,Remark) values ('" + model2.NavicertCode + "','" + model2.RoomCode + "',");
                    sbInsert.Append("'" + model2.CarCode + "','" + model2.CarNo + "','" + model2.CarType + "','" + model2.CarOwnerName + "',");
                    sbInsert.Append("'" + model2.NavicertState + "','" + model2.CardType + "','" + model2.StartTime + "','" + model2.EndTime + "',");
                    sbInsert.Append("'" + model2.SendPerson + "','" + model2.ClaimPersonName + "','" + model2.CarOwnerPhone + "',");
                    sbInsert.Append("'" + model2.CarOwnerIDCard + "','" + model2.MostWeight + "','" + model2.EmptyWeight + "',");
                    sbInsert.Append("'" + model2.IsForbid + "','" + model2.Remark + "');");
                    sbInsert.Append("update TT_Navicert set NavicertState='3'");
                    sbInsert.Append("where CarCode='" + this.txtBEmptyCode.Text.Trim() + "'and NavicertState='1'");

                    #region 插入sql语句到同步表中
                   string sqlInsert = "insert [NetWorkDisconnectionLog] (ID, SQLcontext, datetime, IP) values (@ID,@SQLcontext,@datetime,@IP)";
                    SqlParameter[] sqlpars = new SqlParameter[]
                        {
                            new SqlParameter("@ID",DateTime.Now.ToString()),
                            new SqlParameter("@SQLcontext",sbInsert.ToString()),
                            new SqlParameter("@datetime",DateTime.Now.ToString()),
                            new SqlParameter("@IP","172.10.14.1")
                        };
                    DbHelperSQL.ExecuteSql(sqlInsert);
                    #endregion

                    alarmSound.Alarm("准运卡办理成功,即将打印办理凭证");
                    new report.NavicertCardPrint(strSuccess, true).ShowDialog();
                    ClearAllText();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 补卡的方法
        /// </summary>
        public void Send()
        {
            if (txtBNavicertCode.Text.Trim() == "")
            {
                alarmSound.Alarm("请刷准运卡");
                return;
            }

            string sSQL = "select NavicertCode from TT_Navicert where NavicertCode='" + txtBNavicertCode.Text.Trim() + "'and NavicertState='1'";
            object OResult = DbHelperSQL.GetSingle(sSQL);
            if (OResult != null)
            {
                alarmSound.Alarm("此卡已经和其它车辆绑定请另外刷卡");
                return;
            }

            strNavicertCode = txtBNavicertCode.Text.Trim();

            CoalTraffic.BLL.TT_Navicert bll = new CoalTraffic.BLL.TT_Navicert();
            DataSet ds = new DataSet();
            ds = bll.GetList("CarCode='" + this.txtBEmptyCode.Text.Trim() + "'");

            if (ds.Tables[0].Rows.Count > 0)
            {
                //注销准运卡表里该条记录
                SendCard.Public.SWPublic dal = new SendCard.Public.SWPublic();
                CoalTraffic.Model.TT_Navicert model = new CoalTraffic.Model.TT_Navicert();
                model.CarCode = this.txtBEmptyCode.Text;
                model.NavicertState = "3";

                dal.Add(model);

                //增加一条新准运卡记录
                CoalTraffic.Model.TT_Navicert model2 = new CoalTraffic.Model.TT_Navicert();
                CoalTraffic.Model.TT_CarInfo modelCarInfo = new CoalTraffic.BLL.TT_CarInfo().GetModel(txtBEmptyCode.Text.Trim().Replace("'", "''"));
                if (model2 != null)
                {
                    model2.NavicertCode = strNavicertCode;
                    model2.RoomCode = modelCarInfo.RoomCode;
                    model2.CarCode = txtBEmptyCode.Text.Trim();
                    model2.CarNo = modelCarInfo.CarNo;
                    model2.CarType = modelCarInfo.CarType;
                    model2.CarOwnerName = modelCarInfo.CarOwnerName;
                    model2.CarOwnerPhone = modelCarInfo.CarOwnerPhone;
                    model2.CarOwnerIDCard = modelCarInfo.CarOwnerIDCard;
                    model2.MostWeight = modelCarInfo.MostWeight;
                    model2.EmptyWeight = modelCarInfo.EmptyWeight;
                    model2.NavicertState = "1";
                    model2.CardType = "1";
                    model2.StartTime = DateTime.Now;
                    model2.EndTime = DateTime.MaxValue;
                    model2.SendPerson = StaticParameter.UserName;
                    model2.ClaimPersonName = txtBClaimPerson.Text.Trim();
                    model2.IsForbid = "0";
                    model2.Remark = txtBRemark.Text.Trim();
                    model2.NavicertNo = strNavicertCode;
                }

                string strSuccess = "";
                strSuccess = bll.Add(model2);
                if (strSuccess != "")
                {
                    //发送消息到磅房
                    //发送修改信息到队列和增加的队列。
                    StringBuilder sbInsert = new StringBuilder();
                    sbInsert.Append("insert into TT_Navicert(NavicertCode,RoomCode,CarCode,CarNo,CarType,CarOwnerName,NavicertState,");
                    sbInsert.Append("CardType,StartTime,EndTime,SendPerson,ClaimPersonName,CarOwnerPhone,CarOwnerIDCard,MostWeight,");
                    sbInsert.Append("EmptyWeight,IsForbid,Remark) values ('" + model2.NavicertCode + "','" + model2.RoomCode + "',");
                    sbInsert.Append("'" + model2.CarCode + "','" + model2.CarNo + "','" + model2.CarType + "','" + model2.CarOwnerName + "',");
                    sbInsert.Append("'" + model2.NavicertState + "','" + model2.CardType + "','" + model2.StartTime + "','" + model2.EndTime + "',");
                    sbInsert.Append("'" + model2.SendPerson + "','" + model2.ClaimPersonName + "','" + model2.CarOwnerPhone + "',");
                    sbInsert.Append("'" + model2.CarOwnerIDCard + "','" + model2.MostWeight + "','" + model2.EmptyWeight + "',");
                    sbInsert.Append("'" + model2.IsForbid + "','" + model2.Remark + "');");
                    sbInsert.Append("update TT_Navicert set NavicertState='3'");
                    sbInsert.Append("where CarCode='" + this.txtBEmptyCode.Text.Trim() + "'and NavicertState='1'");
                    MsmqManage mq = new MsmqManage();
                    string strMq = mq.AllStation + mq.Prefix + "TT_Navicert" + mq.Prefix + mq.AddFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + mq.Prefix + sbInsert.ToString();
                    mq.AddMsmq(strMq.ToString());
                    alarmSound.Alarm("准运卡办理成功,即将打印办理凭证");
                    new report.NavicertCardPrint(strSuccess, true).ShowDialog();
                }
            }
        }