Example #1
0
 private void btnModification_Click(object sender, EventArgs e)
 {
     if (btnModification.Text == "修改")
     {
         label3.Show();
         txtNewPassword.Show();
         btnModification.Text = "确认";
     }
     else
     {
         password = GClsConfigFile.ReadConfig("config.ini", "user", "password", "1");
         if (txtPassword.Text == password)
         {
             GClsConfigFile.WriteConfig("config.ini", "user", "name", txtUserName.Text);
             GClsConfigFile.WriteConfig("config.ini", "user", "password", txtNewPassword.Text);
             MessageBox.Show("修改成功");
             btnModification.Text = "修改";
             label3.Hide();
             txtNewPassword.Hide();
         }
         else
         {
             MessageBox.Show("密码错误,请重新确认");
         }
     }
 }
Example #2
0
 private void btnUnload_Click(object sender, EventArgs e)//退出界面
 {
     name     = GClsConfigFile.ReadConfig("config.ini", "user", "name", "1");
     password = GClsConfigFile.ReadConfig("config.ini", "user", "password", "1");
     if (txtUserName.Text == name && txtPassword.Text == password)
     {
         login_password = true;
         Close();
     }
     else
     {
         MessageBox.Show("请检查密码是否正确");
         login_password = false;
     }
 }
Example #3
0
        public static GClsConfigFile configFile;                                                      //定义配置文件
        public static string ReadConfig(string FileName, string label, string name, String defultVal) //读配置文件
        {
            string ret;

            configFile = new GClsConfigFile(Application.StartupPath + "/Config/" + FileName);
            ret        = configFile.GetString(label, name, defultVal);

            if (ret == defultVal)
            {
                configFile.WriteValue(label, name, defultVal);
            }


            return(ret);
        }
Example #4
0
 private void txtPassword_KeyPress(object sender, KeyPressEventArgs e)//密码输入后按回车键执行同样的动作
 {
     if (e.KeyChar == '\r')
     {
         name     = GClsConfigFile.ReadConfig("config.ini", "user", "name", "1");
         password = GClsConfigFile.ReadConfig("config.ini", "user", "password", "1");
         if (txtUserName.Text == name && txtPassword.Text == password)
         {
             login_password = true;
             Close();
         }
         else
         {
             MessageBox.Show("请检查密码是否正确");
             login_password = false;
         }
     }
 }
Example #5
0
 private void Login_Load(object sender, EventArgs e)
 {
     label3.Hide();
     txtNewPassword.Hide();
     txtUserName.Text = GClsConfigFile.ReadConfig("config.ini", "user", "name", "1");
 }
Example #6
0
 public static void WriteConfig(string FileName, string label, string name, String defultVal)  //写配置文件
 {
     configFile = new GClsConfigFile(Application.StartupPath + "/Config/" + FileName);
     configFile.WriteValue(label, name, defultVal);
 }