Example #1
0
 public bool LoadUserConfigurationFile()
 {
     try
     {
         mSingletonConfiguration = (UserConfiguration)MiscFunction.GetInstance().DeSerializeBinaryFile(MiscFunction.GetInstance().GetAssemblyPath() + mConfigurationFilePath);
         mSingletonConfiguration.ConfigurationFilePath = mConfigurationFilePath;
         return(true);
     }
     catch (System.Exception ex)
     {
         CreateDefualtUserConfigurationFile();
         System.Console.Out.WriteLine(ex.Message);
         return(false);
     }
 }
Example #2
0
        public FormChipDetection(bool isResetConfiguration)
        {
            mIsResetConfiguration = isResetConfiguration;
            InitializeComponent();

            Parameter.GetInstance().LoadOptionFile();
            mConfiguration = new Configuration(isResetConfiguration);

            if (isResetConfiguration)
            {
                UserConfiguration.GetInstance().CreateDefualtUserConfigurationFile();
            }
            else
            {
                UserConfiguration.GetInstance().LoadUserConfigurationFile();
            }
            mChipDetection = new ChipDetection();

            Parameter.GetInstance().WidthRatio  = ((double)Parameter.GetInstance().WidthPixels) / picImage.Width;
            Parameter.GetInstance().HeightRatio = ((double)Parameter.GetInstance().HeightPixels) / picImage.Height;

            lblMark.BackColor = Color.Transparent;
            Form.CheckForIllegalCrossThreadCalls = false;

            picImage.Paint += new PaintEventHandler(PicImage_Paint);

            InitializeTimers();
            //UserLogin(false);

            m_grabThreadExited = new AutoResetEvent(false);
            CAM_connect();

            //mCom_ = new SerialPort();
            //mCom_Open();

            ResetTestStatus();

            lblStatusIndicator.Text = "初始化完成";
        }
Example #3
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                //this.DialogResult = DialogResult.Cancel;
                string userName = txtUserName.Text.Trim();
                if (string.IsNullOrEmpty(userName))
                {
                    txtUserName.Focus();
                    txtUserName.SelectAll();

                    MessageBox.Show("用户名不能为空!", "错误");
                    return;
                }
                //string oldPassword = txtOldPassword.Text.Trim();
                string newPassword = txtNewPassword.Text.Trim();

                //if (oldPassword.Length!=6)
                //{
                //    txtOldPassword.Focus();
                //    txtOldPassword.SelectAll();
                //    MessageBox.Show(mResources.GetString("txtPasswordLengthError"), mResources.GetString("error"));
                //    return;
                //}
                if (newPassword.Length != 6)
                {
                    txtNewPassword.Focus();
                    txtNewPassword.SelectAll();
                    MessageBox.Show("密码长度应为6位!", "错误");
                    return;
                }
                if (!UserConfiguration.GetInstance().User.ContainsKey(userName))
                {
                    mUserAuthority = new UserAuthority(userName, newPassword, (UserType)cmbUserType.SelectedIndex);
                    UserConfiguration.GetInstance().User.Add(mUserAuthority.Name, mUserAuthority);
                    //if (oldPassword.Equals(userAuthority.Password))
                    {
                        //userAuthority.Set(userName,newPassword,userAuthority.UserType);
                        //mUserConfiguration.SaveConfigurationFile();
                        //MessageBox.Show(mResources.GetString("txtChangePasswordSuccess"), mResources.GetString("hint"));
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }

                    //else
                    //{
                    //    txtOldPassword.Focus();
                    //    txtOldPassword.SelectAll();

                    //    MessageBox.Show(mResources.GetString("txtWrongPassword"), mResources.GetString("error"));

                    //}
                }
                else
                {
                    txtUserName.Focus();
                    txtUserName.SelectAll();
                    MessageBox.Show("用户名错误!", "错误");
                    return;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "错误");
            }
        }
Example #4
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                int myrow;
                for (int row = 0; row < usrGrid.Rows.Count - 1; row++)
                {
                    if (usrGrid.Rows[row].Cells[0].Value == null)
                    {
                        myrow = row + 1;
                        MessageBox.Show("第" + myrow.ToString() + "行输入的用户名为空,请重新输入!", "错误");
                        usrGrid.Rows[row].Selected = true;
                        return;
                    }
                    if (usrGrid.Rows[row].Cells[1].Value == null)
                    {
                        myrow = row + 1;
                        MessageBox.Show("第" + myrow.ToString() + "行输入的密码为空,请重新输入!", "错误");
                        usrGrid.Rows[row].Selected = true;
                        return;
                    }
                    if (usrGrid.Rows[row].Cells[2].Value == null)
                    {
                        myrow = row + 1;
                        MessageBox.Show("第" + myrow.ToString() + "行用户类型为空,请重新输入!", "错误");
                        usrGrid.Rows[row].Selected = true;
                        return;
                    }

                    string password = usrGrid.Rows[row].Cells[1].Value.ToString();
                    if (password.Length != 6)
                    {
                        myrow = row + 1;
                        MessageBox.Show("第" + myrow.ToString() + "行输入的密码长度必须会6位,请重新输入!", "错误");
                        usrGrid.Rows[row].Selected = true;
                        return;
                    }
                    string strusrname = usrGrid.Rows[row].Cells[0].Value.ToString();
                    strusrname.Trim();

                    for (int i = 0; i < row; i++)
                    {
                        string prename = usrGrid.Rows[i].Cells[0].Value.ToString();
                        if (prename.Trim().Equals(strusrname))
                        {
                            myrow = row + 1;
                            MessageBox.Show("第" + myrow.ToString() + "行输入的用户名已存在,请重新输入!", "错误");
                            usrGrid.Rows[row].Selected = true;
                            return;
                        }
                    }
                }

                UserConfiguration.GetInstance().User.Clear();
                for (int row = 0; row < usrGrid.Rows.Count - 1; row++)
                {
                    string        name     = usrGrid.Rows[row].Cells[0].Value.ToString();
                    string        password = usrGrid.Rows[row].Cells[1].Value.ToString();
                    UserType      type     = usrGrid.Rows[row].Cells[2].Value.ToString().Equals("管理员") ? UserType.Administrator : UserType.Operator;
                    UserAuthority user     = new UserAuthority(name, password, type);
                    user.Remark = "";
                    if (usrGrid.Rows[row].Cells[3].Value != null)
                    {
                        user.Remark = usrGrid.Rows[row].Cells[3].Value.ToString();
                    }
                    UserConfiguration.GetInstance().User.Add(user.Name, user);
                }
                UserConfiguration.GetInstance().SaveConfigurationFile();
                MessageBox.Show("保存用户权限成功!", "提示");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "错误");
            }
        }