예제 #1
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);
        }
예제 #2
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);

                    int  i;
                    bool success = Int32.TryParse(Port, out i);
                    if (success)
                    {
                        key.SetValue(name.Port, Port);
                        flag = true;
                    }
                }
            }
            catch (Exception ex)
            {
                RecordOfExceptions.Save(Convert.ToString(ex), "DataSender");
                flag = false;
            }
            return(flag);
        }
예제 #3
0
        private void CreateSQLiteDatabaseFile()
        {
            DirectoryInfo di = new DirectoryInfo(folderDatabase);

            if (!di.Exists)
            {
                try
                {
                    di.Create();
                }
                catch (Exception ex)
                {
                    RecordOfExceptions.Save(Convert.ToString(ex), "CreateSQLiteDatabaseFile");
                }
            }

            FileInfo fi = new FileInfo(folderDatabase + databaseFile);

            if (!fi.Exists)
            {
                SQLiteConnection.CreateFile(folderDatabase + databaseFile);
            }
            else
            {
            }
        }
예제 #4
0
        public void ClearTRegistry()
        {
            RegistryKey key = Microsoft.Win32.Registry.CurrentUser;

            try
            {
                key.DeleteSubKey(subKey);
            }
            catch (Exception ex)
            {
                RecordOfExceptions.Save(Convert.ToString(ex), "SaveRegistry");
            }
            key.Close();
        }
예제 #5
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");
     }
 }
예제 #6
0
 private void CreateSQLiteDishes(SQLiteConnection cn)
 {
     using (cn)
     {
         string sql2 = "CREATE TABLE '" + name.Dishes + "'('id' INTEGER PRIMARY KEY,'" + name.IdPrice + "' int, '" + name.Dish + "' TEXT ,'" + name.Price + "' TEXT,'" + name.SidesDishes + "' );";
         try
         {
             cn.Open();
             SQLiteCommand cmd = new SQLiteCommand(sql2, cn);
             cmd.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             RecordOfExceptions.Save(Convert.ToString(ex), "CreateSQLiteDishes");
         }
         cn.Close();
     }
 }
예제 #7
0
 private void CreateSQLitePriceAll(SQLiteConnection cn)
 {
     using (cn)
     {
         string sql = "CREATE TABLE '" + name.PriceAll + "'('id' INTEGER PRIMARY KEY , '" + name.Price + "' TEXT, '" + name.Date + "' TEXT, '" + name.Comments + "' TEXT);";
         try
         {
             cn.Open();
             SQLiteCommand cmd = new SQLiteCommand(sql, cn);
             cmd.ExecuteNonQuery();
             cmd.Cancel();
         }
         catch (Exception ex)
         {
             RecordOfExceptions.Save(Convert.ToString(ex), "CreateSQLitePriceAll");
         }
         cn.Close();
     }
 }
예제 #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);
        }