Torna al Thread
private void Modifica()
{
string connetionString;
string Descr = this.txtCap.ToString().Replace("'", "''");
string queryString;
string Percorso = this.lblNomePerc.Text;
queryString = @"UPDATE Azienda SET Denominazione = @Nome, Indirizzo = @Ind, Luogo = @Luogo, Cap = @Cap, Comune = @City, Provincia = @Provincia,
Partiva = @PI, CodFisc = @CF, Telefono = @Tel, Fax = @Fax,
Sito = @Sito, Posta = @Posta, Denominazione2 = @Denominazione2, Indirizzo2 = @Ind2, Luogo2 = @Luogo2, Cap2 = @Cap2, Comune2 = @City2, Prov2 = @Provincia2,
Telefono2 = @Tel2, Fax2 = @Fax2, Banca = @Banca, coordinate = @coordinate,
Banca2 = @Banca2, coordinate2 = @coordinate2, marchio = @marchio WHERE ID = @ID";
//MessageBox.Show(queryString);
connetionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Percorso + "\\PlazArch.accdb;Persist Security Info=False;";
MessageBox.Show(connetionString);
string luogoA = (this.txtCap.Text.ToString() + " - " + this.txtComune.Text.ToString() + " " + this.txtProvincia.Text.ToString()).Replace("'", "''");
string luogoB = (this.txtCap2.Text.ToString() + " - " + this.txtComune2.Text.ToString() + " " + this.txtProv2.Text.ToString()).Replace("'", "''");
try
{
using (OleDbConnection connection = new OleDbConnection(
connetionString))
{
OleDbCommand command = new OleDbCommand(queryString, connection);
command.Connection.Open();
command.Parameters.Add("@ID", OleDbType.Integer, 4, "ID").Value = int.Parse(1.ToString());
command.Parameters.Add("@Nome", OleDbType.VarChar, 255, "Denominazione").Value = Descr;
command.Parameters.Add("@Ind", OleDbType.VarChar, 255, "Indirizzo").Value = this.txtIndirizzo.ToString().Replace("'", "''");
command.Parameters.Add("@Luogo", OleDbType.VarChar, 255, "Luogo").Value = luogoA;
command.Parameters.Add("@Cap", OleDbType.VarChar, 255, "Cap").Value = this.txtCap.Text.ToString().Replace("'", "''");
command.Parameters.Add("@City", OleDbType.VarChar, 255, "Comune").Value = this.txtComune.ToString().Replace("'", "''");
command.Parameters.Add("@Provincia", OleDbType.VarChar, 255, "Provincia").Value = this.txtProvincia.ToString().Replace("'", "''");
command.Parameters.Add("@PI", OleDbType.VarChar, 255, "Partiva").Value = this.txtPartIva.ToString().Replace("'", "''");
command.Parameters.Add("@CF", OleDbType.VarChar, 255, "CodFisc").Value = this.txtCodFisc.ToString().Replace("'", "''");
command.Parameters.Add("@Tel", OleDbType.VarChar, 255, "Telefono").Value = this.txtTelefono.ToString().Replace("'", "''");
command.Parameters.Add("@Fax", OleDbType.VarChar, 255, "Fax").Value = this.txtFax.ToString().Replace("'", "''");
command.Parameters.Add("@Sito", OleDbType.VarChar, 255, "Sito").Value = this.txtSito.ToString().Replace("'", "''");
command.Parameters.Add("@Posta", OleDbType.VarChar, 255, "Posta").Value = this.txtPosta.ToString().Replace("'", "''");
command.Parameters.Add("@Denominazione2", OleDbType.VarChar, 255, "Denominazione2").Value = this.txtSede2.ToString().Replace("'", "''");
command.Parameters.Add("@Ind2", OleDbType.VarChar, 255, "Indirizzo2").Value = this.txtIndirizzo2.ToString().Replace("'", "''");
command.Parameters.Add("@Luogo2", OleDbType.VarChar, 255, "Luogo2").Value = luogoB;
command.Parameters.Add("@Cap2", OleDbType.VarChar, 255, "Cap2").Value = this.txtCap2.ToString().Replace("'", "''");
command.Parameters.Add("@City2", OleDbType.VarChar, 255, "Comune2").Value = this.txtComune2.ToString().Replace("'", "''");
command.Parameters.Add("@Provincia2", OleDbType.VarChar, 255, "Provincia2").Value = this.txtProv2.ToString().Replace("'", "''");
command.Parameters.Add("@Tel2", OleDbType.VarChar, 255, "Telefono2").Value = this.txtTelefono2.ToString().Replace("'", "''");
command.Parameters.Add("@Fax2", OleDbType.VarChar, 255, "Fax2").Value = this.txtFax2.ToString().Replace("'", "''");
command.Parameters.Add("@Banca", OleDbType.VarChar, 255, "Banca").Value = this.txtBanca.ToString().Replace("'", "''");
command.Parameters.Add("@coordinate", OleDbType.VarChar, 255, "coordinate").Value = this.txtIban.ToString().Replace("'", "''");
command.Parameters.Add("@Banca2", OleDbType.VarChar, 255, "Banca2").Value = this.txtBanca2.ToString().Replace("'", "''");
command.Parameters.Add("@coordinate2", OleDbType.VarChar, 255, "coordinate2").Value = this.txtIban2.ToString().Replace("'", "''");
command.Parameters.Add("@marchio", OleDbType.VarChar, 255, "marchio").Value = this.textBox1.ToString().Replace("'", "''");
command.ExecuteNonQuery();
command.Connection.Close();
}
MessageBox.Show("Modifica dati effettuata.", "Plaza " + this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Blocca();
btnModifica.Enabled = true;
this.btnSalva.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString() + "\nerrore nella modifica dei dati.");
//this.txtFile.Text = "";
}
}