Beispiel #1
0
        /// <summary>
        /// Кнопка сканирования почты для импорта отчетов провайдера
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonScanTransportTable_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                ShefflerWB.ExcelOptimizateOn();
                if (Properties.Settings.Default.OutlookFolders == "")
                {
                    MessageBox.Show("Задайте папки для сканирования почты", "Необходима настройка программы", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                ScanMail scanMail = new ScanMail();

                if (scanMail.SaveAttachments() == 0)
                {
                    MessageBox.Show("Письма не обнаружены", "Сканирование почты", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    TransportTable transportTable = new TransportTable();
                    transportTable.GetDataFromProviderFiles();
                    transportTable.SaveAndClose();
                    MessageBox.Show("Данные импортированы. Изменения выделены цветом.", "Импорт данных", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                ShefflerWB.ExcelOptimizateOff();
            }
        }
Beispiel #2
0
 /// <summary>
 /// Кнопка сканирования писем от провайдеров
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnReadCarrierInvoice_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         if (Properties.Settings.Default.OutlookFolders == "")
         {
             MessageBox.Show("Задайте папки для сканирования почты", "Необходима настройка программы", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         ScanMail scanMail = new ScanMail();
         if (scanMail.SaveAttachments() == 0)
         {
             MessageBox.Show("Письма не обнаружены", "Сканирование почты", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             scanMail.GetDataFromProviderFiles();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
        private void Лист2_SelectionChange(Range Target)
        {
            try
            {
                ShefflerWB.ExcelOptimizateOn();
                Worksheet  deliverySheet = Globals.ThisWorkbook.Sheets["Delivery"];
                ListObject carrierTable  = deliverySheet?.ListObjects["TableCarrier"];
                ListObject OrdersTable   = deliverySheet?.ListObjects["TableOrders"];
                if (carrierTable == null || OrdersTable == null)
                {
                    return;
                }

                Range commonOrdrrRng = Globals.ThisWorkbook.Application.Intersect(Target, OrdersTable.Range);
                if (carrierTable?.DataBodyRange == null)
                {
                    return;
                }

                Range commonRng = Globals.ThisWorkbook.Application.Intersect(Target, carrierTable.DataBodyRange);
                if (commonRng == null && commonOrdrrRng == null)
                {
                    OrdersTable.Range.AutoFilter(Field: 1);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                ShefflerWB.ExcelOptimizateOff();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Отправка таблицы Отгрузка провайдерам
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonTotalToProviders_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                SelectProvider selectProvider = new SelectProvider();
                selectProvider.ShowDialog();
                if (selectProvider.DialogResult != DialogResult.OK)
                {
                    return;
                }
                ShefflerWB.ExcelOptimizateOn();

                if (selectProvider.Provider == "Отправить всем")
                {
                    new Functions().SendEmailToProviderAdoutAdding();
                }
                else
                {
                    new Functions().SendEmailToProviderAdoutAdding(selectProvider.Provider);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                ShefflerWB.ExcelOptimizateOff();
            }
        }
        /// <summary>
        /// Смена провайдера по двойному клику
        /// </summary>
        /// <param name="Target"></param>
        /// <param name="Cancel"></param>
        private void TableCarrier_BeforeDoubleClick(Range Target, ref bool Cancel)
        {
            Worksheet  deliverySheet = ShefflerWB.DeliverySheet;
            ListObject deliveryTable = ShefflerWB.DeliveryTable;
            ListObject ordersTable   = ShefflerWB.OrdersTable;

            if (Target.Column == deliveryTable.ListColumns["Компания"].Range.Column &&
                Target.Row > deliveryTable.HeaderRowRange.Row &&
                Target.Text != "")
            {
                Cancel = true;
                ProviderEditor providerFrm = new ProviderEditor();
                string         wt          = deliverySheet.Cells[Target.Row, deliveryTable.ListColumns["Вес доставки"].Range.Column].Text;
                Functions      functions   = new Functions();
                List <Order>   orders      = functions.GetOrdersFromTable();
                Delivery       delivery    = new Delivery();
                string         numStr      = deliverySheet.Cells[Target.Row, deliveryTable.ListColumns["№ Доставки"].Range.Column].Text;
                int            number      = int.TryParse(numStr, out int n) ? n : 0;
                if (number == 0)
                {
                    return;
                }
                delivery.Orders = orders.FindAll(o => o.DeliveryNumber == number);

                if (orders.Count == 0)
                {
                    return;
                }
                providerFrm.Weight         = double.TryParse(wt, out double weight) ? weight : 0;
                providerFrm.ProviderName   = Target.Text;
                providerFrm.DeliveryTarget = delivery;
                //=========
                providerFrm.ShowDialog();
                if (providerFrm.DialogResult == DialogResult.OK)
                {
                    Target.Value = providerFrm.ProviderName;
                    ResetProvider(numStr, providerFrm.ProviderName);

                    //На лист отгрузки
                    string idOrder = delivery.Orders[0].Id;
                    Range  row     = null;
                    row = new ShefflerWB().GetRowOrderTotal(idOrder);
                    if (providerFrm.ProviderName == "Деловые линии")
                    {
                        delivery.MapDelivery.ForEach(p => p.RouteName = "Сборный груз");
                        Target.Offset[0, 5].Value = "Сборный груз";
                        Target.Offset[0, 2].Value = "0";
                        Target.Offset[0, 1].Value = "0";
                        row.Cells[1, ShefflerWB.TotalTable.ListColumns["Тип ТС, тонн"].Index].Value = "0";
                    }

                    Target.Offset[0, 4].Value = providerFrm.CostDelivery;
                    if (row != null)
                    {
                        row.Cells[1, ShefflerWB.TotalTable.ListColumns["Экспедитор"].Index].Value         = providerFrm.ProviderName;
                        row.Cells[1, ShefflerWB.TotalTable.ListColumns["Стоимость доставки"].Index].Value = providerFrm.CostDelivery;
                    }
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Кнопка удаления авто
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonDeleteAuto_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new Functions().DeleteAuto();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #7
0
 private void BtnSettings_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new Settings().ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #8
0
 /// <summary>
 /// Сохранение временного архива в TransportTable
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SaveToTransportTable_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         Archive.ToTransportTableAndShepments();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #9
0
 /// <summary>
 /// Кнопка Export from SAP
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnExportFromSap_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new Functions().ExportFromSAP();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #10
0
 /// <summary>
 /// Кнопка отправки писем провайдерам
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnSendShippingCompany_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new Functions().SendEmailToProviderAdoutOrders();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #11
0
 /// <summary>
 /// Сквозное нумерование доставок
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NunerateDeliveries(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new Functions().RenumberDeliveries();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #12
0
 /// <summary>
 /// Отправка файла отгрузки в CS
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonSendToCS_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new Functions().CreateLetterToCS();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #13
0
 /// <summary>
 /// Выбор папки для сканирования писем от провайдеров
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonSelectFoldersOutlook_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new OutlookFoldersSelect().ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #14
0
 /// <summary>
 /// Кнопка перенести в отгрузки
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnFillTable_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new Functions().UpdateTotal();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #15
0
 /// <summary>
 /// Сохранение листа отгрузки во временный архив
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SaveToArchive_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         Archive.LoadToArhive();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
Beispiel #16
0
 /// <summary>
 /// Кнопка пересчитать стоимость
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnChangeRoute_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ShefflerWB.ExcelOptimizateOn();
         new Functions().СhangeDelivery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         ShefflerWB.ExcelOptimizateOff();
     }
 }
        /// <summary>
        /// При смене провайдера изменить Id в отгрузках
        /// </summary>
        public void ResetProvider(string deliveryNumber, string provider)
        {
            foreach (ListRow row in ShefflerWB.TotalTable.ListRows)
            {
                string numDelivery  = row.Range[1, ShefflerWB.TotalTable.ListColumns["№ Доставки"].Index].Text;
                string providerName = row.Range[1, ShefflerWB.TotalTable.ListColumns["Экспедитор"].Index].Text;
                string id           = row.Range[1, ShefflerWB.TotalTable.ListColumns["ID экспедитора"].Index].Text;

                if (numDelivery == deliveryNumber && providerName != "" && providerName != provider && id != "")
                {
                    DialogResult msg = MessageBox.Show("По данной отгрузке уже был назначен провайдер. Также был присвоен ID экспедитора. " +
                                                       "Вы хотите назначить нового провайдера? Если да, то будет сформирован новый ID экспедитора", "Экспедитор уже назнчен", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (DialogResult.Yes == msg)
                    {
                        string newIdProvider = provider == "Деловые линии" ? "" : ShefflerWB.GetProviderId(provider);
                        row.Range[1, ShefflerWB.TotalTable.ListColumns["ID экспедитора"].Index].Value = newIdProvider;
                    }
                }
            }
        }
        /// <summary>
        /// Фильтр заказов по активной доставке
        /// </summary>
        /// <param name="Target"></param>
        private void TableCarrier_SelectionChange(Range Target)
        {
            try
            {
                ShefflerWB.ExcelOptimizateOn();
                Worksheet  deliverySheet = Globals.ThisWorkbook.Sheets["Delivery"];
                ListObject carrierTable  = deliverySheet.ListObjects["TableCarrier"];
                ListObject OrdersTable   = deliverySheet.ListObjects["TableOrders"];
                Range      TargetCell    = Globals.ThisWorkbook.Application.ActiveCell;
                OrdersTable.Range.AutoFilter(Field: 1);
                if (TargetCell == null)
                {
                    return;
                }
                if (carrierTable.DataBodyRange == null)
                {
                    return;
                }

                Range commonRng = Globals.ThisWorkbook.Application.Intersect(TargetCell, carrierTable.DataBodyRange);

                if (commonRng != null)
                {
                    string numberDelivery = deliverySheet.Cells[TargetCell.Row, carrierTable.ListColumns[1].Range.Column].Text;
                    OrdersTable.Range.AutoFilter(Field: 1, Criteria1: numberDelivery);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                ShefflerWB.ExcelOptimizateOff();
            }
        }
Beispiel #19
0
        /// <summary>
        /// Кнопка отправки очета провайдеру
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonSendTransportTable_Click(object sender, RibbonControlEventArgs e)
        {
            TransportTableSending tableSending = new TransportTableSending();

            tableSending.ShowDialog();
            if (tableSending.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                ShefflerWB.ExcelOptimizateOn();
                new TransportTable().MessageProvider(tableSending.DateStart, tableSending.DateEnd, tableSending.Provider);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                ShefflerWB.ExcelOptimizateOff();
            }
        }