Inheritance: IdentifiedEntity
Ejemplo n.º 1
0
        private async void EditClientForm_Load(object sender, EventArgs e)
        {
            if (clientId != Guid.Empty)
            {
                Enabled = false;

                using (var channel = ChannelManager.CreateChannel())
                {
                    try
                    {
                        Client = await taskPool.AddTask(channel.Service.GetClient(clientId));

                        Enabled = true;
                    }
                    catch (OperationCanceledException) { }
                    catch (CommunicationObjectAbortedException) { }
                    catch (ObjectDisposedException) { }
                    catch (InvalidOperationException) { }
                    catch (FaultException exception)
                    {
                        UIHelper.Warning(exception.Reason.ToString());
                    }
                    catch (Exception exception)
                    {
                        UIHelper.Warning(exception.Message);
                    }
                }
            }
            else
            {
                Client = new Client()
                {
                    Surname = "Новый клиент"
                };
            }
        }
Ejemplo n.º 2
0
        public PortalClientService()
            : base()
        {
            try
            {
                sessionId = Guid.Parse(request.Headers[ExtendHttpHeaders.Session]);

                using (var channel = ChannelManager.CreateChannel())
                {
                    try
                    {
                        currentClient = channel.Service.OpenClientSession(sessionId).Result;
                    }
                    catch (FaultException exception)
                    {
                        throw new WebFaultException<string>(exception.Reason.ToString(), HttpStatusCode.BadRequest);
                    }
                }
            }
            catch (Exception exception)
            {
                logger.Warn(exception);
            }
        }
Ejemplo n.º 3
0
        private async void saveButton_Click(object sender, EventArgs e)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    saveButton.Enabled = false;

                    Client = await taskPool.AddTask(channel.Service.EditClient(client));

                    if (Saved != null)
                    {
                        Saved(this, EventArgs.Empty);
                    }
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
                finally
                {
                    saveButton.Enabled = true;
                }
            }
        }
Ejemplo n.º 4
0
 private void ClientsGridViewRenderRow(DataGridViewRow row, Client client)
 {
     row.Cells["registerDateColumn"].Value = client.RegisterDate;
     row.Cells["surnameColumn"].Value = client.Surname;
     row.Cells["nameColumn"].Value = client.Name;
     row.Cells["patronymicColumn"].Value = client.Patronymic;
     row.Cells["emailColumn"].Value = client.Email;
     row.Cells["mobileColumn"].Value = client.Mobile;
     row.Tag = client;
 }
Ejemplo n.º 5
0
        public async Task<Client> EditProfile(string surname, string name, string patronymic, string mobile)
        {
            checkLogin();

            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    currentClient.Surname = surname;
                    currentClient.Name = name;
                    currentClient.Patronymic = patronymic;
                    currentClient.Mobile = mobile;

                    currentClient = await channel.Service.EditClient(currentClient);
                    return currentClient;
                }
                catch (FaultException exception)
                {
                    throw new WebFaultException<string>(exception.Reason.ToString(), HttpStatusCode.BadRequest);
                }
            }
        }
Ejemplo n.º 6
0
 private void clientsListBox_SelectedValueChanged(object sender, EventArgs e)
 {
     CurrentClient = (Client)clientsListBox.SelectedItem;
 }
Ejemplo n.º 7
0
 private void clearCurrentClientButton_Click(object sender, EventArgs e)
 {
     CurrentClient = null;
 }
Ejemplo n.º 8
0
        private async void addButton_Click(object clickSender, EventArgs eventArg)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    addButton.Enabled = false;

                    var surname = clientSurnameTextBox.Text.Trim();

                    if (CurrentClient == null && !string.IsNullOrWhiteSpace(surname))
                    {
                        Client client = new Client()
                        {
                            Surname = surname,
                            Name = clientNameTextBox.Text.Trim(),
                            Patronymic = clientPatronymicTextBox.Text.Trim(),
                            Mobile = clientMobileTextBox.Text.Trim()
                        };

                        CurrentClient = await taskPool.AddTask(channel.Service.EditClient(client));
                    }

                    var selectedItem = servicesTreeView.SelectedNode;
                    if (selectedItem != null)
                    {
                        var selectedQueueService = (Service)selectedItem.Tag;
                        if (selectedQueueService != null)
                        {
                            ClientRequest clientRequest;

                            int subjects = (int)subjectsUpDown.Value;

                            var currentClientId = CurrentClient != null
                                ? CurrentClient.Id : Guid.Empty;

                            if (liveRadioButton.Checked)
                            {
                                clientRequest = await taskPool.AddTask(channel.Service
                                    .AddLiveClientRequest(currentClientId, selectedQueueService.Id, priorityCheckBox.Checked,
                                    new Dictionary<Guid, object>(), subjects));
                            }
                            else
                            {
                                object selectedTime = freeTimeComboBox.SelectedItem;
                                if (selectedTime != null)
                                {
                                    clientRequest = await taskPool.AddTask(channel.Service
                                        .AddEarlyClientRequest(currentClientId, selectedQueueService.Id, earlyDatePicker.Value, (TimeSpan)selectedTime,
                                        new Dictionary<Guid, object>(), subjects));
                                }
                                else
                                {
                                    UIHelper.Warning("Не указано время предварительной записи");
                                    return;
                                }
                            }

                            LoadFreeTime();

                            CurrentClient = null;
                            subjectsUpDown.Value = Math.Min(1, subjectsUpDown.Maximum);
                            priorityCheckBox.Checked = false;

                            var coupon = await taskPool.AddTask(channel.Service.GetClientRequestCoupon(clientRequest.Id));
                            var template = TemplateManager.GetTemplate(Templates.Coupon);

                            if (couponAutoPrintCheckBox.Checked)
                            {
                                XPSUtils.PrintXaml(template, coupon, Settings.CouponPrinter);
                            }
                            else
                            {
                                Process.Start(XPSUtils.WriteXaml(template, coupon));
                            }
                        }
                    }
                    else
                    {
                        UIHelper.Warning("Услуга не выбрана");
                    }
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
                finally
                {
                    addButton.Enabled = true;
                }
            }
        }