Exemple #1
0
        //запись данных в файл
        //запись в базу данных
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //работа с Excel
            //save.XLWb = save.XApp.Workbooks.Open(save.FileName);
            //save.Worksheet = save.XLWb.Sheets[1];
            //save.NumLastRow = save.Worksheet.Cells[save.Worksheet.Rows.Count, "C"].End[Excel.XlDirection.xlUp].Row;
            //save.NumLastRow++;
            //save.Worksheet.Cells[save.NumLastRow, "A"] = TBSite.Text;
            //save.Worksheet.Cells[save.NumLastRow, "B"] = TBLogin.Text;
            //save.Worksheet.Cells[save.NumLastRow, "C"] = PBPass.Password;

            //MessageBox.Show("Save data!");
            //save.XLWb.Close(true);

            // для удаления из базы данных DataBaseWorker.QueryWithoutResponse("DELETE FROM [DBPass] WHERE id=1");
            DataBaseWorker.Conection();
            string site = TBSite.Text;
            string log  = TBLogin.Text;
            string pas  = PBPass.Password;

            if (site != "Write Source" && log != "Write Login" && log != "")
            {
                string sqlExpression = String.Format("INSERT INTO DBPass(LoginSite,Login,Password) VALUES ('{0}', '{1}','{2}')", site, log, pas);
                DataBaseWorker.QueryWithoutResponse(sqlExpression);
                DataBaseWorker.CloseConection();
                TBSite.Text  = "Write Source";
                TBLogin.Text = "Write Login";
                PBPass.Clear();
            }
            else
            {
                MessageBox.Show("Specify data to write", "Attantion", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #2
0
        //показ базы паролей
        private void Button_Click_ShowDB(object sender, RoutedEventArgs e)
        {
            //работа с Excel
            //if (File.Exists(save.FileName))
            //{
            //    Process.Start(save.FileName);
            //}
            //else
            //{
            //    MessageBox.Show("Not file!");
            //}

            DataBaseWorker.Conection();
            List <string[]> mas = DataBaseWorker.GetData("SELECT * FROM DBPass", 4);

            Info info = new Info();

            if (mas != null)
            {
                foreach (var item in mas)
                {
                    info.a = item[1];
                    info.b = item[2];
                    info.v = item[3];

                    listDB.Items.Add(info);
                }
                Grid_ListView.Visibility = Visibility.Visible;
            }
            else
            {
                MessageBox.Show("DataBase is empty!");
            }
            DataBaseWorker.CloseConection();
        }
Exemple #3
0
        // поиск сайта по базе
        private void Find(object sender, RoutedEventArgs e)
        {
            //работа с Excel
            //save.XLWb = save.XApp.Workbooks.Open(save.FileName);
            //save.Worksheet = save.XLWb.Sheets[1];
            //string data = SearchSite.Text;
            //string Site = "";
            //string Login = "";
            //string Pas = "";
            //int i = 2;
            //int g = 1;
            //bool flag = false;

            //    while (save.Worksheet.Cells[i, g].Value2!=null)
            //    {
            //        if (save.Worksheet.Cells[i, g].Value2 == data)
            //        {
            //            Site = save.Worksheet.Cells[i, g].Value2;
            //            Login = save.Worksheet.Cells[i, g+1].Value2;
            //            Pas = save.Worksheet.Cells[i, g + 2].Value2;

            //            TBSite.Text = Site;
            //            TBLogin.Text = Login;
            //            PBPass.Password = Pas;
            //            flag = true;
            //        break;
            //        }
            //        i++;
            //    }

            //if (flag!=true)
            //{
            //    MessageBox.Show("Not found");
            //}
            //SearchSite.Text = "What to find?";
            //save.XLWb.Close(true);

            DataBaseWorker.Conection();
            List <string[]> mas  = DataBaseWorker.GetData("SELECT * FROM DBPass", 4);
            bool            flag = false;

            foreach (var item in mas)
            {
                if (item[1] == SearchSite.Text)
                {
                    TBSite.Text     = item[1];
                    TBLogin.Text    = item[2];
                    PBPass.Password = item[3];
                    flag            = true;
                    break;
                }
            }
            if (flag == false)
            {
                MessageBox.Show("Not found", "Attantion", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            DataBaseWorker.CloseConection();
        }
Exemple #4
0
        //очистить базу данных
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result;

            result = MessageBox.Show("Delete DataBase?", "Attantion", MessageBoxButton.YesNo, MessageBoxImage.Question);
            if (result == MessageBoxResult.Yes)
            {
                DataBaseWorker.Conection();
                string qury = "TRUNCATE TABLE DBPass";
                DataBaseWorker.QueryWithoutResponse(qury);
                DataBaseWorker.CloseConection();
            }
        }