public void prendidestinazionicliente(string cliente) { clientedestinazione.Clear(); try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from cliente_destinazione where nomecliente = @nomecli"; cmd.Parameters.AddWithValue("@nomecli" , cliente); cmd.Connection = conn; destinazioniadapter.SelectCommand = cmd; destinazioniadapter.Fill(clientedestinazione); destinazionibuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(destinazioniadapter); datagriddestinazioni.DataSource = clientedestinazione; conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
private void FrmCheckProduct_Load(object sender, EventArgs e) { string select = @"SET @sql = NULL; SELECT GROUP_CONCAT(DISTINCT CONCAT( 'GROUP_CONCAT((CASE Storeid when ', Storeid, ' then quantity else NULL END)) AS ', Storename ) ) INTO @sql FROM ProductInStock; SET @sql = CONCAT('SELECT Productid, ProductName, ', @sql, ' FROM ProductInStock GROUP BY ProductId, ProductName'); PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;"; MySql.Data.MySqlClient.MySqlConnection cnn = DBUtility.getConnection(); MySql.Data.MySqlClient.MySqlDataAdapter dataAdapter = new MySql.Data.MySqlClient.MySqlDataAdapter(select, cnn); //c.con is the connection string MySql.Data.MySqlClient.MySqlCommandBuilder commandBuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(dataAdapter); DataSet ds = new DataSet(); dataAdapter.Fill(ds); dataGridView1.ReadOnly = true; dataGridView1.DataSource = ds.Tables[0]; }
public void prendidestinazionicliente(string cliente) { clientedestinazione.Clear(); try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from cliente_destinazione where nomecliente = @nomecli"; cmd.Parameters.AddWithValue("@nomecli", cliente); cmd.Connection = conn; destinazioniadapter.SelectCommand = cmd; destinazioniadapter.Fill(clientedestinazione); destinazionibuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(destinazioniadapter); AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection(); foreach (DataRow row in clientedestinazione.Rows) { namesCollection.Add(row["indirizzo"].ToString()); } destinazionetextbox.AutoCompleteCustomSource = namesCollection; destinazionetextbox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; destinazionetextbox.AutoCompleteSource = AutoCompleteSource.CustomSource; conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
public string LoadDataToTargetTable(string tableName, MySql.Data.MySqlClient.MySqlConnection connection, ref DataTable dtTarget) { string errorMessage = ""; try { using (MySql.Data.MySqlClient.MySqlTransaction tran = connection.BeginTransaction(System.Data.IsolationLevel.Serializable)) { using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand()) { cmd.Connection = connection; cmd.Transaction = tran; cmd.CommandText = "SELECT * FROM MTG.Cards"; using (MySql.Data.MySqlClient.MySqlDataAdapter da = new MySql.Data.MySqlClient.MySqlDataAdapter(cmd)) { da.UpdateBatchSize = 1000; using (MySql.Data.MySqlClient.MySqlCommandBuilder cb = new MySql.Data.MySqlClient.MySqlCommandBuilder(da)) { rowsCopied += da.Update(dtTarget); tran.Commit(); } } } } System.Console.WriteLine($"{rowsCopied} rows copied."); } catch (Exception ex) { errorMessage = ex.Message; } return errorMessage; }
public void sendData(ref DataSet data) { try { dbadapter = new MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM " + Table, connection); MySql.Data.MySqlClient.MySqlCommandBuilder builder = new MySql.Data.MySqlClient.MySqlCommandBuilder(dbadapter); dbadapter.Update(data, Table); } catch (MySql.Data.MySqlClient.MySqlException ex) { throw ex; } }
public clsDataBaseAccessMySql(ref mdlTratamentoErro.clsTratamentoErro TratadorErro, string strHost, string strPort, string strDataBaseName, string strUser, string strPassword) : base(ref TratadorErro, strUser, strPassword) { m_enumConnectionType = ConnectionType.PATH; m_strHost = strHost; m_strPort = m_strPort; m_strDataBaseName = strDataBaseName.ToLower(); GenerateConnectionString(); m_DataAdapter = new MySql.Data.MySqlClient.MySqlDataAdapter(); m_CommandSelect = new MySql.Data.MySqlClient.MySqlCommand(); m_CommandSelect.Connection = m_Connection; m_DataAdapter.SelectCommand = m_CommandSelect; m_CommandBuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(m_DataAdapter); m_nDefaultPort = 3306; }
protected DataSet QueryDataSet(string Sql) { try { String mysqlStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; MySql.Data.MySqlClient.MySqlConnection mysqlcon = new MySql.Data.MySqlClient.MySqlConnection(mysqlStr); MySql.Data.MySqlClient.MySqlDataAdapter mysqlad = new MySql.Data.MySqlClient.MySqlDataAdapter(Sql, mysqlcon); MySql.Data.MySqlClient.MySqlCommandBuilder sb1 = new MySql.Data.MySqlClient.MySqlCommandBuilder(mysqlad); DataSet ds = new DataSet(); mysqlad.Fill(ds); return(ds); } catch (Exception ex) { throw; } }
public static void prendibollefatturate() { try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from bolla_fatturata"; cmd.Connection = conn; bollefatturateadapter.SelectCommand = cmd; bollefatturateadapter.Fill(bollefatturate); bollefatturatebuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(bollefatturateadapter); conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
public void metodo() { articoli.Clear(); try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from articolo"; cmd.Connection = conn; adapter.SelectCommand = cmd; adapter.Fill(articoli); cmbl = new MySql.Data.MySqlClient.MySqlCommandBuilder(adapter); dataGridView1.DataSource = articoli; cmd = new MySql.Data.MySqlClient.MySqlCommand(); string nomecli = textBox3.Text; string piva = getPartitaIvaDiCliente(nomecli); cmd.CommandText = "Select * from prezzo_articolo_cliente where nomecliente = @nomecli"; cmd.Parameters.AddWithValue("@nomecli", piva); cmd.Connection = conn; adapter.SelectCommand = cmd; adapter.Fill(prezzocliente); conn.Close(); foreach (DataRow row in prezzocliente.Rows) { foreach (DataRow art in articoli.Rows) { if (art["codicearticolo"].Equals(row["codicearticolo"])) { art["prezzolistino"] = (double)row["prezzocliente"] + 999999; } } } } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
public void prendiarticoli() { try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from articolo"; cmd.Connection = conn; articoliadapter.SelectCommand = cmd; articoliadapter.Fill(articoli); articolibuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(articoliadapter); datagridarticoli.DataSource = articoli; conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
public void prendiinformazioni() { try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from informazioni"; cmd.Connection = conn; informazioniadapter.SelectCommand = cmd; informazioniadapter.Fill(informazioni); informazionibuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(informazioniadapter); datagridinformazioni.DataSource = informazioni; conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
public void prendiclienti() { try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from cliente"; cmd.Connection = conn; clientiadapter.SelectCommand = cmd; clientiadapter.Fill(clienti); clientibuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(clientiadapter); datagridclienti.DataSource = clienti; conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
public void prendiprezziadhoc(string codicearticolo) { prezzoadhoc.Clear(); try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from prezzo_articolo_cliente where codicearticolo = @codice"; cmd.Connection = conn; cmd.Parameters.AddWithValue("@codice", codicearticolo); hocadapter.SelectCommand = cmd; hocadapter.Fill(prezzoadhoc); hocbuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(hocadapter); datagridprezziadhoc.DataSource = prezzoadhoc; conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
public void prendipivacliente(string cliente) { clientepiva.Clear(); try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from cliente_piva where nomecliente = @nomecli"; cmd.Parameters.AddWithValue("@nomecli", cliente); cmd.Connection = conn; pivaadapter.SelectCommand = cmd; pivaadapter.Fill(clientepiva); pivabuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(pivaadapter); datagridpartitaiva.DataSource = clientepiva; conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }
public void prendirighedibolla(string numerodoc, DateTime datadoc) { righebolla.Rows.Clear(); try { conn = new MySql.Data.MySqlClient.MySqlConnection(connessione); conn.Open(); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "Select * from riga_bolla where numerodocumento = @numerodocumento and datadocumento = @datadocumento"; cmd.Connection = conn; cmd.Parameters.AddWithValue("@numerodocumento", numerodoc); cmd.Parameters.AddWithValue("@datadocumento", datadoc); rigabollaadapter.SelectCommand = cmd; rigabollaadapter.Fill(righebolla); rigabollabuilder = new MySql.Data.MySqlClient.MySqlCommandBuilder(rigabollaadapter); datagridrighe.DataSource = righebolla; conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException e) { conn.Close(); throw; } }