private void btnOK_Click(object sender, EventArgs e)
        {
            CoalTraffic.Model.TT_EmptyWeight model = new CoalTraffic.Model.TT_EmptyWeight();
            if (txtCarNo.Text.Trim() != "" && txtCarOwnerName.Text.Trim() != "" && txtCarOwnerPhone.Text.Trim() != "" && txtCarOwnerIDCard.Text.Trim() != "" && lblDigital.Text.Trim() != "0.00")
            {
                if (txtCarOwnerIDCard.Text.Trim().Length == 15 || txtCarOwnerIDCard.Text.Trim().Length == 18)
                {
                    if (CommonMethod.isValidICCard(CommonMethod.ToDBC(txtCarOwnerIDCard.Text.Trim())))
                    {
                        if (RbLoadWeight.Checked)
                        {
                            decimal DLimitWeight = decimal.Parse(ini.IniReadValue("RoomSetting", "WeightThreshold"));
                            decimal DOverWeight = 0.00m;
                            if (strCurrentMenu != "Person")
                            {
                                DOverWeight = Math.Abs(Convert.ToDecimal(lblDigital.Text.Trim()) - Convert.ToDecimal(txtEmptyWeight.Text.Trim()));
                            }
                            else
                            {
                                #region 验证数据的正确性
                                if (txtManDigital.Text.Trim() != "" && CommonMethod.IsDecimal(CommonMethod.ToDBC(txtManDigital.Text.Trim())))
                                {
                                    if (Convert.ToDecimal(CommonMethod.ToDBC(txtManDigital.Text.Trim())) >= Convert.ToDecimal(lblDigital.Text.Trim()))
                                    {
                                        DOverWeight = Math.Abs(Convert.ToDecimal(CommonMethod.ToDBC(txtManDigital.Text.Trim())) - Convert.ToDecimal(txtEmptyWeight.Text.Trim()));
                                    }
                                    else
                                    {
                                        alarmSound.Alarm("你输入的重车重量不能小于磅秤重量");
                                        txtManDigital.Text = "";
                                        return;
                                    }
                                }
                                else
                                {
                                    alarmSound.Alarm("你输入的重车重量格式不对");
                                    txtManDigital.Text = "";
                                    return;
                                }
                                #endregion
                            }

                            if (DOverWeight > DLimitWeight)
                            {
                                alarmSound.Alarm("空车重量异常,该车辆可能改装");
                                InsertState = 0;
                                InsertBadReCordInfo("异常", txtCarNo.Text.Trim(), "车牌号为:" + txtCarNo.Text.Trim() + "车辆的空车重量异常,该车辆登记时重量为:" + txtEmptyWeight.Text.Trim() + "现在重量为:" + txtManDigital.Text.Trim() + "");

                                return;
                            }
                        }

                        #region 空车过磅实体
                        model.BangTime = DateTime.Now;
                        model.BangType = strBangType;
                        model.CarCode = strCarCode;
                        model.EmptyCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss");
                        if (strBangType == "自动")
                        {
                            model.EmptyWeight = Convert.ToDecimal(this.lblDigital.Text);
                        }
                        else
                        {
                            model.EmptyWeight = Convert.ToDecimal(CommonMethod.ToDBC(this.txtManDigital.Text.Trim()));
                        }

                        if (StaticParameter.IsVideo == "1")
                        {
                            if (byteFrontImage == null)
                            {
                                strFrontImage = Guid.NewGuid().ToString().Replace("-", "");
                                byteFrontImage = this.dHVideo.CapturePic();
                            }

                            model.FrontImage = strFrontImage;
                            model.FrontImageContent = byteFrontImage;
                        }
                        else
                        {
                            model.FrontImage = "";
                            model.FrontImageContent = null;
                        }

                        model.NavicertCode = strNavicertCode;
                        model.Operator = StaticParameter.UserName;
                        model.RemoteCardCode = strReadRemoteCode;
                        model.RoomCode = strRoomCode;
                        model.Carno = CommonMethod.ToDBC(txtCarNo.Text.Trim());
                        model.Caronername = CommonMethod.ToDBC(txtCarOwnerName.Text.Trim());
                        model.CarowneridCard = CommonMethod.ToDBC(txtCarOwnerIDCard.Text.Trim());
                        model.Carownerphone = CommonMethod.ToDBC(txtCarOwnerPhone.Text.Trim());
                        model.Randomcode = CommonMethod.getRandom(4);
                        #endregion

                        string strEmptyCode = bll.Add(model);
                        if (strEmptyCode != "")
                        {
                            alarmSound.Alarm("空车过磅成功");
                            CommonMethod.MessageBox("空车过磅成功!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                            //冯磊 2010-05-13 屏蔽了空车过磅打印功能

                            //alarmSound.Alarm("空车过磅成功,点击确定打印空车过磅单");
                            //CommonMethod.MessageBox("空车过磅成功,点击确定打印空车过磅单!", 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 + "EmptyWeightPrintByEmpty");
                            //object obj = Activator.CreateInstance(type, strEmptyCode, true); Form formToShow = (Form)obj; formToShow.ShowDialog();


                            #region 将数据上传到服务器
                            try
                            {
                                //CoalTraffic.DBUtility.MSMQClient mq = new MSMQClient();
                                string strSql = "PT_EmptyWeight '" + model.EmptyCode + "','" + model.CarCode + "','" + model.RemoteCardCode
                                    + "','" + model.NavicertCode + "','" + model.EmptyWeight + "','" + model.BangType + "','"
                                    + model.RoomCode + "','" + model.FrontImage + "','" + model.Operator + "','" + model.BangTime
                                    + "',null,'" + model.Carno + "','" + model.Caronername + "','" + model.CarowneridCard
                                    + "','" + model.Carownerphone + "','" + model.Randomcode + "'";
                                MC.AddNewSqlText(MC.AllStation + MC.Prefix + "TT_EmptyWeight" + 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 (model.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
                                        + model.FrontImage + ",jpg," + Convert.ToBase64String(model.FrontImageContent, 0, model.FrontImageContent.Length);
                                    MC.AddNewSqlText(strPic);
                                }

                                /********************************************************/
                                //Add By 鲍永迎 向BS实时监控服务器消息队列发送空车过磅消息
                                /********************************************************/
                                string strRoomName = ini.IniReadValue("RoomSetting", "RoomName");
                                string emptyMessage = strRoomName + "," + model.CarCode + "," + model.NavicertCode + "," + model.EmptyWeight.ToString() + "," + model.BangTime.ToString();//定义消息格式:磅房名称,车辆信息编号,准运卡号,空车重量,过磅时间
                                RealTimeMonitor monitor = new RealTimeMonitor();//发送消息
                                monitor.SendEmptyWeightMessage(emptyMessage);
                                /********************************************************/
                            }
                            catch { }
                            #endregion

                            ClearAllControls();
                            ClearUserControl();

                        }
                        else
                        {
                            alarmSound.Alarm("该站的数据库异常");
                            InsertState = 0;
                            InsertBadReCordInfo("异常", txtCarNo.Text.Trim(), ini.IniReadValue("RoomSetting", "RoomName") + "的数据库异常");
                        }
                    }
                    else
                    {
                        alarmSound.Alarm("你输入的车主身份证号格式不正确");

                    }
                }
                else
                {
                    alarmSound.Alarm("你输入的车主身份证号长度不正确");
                }
            }
            else
            {
                alarmSound.Alarm("请确保信息的完整性");
            }

        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            CoalTraffic.Model.TT_LoadWeight model = new CoalTraffic.Model.TT_LoadWeight();

            if (cmbCustomers.SelectedValue.ToString() != "-1")
            {
                if (strCurrentMenu == "Auto")
                {
                    model.LoadWeight = Convert.ToDecimal(lblDigital.Text);
                    model.NetWeight = Convert.ToDecimal(lblDigital.Text) - 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()))
                        {
                            alarmSound.Alarm("��������س���������С�ڰ�������");
                            txtHandDigital.Text = "";
                            return;
                        }
                        else
                        {
                            model.LoadWeight = Convert.ToDecimal(CommonMethod.ToDBC(this.txtHandDigital.Text.Trim()));
                            model.NetWeight = Convert.ToDecimal(CommonMethod.ToDBC(this.txtHandDigital.Text.Trim())) - Convert.ToDecimal(txtEmptyWeight.Text.Trim());
                        }
                    }
                    else
                    {
                        alarmSound.Alarm("��������س�������ʽ����");
                        txtHandDigital.Text = "";
                        return;
                    }
                    #endregion
                }
                if (model.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 ��Ƶץͼ
                        //ץͼ��Ϣ
                        byte[] byteFrontImage = null;
                        byte[] byteBackImage = null;
                        byte[] byteUpImage = null;
                        byte[] byteRoomImage = null;

                        //ͼƬ�洢��SYS_FileSave������
                        string strFrontImage = "";
                        string strBackImage = "";
                        string strUpImage = "";
                        string strRoomImage = "";

                        if (strIsVideo == "1")
                        {
                            strFrontImage = Guid.NewGuid().ToString().Replace("-", "");
                            strBackImage = Guid.NewGuid().ToString().Replace("-", "");
                            strUpImage = Guid.NewGuid().ToString().Replace("-", "");
                            strRoomImage = Guid.NewGuid().ToString().Replace("-", "");

                            byteFrontImage = ((DHVideo)Form1.PF.Controls["videoFrontImage"]).CapturePic();
                            byteBackImage = ((DHVideo)Form1.PF.Controls["videoBackImage"]).CapturePic();
                            byteUpImage = ((DHVideo)Form1.PF.Controls["videoUpImage"]).CapturePic();
                            byteRoomImage = ((DHVideo)Form1.PF.Controls["videoRoomImage"]).CapturePic();
                        }
                        #endregion

                        #region ʵ�����س�
                        string strWeightCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss");
                        model.WeightCode = strWeightCode;
                        model.TrafficCode = strWeightCode;
                        model.NavicertCode = strNavicertCode;
                        model.MarkedCardCode = strMardedCardCode;
                        model.RemoteCardCode = strRemoteCode;

                        model.CollCode = strCollCode;
                        model.CollName = this.txtCollName.Text.Trim();
                        model.CoalKindCode = strCoalKindCode;
                        model.CoalKindName = this.txtKindName.Text;
                        model.CarOwnerName = strCarOwnerName;

                        model.CarNo = txtCarNo.Text;
                        model.CarType = txtCarType.Text;
                        model.EmptyWeight = Convert.ToDecimal(txtEmptyWeight.Text);

                        model.OverWeight = 0;
                        model.RoomCode = strRoomCode;
                        model.RoomName = strRoomName;
                        model.BangType = strBangType;
                        model.Operator = StaticParameter.UserName;

                        model.WeightTime = DateTime.Now;
                        model.RandomCode = CommonMethod.getRandom(4);
                        model.CustomerName = cmbCustomers.SelectedValue.ToString();
                        model.IsFirstSite = "1";
                        model.TaxType = "�س�������˰";

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

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

                        if (bll.Add(model) != "")
                        {
                            #region ��ӳɹ���������ͬ��
                            try
                            {
                                string strSql = "PT_LoadWeight '" + model.WeightCode + "','" + model.TrafficCode + "','" + model.NavicertCode + "','" + model.MarkedCardCode + "','" + model.RemoteCardCode + "',"
                     + "'" + model.CollCode + "','" + model.CollName + "','" + model.CoalKindCode + "','" + model.CoalKindName + "','" + model.CarOwnerName + "',"
                     + "'" + model.CarNo + "','" + model.CarType + "','" + model.LoadWeight + "','" + model.EmptyWeight + "','" + model.NetWeight + "',"
                     + "'" + model.OverWeight + "','" + model.RoomCode + "','" + model.RoomName + "','" + model.BangType + "','" + model.Operator + "',"
                     + "'" + model.WeightTime + "','" + model.RandomCode + "','" + model.CustomerName + "','" + model.TaxType + "','" + model.TaxObject + "',"
                     + "'" + model.IsFirstSite + "','" + model.FrontImage + "','" + model.BackImage + "','" + model.UpImage + "','" + model.RoomImage + "',"
                     + "'" + model.FrontImageContent + "','" + model.BackImageContent + "','" + model.UpImageContent + "','" + model.RoomImageContent + "','" + model.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);

                                /********************************************************/
                                //Add By ����ӭ ��BSʵʱ��ط�������Ϣ���з����س�������Ϣ
                                /********************************************************/
                                string loadMessage = model.RoomName + "," + model.CarOwnerName + "," + model.CoalKindName + "," + model.NavicertCode + "," + model.NetWeight.ToString() + "," + model.WeightTime.ToString();//������Ϣ��ʽ����������,����������ú������,׼�˿��ţ�ú̿���أ�����ʱ��
                                RealTimeMonitor monitor = new RealTimeMonitor();//������Ϣ
                                monitor.SendEmptyWeightMessage(loadMessage);
                                /********************************************************/

                            }
                            catch { }
                            #endregion

                            string strErro = "";
                            if (strIsHaveMarkedCard == "1")
                            {
                                strErro = "�����ձ�ʶ��";
                            }
                            alarmSound.Alarm("�����ɹ�,���ȷ����ӡ�س�������" + strErro + "");
                            CommonMethod.MessageBox("�����ɹ�,���ȷ����ӡ�س�������" + strErro + "!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            new CoalTraffic.Report.LoadWeightPrint(strWeightCode, true).ShowDialog();
                        }
                        else
                        {
                            this.alarmSound.Alarm("��վ�����ݿ��쳣");
                            InsertState = 0;
                            InsertBadReCordInfo("�쳣", txtCarNo.Text.Trim(), ini.IniReadValue("RoomSetting", "RoomName") + "�����ݿ��쳣");
                        }

                    }
                    else if (strLeastValue == "1")
                    {
                        alarmSound.Alarm("ú������������,���ܼ�������");
                    }
                    else if (strLeastValue == "2")
                    {
                        alarmSound.Alarm("��ú��������ú��,���ܼ�������");
                        InsertState = 0;
                        InsertBadReCordInfo("�쳣", txtCarNo.Text.Trim(), strCollName + "������" + strCoalKindName);
                    }
                    else if (strLeastValue == "-1")
                    {
                        alarmSound.Alarm("��ú�󲻴���,���ܼ�������");
                        InsertState = 0;
                        InsertBadReCordInfo("�쳣", txtCarNo.Text.Trim(), "���Ϊ��" + strCollCode + "��ú�󲻴���");
                    }

                    btnOK.Enabled = false;
                    ClearAll();
                    if (strCard == "IC")
                        icCard.FactoryCodeInitValue = "";
                }
                else
                {
                    alarmSound.Alarm("ú̿�����쳣");
                    InsertState = 0;
                    InsertBadReCordInfo("�쳣", txtCarNo.Text.Trim(), "���ƺ�Ϊ��" + txtCarNo.Text.Trim() + "������ú̿�����쳣");
                }
            }
            else
            {
                alarmSound.Alarm("��ѡ���ջ���λ");
            }
        }