private void btnNetSave_Click(object sender, EventArgs e) { try { _params.HostName = teIp.Text; _params.Port = int.Parse(tePort.Text); var strAddress = string.Format("http://{0}:{1}/ClientBonusService/", _params.HostName, _params.Port); _service = new ClientBonusServiceClient("BasicHttpBinding_IClientBonusService", strAddress); _params.Save(); MessageBox.Show( this, Resources.LoginForm_ConnectionParamsAreSaved, Resources.LoginForm_MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show( this, Resources.LoginForm_btnNetSave_BadData, Resources.LoginForm_MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); _params = ClientParams.Load(); } }
public UserControlForm(IClientBonusService service, LoginInfo loginInfo) { _service = service; _loginInfo = loginInfo; InitializeComponent(); UpdateUsersGrid(); }
private void Login() { using (var loginForm = new LoginForm(_service)) { if (loginForm.ShowDialog(this) == DialogResult.OK) { _loginInfo = loginForm.GetLoginInfo(); _service = loginForm.GetService(); switch (_loginInfo.RoleType) { case RoleTypes.Payin: tsPayInBtn.Enabled = true; tsPayoutBtn.Enabled = false; tsUserControl.Enabled = false; tsUserControl.Visible = false; break; case RoleTypes.Payout: tsPayInBtn.Enabled = false; tsPayoutBtn.Enabled = true; tsUserControl.Enabled = false; tsUserControl.Visible = false; break; case RoleTypes.Admin: tsPayInBtn.Enabled = true; tsPayoutBtn.Enabled = true; tsUserControl.Enabled = true; tsUserControl.Visible = true; break; default: tsPayInBtn.Enabled = false; tsPayoutBtn.Enabled = false; tsUserControl.Enabled = false; tsUserControl.Visible = false; break; } } else { _loginInfo = null; _clientInfo = null; tsPayInBtn.Enabled = false; tsPayoutBtn.Enabled = false; tsUserControl.Enabled = false; tsUserControl.Visible = false; } } UpdateTitle(); UpdateInfo(); }
public BonusOperationsForm(ClientInfo clientInfo, IClientBonusService service, OperationType operationType, LoginInfo loginInfo) { _loginInfo = loginInfo; _operationType = operationType; ClientInfo = clientInfo; _service = service; _codeWasSent = false; InitializeComponent(); lblCode.Visible = false; teCode.Visible = false; teName.Text = ClientInfo.Name; tePhone.Text = ClientInfo.Phone; btnSendAgain.Visible = false; switch (_operationType) { case OperationType.PayIn: teSumm.Visible = true; lblSumm.Visible = true; teOpSumm.Enabled = false; teOpSumm.ReadOnly = true; lblOperationSumm.Text = "Зачислить"; _operationTitle = "Зачисление на счет"; break; case OperationType.PayOut: teSumm.Visible = false; lblSumm.Visible = false; lblOperationSumm.Text = "Списать"; teOpSumm.Enabled = true; teOpSumm.ReadOnly = false; teOpSumm.MaxValue = ClientInfo.Balance; _operationTitle = "Списание со счета"; break; default: _operationTitle = "Не известный тип операции"; break; } this.Text = _operationTitle; _resendEnable = () => { btnSendAgain.Visible = true; btnSendAgain.Enabled = true; }; }
public LoginForm(IClientBonusService service) { _service = service; InitializeComponent(); _params = ClientParams.Load(); teLogin.Text = _params.UserName; if (_params.RoleType.HasValue) { switch (_params.RoleType.Value) { case RoleTypes.Payin: cbRole.SelectedIndex = 0; break; case RoleTypes.Payout: cbRole.SelectedIndex = 1; break; } } teIp.Text = _params.HostName; tePort.Text = _params.Port.ToString(); }
private async void btnLogin_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(teLogin.Text)) { MessageBox.Show( this, Resources.LoginForm_UserNameCantBeEmpty, Resources.LoginForm_MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_service == null) { var strAddress = string.Format("http://{0}:{1}/ClientBonusService/", _params.HostName, _params.Port); _service = new ClientBonusServiceClient("BasicHttpBinding_IClientBonusService", strAddress); } RoleTypes roleType = cbRole.SelectedIndex == 0 ? RoleTypes.Payin : RoleTypes.Payout; ResultOfLoginInfoxdEytY2q result; try { result = await _service.LoginAsync(teLogin.Text, tePass.Text, roleType); } catch (EndpointNotFoundException) { result = new ResultOfLoginInfoxdEytY2q { IsSucssied = false, Message = "Не удалось подключиться к серверу. Сервер не найден.\nПроверьте настройки подлючения" }; } catch (Exception exception) { result = new ResultOfLoginInfoxdEytY2q { IsSucssied = false, Message = string.Format("Не удалось подключиться к серверу.\nОшибка: {0}", exception.Message) }; } if (!result.IsSucssied) { MessageBox.Show( this, result.Message, Resources.LoginForm_MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (chSaveUser.Checked) { _params.UserName = teLogin.Text; _params.RoleType = roleType; _params.Save(); } _loginInfo = result.Data; DialogResult = DialogResult.OK; Close(); }