private void btnOK_Click(object sender, EventArgs e)
        {
            Model.TT_LoadWeight MLW = new TT_LoadWeight();
            BLL.TT_LoadWeight BLW = new CoalTraffic.BLL.TT_LoadWeight();

            if (strCurrentMenu != "Person")
            {
                MLW.LoadWeight = decimal.Parse(lblDigital.Text.Trim());
                MLW.NetWeight = MLW.LoadWeight - Convert.ToDecimal(txtEmptyWeight.Text.Trim());
            }
            else
            {
                #region 验证数据的正确性
                if (txtHandDigital.Text.Trim() != "" && CommonMethod.IsDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())))
                {
                    if (Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) < Convert.ToDecimal(lblDigital.Text.Trim()))
                    {
                        alSound.Alarm("你输入的重车重量不能小于磅秤重量");
                        txtHandDigital.Text = "";
                        return;
                    }
                    else
                    {
                        MLW.LoadWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim()));
                        MLW.NetWeight = MLW.LoadWeight - Convert.ToDecimal(txtEmptyWeight.Text.Trim());
                    }
                }
                else
                {
                    alSound.Alarm("你输入的重车重量格式不对");
                    txtHandDigital.Text = "";
                    return;
                }
                #endregion
            }

            if (MLW.NetWeight > 0.00m)
            {
                #region 读取与煤矿相关的信息
                SqlParameter[] parameter =
                {
                    new SqlParameter("@CollCode", SqlDbType.VarChar,10),
                    new SqlParameter("@CoalKindCode", SqlDbType.VarChar,4)
                };

                parameter[0].Value = strCollCode;
                parameter[1].Value = strCoalKindCode;
                DataSet dstColieryAccount = DbHelperSQL.RunProcedure("PT_ColieryAccountJudge", parameter, "ColieryAccount");
                #endregion

                string strLeastValue = dstColieryAccount.Tables["ColieryAccount"].Rows[0]["ReturnValue"].ToString();
                string isConnection = ini.IniReadValue("Connection", "isConnection");
                if (strLeastValue == "0") //0:正常,可过磅
                {

                    #region 视频抓图
                    if (StaticParameter.IsVideo == "1")
                    {
                        if (byteFrontImage == null && byteBackImage == null && byteUpImage == null && byteRoomImage == null)
                        {
                            strFrontImage = Guid.NewGuid().ToString().Replace("-", "");
                            strBackImage = Guid.NewGuid().ToString().Replace("-", "");
                            strUpImage = Guid.NewGuid().ToString().Replace("-", "");
                            strRoomImage = Guid.NewGuid().ToString().Replace("-", "");

                            byteFrontImage = this.videoFrontImage.CapturePic();
                            byteBackImage = this.videoBackImage.CapturePic();
                            byteUpImage = this.videoUpImage.CapturePic();
                            byteRoomImage = this.videoRoomImage.CapturePic();
                        }

                    }
                    #endregion

                    #region 实例化重车过磅
                    string strWeightCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss");
                    MLW.WeightCode = strWeightCode;
                    MLW.TrafficCode = strWeightCode;
                    MLW.NavicertCode = "";
                    MLW.MarkedCardCode = strMarkedCardCode;
                    MLW.RemoteCardCode = "";

                    MLW.CollCode = strCollCode;
                    MLW.CollName = strCollName;
                    MLW.CoalKindCode = strCoalKindCode;
                    MLW.CoalKindName = strCoalKindName;
                    MLW.CarOwnerName = txtCarOwnerName.Text.Trim();

                    MLW.CarNo = txtCarNo.Text.Trim();
                    MLW.CarType = "";
                    MLW.EmptyWeight = decimal.Parse(txtEmptyWeight.Text.Trim());
                    MLW.OverWeight = 0.0m;
                    MLW.RoomCode = strRoomCode;
                    MLW.RoomName = strRoomName;
                    MLW.BangType = "散煤" + strBangType + "过磅";
                    MLW.Operator = StaticParameter.UserName;

                    MLW.WeightTime = DateTime.Now;
                    MLW.RandomCode = CommonMethod.getRandom(4);
                    MLW.CustomerName = "运煤去向";
                    MLW.TaxType = "正常扣税";
                    MLW.IsFirstSite = "1";

                    MLW.FrontImage = strFrontImage;
                    MLW.BackImage = strBackImage;
                    MLW.UpImage = strUpImage;
                    MLW.RoomImage = strRoomImage;
                    MLW.FrontImageContent = byteFrontImage;

                    MLW.BackImageContent = byteBackImage;
                    MLW.UpImageContent = byteUpImage;
                    MLW.RoomImageContent = byteRoomImage;
                    MLW.TaxObject = ConfigurationManager.AppSettings["TaxObject"].ToString();
                    MLW.EmptyCode = strEmptyCode;
                    #endregion

                    if (BLW.Add(MLW) != "")
                    {
                        if (BLW.Add(MLW) != "-1")
                        {
                            #region 当联网的时:插入同步sql语句到服务器,sql语句本地执行
                            if (isConnection == "0")
                            {
                                string strSqlLocal = "PT_LoadWeight '" + MLW.WeightCode + "','" + MLW.TrafficCode + "','" +
                                           MLW.NavicertCode + "','" + MLW.MarkedCardCode + "','" + MLW.RemoteCardCode +
                                           "',"
                                           + "'" + MLW.CollCode + "','" + MLW.CollName + "','" + MLW.CoalKindCode +
                                           "','" + MLW.CoalKindName + "','" + MLW.CarOwnerName + "',"
                                           + "'" + MLW.CarNo + "','" + MLW.CarType + "','" + MLW.LoadWeight + "','" +
                                           MLW.EmptyWeight + "','" + MLW.NetWeight + "',"
                                           + "'" + MLW.OverWeight + "','" + MLW.RoomCode + "','" + MLW.RoomName + "','" +
                                           MLW.BangType + "','" + MLW.Operator + "',"
                                           + "'" + MLW.WeightTime + "','" + MLW.RandomCode + "','" + MLW.CustomerName +
                                           "','" + MLW.TaxType + "','" + MLW.TaxObject + "',"
                                           + "'" + MLW.IsFirstSite + "','" + MLW.FrontImage + "','" + MLW.BackImage +
                                           "','" + MLW.UpImage + "','" + MLW.RoomImage + "',"
                                           + "null,null,null,null,'" + MLW.EmptyCode + "'";

                                string sqlInsert = "insert [NetWorkDisconnectionLog] (ID, SQLcontext, datetime, IP) values (@ID,@SQLcontext,@datetime,@IP)";
                                SqlParameter[] sqlpars = new SqlParameter[]
                        {
                            new SqlParameter("@ID",DateTime.Now.ToString("yyyyMMddHHmmss")),
                            new SqlParameter("@SQLcontext",strSqlLocal.ToString()),
                            new SqlParameter("@datetime",DateTime.Now.ToString()),
                            new SqlParameter("@IP",ini.IniReadValue("Connection","LServer"))
                        };
                                DbHelperSQL.ExecuteSql(sqlInsert, sqlpars); //插入同步sql语句
                                DbHelperSQL.ExecuteSql2(strSqlLocal.ToString(), "1");//sql语句本地执行

                            }
                            #endregion

                            #region 当断网时,添加重车过磅sql语句

                            string strSql = "PT_LoadWeight '" + MLW.WeightCode + "','" + MLW.TrafficCode + "','" +
                                            MLW.NavicertCode + "','" + MLW.MarkedCardCode + "','" + MLW.RemoteCardCode +
                                            "',"
                                            + "'" + MLW.CollCode + "','" + MLW.CollName + "','" + MLW.CoalKindCode +
                                            "','" + MLW.CoalKindName + "','" + MLW.CarOwnerName + "',"
                                            + "'" + MLW.CarNo + "','" + MLW.CarType + "','" + MLW.LoadWeight + "','" +
                                            MLW.EmptyWeight + "','" + MLW.NetWeight + "',"
                                            + "'" + MLW.OverWeight + "','" + MLW.RoomCode + "','" + MLW.RoomName + "','" +
                                            MLW.BangType + "','" + MLW.Operator + "',"
                                            + "'" + MLW.WeightTime + "','" + MLW.RandomCode + "','" + MLW.CustomerName +
                                            "','" + MLW.TaxType + "','" + MLW.TaxObject + "',"
                                            + "'" + MLW.IsFirstSite + "','" + MLW.FrontImage + "','" + MLW.BackImage +
                                            "','" + MLW.UpImage + "','" + MLW.RoomImage + "',"
                                            + "null,null,null,null,'" + MLW.EmptyCode + "'";
                            if (isConnection == "1")
                            {
                                string id = DateTime.Now.ToString("yyyyMMddHHmmss");
                                StringBuilder sbsqlcontext = new StringBuilder();
                                sbsqlcontext.Append(
                                    "insert into NetWorkDisconnection (ID, SQLcontext, DateTime) values(@id,@sqlcontext,@datetime)");
                                SqlParameter[] parameters = new SqlParameter[]
                                                                {
                                                                    new SqlParameter("@id", id),
                                                                    new SqlParameter("@sqlcontext",
                                                                                     strSql.ToString()),
                                                                    new SqlParameter("@datetime", DateTime.Now)
                                                                };
                                DbHelperSQL.ExecuteSql(sbsqlcontext.ToString(), parameters);
                            }

                            #endregion

                            string strErro = "";
                            if (StaticParameter.IsHaveMarkedCard == "1")
                            {
                                strErro = "并回收标识卡";
                            }

                            alSound.Alarm("散煤过磅成功,点击确定打印散煤过磅单" + strErro + "");
                            CommonMethod.MessageBox("散煤过磅成功,点击确定打印散煤过磅单" + strErro + "!", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Asterisk);

                            #region 打印相关

                            Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                            string strFileName = "";
                            if (StaticParameter.ReportFile == "FuYuan.")
                            {
                                strFileName = "ZiChang.";
                            }
                            else
                            {
                                strFileName = StaticParameter.ReportFile;
                            }

                            Type type = assembly.GetType("CoalTraffic.Report." + strFileName + "SpreadWeightPrint");
                            object obj = Activator.CreateInstance(type, MLW.WeightCode, true);
                            Form formToShow = (Form)obj;
                            formToShow.ShowDialog();

                            #endregion
                        }
                        else
                        {
                            alSound.Alarm("账户余额已不足本车的扣款,请通知" + txtCollName.Text.Trim() + "速来交费");
                            MessageBox.Show("账户余额已不足本车的扣款,请通知" + txtCollName.Text.Trim() + "速来交费!", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                    else
                    {
                        if (isConnection == "0")
                        {
                            ini.IniWriteValue("Connection", "isConnection", CommonMethod.ToDBC("1"));
                            MessageBox.Show("系统与服务器断开连接,请联系中心机房!", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            Application.ExitThread();
                            Application.Exit();
                        }
                        else
                        {
                            alSound.Alarm("数据连接字符串库异常");
                            MessageBox.Show("数据连接字符串库异常", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            InsertState = 0;
                            InsertBadReCordInfo("异常", strRoomName + "的数据库异常");
                        }
                    }
                }
                else if (strLeastValue == "1")
                {
                    alSound.Alarm("煤矿余额低于下限,不能继续过磅");
                    MessageBox.Show("煤矿余额低于下限,不能继续过磅", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else if (strLeastValue == "2")
                {
                    alSound.Alarm("该煤矿不生产该煤种,不能继续过磅");
                    MessageBox.Show("该煤矿不生产该煤种,不能继续过磅", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    InsertState = 0;
                    InsertBadReCordInfo("异常", strCollName + "不生产" + strCoalKindName);
                }
                else if (strLeastValue == "-1")
                {
                    alSound.Alarm("该煤矿不存在,不能继续过磅");
                    MessageBox.Show("数据连接字符串库异常", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    InsertState = 0;
                    InsertBadReCordInfo("异常", "编号为:" + strCollCode + "的煤矿不存在");
                }
                this.ClearAllControl();
                ClearUserControl();
            }
            else
            {
                alSound.Alarm("煤炭净重异常");
                MessageBox.Show("煤炭净重异常", "天大天科", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                InsertState = 0;
                InsertBadReCordInfo("异常", "车牌号为:" + txtCarNo.Text.Trim() + "车辆的煤炭净重异常");
            }
        }
예제 #2
0
        /// <summary>
        /// 验证码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        #region 验证码
        private void btnOK_Click(object sender, EventArgs e)
        {
            Model.TT_BadRecord MBR = new CoalTraffic.Model.TT_BadRecord();
            BLL.TT_BadRecord BBR = new CoalTraffic.BLL.TT_BadRecord();
            Model.TT_LoadWeight MLW = new CoalTraffic.Model.TT_LoadWeight();
            BLL.TT_LoadWeight BLW = new CoalTraffic.BLL.TT_LoadWeight();

            decimal DNetWeight = 0.00m;

            #region 计算水泥净重
            if (strCurrentMenu != "Person")
            {
                decimal dDigital, dEmptyWeight;
                if (decimal.TryParse(lblDigital.Text.Trim(), out dDigital) && decimal.TryParse(strEmptyWeight, out dEmptyWeight))
                {
                    DNetWeight = Convert.ToDecimal(dDigital - dEmptyWeight);
                }
                else
                {
                    aSound.Alarm("重量数据格式不正确");
                    return;

                }
            }
            else
            {
                #region 验证数据的正确性
                if (txtHandDigital.Text.Trim() != "" && CommonMethod.IsDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())))
                {

                    if (Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) < Convert.ToDecimal(lblDigital.Text.Trim()))
                    {
                        aSound.Alarm("你输入的重车重量不能小于磅秤重量");
                        txtHandDigital.Text = "";
                        return;
                    }
                    else
                    {
                        DNetWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) - Convert.ToDecimal(strEmptyWeight);
                    }
                }
                else
                {
                    aSound.Alarm("你输入的重车重量格式不对");
                    txtHandDigital.Text = "";
                    return;
                }
                #endregion
            }
            #endregion

            if (DNetWeight > 0.00m)
            {
                #region 视频抓图

                if (StaticParameter.IsVideo == "1")
                {
                    if (byteFrontImage == null && byteBackImage == null && byteUpImage == null && byteRoomImage == null)
                    {
                        strFrontImage = Guid.NewGuid().ToString().Replace("-", "");
                        strBackImage = Guid.NewGuid().ToString().Replace("-", "");
                        strUpImage = Guid.NewGuid().ToString().Replace("-", "");
                        strRoomImage = Guid.NewGuid().ToString().Replace("-", "");

                        byteFrontImage = this.videoFrontImage.CapturePic();
                        byteBackImage = this.videoBackImage.CapturePic();
                        byteUpImage = this.videoUpImage.CapturePic();
                        byteRoomImage = this.videoRoomImage.CapturePic();
                    }
                }
                #endregion


                #region 重车验票
                CoalTraffic.BLL.TT_CheckBang bllCheckBang = new CoalTraffic.BLL.TT_CheckBang();
                CoalTraffic.Model.TT_CheckBang modelCheckBang = new CoalTraffic.Model.TT_CheckBang();

                modelCheckBang.RoomCode = strRoomCode;
                modelCheckBang.NetWeight = DNetWeight;

                #region 监察该重车是否已经验票
                bool bolChecked = bllCheckBang.IsChecked(strTrafficCode, modelCheckBang.RoomCode);
                #endregion

                decimal dOverWeight = 0.0m;
                decimal DLimitWeight = 0.0m;

                if (bolChecked)
                {
                    modelCheckBang.CheckResult = "重车验票不通过,该过磅单在本磅房中已检验过";
                    modelCheckBang.IsPassed = "0";
                }
                else
                {
                    #region 验证验证码是否正确
                    if (CommonMethod.ToDBC(this.txtRandCode.Text.Trim()) != strRandomCode && iCount < iTryAgainTime)
                    {
                        CommonMethod.MessageBox("您输入的验证码不正确,请重新输入,您还有" + (iTryAgainTime - iCount) + "次输入机会", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //aSound.Alarm("您输入的验证码不正确,请重新输入,您还有" + (iTryAgainTime - iCount) + "次输入机会");
                        txtRandCode.Text = "";
                        btnOK.Enabled = false;
                        iCount++;
                        return;
                    }
                    else if (CommonMethod.ToDBC(this.txtRandCode.Text.Trim()) != strRandomCode && iCount == iTryAgainTime)
                    {
                        modelCheckBang.CheckResult = "重车验票不通过,验票单可能造假"; //验票结果:通过 or 不通过
                        modelCheckBang.IsPassed = "0";
                    }
                    else if (CommonMethod.ToDBC(this.txtRandCode.Text.Trim()) == strRandomCode)
                    {
                        modelCheckBang.CheckResult = "重车验票通过";
                        modelCheckBang.IsPassed = "1";
                    }
                    #endregion
                }

                #region 实例化检票
                modelCheckBang.CheckCode = Guid.NewGuid().ToString().Replace("-", "");
                modelCheckBang.CheckTime = DateTime.Now;
                modelCheckBang.Operator = StaticParameter.UserName;
                modelCheckBang.MarkedCardCode = strMardedCardCode;
                modelCheckBang.NavicertCode = strNavicertCode;
                modelCheckBang.WeightCode = this.strTrafficCode;

                modelCheckBang.FrontImage = strFrontImage;
                modelCheckBang.BackImage = strBackImage;
                modelCheckBang.UpImage = strUpImage;
                modelCheckBang.RoomImage = strRoomImage;

                modelCheckBang.FrontImageContent = byteFrontImage;
                modelCheckBang.BackImageContent = byteBackImage;
                modelCheckBang.UpImageContent = byteUpImage;
                modelCheckBang.RoomImageContent = byteRoomImage;

                #endregion

                if (modelCheckBang.IsPassed == "0")
                {
                    InsertState = 0;
                    InsertBadReCordInfo("不通过", modelCheckBang.CheckResult);
                }
                else
                {
                    #region 获取最大重车重量
                    string strsql = "select max(LoadWeight) from TT_LoadWeight where TrafficCode ='" + strTrafficCode + "'";

                    object OMLoadWeight = DbHelperSQL.GetSingle(strsql);

                    if (strCurrentMenu != "Person")
                    {
                        dOverWeight = decimal.Parse(lblDigital.Text.Trim()) - decimal.Parse(OMLoadWeight.ToString());
                    }
                    else
                    {
                        dOverWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) - Convert.ToDecimal(OMLoadWeight.ToString());
                    }

                    DLimitWeight = StaticParameter.WeightThreshold;
                    #endregion

                    if (dOverWeight >= DLimitWeight)
                    {
                        #region 实例化重车过磅
                        string strWeightCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss");
                        MLW.WeightCode = strWeightCode;
                        MLW.TrafficCode = strTrafficCode;
                        MLW.NavicertCode = strNavicertCode;
                        MLW.MarkedCardCode = strMardedCardCode;
                        MLW.RemoteCardCode = strRemoteCode;

                        MLW.CollCode = strCollCode;
                        //冯磊 2010-05-19 选择产品改成下拉框
                        //MLW.CollName = strCollName;
                        //MLW.CoalKindCode = strCoalKindCode;
                        //MLW.CoalKindName = strCoalKindName;
                        MLW.CollName = this.txtCompany.Text.Trim();
                        MLW.CoalKindCode = strCoalKindCode;
                        MLW.CoalKindName = this.txtProduce.Text.Trim();

                        MLW.CarOwnerName = txtCarOwner.Text.Trim();
                        MLW.CarNo = txtCarNo.Text.Trim();
                        MLW.CarType = txtCarType.Text.Trim();
                        if (strCurrentMenu != "Person")
                        {
                            MLW.LoadWeight = decimal.Parse(lblDigital.Text.Trim());
                        }
                        else
                        {
                            MLW.LoadWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim()));
                        }
                        //MLW.EmptyWeight = decimal.Parse(lblEmptyWeight.Text.Trim());
                        MLW.EmptyWeight = decimal.Parse(txtEmptyWeight.Text.Replace("吨", "").Trim());
                        MLW.NetWeight = 0.0m;

                        MLW.OverWeight = decimal.Parse(dOverWeight.ToString());
                        MLW.RoomCode = strRoomCode;
                        MLW.RoomName = strRoomName;
                        MLW.BangType = "重车" + strBangType + "验票";
                        MLW.Operator = StaticParameter.UserName;

                        MLW.WeightTime = DateTime.Now;
                        MLW.RandomCode = CommonMethod.getRandom(4);
                        MLW.CustomerName = "水泥去向";
                        MLW.TaxType = "重车补扣税费";
                        MLW.IsFirstSite = "0";

                        MLW.FrontImage = Guid.NewGuid().ToString().Replace("-", "");
                        MLW.BackImage = Guid.NewGuid().ToString().Replace("-", "");
                        MLW.UpImage = Guid.NewGuid().ToString().Replace("-", "");
                        MLW.RoomImage = Guid.NewGuid().ToString().Replace("-", "");
                        MLW.FrontImageContent = byteFrontImage;

                        MLW.BackImageContent = byteBackImage;
                        MLW.UpImageContent = byteUpImage;
                        MLW.RoomImageContent = byteRoomImage;
                        MLW.TaxObject = ConfigurationManager.AppSettings["TaxObject"].ToString();
                        MLW.EmptyCode = strEmptyCode;
                        #endregion
                    }
                }

                bool ISSound = false;
                bool IsLoadWeight = true;


                if ((dOverWeight >= DLimitWeight) && (dOverWeight != 0.0m))
                {
                    #region 添加重车过磅记录
                    if (BLW.Add(MLW) != "")
                    {
                        ISSound = true;

                        if (BLW.Add(MLW) != "-1")
                        {
                            #region 数据上传

                            string strSql = "PT_LoadWeight '" + MLW.WeightCode + "','" + MLW.TrafficCode + "','" + MLW.NavicertCode + "','" + MLW.MarkedCardCode + "','" + MLW.RemoteCardCode + "',"
                          + "'" + MLW.CollCode + "','" + MLW.CollName + "','" + MLW.CoalKindCode + "','" + MLW.CoalKindName + "','" + MLW.CarOwnerName + "',"
                          + "'" + MLW.CarNo + "','" + MLW.CarType + "','" + MLW.LoadWeight + "','" + MLW.EmptyWeight + "','" + MLW.NetWeight + "',"
                          + "'" + MLW.OverWeight + "','" + MLW.RoomCode + "','" + MLW.RoomName + "','" + MLW.BangType + "','" + MLW.Operator + "',"
                          + "'" + MLW.WeightTime + "','" + MLW.RandomCode + "','" + MLW.CustomerName + "','" + MLW.TaxType + "','" + MLW.TaxObject + "',"
                          + "'" + MLW.IsFirstSite + "','" + MLW.FrontImage + "','" + MLW.BackImage + "','" + MLW.UpImage + "','" + MLW.RoomImage + "',null,null,null,null,'" + MLW.EmptyCode + "'";
                            MC.AddNewSqlText(MC.CheckStation + MC.Prefix + "TT_LoadWeight" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + strSql);

                            //发送图片
                            string strIsSendPicToRoom = StaticParameter.IsSendPicToRoom;
                            int iSend = MC.ServerStation;
                            //是否发送磅房
                            if (strIsSendPicToRoom == "1")
                                iSend = MC.CheckStation;
                            string strPic = "";
                            if (MLW.FrontImageContent != null)
                            {
                                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                    + MLW.FrontImage + ",jpg," + Convert.ToBase64String(MLW.FrontImageContent, 0, MLW.FrontImageContent.Length);
                                MC.AddNewSqlText(strPic);
                            }
                            if (MLW.BackImageContent != null)
                            {
                                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                    + MLW.BackImage + ",jpg," + Convert.ToBase64String(MLW.BackImageContent, 0, MLW.BackImageContent.Length);
                                MC.AddNewSqlText(strPic);
                            }
                            if (MLW.UpImageContent != null)
                            {
                                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                    + MLW.UpImage + ",jpg," + Convert.ToBase64String(MLW.UpImageContent, 0, MLW.UpImageContent.Length);
                                MC.AddNewSqlText(strPic);
                            }
                            if (MLW.RoomImageContent != null)
                            {
                                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                    + MLW.RoomImage + ",jpg," + Convert.ToBase64String(MLW.RoomImageContent, 0, MLW.RoomImageContent.Length);
                                MC.AddNewSqlText(strPic);
                            }
                            /********************************************************/
                            //Add By 鲍永迎 向BS实时监控服务器消息队列发送重车过磅消息
                            /********************************************************/
                            //string loadMessage = MLW.RoomName + "," + MLW.LoadWeight + "," + MLW.CoalKindName + "," + MLW.NavicertCode + "," + MLW.NetWeight.ToString() + "," + MLW.WeightTime.ToString();//定义消息格式:磅房名称,车主姓名,煤种名称,准运卡号,煤炭净重,过磅时间
                            //RealTimeMonitor monitor = new RealTimeMonitor();//发送消息
                            //monitor.SendLoadWeightMessage(loadMessage);

                            //冯磊 2010-05-18 修改向BS实时监控服务器消息队列发送重车过磅消息
                            string loadMessage = MLW.EmptyWeight.ToString() + "," + MLW.LoadWeight.ToString() + "," + MLW.NetWeight.ToString() + "," + MLW.OverWeight.ToString() + "," + MLW.TaxAmount.ToString() + "," + MLW.FundAmount.ToString() + "," + MLW.Operator.ToString() + "," + MLW.WeightTime.ToString()
                                + "," + MLW.CarNo.ToString() + "," + MLW.CarOwnerName.ToString() + "," + MLW.RoomName.ToString() + "," + MLW.CollName.ToString() + "," + MLW.CoalKindName.ToString() + "," +
                                MLW.NavicertCode.ToString() + "," + MLW.MarkedCardCode.ToString() + "," + MLW.RemoteCardCode.ToString() + "," + MLW.WeightCode.ToString();//定义消息格式:空车重量,重车重量,净重,超重,税费,基金,操作人,过磅时间,车牌号,车主姓名,磅房名称,煤矿名称,煤种名称,准运卡号,标识卡号,远程卡号,过磅单号
                            RealTimeMonitor monitor = new RealTimeMonitor();//发送消息
                            monitor.SendLoadWeightMessage(loadMessage);
                            /********************************************************/
                            #endregion

                            aSound.Alarm("重车验票过磅通过,点击确定打印重车验票过磅单");
                            CommonMethod.MessageBox("重车过磅验票通过,点击确定打印重车验票过磅单!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            //设置扣税标志位
                            this.isks = true;
                            Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                            string strFileName = "";
                            if (StaticParameter.ReportFile == "FuYuan.")
                            {
                                strFileName = "ZiChang.";
                            }
                            else
                            {
                                strFileName = StaticParameter.ReportFile;
                            }
                            Type type = assembly.GetType("CoalTraffic.Report." + strFileName + "CheckLoadWeightPrint");
                            object obj = Activator.CreateInstance(type, MLW.WeightCode, true); Form formToShow = (Form)obj; formToShow.ShowDialog();
                        }
                        else
                        {
                            aSound.Alarm("账户余额已不足本车的扣款,请通知" + this.txtCompany.Text.Trim() + "速来交费");
                            IsLoadWeight = false;
                        }
                    }
                    else
                    {
                        this.aSound.Alarm("该站的数据库异常");
                        InsertState = 0;
                        InsertBadReCordInfo("异常", strRoomName + "的数据库异常");
                    }
                    #endregion
                }

                #region 添加验票信息
                if (IsLoadWeight)
                {
                    if (bllCheckBang.Add(modelCheckBang) != "")
                    {
                        #region 数据上传
                        try
                        {
                            StringBuilder sbInsertCheckBang = new StringBuilder();
                            sbInsertCheckBang.Append("PT_CheckBang '" + modelCheckBang.CheckCode + "','" + modelCheckBang.WeightCode + "','" + modelCheckBang.NavicertCode + "',");
                            sbInsertCheckBang.Append("'" + modelCheckBang.MarkedCardCode + "','" + modelCheckBang.NetWeight + "','" + modelCheckBang.RoomCode + "',");
                            sbInsertCheckBang.Append("'" + modelCheckBang.IsPassed + "','" + modelCheckBang.CheckResult + "','" + modelCheckBang.CheckTime + "',");
                            sbInsertCheckBang.Append("'" + modelCheckBang.Operator + "','" + modelCheckBang.FrontImage + "',null,");
                            sbInsertCheckBang.Append("'" + modelCheckBang.BackImage + "',null,'" + modelCheckBang.UpImage + "',");
                            sbInsertCheckBang.Append("null,'" + modelCheckBang.RoomImage + "',null");

                            MC.AddNewSqlText(MC.CheckStation + MC.Prefix + "TT_CheckBang" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + sbInsertCheckBang.ToString());
                            //发送图片
                            string strIsSendPicToRoom = StaticParameter.IsSendPicToRoom;
                            int iSend = MC.ServerStation;
                            //是否发送磅房
                            if (strIsSendPicToRoom == "1")
                                iSend = MC.CheckStation;
                            string strPic = "";
                            if (modelCheckBang.FrontImageContent != null)
                            {
                                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                    + modelCheckBang.FrontImage + ",jpg," + Convert.ToBase64String(modelCheckBang.FrontImageContent, 0, modelCheckBang.FrontImageContent.Length);
                                MC.AddNewSqlText(strPic);
                            }
                            if (modelCheckBang.BackImageContent != null)
                            {
                                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                    + modelCheckBang.BackImage + ",jpg," + Convert.ToBase64String(modelCheckBang.BackImageContent, 0, modelCheckBang.BackImageContent.Length);
                                MC.AddNewSqlText(strPic);
                            }
                            if (modelCheckBang.UpImageContent != null)
                            {
                                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                    + modelCheckBang.UpImage + ",jpg," + Convert.ToBase64String(modelCheckBang.UpImageContent, 0, modelCheckBang.UpImageContent.Length);
                                MC.AddNewSqlText(strPic);
                            }
                            if (modelCheckBang.RoomImageContent != null)
                            {
                                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                    + modelCheckBang.RoomImage + ",jpg," + Convert.ToBase64String(modelCheckBang.RoomImageContent, 0, modelCheckBang.RoomImageContent.Length);
                                MC.AddNewSqlText(strPic);
                            }
                        }
                        catch { }
                        #endregion

                        if (!ISSound)
                        {
                            aSound.Alarm(modelCheckBang.CheckResult);
                            CommonMethod.MessageBox(modelCheckBang.CheckResult, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                        }

                        spRemote.CardCode = "";
                    }
                    else
                    {
                        aSound.Alarm("该站的数据库异常");
                        InsertState = 0;
                        InsertBadReCordInfo("异常", strRoomName + "的数据库异常");
                    }
                }
                #endregion

                #endregion

                ClearAllUIControlEmpty();
                this.ClearOwnerValue();
            }
            else
            {
                aSound.Alarm("水泥净重异常");
                InsertState = 0;
                InsertBadReCordInfo("异常", "车牌号为:" + txtCarNo.Text.Trim() + "车辆的水泥净重异常");
            }
            this.lblRemoteCode.Text = "";
        }
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 判断电子标签是否与准运卡一致,可否过磅?
            if (CoalTraffic.DBUtility.StaticParameter.IsRemoteReader == "1")
            {
                if (true)
                {
                    string rfcode = "";
                    if (dgvRemotes.Rows.Count > 0)
                    {
                        rfcode = dgvRemotes.Rows[0].Cells["RemoteCardCode"].Value.ToString();
                    }
                    else
                    {
                        aSound.Alarm("没有读取到该车的电子标签,是否确定过磅");
                        if (MessageBox.Show("没有读取到该车的电子标签,是否确定过磅?", "确定吗?", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            ClearAllUIControlEmpty();
                            return;
                        }
                    }
                    if (!string.IsNullOrEmpty(lblRemoteCode.Text) && !string.IsNullOrEmpty(rfcode))
                    {
                        if (rfcode != lblRemoteCode.Text)
                        {
                            aSound.Alarm("准运卡与电子标签不匹配,是否确定过磅");
                            if (MessageBox.Show("准运卡与电子标签不匹配,是否确定过磅?", "确定吗?", MessageBoxButtons.YesNo) == DialogResult.No)
                            {
                                ClearAllUIControlEmpty();
                                return;
                            }
                        }

                    }
                    #region 将读取到电子标签号写入到空的车辆信息中
                    string isWriteRF = ini.IniReadValue("RF", "writeRF");
                    if (isWriteRF == "1")
                    {
                        if (!string.IsNullOrEmpty(strReadRemoteCardCode) && string.IsNullOrEmpty(lblRemoteCode.Text))
                        {
                            string sqlCarcode = "  select CarCode from [TT_Navicert] where NavicertCode='" + strNavicertCode + "'";
                            string carcode = DbHelperSQL.GetSingle(sqlCarcode).ToString();
                            string sqlInsertRF = "update [TT_CarInfo] set RemoteCardCode='" + strReadRemoteCardCode + "' where CarCode='" + carcode + "'";
                            DbHelperSQL.ExecuteSql(sqlInsertRF);
                            return;
                        }
                    }
                    #endregion

                }
            }
            #endregion

            Model.TT_BadRecord MBR = new CoalTraffic.Model.TT_BadRecord();
            BLL.TT_BadRecord BBR = new CoalTraffic.BLL.TT_BadRecord();
            Model.TT_LoadWeight MLW = new CoalTraffic.Model.TT_LoadWeight();
            BLL.TT_LoadWeight BLW = new CoalTraffic.BLL.TT_LoadWeight();

            decimal DNetWeight = 0.00m;//根据当前磅秤数据和车皮获得到临时净重---变量

            #region 计算煤炭净重
            if (strCurrentMenu != "Person")
            {
                decimal dDigital, dEmptyWeight;
                if (decimal.TryParse(lblDigital.Text.Trim(), out dDigital) && decimal.TryParse(strEmptyWeight, out dEmptyWeight))//将磅秤的数据(字符串)转为decmal,将空车重量(字符串)转为decmal
                {
                    DNetWeight = Convert.ToDecimal(dDigital - dEmptyWeight);//获得到净重
                }
                else
                {
                    aSound.Alarm("重量数据格式不正确");
                    return;

                }
            }
            else//如果是人工错做,则进行数据校验
            {
                #region 验证数据的正确性
                if (txtHandDigital.Text.Trim() != "" && CommonMethod.IsDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())))
                {

                    if (Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) < Convert.ToDecimal(lblDigital.Text.Trim()))
                    {
                        aSound.Alarm("你输入的重重车量不能小于磅秤重量");
                        txtHandDigital.Text = "";
                        return;
                    }
                    else
                    {
                        DNetWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) - Convert.ToDecimal(strEmptyWeight);
                    }
                }
                else
                {
                    aSound.Alarm("你输入的重车重量格式不对");
                    txtHandDigital.Text = "";
                    return;
                }
                #endregion
            }
            #endregion

            if (DNetWeight > 0.00m)//如果净重大于0,那么就进行视频抓图,重车验票
            {
                #region 视频抓图

                if (StaticParameter.IsVideo == "1")
                {
                    if (byteFrontImage == null && byteBackImage == null && byteUpImage == null && byteRoomImage == null)
                    {
                        strFrontImage = Guid.NewGuid().ToString().Replace("-", "");
                        strBackImage = Guid.NewGuid().ToString().Replace("-", "");
                        strUpImage = Guid.NewGuid().ToString().Replace("-", "");
                        strRoomImage = Guid.NewGuid().ToString().Replace("-", "");

                        byteFrontImage = this.videoFrontImage.CapturePic();
                        byteBackImage = this.videoBackImage.CapturePic();
                        byteUpImage = this.videoUpImage.CapturePic();
                        byteRoomImage = this.videoRoomImage.CapturePic();
                    }
                }
                #endregion

                if (rbCheck.Checked)//重车验票
                {
                    #region 重车验票
                    CoalTraffic.BLL.TT_CheckBang bllCheckBang = new CoalTraffic.BLL.TT_CheckBang();
                    CoalTraffic.Model.TT_CheckBang modelCheckBang = new CoalTraffic.Model.TT_CheckBang();

                    modelCheckBang.RoomCode = strRoomCode;//磅房编号
                    modelCheckBang.NetWeight = DNetWeight;//净重

                    #region 查询该重车是否已经验票
                    bool bolChecked = bllCheckBang.IsChecked(strTrafficCode, modelCheckBang.RoomCode);
                    #endregion

                    decimal dOverWeight = 0.0m;//超重
                    decimal DLimitWeight = 0.0m;//限定重量
                    /*验票站的:通过为1,不通过为0*/
                    if (bolChecked)
                    {
                        modelCheckBang.CheckResult = "重车验票不通过,该过磅单在本磅房中已检验过";
                        modelCheckBang.IsPassed = "0";
                    }
                    else//是第一次验票
                    {
                        #region 验证验证码是否正确
                        if (CommonMethod.ToDBC(this.txtRandCode.Text.Trim()) != strRandomCode && iCount < iTryAgainTime)
                        {
                            //总共是三次机会来输入验证码
                            CommonMethod.MessageBox("您输入的验证码不正确,请重新输入,您还有" + (iTryAgainTime - iCount) + "次输入机会", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            aSound.Alarm("您输入的验证码不正确,请重新输入,您还有" + (iTryAgainTime - iCount) + "次输入机会");
                            txtRandCode.Text = "";
                            btnOK.Enabled = false;
                            iCount++;
                            return;
                        }//验证码错误并且已经输入3次都是错误,就验票不通过。
                        else if (CommonMethod.ToDBC(this.txtRandCode.Text.Trim()) != strRandomCode && iCount == iTryAgainTime)
                        {
                            modelCheckBang.CheckResult = "重车验票不通过,验票单可能造假"; //验票结果:通过 or 不通过
                            modelCheckBang.IsPassed = "0";
                        }//验证码输入正确
                        else if (CommonMethod.ToDBC(this.txtRandCode.Text.Trim()) == strRandomCode)
                        {
                            modelCheckBang.CheckResult = "重车验票通过";
                            modelCheckBang.IsPassed = "1";
                        }
                        #endregion
                    }

                    #region 实例化检票
                    modelCheckBang.CheckCode = Guid.NewGuid().ToString().Replace("-", "");
                    modelCheckBang.CheckTime = DateTime.Now;
                    modelCheckBang.Operator = StaticParameter.UserName;
                    modelCheckBang.MarkedCardCode = strMardedCardCode;
                    modelCheckBang.NavicertCode = strNavicertCode;
                    modelCheckBang.WeightCode = this.strTrafficCode;

                    modelCheckBang.FrontImage = strFrontImage;
                    modelCheckBang.BackImage = strBackImage;
                    modelCheckBang.UpImage = strUpImage;
                    modelCheckBang.RoomImage = strRoomImage;

                    modelCheckBang.FrontImageContent = byteFrontImage;
                    modelCheckBang.BackImageContent = byteBackImage;
                    modelCheckBang.UpImageContent = byteUpImage;
                    modelCheckBang.RoomImageContent = byteRoomImage;

                    #endregion

                    if (modelCheckBang.IsPassed == "0")//验票不通过,将不通过的信息,插入报警信息
                    {
                        InsertState = 0;
                        InsertBadReCordInfo("不通过", modelCheckBang.NavicertCode, modelCheckBang.CheckResult);//添加验票失败的报警信息,并同步到机房
                    }
                    else//验票通过(验证码等信息通过)
                    {
                        #region 获取最大重车重量
                        //根据运输编号找到该车的过磅重量(最新的)
                        string strsql = "select top 1 LoadWeight from TT_LoadWeight where TrafficCode ='" + strTrafficCode + "'  order by WeightTime desc";

                        object OMLoadWeight = DbHelperSQL.GetSingle(strsql);

                        if (strCurrentMenu != "Person")//不是人工过磅,获取该车的超重信息
                        {
                            dOverWeight = decimal.Parse(lblDigital.Text.Trim()) - decimal.Parse(OMLoadWeight.ToString());
                        }
                        else//人工过磅,获取该车的超重信息
                        {
                            dOverWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) - Convert.ToDecimal(OMLoadWeight.ToString());
                        }

                        DLimitWeight = StaticParameter.WeightThreshold;//获取配置文件中限定重量
                        #endregion

                        if (dOverWeight >= DLimitWeight)//超重的重量大于限定的重量,再次扣除超重的税费(MLW)
                        {
                            #region 实例化重车过磅(由于超重)
                            string strWeightCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss");
                            MLW.WeightCode = strWeightCode;
                            MLW.TrafficCode = strTrafficCode;
                            MLW.NavicertCode = strNavicertCode;
                            MLW.MarkedCardCode = strMardedCardCode;
                            MLW.RemoteCardCode = strRemoteCode;

                            MLW.CollCode = strCollCode;
                            MLW.CollName = this.cmbCollName.Text.Trim();
                            MLW.CoalKindCode = this.cmbCoalKind.SelectedValue.ToString();
                            MLW.CoalKindName = this.cmbCoalKind.Text.Trim();

                            MLW.CarOwnerName = txtCarOwner.Text.Trim();
                            MLW.CarNo = txtCarNo.Text.Trim();
                            MLW.CarType = txtCarType.Text.Trim();
                            if (strCurrentMenu != "Person")
                            {
                                MLW.LoadWeight = decimal.Parse(lblDigital.Text.Trim());
                            }
                            else
                            {
                                MLW.LoadWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim()));
                            }
                            //MLW.EmptyWeight = decimal.Parse(lblEmptyWeight.Text.Trim());
                            MLW.EmptyWeight = decimal.Parse(txtEmptyWeight.Text.Replace("吨", "").Trim());
                            MLW.NetWeight = 0.0m;

                            MLW.OverWeight = decimal.Parse(dOverWeight.ToString());
                            MLW.RoomCode = strRoomCode;
                            MLW.RoomName = strRoomName;
                            MLW.BangType = "重车" + strBangType + "验票";
                            MLW.Operator = StaticParameter.UserName;

                            MLW.WeightTime = DateTime.Now;
                            MLW.RandomCode = CommonMethod.getRandom(4);
                            MLW.CustomerName = "运煤去向";
                            MLW.TaxType = "重车补扣税费";
                            MLW.IsFirstSite = "0";

                            MLW.FrontImage = Guid.NewGuid().ToString().Replace("-", "");
                            MLW.BackImage = Guid.NewGuid().ToString().Replace("-", "");
                            MLW.UpImage = Guid.NewGuid().ToString().Replace("-", "");
                            MLW.RoomImage = Guid.NewGuid().ToString().Replace("-", "");
                            MLW.FrontImageContent = byteFrontImage;

                            MLW.BackImageContent = byteBackImage;
                            MLW.UpImageContent = byteUpImage;
                            MLW.RoomImageContent = byteRoomImage;
                            MLW.TaxObject = ini.IniReadValue("GFSet", "TaxObject");//扣费标准:1以磅房来算,2以煤矿来算,3以片区来算——————ypf20130519
                            MLW.EmptyCode = strEmptyCode;
                            #endregion
                        }
                    }

                    bool ISSound = false;
                    bool IsLoadWeight = true;

                    #region 超重扣税功能---此处将其注释。(王双峰要求)
                    //if ((dOverWeight >= DLimitWeight) && (dOverWeight != 0.0m))//超重的重量大于限定的重量
                    //{
                    //    #region 添加重车(由于超重)过磅记录
                    //    if (BLW.Add(MLW) != "")//添加超重的信息到重车过磅表中,将数据添加到本地数据库
                    //    {
                    //        ISSound = true;

                    //        if (BLW.Add(MLW) != "-1")
                    //        {
                    //            #region 数据上传,更新到服务器,并有服务器进行各个磅房更新

                    //            string strSql = "PT_LoadWeight '" + MLW.WeightCode + "','" + MLW.TrafficCode + "','" + MLW.NavicertCode + "','" + MLW.MarkedCardCode + "','" + MLW.RemoteCardCode + "',"
                    //          + "'" + MLW.CollCode + "','" + MLW.CollName + "','" + MLW.CoalKindCode + "','" + MLW.CoalKindName + "','" + MLW.CarOwnerName + "',"
                    //          + "'" + MLW.CarNo + "','" + MLW.CarType + "','" + MLW.LoadWeight + "','" + MLW.EmptyWeight + "','" + MLW.NetWeight + "',"
                    //          + "'" + MLW.OverWeight + "','" + MLW.RoomCode + "','" + MLW.RoomName + "','" + MLW.BangType + "','" + MLW.Operator + "',"
                    //          + "'" + MLW.WeightTime + "','" + MLW.RandomCode + "','" + MLW.CustomerName + "','" + MLW.TaxType + "','" + MLW.TaxObject + "',"
                    //          + "'" + MLW.IsFirstSite + "','" + MLW.FrontImage + "','" + MLW.BackImage + "','" + MLW.UpImage + "','" + MLW.RoomImage + "',null,null,null,null,'" + MLW.EmptyCode + "'";
                    //            MC.AddNewSqlText(MC.AllStation + MC.Prefix + "TT_LoadWeight" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + strSql);

                    //            //发送图片
                    //            string strIsSendPicToRoom = StaticParameter.IsSendPicToRoom;
                    //            int iSend = MC.ServerStation;
                    //            //是否发送磅房
                    //            if (strIsSendPicToRoom == "1")
                    //                iSend = MC.CheckStation;
                    //            string strPic = "";
                    //            if (MLW.FrontImageContent != null)
                    //            {
                    //                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                    //                    + MLW.FrontImage + ",jpg," + Convert.ToBase64String(MLW.FrontImageContent, 0, MLW.FrontImageContent.Length);
                    //                MC.AddNewSqlText(strPic);
                    //            }
                    //            if (MLW.BackImageContent != null)
                    //            {
                    //                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                    //                    + MLW.BackImage + ",jpg," + Convert.ToBase64String(MLW.BackImageContent, 0, MLW.BackImageContent.Length);
                    //                MC.AddNewSqlText(strPic);
                    //            }
                    //            if (MLW.UpImageContent != null)
                    //            {
                    //                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                    //                    + MLW.UpImage + ",jpg," + Convert.ToBase64String(MLW.UpImageContent, 0, MLW.UpImageContent.Length);
                    //                MC.AddNewSqlText(strPic);
                    //            }
                    //            if (MLW.RoomImageContent != null)
                    //            {
                    //                strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                    //                    + MLW.RoomImage + ",jpg," + Convert.ToBase64String(MLW.RoomImageContent, 0, MLW.RoomImageContent.Length);
                    //                MC.AddNewSqlText(strPic);
                    //            }
                    //            /********************************************************/
                    //            //Add By 鲍永迎 向BS实时监控服务器消息队列发送重车过磅消息
                    //            /********************************************************/
                    //            //string loadMessage = MLW.RoomName + "," + MLW.LoadWeight + "," + MLW.CoalKindName + "," + MLW.NavicertCode + "," + MLW.NetWeight.ToString() + "," + MLW.WeightTime.ToString();//定义消息格式:磅房名称,车主姓名,煤种名称,准运卡号,煤炭净重,过磅时间
                    //            //RealTimeMonitor monitor = new RealTimeMonitor();//发送消息
                    //            //monitor.SendLoadWeightMessage(loadMessage);

                    //            //冯磊 2010-05-18 修改向BS实时监控服务器消息队列发送重车过磅消息
                    //            string loadMessage = MLW.EmptyWeight.ToString() + "," + MLW.LoadWeight.ToString() + "," + MLW.NetWeight.ToString() + "," + MLW.OverWeight.ToString() + "," + MLW.TaxAmount.ToString() + "," + MLW.FundAmount.ToString() + "," + MLW.Operator.ToString() + "," + MLW.WeightTime.ToString()
                    //                + "," + MLW.CarNo.ToString() + "," + MLW.CarOwnerName.ToString() + "," + MLW.RoomName.ToString() + "," + MLW.CollName.ToString() + "," + MLW.CoalKindName.ToString() + "," +
                    //                MLW.NavicertCode.ToString() + "," + MLW.MarkedCardCode.ToString() + "," + MLW.RemoteCardCode.ToString() + "," + MLW.WeightCode.ToString();//定义消息格式:空车重量,重车重量,净重,超重,税费,基金,操作人,过磅时间,车牌号,车主姓名,磅房名称,煤矿名称,煤种名称,准运卡号,标识卡号,远程卡号,过磅单号
                    //            RealTimeMonitor monitor = new RealTimeMonitor();//发送消息
                    //            monitor.SendLoadWeightMessage(loadMessage);
                    //            /********************************************************/
                    //            #endregion//

                    //            if (strMardedCardCode != "" && ini.IniReadValue("RoomSetting", "IsHaveMarkedCard") == "1")
                    //            {
                    //                aSound.Alarm("重车验票过磅通过,点击确定打印重车验票过磅单 并且回收标识卡");
                    //                CommonMethod.MessageBox("重车过磅验票通过,点击确定打印重车验票过磅单并且回收标识卡!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    //            }
                    //            else
                    //            {
                    //                aSound.Alarm("重车验票过磅通过,点击确定打印重车验票过磅单");
                    //                CommonMethod.MessageBox("重车过磅验票通过,点击确定打印重车验票过磅单!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    //            }

                    //            //设置扣税标志位
                    //            this.isks = true;
                    //            #region 打印相关
                    //            Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                    //            string strFileName = "";
                    //            if (StaticParameter.ReportFile == "FuYuan.")
                    //            {
                    //                strFileName = "ZiChang.";
                    //            }
                    //            else
                    //            {
                    //                strFileName = StaticParameter.ReportFile;
                    //            }
                    //            Type type = assembly.GetType("CoalTraffic.Report." + strFileName + "CheckLoadWeightPrint");
                    //            object obj = Activator.CreateInstance(type, MLW.WeightCode, true);
                    //            Form formToShow = (Form)obj;
                    //            formToShow.ShowDialog();
                    //            #endregion
                    //        }
                    //        else
                    //        {
                    //            aSound.Alarm("账户余额已不足本车的扣款,请通知" + cmbCollName.Text.Trim() + "速来交费");
                    //            IsLoadWeight = false;
                    //        }
                    //    }
                    //    else
                    //    {
                    //        this.aSound.Alarm("该站的数据库异常");
                    //        InsertState = 0;
                    //        InsertBadReCordInfo("异常", strRoomName + "的数据库异常");
                    //    }
                    //    #endregion
                    //}
                    #endregion

                    #region 添加验票信息
                    string isConnection = ini.IniReadValue("Connection", "isConnection");
                    if (IsLoadWeight)
                    {

                        if (bllCheckBang.Add(modelCheckBang) != "")//执行验票
                        {

                            #region 当联网的时:插入同步sql语句到服务器,sql语句本地执行
                            if (isConnection == "0")
                            {
                                StringBuilder sbInsertCheckBang = new StringBuilder();
                                sbInsertCheckBang.Append("PT_CheckBang '" + modelCheckBang.CheckCode + "','" + modelCheckBang.WeightCode + "','" + modelCheckBang.NavicertCode + "',");
                                sbInsertCheckBang.Append("'" + modelCheckBang.MarkedCardCode + "','" + modelCheckBang.NetWeight + "','" + modelCheckBang.RoomCode + "',");
                                sbInsertCheckBang.Append("'" + modelCheckBang.IsPassed + "','" + modelCheckBang.CheckResult + "','" + modelCheckBang.CheckTime + "',");
                                sbInsertCheckBang.Append("'" + modelCheckBang.Operator + "','" + modelCheckBang.FrontImage + "',null,");
                                sbInsertCheckBang.Append("'" + modelCheckBang.BackImage + "',null,'" + modelCheckBang.UpImage + "',");
                                sbInsertCheckBang.Append("null,'" + modelCheckBang.RoomImage + "',null");
                                DbHelperSQL.ExecuteSql2(sbInsertCheckBang.ToString(), "1");//sql语句本地执行
                                string sqlInsertLog = "insert [NetWorkDisconnectionLog] (ID, SQLcontext, datetime, IP) values (@ID,@SQLcontext,@datetime,@IP)";
                                SqlParameter[] sqlpars = new SqlParameter[]
                        {
                            new SqlParameter("@ID",DateTime.Now.ToString("yyyyMMddHHmmss")),
                            new SqlParameter("@SQLcontext",sbInsertCheckBang.ToString()),
                            new SqlParameter("@datetime",DateTime.Now.ToString()),
                            new SqlParameter("@IP",ini.IniReadValue("Connection","LServer"))
                        };
                                DbHelperSQL.ExecuteSql(sqlInsertLog,sqlpars); //插入同步sql语句
                            }
                            #endregion

                            #region 断网时,添加验票sql语句
                            try
                            {
                                StringBuilder sbInsertCheckBang = new StringBuilder();
                                sbInsertCheckBang.Append("PT_CheckBang '" + modelCheckBang.CheckCode + "','" + modelCheckBang.WeightCode + "','" + modelCheckBang.NavicertCode + "',");
                                sbInsertCheckBang.Append("'" + modelCheckBang.MarkedCardCode + "','" + modelCheckBang.NetWeight + "','" + modelCheckBang.RoomCode + "',");
                                sbInsertCheckBang.Append("'" + modelCheckBang.IsPassed + "','" + modelCheckBang.CheckResult + "','" + modelCheckBang.CheckTime + "',");
                                sbInsertCheckBang.Append("'" + modelCheckBang.Operator + "','" + modelCheckBang.FrontImage + "',null,");
                                sbInsertCheckBang.Append("'" + modelCheckBang.BackImage + "',null,'" + modelCheckBang.UpImage + "',");
                                sbInsertCheckBang.Append("null,'" + modelCheckBang.RoomImage + "',null");
                                if (isConnection == "1")
                                {
                                    string id = DateTime.Now.ToString("yyyyMMddHHmmss");
                                    StringBuilder sbsqlcontext = new StringBuilder();
                                    sbsqlcontext.Append("insert into NetWorkDisconnection (ID, SQLcontext, DateTime) values(@id,@sqlcontext,@datetime)");
                                    SqlParameter[] parameters = new SqlParameter[] {
                                                                                            new SqlParameter("@id",id),
                                                                                            new SqlParameter("@sqlcontext",sbInsertCheckBang.ToString()),
                                                                                            new SqlParameter("@datetime",DateTime.Now)
                                                                                             };
                                    DbHelperSQL.ExecuteSql(sbsqlcontext.ToString(), parameters);
                                }
                            }
                            catch { }
                            #endregion

                            if (!ISSound)
                            {
                                aSound.Alarm(modelCheckBang.CheckResult);
                            }

                            spRemote.CardCode = "";
                        }
                        else
                        {
                            if (isConnection == "0")
                            {
                                ini.IniWriteValue("RoomSetting", "IsHaveMarkedCard", CommonMethod.ToDBC("1"));
                                MessageBox.Show("系统与服务器断开连接,请联系中心机房!");
                                Application.ExitThread();
                                Application.Exit();
                            }
                            else
                            {
                                aSound.Alarm("该站的数据库异常");
                                InsertState = 0;
                                InsertBadReCordInfo("异常", "", strRoomName + "的数据库异常");
                            }
                        }
                    }
                    #endregion

                    #endregion
                }
                else//重车过磅选项
                {
                    #region 重车过磅

                    #region 读取与煤矿相关的信息
                    SqlParameter[] parameter =
                    {
                        new SqlParameter("@CollCode", SqlDbType.VarChar,10),
                        new SqlParameter("@CoalKindCode", SqlDbType.VarChar,4)
                    };

                    parameter[0].Value = strCollCode;
                    parameter[1].Value = strCoalKindCode;
                    DataSet dstColieryAccount = DbHelperSQL.RunProcedure("PT_ColieryAccountJudge", parameter, "ColieryAccount");
                    #endregion

                    string strLeastValue = dstColieryAccount.Tables["ColieryAccount"].Rows[0]["ReturnValue"].ToString();

                    if (strLeastValue == "0") //0:正常,可过磅
                    {
                        if (strCurrentMenu != "Person")
                        {
                            MLW.LoadWeight = decimal.Parse(lblDigital.Text.Trim());
                        }
                        else
                        {
                            MLW.LoadWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim()));
                        }

                        #region 实例化重车过磅
                        string strWeightCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss");
                        MLW.WeightCode = strWeightCode;
                        MLW.TrafficCode = strWeightCode;
                        MLW.NavicertCode = strNavicertCode;
                        MLW.MarkedCardCode = strMardedCardCode;
                        MLW.RemoteCardCode = strRemoteCode;

                        MLW.CollCode = strCollCode;
                        MLW.CollName = cmbCollName.Text;
                        MLW.CoalKindCode = cmbCoalKind.SelectedValue.ToString();
                        MLW.CoalKindName = cmbCoalKind.Text;
                        MLW.CarOwnerName = txtCarOwner.Text.Trim();

                        MLW.CarNo = txtCarNo.Text.Trim();
                        MLW.CarType = txtCarType.Text.Trim();

                        MLW.EmptyWeight = decimal.Parse(strEmptyWeight);
                        MLW.NetWeight = MLW.LoadWeight - MLW.EmptyWeight;
                        MLW.OverWeight = 0.00m;

                        MLW.RoomCode = strRoomCode;
                        MLW.RoomName = strRoomName;
                        MLW.BangType = "重车" + strBangType + "过磅";
                        MLW.Operator = StaticParameter.UserName;

                        MLW.WeightTime = DateTime.Now;
                        MLW.RandomCode = CommonMethod.getRandom(4);
                        MLW.CustomerName = "运煤去向";
                        MLW.TaxType = "重车正常扣税";
                        MLW.IsFirstSite = "1";

                        MLW.FrontImage = strFrontImage;
                        MLW.BackImage = strBackImage;
                        MLW.UpImage = strUpImage;
                        MLW.RoomImage = strRoomImage;
                        MLW.FrontImageContent = byteFrontImage;

                        MLW.BackImageContent = byteBackImage;
                        MLW.UpImageContent = byteUpImage;
                        MLW.RoomImageContent = byteRoomImage;
                        MLW.TaxObject = ConfigurationManager.AppSettings["TaxObject"].ToString();
                        MLW.EmptyCode = strEmptyCode;
                        #endregion

                        #region 添加重车过磅记录
                        string isConnection = ini.IniReadValue("Connection", "isConnection");
                        if (BLW.Add(MLW) != "")
                        {
                            if (BLW.Add(MLW) != "-1")
                            {

                                #region 当联网的时:插入同步sql语句到服务器,sql语句本地执行
                                if (isConnection == "0")
                                {
                                    string strSql2Local = "PT_LoadWeight '" + MLW.WeightCode + "','" + MLW.TrafficCode + "','" + MLW.NavicertCode + "','" + MLW.MarkedCardCode + "','" + MLW.RemoteCardCode + "',"
                                     + "'" + MLW.CollCode + "','" + MLW.CollName + "','" + MLW.CoalKindCode + "','" + MLW.CoalKindName + "','" + MLW.CarOwnerName + "',"
                                     + "'" + MLW.CarNo + "','" + MLW.CarType + "','" + MLW.LoadWeight + "','" + MLW.EmptyWeight + "','" + MLW.NetWeight + "',"
                                     + "'" + MLW.OverWeight + "','" + MLW.RoomCode + "','" + MLW.RoomName + "','" + MLW.BangType + "','" + MLW.Operator + "',"
                                     + "'" + MLW.WeightTime + "','" + MLW.RandomCode + "','" + MLW.CustomerName + "','" + MLW.TaxType + "','" + MLW.TaxObject + "',"
                                     + "'" + MLW.IsFirstSite + "','" + MLW.FrontImage + "','" + MLW.BackImage + "','" + MLW.UpImage + "','" + MLW.RoomImage + "',null,null,null,null,'" + MLW.EmptyCode + "'";

                                    string sqlInsertLog = "insert [NetWorkDisconnectionLog] (ID, SQLcontext, datetime, IP) values (@ID,@SQLcontext,@datetime,@IP)";
                                    SqlParameter[] sqlpars = new SqlParameter[]
                        {
                            new SqlParameter("@ID",DateTime.Now.ToString("yyyyMMddHHmmss")),
                            new SqlParameter("@SQLcontext",strSql2Local.ToString()),
                            new SqlParameter("@datetime",DateTime.Now.ToString()),
                            new SqlParameter("@IP",ini.IniReadValue("Connection","LServer"))
                        };
                                    DbHelperSQL.ExecuteSql(sqlInsertLog,sqlpars); //插入同步sql语句
                                    DbHelperSQL.ExecuteSql2(strSql2Local.ToString(), "1");//sql语句本地执行
                                }
                                #endregion

                                #region 断网时,添加重车过磅sql语句
                                string strSql2 = "PT_LoadWeight '" + MLW.WeightCode + "','" + MLW.TrafficCode + "','" + MLW.NavicertCode + "','" + MLW.MarkedCardCode + "','" + MLW.RemoteCardCode + "',"
                                        + "'" + MLW.CollCode + "','" + MLW.CollName + "','" + MLW.CoalKindCode + "','" + MLW.CoalKindName + "','" + MLW.CarOwnerName + "',"
                                        + "'" + MLW.CarNo + "','" + MLW.CarType + "','" + MLW.LoadWeight + "','" + MLW.EmptyWeight + "','" + MLW.NetWeight + "',"
                                        + "'" + MLW.OverWeight + "','" + MLW.RoomCode + "','" + MLW.RoomName + "','" + MLW.BangType + "','" + MLW.Operator + "',"
                                        + "'" + MLW.WeightTime + "','" + MLW.RandomCode + "','" + MLW.CustomerName + "','" + MLW.TaxType + "','" + MLW.TaxObject + "',"
                                        + "'" + MLW.IsFirstSite + "','" + MLW.FrontImage + "','" + MLW.BackImage + "','" + MLW.UpImage + "','" + MLW.RoomImage + "',null,null,null,null,'" + MLW.EmptyCode + "'";

                                if (isConnection == "1")
                                {
                                    string id = DateTime.Now.ToString("yyyyMMddHHmmss");
                                    StringBuilder sbsqlcontext = new StringBuilder();
                                    sbsqlcontext.Append("insert into NetWorkDisconnection (ID, SQLcontext, DateTime) values(@id,@sqlcontext,@datetime)");
                                    SqlParameter[] parameters = new SqlParameter[] {
                                                                                            new SqlParameter("@id",id),
                                                                                            new SqlParameter("@sqlcontext",strSql2.ToString()),
                                                                                            new SqlParameter("@datetime",DateTime.Now)
                                                                                             };
                                    DbHelperSQL.ExecuteSql(sbsqlcontext.ToString(), parameters);
                                }
                                #endregion

                                #region 打印相关
                                aSound.Alarm("重车过磅通过,点击确定打印重车过磅单");
                                CommonMethod.MessageBox("重车过磅通过,点击确定打印重车过磅单!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                //设置扣税标志位
                                this.isks = true;
                                Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                                string strFileName = "";
                                if (StaticParameter.ReportFile == "FuYuan.")
                                {
                                    strFileName = "ZiChang.";
                                }
                                else
                                {
                                    strFileName = StaticParameter.ReportFile;
                                }
                                Type type = assembly.GetType("CoalTraffic.Report." + strFileName + "LoadWeightPrint");
                                object obj = Activator.CreateInstance(type, MLW.WeightCode, true); Form formToShow = (Form)obj; formToShow.ShowDialog();
                                #endregion
                            }
                            else
                            {
                                aSound.Alarm("账户余额已不足本车的扣款,请通知" + cmbCollName.Text.Trim() + "速来交费");
                            }
                        }
                        else
                        {
                            if (isConnection == "0")
                            {
                                //ini.IniWriteValue("RoomSetting", "IsHaveMarkedCard", CommonMethod.ToDBC("1"));
                                MessageBox.Show("系统与服务器断开连接,请联系中心机房!");
                                Application.ExitThread();
                                Application.Exit();
                            }
                            else
                            {
                                this.aSound.Alarm("该站的数据库异常");
                                InsertState = 0;
                                InsertBadReCordInfo("异常", MLW.RoomName, strRoomName + "的数据库异常");
                            }
                        }
                        #endregion
                    }
                    else if (strLeastValue == "1")
                    {
                        aSound.Alarm("煤矿余额低于下限,不能继续过磅");
                    }
                    else if (strLeastValue == "2")
                    {
                        aSound.Alarm("该煤矿不生产该煤种,不能继续过磅");
                        InsertState = 0;
                        InsertBadReCordInfo("异常", "", strCollName + "不生产" + strCoalKindName);
                    }
                    else if (strLeastValue == "-1")
                    {
                        aSound.Alarm("该煤矿不存在,不能继续过磅");
                        InsertState = 0;
                        InsertBadReCordInfo("异常", "", "编号为:" + strCollCode + "的煤矿不存在");
                    }
                    #endregion
                }

                ClearAllUIControlEmpty();
                this.ClearOwnerValue();
            }
            else
            {
                aSound.Alarm("煤炭净重异常");
                InsertState = 0;
                InsertBadReCordInfo("异常", "", "车牌号为:" + txtCarNo.Text.Trim() + "车辆的煤炭净重异常");
            }
            this.lblRemoteCode.Text = "";
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            Model.TT_LoadWeight MLW = new TT_LoadWeight();
            BLL.TT_LoadWeight BLW = new CoalTraffic.BLL.TT_LoadWeight();

            if (strCurrentMenu != "Person")
            {
                MLW.LoadWeight = decimal.Parse(lblDigital.Text.Trim());
                MLW.NetWeight = MLW.LoadWeight - Convert.ToDecimal(txtEmptyWeight.Text.Trim());
            }
            else
            {
                #region 验证数据的正确性
                if (txtHandDigital.Text.Trim() != "" && CommonMethod.IsDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())))
                {
                    if (Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) < Convert.ToDecimal(lblDigital.Text.Trim()))
                    {
                        alSound.Alarm("你输入的重车重量不能小于磅秤重量");
                        txtHandDigital.Text = "";
                        return;
                    }
                    else
                    {
                        MLW.LoadWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim()));
                        MLW.NetWeight = MLW.LoadWeight - Convert.ToDecimal(txtEmptyWeight.Text.Trim());
                    }
                }
                else
                {
                    alSound.Alarm("你输入的重车重量格式不对");
                    txtHandDigital.Text = "";
                    return;
                }
                #endregion
            }

            if (MLW.NetWeight > 0.00m)
            {
                #region 读取与煤矿相关的信息
                SqlParameter[] parameter =
                {
                    new SqlParameter("@CollCode", SqlDbType.VarChar,10),
                    new SqlParameter("@CoalKindCode", SqlDbType.VarChar,4)
                };

                parameter[0].Value = strCollCode;
                parameter[1].Value = strCoalKindCode;
                DataSet dstColieryAccount = DbHelperSQL.RunProcedure("PT_ColieryAccountJudge", parameter, "ColieryAccount");
                #endregion

                string strLeastValue = dstColieryAccount.Tables["ColieryAccount"].Rows[0]["ReturnValue"].ToString();

                if (strLeastValue == "0") //0:正常,可过磅
                {

                    #region 视频抓图
                    if (StaticParameter.IsVideo == "1")
                    {
                        if (byteFrontImage == null && byteBackImage == null && byteUpImage == null && byteRoomImage == null)
                        {
                            strFrontImage = Guid.NewGuid().ToString().Replace("-", "");
                            strBackImage = Guid.NewGuid().ToString().Replace("-", "");
                            strUpImage = Guid.NewGuid().ToString().Replace("-", "");
                            strRoomImage = Guid.NewGuid().ToString().Replace("-", "");

                            byteFrontImage = this.videoFrontImage.CapturePic();
                            byteBackImage = this.videoBackImage.CapturePic();
                            byteUpImage = this.videoUpImage.CapturePic();
                            byteRoomImage = this.videoRoomImage.CapturePic();
                        }

                    }
                    #endregion

                    #region 实例化重车过磅
                    string strWeightCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss");
                    MLW.WeightCode = strWeightCode;
                    MLW.TrafficCode = strWeightCode;
                    MLW.NavicertCode = "";
                    MLW.MarkedCardCode = strMarkedCardCode;
                    MLW.RemoteCardCode = "";

                    MLW.CollCode = strCollCode;
                    MLW.CollName = strCollName;
                    MLW.CoalKindCode = strCoalKindCode;
                    MLW.CoalKindName = strCoalKindName;
                    MLW.CarOwnerName = txtCarOwnerName.Text.Trim();

                    MLW.CarNo = txtCarNo.Text.Trim();
                    MLW.CarType = "";
                    MLW.EmptyWeight = decimal.Parse(txtEmptyWeight.Text.Trim());
                    MLW.OverWeight = 0.0m;
                    MLW.RoomCode = strRoomCode;
                    MLW.RoomName = strRoomName;
                    MLW.BangType = "散煤" + strBangType + "过磅";
                    MLW.Operator = StaticParameter.UserName;

                    MLW.WeightTime = DateTime.Now;
                    MLW.RandomCode = CommonMethod.getRandom(4);
                    MLW.CustomerName = "运煤去向";
                    MLW.TaxType = "正常扣税";
                    MLW.IsFirstSite = "1";

                    MLW.FrontImage = strFrontImage;
                    MLW.BackImage = strBackImage;
                    MLW.UpImage = strUpImage;
                    MLW.RoomImage = strRoomImage;
                    MLW.FrontImageContent = byteFrontImage;

                    MLW.BackImageContent = byteBackImage;
                    MLW.UpImageContent = byteUpImage;
                    MLW.RoomImageContent = byteRoomImage;
                    MLW.TaxObject = ConfigurationManager.AppSettings["TaxObject"].ToString();
                    MLW.EmptyCode = strEmptyCode;
                    #endregion

                    if (BLW.Add(MLW) != "")
                    {
                        if (BLW.Add(MLW) != "-1")
                        {
                            #region 数据上传
                            try
                            {
                                //MSMQClient MC = new MSMQClient();
                                string strSql = "PT_LoadWeight '" + MLW.WeightCode + "','" + MLW.TrafficCode + "','" + MLW.NavicertCode + "','" + MLW.MarkedCardCode + "','" + MLW.RemoteCardCode + "',"
                                              + "'" + MLW.CollCode + "','" + MLW.CollName + "','" + MLW.CoalKindCode + "','" + MLW.CoalKindName + "','" + MLW.CarOwnerName + "',"
                                              + "'" + MLW.CarNo + "','" + MLW.CarType + "','" + MLW.LoadWeight + "','" + MLW.EmptyWeight + "','" + MLW.NetWeight + "',"
                                              + "'" + MLW.OverWeight + "','" + MLW.RoomCode + "','" + MLW.RoomName + "','" + MLW.BangType + "','" + MLW.Operator + "',"
                                              + "'" + MLW.WeightTime + "','" + MLW.RandomCode + "','" + MLW.CustomerName + "','" + MLW.TaxType + "','" + MLW.TaxObject + "',"
                                              + "'" + MLW.IsFirstSite + "','" + MLW.FrontImage + "','" + MLW.BackImage + "','" + MLW.UpImage + "','" + MLW.RoomImage + "',"
                                              + "null,null,null,null,'" + MLW.EmptyCode + "'";
                                MC.AddNewSqlText(MC.AllStation + MC.Prefix + "TT_LoadWeight" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + strSql);

                                //发送图片
                                string strIsSendPicToRoom = StaticParameter.IsSendPicToRoom;
                                int iSend = MC.ServerStation;
                                //是否发送磅房
                                if (strIsSendPicToRoom == "1")
                                    iSend = MC.AllStation;
                                string strPic = "";
                                if (MLW.FrontImageContent != null)
                                {
                                    strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                        + MLW.FrontImage + ",jpg," + Convert.ToBase64String(MLW.FrontImageContent, 0, MLW.FrontImageContent.Length);
                                    MC.AddNewSqlText(strPic);
                                }
                                if (MLW.BackImageContent != null)
                                {
                                    strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                        + MLW.BackImage + ",jpg," + Convert.ToBase64String(MLW.BackImageContent, 0, MLW.BackImageContent.Length);
                                    MC.AddNewSqlText(strPic);
                                }
                                if (MLW.UpImageContent != null)
                                {
                                    strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                        + MLW.UpImage + ",jpg," + Convert.ToBase64String(MLW.UpImageContent, 0, MLW.UpImageContent.Length);
                                    MC.AddNewSqlText(strPic);
                                }
                                if (MLW.RoomImageContent != null)
                                {
                                    strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix
                                        + MLW.RoomImage + ",jpg," + Convert.ToBase64String(MLW.RoomImageContent, 0, MLW.RoomImageContent.Length);
                                    MC.AddNewSqlText(strPic);
                                }
                            }
                            catch
                            { }
                            #endregion

                            string strErro = "";
                            if (StaticParameter.IsHaveMarkedCard == "1")
                            {
                                strErro = "并回收标识卡";
                            }

                            alSound.Alarm("散煤过磅成功,点击确定打印散煤过磅单" + strErro + "");
                            CommonMethod.MessageBox("散煤过磅成功,点击确定打印散煤过磅单" + strErro + "!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                            string strFileName = "";
                            if (StaticParameter.ReportFile == "FuYuan.")
                            {
                                strFileName = "ZiChang.";
                            }
                            else
                            {
                                strFileName = StaticParameter.ReportFile;
                            }
                            Type type = assembly.GetType("CoalTraffic.Report." + strFileName + "SpreadWeightPrint");
                            object obj = Activator.CreateInstance(type, MLW.WeightCode, true); Form formToShow = (Form)obj; formToShow.ShowDialog();
                        }
                        else
                        {
                            alSound.Alarm("账户余额已不足本车的扣款,请通知" + txtCollName.Text.Trim() + "速来交费");
                        }
                    }
                    else
                    {
                        alSound.Alarm("数据库异常");
                        InsertState = 0;

                        InsertBadReCordInfo("异常", strRoomName + "的数据库异常");
                    }
                }
                else if (strLeastValue == "1")
                {
                    alSound.Alarm("煤矿余额低于下限,不能继续过磅");
                }
                else if (strLeastValue == "2")
                {
                    alSound.Alarm("该煤矿不生产该煤种,不能继续过磅");
                    InsertState = 0;
                    InsertBadReCordInfo("异常",strCollName + "不生产" + strCoalKindName);
                }
                else if (strLeastValue == "-1")
                {
                    alSound.Alarm("该煤矿不存在,不能继续过磅");
                    InsertState = 0;
                    InsertBadReCordInfo("异常", "编号为:" + strCollCode + "的煤矿不存在");
                }
                this.ClearAllControl();
                ClearUserControl();
            }
            else
            {
                alSound.Alarm("煤炭净重异常");
                InsertState = 0;
                InsertBadReCordInfo("异常", "车牌号为:" + txtCarNo.Text.Trim() + "车辆的煤炭净重异常");
            }
        }