Exemplo n.º 1
0
        bool DataSender(RegistryKey key)
        {
            bool flag = false;

            try
            {
                if (IsValidEmail(Sender))
                {
                    key.SetValue(name.Sender, Sender);
                    key.SetValue(name.Password, Password);
                    key.SetValue(name.Smtp, Smtp);

                    bool success = Int32.TryParse(Port, out int i);
                    if (success)
                    {
                        key.SetValue(name.Port, Port);
                        flag = true;
                    }
                }
            }
            catch (Exception ex)
            {
                RecordOfExceptions.Save(Convert.ToString(ex), "DataSender");
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 2
0
        public bool SaveRegistry()
        {
            bool        flag = false;
            RegistryKey key  = Microsoft.Win32.Registry.CurrentUser;

            try
            {
                key.CreateSubKey(subKey);
                key = key.OpenSubKey(subKey, true);

                if (IsValidEmail(Recipient))
                {
                    if (DataSender(key))
                    {
                        key.SetValue(name.Recipient, Recipient);
                        flag = true;
                    }
                }
            }
            catch (Exception ex)
            {
                RecordOfExceptions.Save(Convert.ToString(ex), "SaveRegistry");
                return(flag);
            }
            key.Close();
            return(flag);
        }
Exemplo n.º 3
0
 public void  ReadingRegistry()
 {
     try
     {
         RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(subKey);
         sender    = (string)key.GetValue(name.Sender);
         password  = (string)key.GetValue(name.Password);
         port      = (string)key.GetValue(name.Port);
         smtp      = (string)key.GetValue(name.Smtp);
         recipient = (string)key.GetValue(name.Recipient);
         key.Close();
     }
     catch (Exception ex)
     {
         RecordOfExceptions.Save(Convert.ToString(ex), "ReadingRegistry");
     }
 }
Exemplo n.º 4
0
 private void Save(Order order)
 {
     try
     {
         using (StreamWriter streamW = new StreamWriter((folderDatabase), true))
         {
             string s = "";
             s = name.BeginningOfOrderCode + "\n" + AddPriceAll(order.PriceAll) + AddDishes(order) + name.EndOfOrderCode;
             streamW.WriteLine(s);
             streamW.Flush();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Zapisanie do pilku txt nie powiodło się ", "Błąd przy zapisie", MessageBoxButtons.OK, MessageBoxIcon.Error);
         RecordOfExceptions.Save(Convert.ToString(ex), "Save");
     }
 }
Exemplo n.º 5
0
        private void SaveListOrder(List <Order> listOrder)
        {
            try
            {
                using (StreamWriter streamW = new StreamWriter((folderDatabase), false))
                {
                    streamW.WriteLine("");
                    streamW.Flush();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Zapisanie do pilku txt nie powiodło się ", "Błąd przy zapisie", MessageBoxButtons.OK, MessageBoxIcon.Error);
                RecordOfExceptions.Save(Convert.ToString(ex), "SaveFiles");
            }

            foreach (var order in listOrder)
            {
                Save(order);
            }
        }
Exemplo n.º 6
0
        public bool SendEmail(string str)
        {
            bool flag = true;

            Registry registry = new Registry();

            Message = str;
            MailMessage send = new MailMessage();

            SmtpClient client = new SmtpClient();

            try
            {
                client.Credentials = new NetworkCredential(registry.Sender, registry.Password);
                client.Host        = registry.Smtp;
                client.Port        = Convert.ToInt32(registry.Port);
                client.EnableSsl   = true;
                try
                {
                    send.From    = new MailAddress(registry.Sender);
                    send.Subject = "Zamówienie Pizza";
                    send.Body    = message;
                    send.To.Add(registry.Recipient);
                }
                catch (Exception ex)
                {
                    RecordOfExceptions.Save(Convert.ToString(ex), "SendEmail");
                    flag = false;
                }
                client.Send(send);
            }
            catch (Exception ex)
            {
                RecordOfExceptions.Save(Convert.ToString(ex), "SendEmail");
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 7
0
        private void AddPriceAll(string order, PriceAll priceAll)
        {
            try
            {
                int    idexEnd             = order.IndexOf(name.PriceAllEnd);
                string stPriceAll          = order.Substring(0, idexEnd);
                int    indexComments       = stPriceAll.IndexOf(name.Comments) + name.Comments.Length;
                int    indexCommentsRemove = stPriceAll.IndexOf(name.Comments);
                int    indexData           = stPriceAll.IndexOf(name.Date) + name.Date.Length;
                int    indexDataRemove     = stPriceAll.IndexOf(name.Date);
                int    indexPriceAll       = stPriceAll.IndexOf(name.PriceAll) + name.PriceAll.Length;

                priceAll.Comments = RemoveWhiteChar(stPriceAll.Substring(indexComments));
                stPriceAll        = RemoveWorkAndTextToEnd(stPriceAll, indexCommentsRemove);
                priceAll.Date     = RemoveWhiteChar(stPriceAll.Substring(indexData));
                stPriceAll        = RemoveWorkAndTextToEnd(stPriceAll, indexDataRemove);
                priceAll.Price    = RemoveWhiteChar(stPriceAll.Substring(indexPriceAll));
            }
            catch (Exception ex)
            {
                RecordOfExceptions.Save(Convert.ToString(ex), "AddPriceAll");
            }
        }
Exemplo n.º 8
0
        private Dish AddDishWithText(Dish dish, string textDish)
        {
            try
            {
                int indexSidesDishes        = textDish.IndexOf(name.SidesDishes) + name.SidesDishes.Length;
                int indexSidesDishessRemove = textDish.IndexOf(name.SidesDishes);
                int indexPrice       = textDish.IndexOf(name.Price) + name.Price.Length;
                int indexPriceRemove = textDish.IndexOf(name.Price);
                int indexName        = textDish.IndexOf(name.Dish) + name.Dish.Length;

                dish.SidesDishes = RemoveWhiteChar(textDish.Substring(indexSidesDishes));
                textDish         = RemoveWorkAndTextToEnd(textDish, indexSidesDishessRemove);
                dish.Price       = RemoveWhiteChar(textDish.Substring(indexPrice));
                textDish         = RemoveWorkAndTextToEnd(textDish, indexPriceRemove);
                dish.Name        = RemoveWhiteChar(textDish.Substring(indexName));
            }

            catch (Exception ex)
            {
                RecordOfExceptions.Save(Convert.ToString(ex), "AddPriceAll");
            }

            return(dish);
        }