Exemplo n.º 1
0
        private void прайсИзделийToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog
            {
                Filter = "doc|*.doc|docx|*.docx"
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string fileName = sfd.FileName;
                Task   task     = Task.Run(() => APICustomer.PostRequestData("api/Report/SaveOutputPrice", new BoundReportModel
                {
                    FileName = fileName
                }));

                task.ContinueWith((prevTask) => MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information),
                                  TaskContinuationOptions.OnlyOnRanToCompletion);

                task.ContinueWith((prevTask) =>
                {
                    var ex = (Exception)prevTask.Exception;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }, TaskContinuationOptions.OnlyOnFaulted);
            }
        }
 private void FormReservesLoad_Load(object sender, EventArgs e)
 {
     try
     {
         dataGridView.Rows.Clear();
         foreach (var elem in Task.Run(() => APICustomer.GetRequestData <List <ModelReservesLoadView> >("api/Report/GetReservesLoad")).Result)
         {
             dataGridView.Rows.Add(new object[] { elem.ReserveName, "", "" });
             foreach (var listElem in elem.Elements)
             {
                 dataGridView.Rows.Add(new object[] { "", listElem.ElementName, listElem.Count });
             }
             dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
             dataGridView.Rows.Add(new object[] { });
         }
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void buttonSaveToExcel_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog
            {
                Filter = "xls|*.xls|xlsx|*.xlsx"
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string fileName = sfd.FileName;
                Task   task     = Task.Run(() => APICustomer.PostRequestData("api/Report/SaveReservesLoad", new BoundReportModel
                {
                    FileName = fileName
                }));

                task.ContinueWith((prevTask) => MessageBox.Show("Выполнено", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information),
                                  TaskContinuationOptions.OnlyOnRanToCompletion);
                task.ContinueWith((prevTask) =>
                {
                    var ex = (Exception)prevTask.Exception;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }, TaskContinuationOptions.OnlyOnFaulted);
            }
        }
 private void FormProduct_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             var product = Task.Run(() => APICustomer.GetRequestData <ModelOutputView>("api/Output/Get/" + id.Value)).Result;
             textBoxName.Text  = product.OutputName;
             textBoxPrice.Text = product.Price.ToString();
             productComponents = product.OutputElements;
             LoadData();
         }
         catch (Exception ex)
         {
             while (ex.InnerException != null)
             {
                 ex = ex.InnerException;
             }
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         productComponents = new List <ModelProdElementView>();
     }
 }
