private void CreateNewClient() { using (var createForm = new NewClientForm(tsPhoneEdit.Text)) { if (createForm.ShowDialog(this) != DialogResult.OK) { return; } ResultOfClientInfoxdEytY2q result; try { result = _service.CreateNewClient(createForm.GetPhone(), createForm.GetName(), _loginInfo.SessionGuid); } catch (EndpointNotFoundException) { result = new ResultOfClientInfoxdEytY2q { IsSucssied = false, Message = "Не удалось подключиться к серверу. Сервер не найден.\nПроверьте настройки подлючения" }; } catch (Exception exception) { result = new ResultOfClientInfoxdEytY2q { IsSucssied = false, Message = string.Format("Не удалось выполнить операцию.\nОшибка: {0}", exception.Message) }; } if (result.IsSucssied) { _clientInfo = result.Data; } else { _clientInfo = null; MessageBox.Show( this, result.Message, Resources.NewClientForm_Title_NewClient, MessageBoxButtons.OK, MessageBoxIcon.Error); } UpdateInfo(); } }
private void btnOk_Click(object sender, EventArgs e) { if (!_codeWasSent) { var result = SendCode(); if (!result.IsSucssied) { MessageBox.Show( this, result.Message, _operationTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _codeWasSent = true; tePhone.Enabled = false; teOpSumm.Enabled = false; lblCode.Visible = true; teCode.Visible = true; btnOk.Text = Resources.BonusOperationsForm_btnOk_Do; TaskToEnableResendBtn(); } else { if (string.IsNullOrWhiteSpace(teCode.Text)) { return; } ResultOfClientInfoxdEytY2q result; try { switch (_operationType) { case OperationType.PayIn: result = _service.PayInToAccount(ClientInfo.Id, int.Parse(teCode.Text), _loginInfo.SessionGuid); break; case OperationType.PayOut: result = _service.PayoutFromAccount(ClientInfo.Id, int.Parse(teCode.Text), _loginInfo.SessionGuid); break; default: result = new ResultOfClientInfoxdEytY2q { IsSucssied = false, Message = string.Format("Тип операции \"{0}\" не определен", _operationType) }; break; } } catch (EndpointNotFoundException) { result = new ResultOfClientInfoxdEytY2q { IsSucssied = false, Message = "Не удалось подключиться к серверу. Сервер не найден.\nПроверьте настройки подлючения" }; } catch (Exception exception) { result = new ResultOfClientInfoxdEytY2q { IsSucssied = false, Message = string.Format("Не удалось выполнить операцию.\nОшибка: {0}", exception.Message) }; } if (!result.IsSucssied) { MessageBox.Show( this, result.Message, _operationTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ClientInfo = result.Data; DialogResult = DialogResult.OK; _tokenSource.Cancel(); MessageBox.Show( this, "Операция выполнена успешно.", _operationTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } }
private void Search() { if (string.IsNullOrWhiteSpace(tsPhoneEdit.Text)) { MessageBox.Show( this, Resources.MainForm_PhoneCantBeEmpty, Resources.MainForm_SearchClient, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_loginInfo == null) { MessageBox.Show( this, Resources.MainForm_MustBeLogined, Resources.MainForm_SearchClient, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ResultOfClientInfoxdEytY2q result; try { result = _service.GetClientByPhone(tsPhoneEdit.Text, _loginInfo.SessionGuid); } catch (EndpointNotFoundException) { result = new ResultOfClientInfoxdEytY2q { IsSucssied = false, Message = "Не удалось подключиться к серверу. Сервер не найден.\nПроверьте настройки подлючения" }; } catch (Exception exception) { result = new ResultOfClientInfoxdEytY2q { IsSucssied = false, Message = string.Format("Не удалось выполнить операцию.\nОшибка: {0}", exception.Message) }; } if (result.IsSucssied) { _clientInfo = result.Data; } else { _clientInfo = null; if (_loginInfo.RoleType == RoleTypes.Payin && result.ErrorType == ErrorTypes.ClientNotFound) { var messageResult = MessageBox.Show( this, string.Format("{0}\n{1}", result.Message, Resources.MainForm_AddNewClient), Resources.MainForm_SearchClient, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (messageResult == DialogResult.Yes) { CreateNewClient(); } } else { MessageBox.Show( this, result.Message, Resources.MainForm_SearchClient, MessageBoxButtons.OK, MessageBoxIcon.Error); } } UpdateInfo(); }