public OutWeight()
        {
            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
            }
            else
            {
                this.Height = this.Height - splitContainer1.Panel1.Height + 50;

                splitContainer1.Panel1Collapsed = true;

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

            //-----------------磅秤显示设置-----------------
            #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");

                    IMsState = this.appearance.Initialize(strComName, IComBaudRate, iDataBits, strStopBits);

                    if (IMsState == 0)
                    {
                        alSound.Alarm("磅秤仪表故障");
                    }
                    else
                    {
                        appearance.SetUIValue += new EventHandler(SetUIMsCom);
                    }
                }
                else
                {
                    alSound.Alarm("磅秤仪表波特率或者数据位错误");
                }
            }
            else
            {
                bangcommclass = new BangCommClass(StaticParameter.BangBaudRate, StaticParameter.BangDateBits,
                        StaticParameter.BangStopBits, StaticParameter.BangParity, StaticParameter.BangPortName);
                bangcommclass.alarmSound = alSound;
                bangcommclass.RecLab = lblDigital;
                bangcommclass.OpenCommPort();
            }
            #endregion
            //----------------------------------------------

            //-----------------IC卡初始化设置---------------------
            #region IC卡初始化设置
            commclass = new CommClassTemp(StaticParameter.BaudRate, StaticParameter.DateBits,
               StaticParameter.StopBits, StaticParameter.Parity, StaticParameter.PortName);
            commclass.RecInvTxt = TemptextBox;
            commclass.alarmSound = alSound;
            commclass.OpenCommPort();
            //if (InRadBut.Checked)
            InWeightTxt.Text = "0.00";
            /*--------
            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)
                   {
                       alSound.Alarm("IC卡读卡器故障");
                   }
                   else
                   {
                       ICCard.SetUIValue += new EventHandler(SetUIICCard);
                       int i = 0;
                       ICCard.ReadBlockData(1, ref i);
                   }
               }
               else
               {
                   alSound.Alarm("IC卡读卡器端口号或者波特率错误");
               }
            }
             * */
            #endregion
            //----------------------------------------------------

            SetRights();
        }
        /// <summary>
        /// ��ʼ������
        /// </summary>
        void InitPound()
        {
            #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)
                            {
                                strRoomName = ini.IniReadValue("RoomSetting", "RoomName");
                                alarmSound.Alarm("�����DZ����");
                                InsertBadReCordInfo("Ӳ���쳣", "", strRoomName + "�İ����DZ�����쳣");
                            }
                            else
                                System.Threading.Thread.Sleep(500);
                        }
                        else
                        {
                            appearance.SetUIValue += new EventHandler(SetUIMsCom);
                            break;
                        }

                    }
                }
                else
                {
                    alarmSound.Alarm("�����DZ�����ʻ�������λ��ʽ����ȷ");
                }
            }//��Ҵ�����
            else
            {
                bangcommclass = new BangCommClass(StaticParameter.BangBaudRate, StaticParameter.BangDateBits,
                            StaticParameter.BangStopBits, StaticParameter.BangParity, StaticParameter.BangPortName);
                bangcommclass.alarmSound = blarmSound;
                bangcommclass.RecLab = lblDigital;
                bangcommclass.OpenCommPort();

            }
            #endregion

            #region
            //string IsNorBang = ini.IniReadValue("BcComSetting", "IsNorBang");
            //if (IsNorBang == "2")
            //{
            //    string strCom = ini.IniReadValue("BcComSetting", "PortName");
            //    int iBaud, iDataBits;
            //    if (int.TryParse(ini.IniReadValue("BcComSetting", "BoudRate"), out iBaud) && int.TryParse(ini.IniReadValue("BcComSetting", "DataBits"), out iDataBits))
            //    {
            //        string strStopBits = ini.IniReadValue("BcComSetting", "StopBits");
            //        short iTimes = 1;
            //        while (iTimes <= 3)
            //        {
            //            IMsState = this.appearance.Initialize(strCom, iBaud, iDataBits, strStopBits);
            //            if (IMsState == 0)
            //            {
            //                iTimes += 1;
            //                if (iTimes == 3)
            //                {
            //                    alarmSound.Alarm("�����DZ����");
            //                    strRoomName = ini.IniReadValue("RoomSetting", "RoomName");
            //                    InsertBadReCordInfo("Ӳ���쳣", "", strRoomName + "�İ����DZ�����쳣");
            //                }
            //                else
            //                    System.Threading.Thread.Sleep(500);
            //            }
            //            else
            //            {
            //                //this.appearance.SetUIValue = (EventHandler)Delegate.Combine(this.appearance.SetUIValue, new EventHandler(this.SetUIPound));

            //                appearance.SetUIValue += new EventHandler(SetUIPound);
            //                break;
            //            }
            //        }
            //    }
            //    else
            //    {
            //        alarmSound.Alarm("�����DZ�����ʻ�������λ����");
            //    }
            //}
            //else//��Ҵ�����
            //{
            //    bangcommclass = new BangCommClass(StaticParameter.BangBaudRate, StaticParameter.BangDateBits,
            //       StaticParameter.BangStopBits, StaticParameter.BangParity, StaticParameter.BangPortName);
            //    bangcommclass.alarmSound = blarmSound;
            //    bangcommclass.RecLab = lblDigital;
            //    bangcommclass.OpenCommPort();
            //}
            #endregion
        }
        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();
        }
        /// <summary>
        /// �������
        /// </summary>
        void InitPound()
        {
            #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)
                            {
                                alarmSound.Alarm("�����DZ����");
                                MessageBox.Show("�����DZ����", "������", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                InsertBadReCordInfo("Ӳ���쳣", "", strRoomName + "�İ����DZ�����쳣");
                            }
                            else
                                System.Threading.Thread.Sleep(500);
                        }
                        else
                        {
                            appearance.SetUIValue += new EventHandler(SetUIMsCom);
                            break;
                        }
                    }
                }
                else
                {
                    alarmSound.Alarm("�����DZ�����ʻ�������λ��ʽ����ȷ");
                    MessageBox.Show("�����DZ�����ʻ�������λ��ʽ����ȷ", "������", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }//��Ҵ�����
            else
            {
                bangcommclass = new BangCommClass(CoalTraffic.DBUtility.StaticParameter.BangBaudRate, CoalTraffic.DBUtility.StaticParameter.BangDateBits,
                            CoalTraffic.DBUtility.StaticParameter.BangStopBits, CoalTraffic.DBUtility.StaticParameter.BangParity, CoalTraffic.DBUtility.StaticParameter.BangPortName);
                bangcommclass.alarmSound = blarmSound;
                bangcommclass.RecLab = lblDigital;
                bangcommclass.OpenCommPort();

            }
            #endregion
        }