private void btnModifica_Click(object sender, RoutedEventArgs e) { linieSelectataGrid = gridIntrastat.SelectedIndex; if (linieSelectataGrid == -1) { gridIntrastat.SelectedIndex = 0; } Declaratii declaratieSelectata = gridIntrastat.SelectedItem as Declaratii; // DataRowView dataRow = (DataRowView)gridIntrastat.SelectedItem; // int index = gridIntrastat.CurrentCell.Column.DisplayIndex; string tip = declaratieSelectata.Tip_Declaratie; string luna = declaratieSelectata.Luna; string an = declaratieSelectata.Anul; StreamReader stream = new StreamReader(FileLocation.System + "key\\chei.txt"); string line = ""; bool flag = false; while (true) { line = stream.ReadLine(); if (line == null) { break; } string[] keys = line.Split('\t'); string[] arrKeyTxt = new string[4]; if (keys[0].Length > 17) { arrKeyTxt = Inregistrare.DecodeKey(keys[0]); if (arrKeyTxt[0] == keys[1] && an == keys[2]) { flag = true; } } } stream.Close(); if (flag == true) { Frm_Intrastat frmIntrastat = new Frm_Intrastat(tip, luna, an); frmIntrastat.Show(); } else { Frm_Mesaj_Demo frmIntrastat = new Frm_Mesaj_Demo("Inregistrare"); frmIntrastat.Show(); } }
private void btnGenereazaFisierIntrastat_Click(object sender, RoutedEventArgs e) { linieSelectataGrid = gridIntrastat.SelectedIndex; if (linieSelectataGrid == -1) { gridIntrastat.SelectedIndex = 0; } Declaratii declaratieSelectata = gridIntrastat.SelectedItem as Declaratii; // DataRowView dataRow = (DataRowView)gridIntrastat.SelectedItem; // int index = gridIntrastat.CurrentCell.Column.DisplayIndex; string tip = declaratieSelectata.Tip_Declaratie; string luna = declaratieSelectata.Luna; string an = declaratieSelectata.Anul; Frm_Intrastat frmIntrastat = new Frm_Intrastat(tip, luna, an); frmIntrastat.Show(); }
private void StergeInregistrare(string tableName) { Declaratii declaratieSelectata = gridIntrastat.SelectedItem as Declaratii; // DataRowView dataRow = (DataRowView)gridIntrastat.SelectedItem; // int index = gridIntrastat.CurrentCell.Column.DisplayIndex; string tip = declaratieSelectata.Tip_Declaratie; string luna = declaratieSelectata.Luna; string an = declaratieSelectata.Anul; string tipmesaj; if (tip == "I") { tipmesaj = "ACHIZITIE"; } else { tipmesaj = "LIVRARE"; } if (MessageBox.Show("STERGETI ACEASTA DECLARATIE?" + "\n" + tipmesaj + " - " + an + " - " + luna, "MESAJ", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { string _oleDBConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data source=" + FileLocation.DataBase + Firma.CodFiscal + ".mdb"; OleDbConnection dbConn = new OleDbConnection(_oleDBConnectionString); OleDbCommand dbCommand = null; string dbQuery = string.Empty; dbConn.Open(); dbQuery = "Delete FROM Intrastat" + " WHERE Anul=" + an + " AND Luna=" + luna + " AND TIP='" + tip + "'"; dbCommand = new OleDbCommand(dbQuery, dbConn); dbCommand.ExecuteNonQuery(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ERROARE: COULD NOT DELETE FROM SPECIFIED TABLES dbQuery = "Delete FROM " + tableName + " WHERE Anul=" + an + " AND Luna=" + luna + " AND TIP='" + tip + "'"; dbCommand = new OleDbCommand(dbQuery, dbConn); dbCommand.ExecuteNonQuery(); dbConn.Close(); } else { //do yes stuff } }