Exemplo n.º 5
0
        private void buttonMake_Click(object sender, EventArgs e)
        {
            if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
            {
                MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                ReportParameter parameter = new ReportParameter("ReportParameterPeriod",
                                                                "c " + dateTimePickerFrom.Value.ToShortDateString() +
                                                                " по " + dateTimePickerTo.Value.ToShortDateString());
                reportViewer.LocalReport.SetParameters(parameter);

                var dataSource = Task.Run(() => APICustomer.PostRequestData <BoundReportModel, List <ModelCustomerBookingsView> >("api/Report/GetCustomerBookings",
                                                                                                                                  new BoundReportModel
                {
                    DateFrom = dateTimePickerFrom.Value,
                    DateTo   = dateTimePickerTo.Value
                })).Result;
                ReportDataSource source = new ReportDataSource("DataSetOrders", dataSource);
                reportViewer.LocalReport.DataSources.Add(source);

                reportViewer.RefreshReport();
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void FormPutOnStock_Load(object sender, EventArgs e)
        {
            try
            {
                List <ModelElementView> listC = Task.Run(() => APICustomer.GetRequestData <List <ModelElementView> >("api/Element/GetList")).Result;
                if (listC != null)
                {
                    comboBoxComponent.DisplayMember = "ElementName";
                    comboBoxComponent.ValueMember   = "Id";
                    comboBoxComponent.DataSource    = listC;
                    comboBoxComponent.SelectedItem  = null;
                }

                List <ModelReserveView> listS = Task.Run(() => APICustomer.GetRequestData <List <ModelReserveView> >("api/Reserve/GetList")).Result;
                if (listS != null)
                {
                    comboBoxStock.DisplayMember = "ReserveName";
                    comboBoxStock.ValueMember   = "Id";
                    comboBoxStock.DataSource    = listS;
                    comboBoxStock.SelectedItem  = null;
                }
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void buttonDel_Click(object sender, EventArgs e)
        {
            if (dataGridViewReserves.SelectedRows.Count == 1)
            {
                if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    int id = Convert.ToInt32(dataGridViewReserves.SelectedRows[0].Cells[0].Value);

                    Task task = Task.Run(() => APICustomer.PostRequestData("api/Reserve/DelElement", new BoundCustomerModel {
                        ID = id
                    }));

                    task.ContinueWith((prevTask) => MessageBox.Show("Запись удалена. Обновите список", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information),
                                      TaskContinuationOptions.OnlyOnRanToCompletion);

                    task.ContinueWith((prevTask) =>
                    {
                        var ex = (Exception)prevTask.Exception;
                        while (ex.InnerException != null)
                        {
                            ex = ex.InnerException;
                        }
                        MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }, TaskContinuationOptions.OnlyOnFaulted);
                }
            }
        }
 private void FormTakeOrderInWork_Load(object sender, EventArgs e)
 {
     try
     {
         if (!id.HasValue)
         {
             MessageBox.Show("Не указан заказ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Close();
         }
         List <ModelExecutorView> list = Task.Run(() => APICustomer.GetRequestData <List <ModelExecutorView> >("api/Executor/GetList")).Result;
         if (list != null)
         {
             comboBoxExecutor.DisplayMember = "ExecutorFullName";
             comboBoxExecutor.ValueMember   = "Id";
             comboBoxExecutor.DataSource    = list;
             comboBoxExecutor.SelectedItem  = null;
         }
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 9
0
        private void buttonPayOrder_Click(object sender, EventArgs e)
        {
            if (dataGridViewMain.SelectedRows.Count == 1)
            {
                int id = Convert.ToInt32(dataGridViewMain.SelectedRows[0].Cells[0].Value);


                Task task = Task.Run(() =>
                {
                    APICustomer.PostRequestData("api/Main/PayBooking", new BoundBookingModel {
                        ID = id
                    });
                }
                                     );

                task.ContinueWith((prevTask) => MessageBox.Show("Статус заказа изменен. Обновите список", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information),
                                  TaskContinuationOptions.OnlyOnRanToCompletion);

                task.ContinueWith(
                    (prevTask) =>
                {
                    var ex = (Exception)prevTask.Exception;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                },
                    TaskContinuationOptions.OnlyOnFaulted
                    );
            }
        }
        private void FormCreateOrder_Load(object sender, EventArgs e)
        {
            try
            {
                List <ModelCustomerView> listC = Task.Run(() => APICustomer.GetRequestData <List <ModelCustomerView> >("api/Customer/GetList")).Result;
                if (listC != null)
                {
                    comboBoxClient.DisplayMember = "CustomerFullName";
                    comboBoxClient.ValueMember   = "Id";
                    comboBoxClient.DataSource    = listC;
                    comboBoxClient.SelectedItem  = null;
                }

                List <ModelOutputView> listP = Task.Run(() => APICustomer.GetRequestData <List <ModelOutputView> >("api/Output/GetList")).Result;
                if (listP != null)
                {
                    comboBoxProduct.DisplayMember = "OutputName";
                    comboBoxProduct.ValueMember   = "Id";
                    comboBoxProduct.DataSource    = listP;
                    comboBoxProduct.SelectedItem  = null;
                }
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 11
0
 static void Main()
 {
     APICustomer.Connect();
     MailClient.CheckMail();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new FormMain());
 }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxFullName.Text))
            {
                MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string fio  = textBoxFullName.Text;
            string mail = textBoxMail.Text;

            if (!string.IsNullOrEmpty(mail))
            {
                if (!Regex.IsMatch(mail, @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                                   @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$"))
                {
                    MessageBox.Show("Неверный формат для электронной почты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            Task task;

            if (id.HasValue)
            {
                task = Task.Run(() => APICustomer.PostRequestData("api/Customer/UpdElement", new BoundCustomerModel
                {
                    ID = id.Value,
                    CustomerFullName = fio,
                    Mail             = mail
                }));
            }
            else
            {
                task = Task.Run(() => APICustomer.PostRequestData("api/Customer/AddElement", new BoundCustomerModel
                {
                    CustomerFullName = fio,
                    Mail             = mail
                }));
            }

            task.ContinueWith((prevTask) => MessageBox.Show("Сохранение прошло успешно. Обновите список", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information),
                              TaskContinuationOptions.OnlyOnRanToCompletion);
            task.ContinueWith((prevTask) =>
            {
                var ex = (Exception)prevTask.Exception;
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }, TaskContinuationOptions.OnlyOnFaulted);

            Close();
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxCount.Text))
            {
                MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (comboBoxComponent.SelectedValue == null)
            {
                MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (comboBoxStock.SelectedValue == null)
            {
                MessageBox.Show("Выберите склад", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                int  componentId = Convert.ToInt32(comboBoxComponent.SelectedValue);
                int  stockId     = Convert.ToInt32(comboBoxStock.SelectedValue);
                int  count       = Convert.ToInt32(textBoxCount.Text);
                Task task        = Task.Run(() => APICustomer.PostRequestData("api/Main/PutElementOnReserve", new BoundResElementModel
                {
                    ElementID = componentId,
                    ReserveID = stockId,
                    Count     = count
                }));

                task.ContinueWith((prevTask) => MessageBox.Show("Склад пополнен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information),
                                  TaskContinuationOptions.OnlyOnRanToCompletion);
                task.ContinueWith((prevTask) =>
                {
                    var ex = (Exception)prevTask.Exception;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }, TaskContinuationOptions.OnlyOnFaulted);

                Close();
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 14
0
 private void FormComponent_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             var component = Task.Run(() => APICustomer.GetRequestData <ModelElementView>("api/Element/Get/" + id.Value)).Result;
             textBoxName.Text = component.ElementName;
         }
         catch (Exception ex)
         {
             while (ex.InnerException != null)
             {
                 ex = ex.InnerException;
             }
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxCount.Text))
            {
                MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (comboBoxClient.SelectedValue == null)
            {
                MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (comboBoxProduct.SelectedValue == null)
            {
                MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int  clientId  = Convert.ToInt32(comboBoxClient.SelectedValue);
            int  productId = Convert.ToInt32(comboBoxProduct.SelectedValue);
            int  count     = Convert.ToInt32(textBoxCount.Text);
            int  sum       = Convert.ToInt32(textBoxSum.Text);
            Task task      = Task.Run(() => APICustomer.PostRequestData("api/Main/CreateBooking", new BoundBookingModel
            {
                CustomerID = clientId,
                OutputID   = productId,
                Count      = count,
                Summa      = sum
            }));

            task.ContinueWith((prevTask) => MessageBox.Show("Сохранение прошло успешно. Обновите список", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information),
                              TaskContinuationOptions.OnlyOnRanToCompletion);
            task.ContinueWith((prevTask) =>
            {
                var ex = (Exception)prevTask.Exception;
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }, TaskContinuationOptions.OnlyOnFaulted);

            Close();
        }
 private void FormImplementer_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             var implementer = Task.Run(() => APICustomer.GetRequestData <ModelExecutorView>("api/Executor/Get/" + id.Value)).Result;
             textBoxFullName.Text = implementer.ExecutorFullName;
         }
         catch (Exception ex)
         {
             while (ex.InnerException != null)
             {
                 ex = ex.InnerException;
             }
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void LoadData()
 {
     try
     {
         List <ModelReserveView> list = Task.Run(() => APICustomer.GetRequestData <List <ModelReserveView> >("api/Reserve/GetList")).Result;
         if (list != null)
         {
             dataGridViewReserves.DataSource              = list;
             dataGridViewReserves.Columns[0].Visible      = false;
             dataGridViewReserves.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         }
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void CalcSum()
 {
     if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
     {
         try
         {
             int             id      = Convert.ToInt32(comboBoxProduct.SelectedValue);
             ModelOutputView product = Task.Run(() => APICustomer.GetRequestData <ModelOutputView>("api/Output/Get/" + id)).Result;
             int             count   = Convert.ToInt32(textBoxCount.Text);
             textBoxSum.Text = (count * (int)product.Price).ToString();
         }
         catch (Exception ex)
         {
             while (ex.InnerException != null)
             {
                 ex = ex.InnerException;
             }
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 19
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxName.Text))
            {
                MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string name = textBoxName.Text;
            Task   task;

            if (id.HasValue)
            {
                task = Task.Run(() => APICustomer.PostRequestData("api/Element/UpdElement", new BoundElementModel
                {
                    ID          = id.Value,
                    ElementName = name
                }));
            }
            else
            {
                task = Task.Run(() => APICustomer.PostRequestData("api/Element/AddElement", new BoundElementModel
                {
                    ElementName = name
                }));
            }

            task.ContinueWith((prevTask) => MessageBox.Show("Сохранение прошло успешно. Обновите список", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information),
                              TaskContinuationOptions.OnlyOnRanToCompletion);
            task.ContinueWith((prevTask) =>
            {
                var ex = (Exception)prevTask.Exception;
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }, TaskContinuationOptions.OnlyOnFaulted);

            Close();
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (comboBoxExecutor.SelectedValue == null)
            {
                MessageBox.Show("Выберите исполнителя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                int  implementerId = Convert.ToInt32(comboBoxExecutor.SelectedValue);
                Task task          = Task.Run(() => APICustomer.PostRequestData("api/Main/TakeBookingInWork", new BoundBookingModel
                {
                    ID         = id.Value,
                    ExecutorID = implementerId
                }));

                task.ContinueWith((prevTask) => MessageBox.Show("Заказ передан в работу. Обновите список", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information),
                                  TaskContinuationOptions.OnlyOnRanToCompletion);
                task.ContinueWith((prevTask) =>
                {
                    var ex = (Exception)prevTask.Exception;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }, TaskContinuationOptions.OnlyOnFaulted);

                Close();
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 21
0
 private void FormMails_Load(object sender, EventArgs e)
 {
     try
     {
         MailClient.CheckMail();
         List <ModelMessageInfoView> list = Task.Run(() =>
                                                     APICustomer.GetRequestData <List <ModelMessageInfoView> >("api/MessageInfo/GetList")).Result;
         if (list != null)
         {
             dataGridView.DataSource              = list;
             dataGridView.Columns[0].Visible      = false;
             dataGridView.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         }
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void FormProductComponent_Load(object sender, EventArgs e)
 {
     try
     {
         comboBoxComponent.DisplayMember = "ElementName";
         comboBoxComponent.ValueMember   = "Id";
         comboBoxComponent.DataSource    = Task.Run(() => APICustomer.GetRequestData <List <ModelElementView> >("api/Element/GetList")).Result;
         comboBoxComponent.SelectedItem  = null;
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     if (model != null)
     {
         comboBoxComponent.Enabled       = false;
         comboBoxComponent.SelectedValue = model.ElementID;
         textBoxCount.Text = model.Count.ToString();
     }
 }
Exemplo n.º 23
0
        public static void CheckMail()
        {
            using (Pop3Client client = new Pop3Client())
            {
                client.Connect("pop.gmail.com", 995, true);
                client.Authenticate(
                    "recent:" + ConfigurationManager.AppSettings["MailLogin"],
                    ConfigurationManager.AppSettings["MailPassword"]
                    );

                int messageCount = client.GetMessageCount();
                List <OpenPop.Mime.Message> allMessages = new List <OpenPop.Mime.Message>(messageCount);
                for (int i = messageCount; i > 0; i--)
                {
                    var header = client.GetMessageHeaders(i);
                    foreach (var toEmail in header.To)
                    {
                        if (toEmail.Address.ToLower().Equals(ConfigurationManager.AppSettings["MailLogin"].ToLower()))
                        {
                            var message = client.GetMessage(i);
                            var body    = message.FindFirstPlainTextVersion();
                            APICustomer.PostRequestData("api/MessageInfo/AddElement",
                                                        new BoundMessageInfoModel
                            {
                                MessageId       = message.Headers.MessageId,
                                FromMailAddress = message.Headers.From.Address,
                                DateDelivery    = message.Headers.DateSent,
                                Subject         = message.Headers.Subject,
                                Body            = body.BodyEncoding.GetString(body.Body)
                            }
                                                        );
                        }
                    }
                }
            }
        }
 private void FormClient_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             var customer = Task.Run(() => APICustomer.GetRequestData <ModelCustomerView>("api/Customer/Get/" + id.Value)).Result;
             textBoxFullName.Text                 = customer.CustomerFullName;
             textBoxMail.Text                     = customer.Mail;
             dataGridView.DataSource              = customer.Messages;
             dataGridView.Columns[0].Visible      = false;
             dataGridView.Columns[1].Visible      = false;
             dataGridView.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         }
         catch (Exception ex)
         {
             while (ex.InnerException != null)
             {
                 ex = ex.InnerException;
             }
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 25
0
        private void buttonToPdf_Click(object sender, EventArgs e)
        {
            if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
            {
                MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            SaveFileDialog sfd = new SaveFileDialog
            {
                Filter = "pdf|*.pdf"
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string fileName = sfd.FileName;
                Task   task     = Task.Run(() => APICustomer.PostRequestData("api/Report/SaveCustomerBookings", new BoundReportModel
                {
                    FileName = fileName,
                    DateFrom = dateTimePickerFrom.Value,
                    DateTo   = dateTimePickerTo.Value
                }));

                task.ContinueWith((prevTask) => MessageBox.Show("Список заказов сохранен", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information),
                                  TaskContinuationOptions.OnlyOnRanToCompletion);

                task.ContinueWith((prevTask) =>
                {
                    var ex = (Exception)prevTask.Exception;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }, TaskContinuationOptions.OnlyOnFaulted);
            }
        }
Exemplo n.º 26
0
 private void FormStock_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             var stock = Task.Run(() => APICustomer.GetRequestData <ModelReserveView>("api/Reserve/Get/" + id.Value)).Result;
             textBoxName.Text = stock.ReserveName;
             dataGridViewReserve.DataSource              = stock.ReserveElements;
             dataGridViewReserve.Columns[0].Visible      = false;
             dataGridViewReserve.Columns[1].Visible      = false;
             dataGridViewReserve.Columns[2].Visible      = false;
             dataGridViewReserve.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         }
         catch (Exception ex)
         {
             while (ex.InnerException != null)
             {
                 ex = ex.InnerException;
             }
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 27
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxName.Text))
            {
                MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxPrice.Text))
            {
                MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (productComponents == null || productComponents.Count == 0)
            {
                MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List <BoundProdElementModel> productComponentBM = new List <BoundProdElementModel>();

            for (int i = 0; i < productComponents.Count; ++i)
            {
                productComponentBM.Add(new BoundProdElementModel
                {
                    ID        = productComponents[i].ID,
                    OutputID  = productComponents[i].OutputID,
                    ElementID = productComponents[i].ElementID,
                    Count     = productComponents[i].Count
                });
            }
            string name  = textBoxName.Text;
            int    price = Convert.ToInt32(textBoxPrice.Text);
            Task   task;

            if (id.HasValue)
            {
                task = Task.Run(() => APICustomer.PostRequestData("api/Output/UpdElement", new BoundOutputModel
                {
                    ID             = id.Value,
                    OutputName     = name,
                    Price          = price,
                    OutputElements = productComponentBM
                }));
            }
            else
            {
                task = Task.Run(() => APICustomer.PostRequestData("api/Output/AddElement", new BoundOutputModel
                {
                    OutputName     = name,
                    Price          = price,
                    OutputElements = productComponentBM
                }));
            }

            task.ContinueWith((prevTask) => MessageBox.Show("Сохранение прошло успешно. Обновите список", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information),
                              TaskContinuationOptions.OnlyOnRanToCompletion);
            task.ContinueWith((prevTask) =>
            {
                var ex = (Exception)prevTask.Exception;
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }, TaskContinuationOptions.OnlyOnFaulted);

            Close();
        }