public MainWindow() { InitializeComponent(); PageButtons = new List <Button>() { RegPageButton, LogPageButton, DepositPageButton, ObtainPageButton, ProfilePageButton }; AppGrids = new List <Grid>() { RegGrid, EnterGrid, DepositGrid, ObtainGrid, ProfileGrid }; RegPageButton.Margin = new Thickness(50, 15, -35, 15); Color lightColor = (Color)ColorConverter.ConvertFromString("#FF707070"); lightColorBrush = new SolidColorBrush(lightColor); foreach (var grid in AppGrids) { foreach (var element in grid.Children) { if (element.GetType().Equals(typeof(TextBox))) { (element as TextBox).Foreground = lightColorBrush; } else if (element.GetType().Equals(typeof(PasswordBox))) { (element as PasswordBox).Foreground = lightColorBrush; } } } KeyText_Reg.Text = RequestSender.Execute(@"https://localhost:44343/Home/GetNextKey", "").ToString(); }
private void DepositButton_Click(object sender, RoutedEventArgs e) { if (FirstNameText_Deposit.Text.Equals(LoggedClient.FirstName) & SecondNameText_Deposit.Text.Equals(LoggedClient.SecondName) & KeyText_Deposit.Text.Equals(LoggedClient.Key.ToString()) & PassText_Deposit.Password.Equals(LoggedClient.Password)) { if (Convert.ToBoolean(RequestSender.Execute(@"https://localhost:44343/Home/DepositMoney", $"FirstName={LoggedClient.FirstName}&SecondName={LoggedClient.SecondName}&ThirdName={LoggedClient.ThirdName}&Key={LoggedClient.Key}&Password={LoggedClient.Password}&Money={MoneyText_Deposit.Text}"))) { new MessageForm(true).Show(); LoggedClient.Money += int.Parse(MoneyText_Deposit.Text); MoneyText_Profile.Text = LoggedClient.Money.ToString(); } else { new MessageForm(false).Show(); } } }
private void RegButton_Click(object sender, RoutedEventArgs e) { string info = string.Empty; using (ClientContext database = new ClientContext()) { int res; if (int.TryParse(KeyText_Reg.Text, out res)) { if (Convert.ToBoolean(RequestSender.Execute(@"https://localhost:44343/Home/SignUp", $"FirstName={FirstNameText_Reg.Text}&SecondName={SecondNameText_Reg.Text}&ThirdName={ThirdNameText_Reg.Text}&Key={int.Parse(KeyText_Reg.Text)}&Password={PassText_Reg.Password}"))) { new MessageForm(true); } else { new MessageForm(false); } } } }
private void EnterButton_Click(object sender, RoutedEventArgs e) { using (ClientContext database = new ClientContext()) { var Clients = database.Clients.Where(q => q.FirstName.Equals(FirstNameText_Log.Text) & q.SecondName.Equals(SecondNameText_Log.Text) & q.ThirdName.Equals(ThirdNameText_Log.Text) & q.Key.Equals(int.Parse(KeyText_Log.Text)) & q.Password.Equals(PassText_Log.Password)); string response = RequestSender.Execute(@"https://localhost:44343/Home/LogIn", $"FirstName={FirstNameText_Log.Text}&SecondName={SecondNameText_Log.Text}&ThirdName={ThirdNameText_Log.Text}&Key={int.Parse(KeyText_Log.Text)}&Password={PassText_Log.Password}").ToString(); bool IsLogged = bool.Parse(response.Split(new char[] { ';' })[0]); if (IsLogged) { string AccountMoney = response.Split(new char[] { ';' })[1]; foreach (var q in PageButtons) { q.IsEnabled = true; } LoggedClient.FirstName = FirstNameText_Log.Text; LoggedClient.SecondName = SecondNameText_Log.Text; LoggedClient.ThirdName = ThirdNameText_Log.Text; LoggedClient.Key = int.Parse(KeyText_Log.Text); LoggedClient.Money = int.Parse(AccountMoney); LoggedClient.Password = PassText_Log.Password; SmallName.Text = $"{LoggedClient.FirstName} {LoggedClient.SecondName}"; SmallestName.Text = LoggedClient.ThirdName; FirstNameText_Profile.Text = LoggedClient.FirstName; SecondNameText_Profile.Text = LoggedClient.SecondName; ThirdNameText_Profile.Text = SmallestName.Text; KeyText_Profile.Text = LoggedClient.Key.ToString(); MoneyText_Profile.Text = LoggedClient.Money.ToString(); new MessageForm(true).Show(); } else { new MessageForm(false).Show(); } } }