コード例 #1
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            EmployeeName selectedItem = listBox1.SelectedItem as EmployeeName;
            AccountData  account      = accountBL.GetByClientId(selectedItem.Id);

            accountBL.DeleteAccount(account.Id);
            bool valid = employeeBL.DeleteClient(selectedItem.Id);

            if (valid)
            {
                InitializeList();
                UserActionData action = new UserActionData()
                {
                    Description = "Deleted a user",
                    Timestamp   = DateTime.Now,
                    UserId      = this.user.Id
                };

                userActionBL.InsertUserAction(action);
            }
            else
            {
                MessageBox.Show("Error",
                                "Delete has been failed!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information,
                                MessageBoxDefaultButton.Button1
                                );
            }
        }
コード例 #2
0
        public bool InsertUserAction(UserActionData action)
        {
            bool valid = true;

            if (action != null)
            {
                if (!string.IsNullOrWhiteSpace(action.Description) && action.Id != null)
                {
                    valid = userActionMapper.InsertUserAction(action);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(valid);
        }
コード例 #3
0
        private async void Timer_Tick(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(firstQrCode))
            {
                var user = await gameSvc.FindScanQrCodeUserAsync(firstQrCode);

                if (user != null && user.Data != null)
                {
                    firstUser = user.Data;
                    //avatorImg.Source = new BitmapImage(new Uri(user.Data.Headimgurl));
                    avatorImg.Source = UriToImage(user.Data.Headimgurl);
                    //await gameSvc.PostDataByUserAsync(firstUser.ActionId.ToString(), null, null, 80);
                }

                var users = await gameSvc.FindScanQrCodeUsersAsync(firstQrCode);

                if (users != null && users.Data != null)
                {
                    scanCountBefore.Content = $"{users.Data.Count} 人";
                }
            }
        }
コード例 #4
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            bool valid = true;

            if (this.client == null)
            {
                ClientData clientToInsert = new ClientData()
                {
                    Firstnme = this.Firstname.Text,
                    Lastname = this.Lastname.Text,
                    CNP      = this.CNP.Text,
                    Mobile   = this.Mobile.Text,
                    Number   = this.Number.Text,
                    City     = this.City.Text,
                    Street   = this.Street.Text
                };

                valid = employeeBL.InserClient(clientToInsert);

                if (valid)
                {
                    ClientData newUser = employeeBL.GetClientByCNP(clientToInsert.CNP);

                    AccountData account = new AccountData()
                    {
                        Balance   = 0.0,
                        IBAN      = this.Account.Text,
                        Startdate = DateTime.Now,
                        TyepId    = 1,
                        ClientId  = newUser.Id
                    };

                    valid = accountBL.InsertAccount(account);

                    if (!valid)
                    {
                        employeeBL.DeleteClient(newUser.Id);
                    }
                }
            }
            else
            {
                ClientData clientToUpdate = new ClientData()
                {
                    Id       = client.Id,
                    Firstnme = this.Firstname.Text,
                    Lastname = this.Lastname.Text,
                    CNP      = this.CNP.Text,
                    Mobile   = this.Mobile.Text,
                    Number   = this.Number.Text,
                    City     = this.City.Text,
                    Street   = this.Street.Text
                };

                AccountData account = accountBL.GetByClientId(client.Id);
                account.IBAN = Account.Text;

                valid = employeeBL.UpdateClient(clientToUpdate);
                valid = accountBL.UpdateAccount(account);
            }

            if (!valid)
            {
                MessageBox.Show(
                    "Error", "Client data cannot be updated!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1
                    );
            }
            else
            {
                MessageBox.Show(
                    "Success", "Client data has been updated!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information,
                    MessageBoxDefaultButton.Button1
                    );

                UserActionData action = new UserActionData()
                {
                    Description = "Insert/Update a user",
                    Timestamp   = DateTime.Now,
                    UserId      = this.user.Id
                };

                userActionBL.InsertUserAction(action);
            }
        }
コード例 #5
0
        private void TransferButton_Click(object sender, EventArgs e)
        {
            switch (MessageBox.Show(this, "Are you sure?", "Do you still want to make the transfer ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
            //Stay on this form
            case DialogResult.No:
                return;

            default:
                break;
            }

            double amount = 0.0;

            try
            {
                amount = Convert.ToDouble(this.Transfer.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Error", "Wrong amount format", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }

            EmployeeName selectedItem1 = listBox1.SelectedItem as EmployeeName;
            ClientData   fromClient    = employeeBL.GetClientById(selectedItem1.Id);

            EmployeeName selectedItem2 = listBox2.SelectedItem as EmployeeName;
            ClientData   toClient      = employeeBL.GetClientById(selectedItem2.Id);

            bool isValid = transferBL.MakeTransfer(fromClient, toClient, amount);

            if (isValid)
            {
                MessageBox.Show("Success", "Transfer succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                UserActionData action = new UserActionData()
                {
                    Description = "transfer between accounts",
                    Timestamp   = DateTime.Now,
                    UserId      = this.user.Id
                };

                userActionBL.InsertUserAction(action);

                switch (MessageBox.Show(this, "Utility bill!", "Do you want to create a utility bill?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                //Stay on this form
                case DialogResult.Yes:
                    new UtilityBill(accountBL.GetByClientId(fromClient.Id), amount, DateTime.Now).Show();
                    break;

                case DialogResult.No:
                    return;

                    break;

                default:
                    break;
                }
            }
            else
            {
                MessageBox.Show("Error", "Insuficient money wrong destination!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }