예제 #1
0
        private void bKT_Click(object sender, EventArgs e)
        {
            var excPkg = ExcelOperations.GetExcelPackage(SelectedOrder.selectedOrder.modelId);// currentOrder.modelId);

            if (excPkg != null)
            {
                string additionalComment = "";// lProdWerehouseStock.Text != "" ? $"Wyrób znajduje się na regale: {lProdWerehouseStock.Text}" : "";
                if (ProductionStock.CurrentStock.Count > 0)
                {
                    additionalComment = $"Wyrób znajduje się na regale: {string.Join(", ", ProductionStock.CurrentStock)}";
                }

                string tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ExcelOperations.ExcelParameters.tempFileName);
                for (int i = 0; i < 20; i++) //try 20 filenames for tempFile
                {
                    tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), $"{i}_{ExcelOperations.ExcelParameters.tempFileName}");
                    if (!ExcelOperations.IsFileLocked(new FileInfo(tempFile)))
                    {
                        break;
                    }
                    if (i == 14)
                    {
                        MessageBox.Show("Nie można uzystać dostępu do programu Excel. Zamknij wszystkie okna Excel i spróbuj ponownie." + Environment.NewLine + "W razie dalszych problemów uruchom ponownie komputer");
                        return;
                    }
                }

                ExcelOperations.FillOutExcelData(ref excPkg, false, additionalComment);
                ExcelOperations.SaveToExcel(excPkg, tempFile);
                Process.Start(tempFile);
            }
        }
예제 #2
0
        private void butKartyTechn_click(object sender, EventArgs e)
        {
            if (DataStorage.currentOrder.orderNo == "")
            {
                MessageBox.Show("Wczytaj lub utwórz zlecenie");
                return;
            }

            bool ledCheck = true;
            var  dtModels = DataStorage.devToolsDb.Where(nc => nc.nc12 == DataStorage.currentOrder.modelId + "00").ToList();

            if (dtModels.Count() == 0)
            {
                MessageBox.Show("Brak danych w DevTools - wpisz ilości LED ręcznie");
                ledCheck = false;
                //........
            }

            Dictionary <string, LedStructForTechnologicSpec> ledForTechCard = DataPreparation.LedForTechCard(ref ledCheck);
            bool nonStandardOrder = false; //false

            if (!ledCheck)
            {
                if (!superuserList.Contains(currentUser))
                {
                    MessageBox.Show("Błąd danych - dioda LED nie neleży do struktury danych." + Environment.NewLine + Environment.NewLine + "Brak uprawnień do stworzenia niestandardowego - tylko Mistrz i Pierwszy Operator");
                    return;
                }

                if (superuserList.Contains(currentUser))
                {
                    MessageBox.Show("Błąd danych - dioda LED nie neleży do struktury danych." + Environment.NewLine + "Należy ręcznie wpisać nazwę, 12NC i ilość diody");
                    nonStandardOrder = true;
                }
            }

            var excPkg = ExcelOperations.GetExcelPackage(DataStorage.currentOrder.modelId);// currentOrder.modelId);

            if (excPkg != null)
            {
                string additionalComment = lProdWerehouseStock.Text != "..." ? $"Wyrób znajduje się na regale: {lProdWerehouseStock.Text}" : "";

                ExcelOperations.FillOutExcelData(DataStorage.currentOrder, ref excPkg, ledForTechCard, nonStandardOrder, additionalComment);
                string tempFile = ExcelOperations.SaveExcelAndReturnPath(excPkg);
                Process.Start(tempFile);
            }
        }