Beispiel #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);
            }
        }
Beispiel #2
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();
            }
        }