public MarkedCardInitialize()
        {
            InitializeComponent();
            strBaudRate = ini.IniReadValue("IcCard", "BoudRate");
            strDataBits = ini.IniReadValue("IcCard", "DataBits");
            strStopBits = ini.IniReadValue("IcCard", "StopBits");
            strParity = ini.IniReadValue("IcCard", "Parity");
            strPortName = ini.IniReadValue("IcCard", "PortName");
            commclass = new CoalTraffic.DBUtility.CommClassSimple(strBaudRate, strDataBits, strStopBits, strParity, strPortName);
            commclass.RecTxt = txtMarkedCode;
            commclass.alarmSound = alarmSound;
            try
            {
                commclass.OpenCommPort();
            }
            catch (Exception ex)
            {

                MessageBox.Show("请检查您的读卡器是否安装正确,并检查读卡器驱动!","天大天科",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }

            iLen = Convert.ToInt32(ini.IniReadValue("IcCard", "CardNoLength"));
            this.txtEditTime.Text = DateTime.Now.ToString();
            this.txtOperator.Text = StaticParameter.UserName;
        }
        /// <summary>
        /// 窗体构造函数
        /// </summary>
        public CardInitialize()
        {
            InitializeComponent();
            #region 读卡器进行配置
            strBaudRate = ini.IniReadValue("IcCard", "BoudRate");
            strDataBits = ini.IniReadValue("IcCard", "DataBits");
            strStopBits = ini.IniReadValue("IcCard", "StopBits");
            strParity = ini.IniReadValue("IcCard", "Parity");
            strPortName = ini.IniReadValue("IcCard", "PortName");
            #endregion
            commclass = new CoalTraffic.DBUtility.CommClassSimple(strBaudRate, strDataBits, strStopBits, strParity, strPortName);
            commclass.RecTxt = txtMarkedCode;
            commclass.alarmSound = alarmSound;
            commclass.OpenCommPort();

            iLen = Convert.ToInt32(ini.IniReadValue("IcCard", "CardNoLength"));
            this.txtEditTime.Text = DateTime.Now.ToString();
            this.txtOperator.Text = StaticParameter.UserName;
        }
        public LoadWeight()
        {
            InitializeComponent();

            #region ��������
            if (ini.IniReadValue("CardType", "IC") == "IC")
            {
                commclass = new CommClassSimple(StaticParameter.BaudRate, StaticParameter.DateBits,
               StaticParameter.StopBits, StaticParameter.Parity, StaticParameter.PortName);
                commclass.RecTxt = TxtTempCardID;
                commclass.alarmSound = alarmSound;
                if (commclass.OpenCommPort())
                    this.lblICCardInit.Text = "�������������";
                else
                    this.lblICCardInit.Text = "���������ʧ��";
            }

            #endregion

            #region ���ش��屳��

            string strBgImage = string.Empty;
            if (StaticParameter.FormType == "1")
            {
                strBgImage = "rbg.jpg";
            }
            else
            {
                strBgImage = "cbg.jpg";
            }
            this.BackgroundImage = Image.FromFile(StaticParameter.Skin + strBgImage);
            this.BackgroundImageLayout = ImageLayout.Stretch;
            #endregion

            #region �ж�������Ƶ
            if (StaticParameter.IsVideo == "1")
            {
                #region ��Ƶ��ʼ��
                string strVideoIp = ini.IniReadValue("VideoSetting", "VideoIP");

                string strVideoName = CommonMethod.DecryptDES(ini.IniReadValue("VideoSetting", "VideoName"), "EncryDes");
                string strVideoPWd = CommonMethod.DecryptDES(ini.IniReadValue("VideoSetting", "VideoPWd"), "EncryDes");
                string strVideoSave = "\\CheckWeightPic\\";//Application.StartupPath +

                int iForntChannel, iBackChannel, iUpChannel, iRoomChannel;

                int.TryParse(ini.IniReadValue("VideoSetting", "CarFrontChannel"), out iForntChannel);
                int.TryParse(ini.IniReadValue("VideoSetting", "CarBackChannel"), out iBackChannel);
                int.TryParse(ini.IniReadValue("VideoSetting", "CarUpChannel"), out iUpChannel);
                int.TryParse(ini.IniReadValue("VideoSetting", "RoomChannel"), out iRoomChannel);

                videoFrontImage.Initialize(strVideoIp, iForntChannel, strVideoName, strVideoPWd, strVideoSave + "FrontImage.jpg");
                videoBackImage.Initialize(strVideoIp, iBackChannel, strVideoName, strVideoPWd, strVideoSave + "BackImage.jpg");
                videoUpImage.Initialize(strVideoIp, iUpChannel, strVideoName, strVideoPWd, strVideoSave + "UpImage.jpg");
                videoRoomImage.Initialize(strVideoIp, iRoomChannel, strVideoName, strVideoPWd, strVideoSave + "RoomImage.jpg");
                videoFrontImage.Amplify = int.Parse(StaticParameter.Amplify);
                videoBackImage.Amplify = int.Parse(StaticParameter.Amplify);
                videoRoomImage.Amplify = int.Parse(StaticParameter.Amplify);
                videoUpImage.Amplify = int.Parse(StaticParameter.Amplify);
                #endregion

                this.Height = this.Height + 20;
            }
            else
            {
                this.Height = this.Height - spCLoadWeight.Panel1.Height + 10;
                int iLastHeight = splitContainer1.Panel1.Height;
                this.spCLoadWeight.Height -= spCLoadWeight.Panel1.Height;
                spCLoadWeight.Panel1Collapsed = true;

                int x = 0, y = 348;
                this.splitContainer1.Location = new Point(x, y - iLastHeight);
            }
            #endregion

            InitPound();//��ʼ������
            InitRemoteCard();
            SetRights();//����Ȩ��
            textBox2.Select();//׼�˿�ˢ���������ؿ��ý���
        }
        public CheckBang()
        {
            InitializeComponent();

            #region 加载窗体背景
            this.BackgroundImage = Image.FromFile(StaticParameter.Skin + "cbg.jpg");
            this.BackgroundImageLayout = ImageLayout.Stretch;
            #endregion

            //-------------------视频初始化设置------------------
            #region 判断有无视频
            if (StaticParameter.IsVideo == "1")
            {
                #region 视频初始化
                string strVideoIp = ini.IniReadValue("VideoSetting", "VideoIP");
                string strVideoName = CommonMethod.DecryptDES(ini.IniReadValue("VideoSetting", "VideoName"), "EncryDes");
                string strVideoPWd = CommonMethod.DecryptDES(ini.IniReadValue("VideoSetting", "VideoPWd"), "EncryDes");
                string strVideoSave = "\\CheckWeightPic\\";//Application.StartupPath +

                int iForntChannel, iBackChannel, iUpChannel, iRoomChannel;

                int.TryParse(ini.IniReadValue("VideoSetting", "CarFrontChannel"), out iForntChannel);
                int.TryParse(ini.IniReadValue("VideoSetting", "CarBackChannel"), out iBackChannel);
                int.TryParse(ini.IniReadValue("VideoSetting", "CarUpChannel"), out iUpChannel);
                int.TryParse(ini.IniReadValue("VideoSetting", "RoomChannel"), out iRoomChannel);

                videoFrontImage.Initialize(strVideoIp, iForntChannel, strVideoName, strVideoPWd, strVideoSave + "FrontImage.jpg");
                videoBackImage.Initialize(strVideoIp, iBackChannel, strVideoName, strVideoPWd, strVideoSave + "BackImage.jpg");
                videoUpImage.Initialize(strVideoIp, iUpChannel, strVideoName, strVideoPWd, strVideoSave + "UpImage.jpg");
                videoRoomImage.Initialize(strVideoIp, iRoomChannel, strVideoName, strVideoPWd, strVideoSave + "RoomImage.jpg");
                videoFrontImage.Amplify = int.Parse(StaticParameter.Amplify);
                videoBackImage.Amplify = int.Parse(StaticParameter.Amplify);
                videoRoomImage.Amplify = int.Parse(StaticParameter.Amplify);
                videoUpImage.Amplify = int.Parse(StaticParameter.Amplify);
                #endregion

                this.Height = this.Height + 20;
            }
            else
            {
                this.Height = this.Height - splitContainer1.Panel1.Height + 10;
                int iLastHeight = splitContainer1.Panel1.Height;
                this.splitContainer1.Height = this.splitContainer1.Height - this.splitContainer1.Panel1.Height;
                splitContainer1.Panel1Collapsed = true;

                int x = 0, y = 340;
                this.splitContainer2.Location = new Point(x, y - iLastHeight);
            }
            #endregion
            //---------------------------------------------------

            strRoomName = ini.IniReadValue("RoomSetting", "RoomName");

            //-----------------磅秤显示设置-----------------
            #region 磅秤显示设置
            string IsNorBang = ini.IniReadValue("BcComSetting", "IsNorBang");
            if (IsNorBang == "2")
            {
                string strComName = ini.IniReadValue("BcComSetting", "COM");
                int IComBaudRate, iDataBits;
                if (int.TryParse(ini.IniReadValue("BcComSetting", "BoudRate"), out IComBaudRate) && int.TryParse(ini.IniReadValue("BcComSetting", "DataBits"), out iDataBits))
                {
                    string strStopBits = ini.IniReadValue("BcComSetting", "StopBits");
                    this.dValveWeight = Convert.ToDouble(ini.IniReadValue("RoomSetting", "ValveWeight"));
                    short iTimes = 1;
                    while (iTimes <= 3)
                    {
                        IMsState = Appearance.Initialize(strComName, IComBaudRate, iDataBits, strStopBits);
                        if (IMsState == 0)
                        {
                            iTimes += 1;
                            if (iTimes == 3)
                            {
                                aSound.Alarm("磅秤仪表故障");
                                InsertBadReCordInfo("硬件异常", "", strRoomName + "的磅秤仪表启动异常");
                            }
                            else
                                System.Threading.Thread.Sleep(500);
                        }
                        else
                        {
                            Appearance.SetUIValue += new EventHandler(SetUIMsCom);
                            break;
                        }
                    }
                }
                else
                {
                    aSound.Alarm("磅秤仪表波特率或者数据位格式不正确");
                }
            }//李家川磅房
            else
            {
                bangcommclass = new BangCommClass(StaticParameter.BangBaudRate, StaticParameter.BangDateBits,
                            StaticParameter.BangStopBits, StaticParameter.BangParity, StaticParameter.BangPortName);
                bangcommclass.alarmSound = bSound;
                bangcommclass.RecLab = lblDigital;
                bangcommclass.OpenCommPort();

            }
            #endregion
            //----------------------------------------------

            //-----------------电子标签设置----------------------
            #region 电子标签设置
            if (StaticParameter.IsRemoteReader == "1")
            {
                this.lblRemoteCode.Text = strRemoteCode;
                string strRemoteCom = ini.IniReadValue("ReMote", "COM");
                string IRemoteBaud = ini.IniReadValue("ReMote", "Boud");

                ////////////////////////////////////////////
                //short iRemoteState = spRemote.Initialize(strRemoteCom, IRemoteBaud);

                //if (iRemoteState != 0)
                //{
                //    aSound.Alarm("电子标签故障");
                //}
                //else
                //{
                //    spRemote.SetUIValue += new EventHandler(SetUISpRemote);
                //}
                short iTimes = 1;
                while (iTimes <= 3)
                {
                    short i = this.spRemote.Initialize(strRemoteCom, IRemoteBaud);
                    if (i != 0)
                    {
                        iTimes += 1;
                        if (iTimes == 3)
                        {
                            //InsertBadReCordInfo("非法卡", "", "卡号为:" + strCardCode + "的准运卡是非法卡");
                            aSound.Alarm("电子标签故障");
                            InsertBadReCordInfo("硬件异常", "", strRoomName + "的电子标签启动异常");
                        }
                        else
                            //等上500毫秒。
                            System.Threading.Thread.Sleep(500);
                    }
                    else
                    {
                        this.spRemote.SetUIValue += new EventHandler(SetUISpRemote);
                        break;
                    }
                }

            }
            else
            {
                this.Height = this.Height - this.splitContainer2.Panel1.Height;
                this.splitContainer2.Height = this.splitContainer2.Height - this.splitContainer2.Panel1.Height;
                this.splitContainer2.Panel1Collapsed = true;
            }

            //this.dgvRemotes.AutoGenerateColumns = false;
            //this.dgvRemotes.DataSource = GetRemoteInfo();
            #endregion
            //---------------------------------------------------

            //-----------------IC卡初始化设置---------------------
            #region IC卡初始化设置

            commclass = new CommClassSimple(StaticParameter.BaudRate, StaticParameter.DateBits,
                StaticParameter.StopBits, StaticParameter.Parity, StaticParameter.PortName);
            commclass.RecTxt = TempTxtCardID;
            commclass.alarmSound = aSound;
            commclass.OpenCommPort();

            /*----------------------------------
            if (StaticParameter.CardType == "IC")
            {
                int iICCom,IICBoudRate;

                if (int.TryParse(ini.IniReadValue("IcCard", "COM"), out iICCom) && int.TryParse(ini.IniReadValue("IcCard", "BoudRate"), out IICBoudRate))
                {
                    string strPasswordA = CommonMethod.DecryptDES(ini.IniReadValue("IcCard", "PasswordA"), "EncryDes");
                    string strPasswordB = CommonMethod.DecryptDES(ini.IniReadValue("IcCard", "PasswordB"), "EncryDes");
                    int IICCardState = ICCard.Initialize(iICCom, IICBoudRate, strPasswordA, strPasswordB, StaticParameter.NavicertLength);

                    if (IICCardState == 0)
                    {
                        aSound.Alarm("IC卡读卡器故障");
                    }
                    else
                    {
                        ICCard.SetUIValue += new EventHandler(SetUIICCard);
                        int i = 0;
                        ICCard.ReadBlockData(1, ref i);

                        this.txtNavicertCode.Focus();
                    }
                }
                else
                {
                    aSound.Alarm("IC卡读卡器端口或者波特率格式不正确");
                }
            }
            else
            {
                string strNavicertsql = "select top 1 BusinName from Sys_Dictionary where BusinTypeID ='1017' and BusinID='2' and IsForBid ='0' order by BusinName desc";

                dNavicert = decimal.Parse(DbHelperSQL.GetSingle(strNavicertsql).ToString());

                string strMarkedCardsql = "select top 1 BusinName from Sys_Dictionary where BusinTypeID ='1017' and BusinID='1' and IsForBid ='0' order by BusinName desc";

                dMarkedCard = decimal.Parse(DbHelperSQL.GetSingle(strMarkedCardsql).ToString());
                txtIDCard.Focus();
            }  //----------------------------------------------------

            -------------------------*/
            #endregion

            SetRights();
        }
        //MSMQClient MC = new MSMQClient();
        //MSMQserver mqServer = new MSMQserver();
        public ValidateRemoteCard()
        {
            InitializeComponent();

            #region 加载窗体背景
            if (StaticParameter.FormType == "1")
            {
                this.BackgroundImage = Image.FromFile(StaticParameter.Skin + "rbg.jpg");
            }
            else
            {
                this.BackgroundImage = Image.FromFile(StaticParameter.Skin + "cbg.jpg");
            }
            this.BackgroundImageLayout = ImageLayout.Stretch;
            #endregion

            //-----------------电子标签设置----------------------
            #region 电子标签设置
            if (StaticParameter.IsRemoteReader == "1")
            {
                string strRemoteCom = ini.IniReadValue("ReMote", "COM");
                string IRemoteBaud = ini.IniReadValue("ReMote", "Boud");

                short IRemoteState = spRemote.Initialize(strRemoteCom, IRemoteBaud);

                if (IRemoteState != 0)
                {
                    alSound.Alarm("电子标签故障");
                }
                else
                {
                    spRemote.SetUIValue += new EventHandler(SetUISpRemote);
                }
            }
            #endregion
            //---------------------------------------------------

            //-----------------IC卡初始化设置---------------------
            #region IC卡初始化设置
            //int iICCom,IICBoudRate;

            //if (int.TryParse(ini.IniReadValue("IcCard", "COM"), out iICCom) && int.TryParse(ini.IniReadValue("IcCard", "BoudRate"),out IICBoudRate))
            //{
            //    string strPasswordA = CommonMethod.DecryptDES(ini.IniReadValue("IcCard", "PasswordA"), "EncryDes");
            //    string strPasswordB = CommonMethod.DecryptDES(ini.IniReadValue("IcCard", "PasswordB"), "EncryDes");

            //    int IICCardState = ICCard.Initialize(iICCom, IICBoudRate, strPasswordA, strPasswordB, StaticParameter.NavicertLength);

            //    if (IICCardState == 0)
            //    {
            //        alSound.Alarm("IC卡读卡器故障");
            //    }
            //    else
            //    {
            //        ICCard.SetUIValue += new EventHandler(SetUIICCard);
            //        int i = 0;
            //        ICCard.ReadBlockData(1, ref i);
            //    }
            //}
            //else
            //{
            //    alSound.Alarm("IC卡读卡器端口或者波特率格式不正确");
            //}
            #endregion
            //----------------------------------------------------
            commclass = new CommClassSimple(CoalTraffic.DBUtility.StaticParameter.BaudRate, CoalTraffic.DBUtility.StaticParameter.DateBits,
              CoalTraffic.DBUtility.StaticParameter.StopBits, CoalTraffic.DBUtility.StaticParameter.Parity, CoalTraffic.DBUtility.StaticParameter.PortName);
            commclass.RecTxt = txtNavicertCard;
            commclass.alarmSound = alSound;
            if (commclass.OpenCommPort())
                this.lblICCardInit.Text = "读卡器启动正常";
            else
                this.lblICCardInit.Text = "读卡器启动失败";
        }