private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            Classes.Register cRegister = new Classes.Register();
            cRegister.Username = txtUsername.Text;
            cRegister.Password = txtPassword.Password;

            var newCompanyMember = "{ 'Username': '******', 'Password': '******'}";

            try
            {
                var json           = File.ReadAllText(@"Users.json");
                var jsonObj        = JObject.Parse(json);
                var EmployeeArrary = jsonObj.GetValue("Users") as JArray;
                var newEmployee    = JObject.Parse(newCompanyMember);
                EmployeeArrary.Add(newEmployee);

                jsonObj["Users"] = EmployeeArrary;
                string newJsonResult = JsonConvert.SerializeObject(jsonObj, Formatting.Indented);
                File.WriteAllText(@"Users.json", newJsonResult);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Occured : " + ex.Message.ToString());
            }
            finally
            {
                MessageBox.Show("Registration Successfull. Redirecting to login page...");
                Login login = new Login();
                login.Show();
                this.Close();
                //txtfName.Clear();
                //txtLName.Clear();
                //txtId.Clear();
                //txtEmail.Clear();
                //txtContactNo.Clear();
                //cmbTitle.Text = "";
            }
        }
Esempio n. 2
0
 private void btnLogin_Click(object sender, RoutedEventArgs e)
 {
     Views.Login vLogin = new Views.Login();
     vLogin.Show();
     this.Hide();
 }