private void LoginForm_Load(object sender, EventArgs e)
        {
            ////打开电源
            //HTApi.WIrUHFOpenPower();
            //HTApi.WIrUHFConnect(2);
            Scanner.openUHF();

            //最大化
            this.WindowState = FormWindowState.Maximized;

            //wince下不支持相对路径
            sCodePath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
            sCodePath = sCodePath.Substring(0, sCodePath.LastIndexOf(@"\"));
            //SQLite DB路径
            string sdbFilename = LoginForm.sCodePath + "\\gvdb.db";
            SQLiteHelper.connectionString = "Data Source=" + sdbFilename;

            SettingForm.LoadSetting();

            textBoxUser.Text = SettingForm.sUser;
            textBoxPass.Text = SettingForm.sPass;

            if (textBoxPass.Text.Length != 0)
            {
                checkBoxStorePass.Checked = true;
            }

            if (SettingForm.sClientId.Equals("PC") || SettingForm.sClientId.Length == 0)
            {
                SettingForm.sClientId = "";
                MessageBox.Show("初次使用,请设置客户端ID!\r\n注:请勿与其他手持机重复,否则会发生同步错误!");
                SettingForm dlg = new SettingForm();
                dlg.ShowDialog();
                //初始化同步
                MainForm f = new MainForm(this);
                f.bIsFirstIni = true;
                f.ShowDialog();

            }
            //setting.Load(sCodePath + "\\setting.xml");
            //IniFile f = new IniFile();
            //textBoxIp.Text = f.sIP;
            //textBoxPort.Text = f.sPort;
            //setting = ;
        }
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            buttonLogin.Enabled = false;
            buttonLogin.Update();
            labelHit.Visible = true;
            labelHit.Update();
            if (textBoxUser.Text.Length == 0 || textBoxPass.Text.Length == 0)
            {
                MessageBox.Show("账号或密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                buttonLogin.Enabled = true;
                labelHit.Visible = false;
                return;
            }
            //SQLite方式
            string sSql = "select * from user where user_no = \'" + textBoxUser.Text + "\'";
            SQLiteDataReader reader = SQLiteHelper.ExecuteReader(sSql, null);
            string sPass = "";
            string sStat = "";
            if (reader.Read())
            {
                sPass = reader["pass"].ToString();
                sUserName = reader["user_nam"].ToString();
                sStat = reader["stat"].ToString();
            }
            reader.Close();
            if (!bLogin)
            {
                if (sPass.Equals(textBoxPass.Text))
                {
                    if (!sStat.Equals("0"))
                    {
                        bLogin = true;
                        buttonLogin.Text = "注销(Ent)";
                        textBoxUser.Visible = false;
                        textBoxPass.Visible = false;
                        checkBoxStorePass.Visible = false;
                        label2.Visible = false;
                        label1.Text = textBoxUser.Text + @"
            " + sUserName + " " + sRole + @"
            " + SettingForm.sCompany + @"
            欢迎使用!";
                        buttonStart.Visible = true;

                        if (checkBoxStorePass.Checked)
                        {
                            sSql = string.Format("update sys_parms set  parm_nam = '{0}',parm_val = '{1}' where parm_id = 'store_accont'", textBoxUser.Text, sPass);
                            SQLiteHelper.ExecuteNonQuery(sSql, null);
                            SettingForm.sUser = textBoxUser.Text;
                            SettingForm.sPass = textBoxPass.Text;
                        }
                        else
                        {
                            sSql = string.Format("update sys_parms set  parm_nam = '{0}',parm_val = '{1}' where parm_id = 'store_accont'", textBoxUser.Text, "");
                            SQLiteHelper.ExecuteNonQuery(sSql, null);
                            SettingForm.sUser = textBoxUser.Text;
                            SettingForm.sPass = "";
                            textBoxPass.Text = "";
                        }

                        MainForm dlg = new MainForm(this);
                        dlg.ShowDialog();
                       // nRet = 1;
                       // this.Close();

                    }
                    else
                    {
                        MessageBox.Show("账号无效!");
                    }

                }
                else
                {
                    MessageBox.Show("账号或密码有误!");
                }
            }
            else
            {
                buttonStart.Visible = false;
                bLogin = false;
                buttonLogin.Text = "登陆(Ent)";
                textBoxUser.Visible = true;
                textBoxPass.Visible = true;
                buttonLogin.Visible = true;
                label1.Text = @"账号:";
                label2.Visible = true;
                checkBoxStorePass.Visible = true;
            }
            buttonLogin.Enabled = true;
            labelHit.Visible = false;
        }
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (bLogin)
            {

                buttonStart.Enabled = false;
                buttonStart.Update();
                labelHit.Visible = true;
                labelHit.Update();
                MainForm dlg = new MainForm(this);
                dlg.ShowDialog();
                buttonStart.Enabled = true;
                labelHit.Visible = false;
            }
        }