Exemplo n.º 1
0
        private static void StartProcess()
        {
            try
            {
                Process process = new Process();
                process.StartInfo.FileName       = @".\tag.pdf";
                process.StartInfo.Verb           = "print";
                process.StartInfo.Arguments      = String.Format(@"/p /h {0}", @".\tag.pdf");
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.WindowStyle    = ProcessWindowStyle.Hidden;

                process.Start();

                if (process.HasExited == false)
                {
                    process.WaitForExit(1000);
                }

                process.EnableRaisingEvents = true;

                if (!process.WaitForExit(1000))
                {
                    process.Kill();
                }

                KillAdobe();
            }
            catch (Exception ex)
            {
                ErrorsCare.AppendErrorOnErrorsFile(ex.Message);

                System.Windows.Forms.MessageBox.Show("Houve um erro fatal ao tentar imprimir a etiqueta! Mais informações no arquivo logs.txt.");
            }
        }
Exemplo n.º 2
0
        public static bool Product(Product product)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Product));

                StreamWriter sw = new StreamWriter(InformationsCore.Directories.Products + product.Id.ToString() + ".xml", false, Encoding.UTF8);

                serializer.Serialize(sw, product);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Ocorreu um erro ao tentar gravar um arquivo no dispositivo, veja o arquivo log.txt para mais detalhes.", "Erro");

                ErrorsCare.AppendErrorOnErrorsFile(ex.Message);

                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public static bool Addresses(List <Address> addresses)
        {
            try
            {
                foreach (Address address in addresses)
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(Address));

                    StreamWriter sw = new StreamWriter(InformationsCore.Directories.Addresses + address.Id.ToString() + ".xml");

                    serializer.Serialize(sw, address);
                }
            }
            catch (Exception ex)
            {
                ErrorsCare.AppendErrorOnErrorsFile(ex.Message);

                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public static bool Kits(List <Kit> kits)
        {
            try
            {
                foreach (Kit kit in kits)
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(Kit));

                    StreamWriter sw = new StreamWriter(InformationsCore.Directories.Products + kit.Id.ToString() + ".xml", false, Encoding.UTF8);

                    serializer.Serialize(sw, kit);
                }
            }
            catch (Exception ex)
            {
                ErrorsCare.AppendErrorOnErrorsFile(ex.Message);

                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        private void BTN_ImportExcel_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult warningResult = MessageBox.Show("O arquivo deverá ser do tipo XML, ter sido gerado pelo Protheus 12 (SA7) e ter apenas 3 colunas, na seguinte sequência: 'Produto', 'Código do cliente' e 'Descrição do Produto'. Caso essa sequência não seja respeitada então os dados dos produtos ficarão invertidos." +
                                                             "\n\nDeseja continuar?", "Atenção!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (warningResult == DialogResult.No)
                {
                    return;
                }

                OFD_FileSelector.Filter = "Arquivos Extensible Markup Language|*.xml";

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

                DialogResult resultConf = MessageBox.Show("O arquivo " + OFD_FileSelector.FileName + " foi selecionado, deseja continuar?", "Confirmar Arquivo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (DialogResult == DialogResult.No)
                {
                    return;
                }

                string fileName = OFD_FileSelector.FileName;
                int    alreadyExist = 0, created = 0;

                OFD_FileSelector.Dispose();

                Library.Protheus12Xml.Reader xmlReader = new Library.Protheus12Xml.Reader(fileName);
                List <Product> products = xmlReader.XmlToProducts();
                if (products.Count < 1)
                {
                    return;
                }

                foreach (Product product in products)
                {
                    if (GlobalVariables.Products.Exists(x => x.CodeBSC == product.CodeBSC && x.CodeClient == product.CodeClient))
                    {
                        alreadyExist++;

                        continue;
                    }
                    else
                    {
                        product.Id = GlobalVariables.CurrentFreeProductsId;
                        GlobalVariables.CurrentFreeProductsId++;

                        // RAM
                        GlobalVariables.Products.Add(product);

                        // LOCAL
                        Library.Serialization.Serialize.Product(product);

                        created++;
                    }
                }

                MessageBox.Show(("Produtos lidos: " + xmlReader.TotalRows.ToString() +
                                 "\nProdutos que já existiam: " + alreadyExist.ToString() +
                                 "\nProdutos cadastrados: " + created.ToString()), "Resultado da importação");

                if (created > 0)
                {
                    this.Added = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não foi possível prosseguir com a importação devido um erro. Para mais detalhes veja o arquivo log.txt", "Erro!");

                ErrorsCare.AppendErrorOnErrorsFile(ex.Message);
            }
        }