public static void obrisiMonitoring(tblMonitoring monitoring) { query = "DELETE Monitoring WHERE IDMonitoring = @idMonitoring"; command = new SqlCommand(query, DBCommOsnovnePostavke.connection); command.Parameters.AddWithValue("@idMonitoring", monitoring.idMonitoring); command.ExecuteNonQuery(); }
public static tblMonitoring getSingleMonitoring(string idKlijent, string naziv) { tblMonitoring monitoring = new tblMonitoring(); query = "SELECT IDMonitoring, IDKlijent, IDVrstaMonitoringa, IDTipFajla, Naziv, SaljeSeMail " + "FROM Monitoring WHERE " + "IDKlijent = @idKlijent AND naziv = @naziv"; command = new SqlCommand(query, DBCommOsnovnePostavke.connection); command.Parameters.AddWithValue("@idKlijent", idKlijent); command.Parameters.AddWithValue("@naziv", naziv); reader = command.ExecuteReader(); Console.WriteLine(idKlijent + " " + naziv); if (reader.Read()) { monitoring.idMonitoring = reader[0].ToString().Trim(); monitoring.idKlijent = reader[1].ToString().Trim(); monitoring.idVrstaMonitoringa = reader[2].ToString().Trim(); monitoring.idTipFajla = reader[3].ToString().Trim(); monitoring.naziv = reader[4].ToString().Trim(); monitoring.saljeSeMail = reader[5].ToString().Trim(); } reader.Close(); return(monitoring); }
private void btnDodajOsnovne_Click(object sender, EventArgs e) { if (txtNaziv.Text.Trim() == "") { return; } if (!edit) { DBCommOsnovnePostavke.connection = new SqlConnection(DBBlokadeData.connectionString); DBCommOsnovnePostavke.connection.Open(); DBCommOsnovnePostavke.insertOsnovne(klijent.idKlijent, ((VrstaMonitoringa)cmbVrstaMonitoringa.SelectedItem).idVrstaMonitoringa, ((TipFajla)cmbTipFajla.SelectedItem).idTipFajla, txtNaziv.Text); DBCommOsnovnePostavke.connection.Close(); } else { DBCommOsnovnePostavke.connection = new SqlConnection(DBBlokadeData.connectionString); DBCommOsnovnePostavke.connection.Open(); DBCommOsnovnePostavke.updateOsnovne(monitoring.idMonitoring, ((VrstaMonitoringa)cmbVrstaMonitoringa.SelectedItem).idVrstaMonitoringa, ((TipFajla)cmbTipFajla.SelectedItem).idTipFajla, txtNaziv.Text, txtMail.Text); DBCommOsnovnePostavke.connection.Close(); } DBCommOsnovnePostavke.connection = new SqlConnection(DBBlokadeData.connectionString); DBCommOsnovnePostavke.connection.Open(); monitoring = DBCommOsnovnePostavke.getSingleMonitoring(klijent.idKlijent, txtNaziv.Text); DBCommOsnovnePostavke.connection.Close(); grpMail.Enabled = grpNadgledaneFirme.Enabled = true; parent.ucitajKlijente(parent.cmbKlijenti.SelectedIndex); parent.ucitajMonitoring(); }
private void btnGenerisiIzabrani_Click(object sender, EventArgs e) { selectedKlijent = (Klijent)cmbKlijenti.SelectedItem; selectedMonitoring = (tblMonitoring)cmbMonitoring.SelectedItem; selectedMonitoring.lstMaticniBrojevi = nfpm.maticniBrojevi; generisiIzvestajThread = new Thread(new ThreadStart(generisi)); generisiIzvestajThread.Start(); }
private void btnObrisiMonitoring_Click(object sender, EventArgs e) { tblMonitoring monitoring = (tblMonitoring)lstMonitorings.SelectedItem; DBCommOsnovnePostavke.connection = new SqlConnection(DBBlokadeData.connectionString); DBCommOsnovnePostavke.connection.Open(); DBCommOsnovnePostavke.obrisiMonitoring(monitoring); DBCommOsnovnePostavke.connection.Close(); ucitajMonitoring(); }
public frmAddOsnovne(Object klijent, bool edit, Object monitoring, frmAddMonitoring parent) { InitializeComponent(); this.monitoring = (tblMonitoring)monitoring; this.edit = edit; this.klijent = (Klijent)klijent; lblKlijent.Text = this.klijent.naziv; ucitajVrstuMonitoringa(); ucitajTipFajla(); txtNaziv.Text = this.monitoring.naziv; ucitajMaticneBrojeve(); ucitajMailove(); btnDodajOsnovne.Text = "Snimi izmene"; if (edit == true) { grpMail.Enabled = grpNadgledaneFirme.Enabled = true; } else { grpMail.Enabled = grpNadgledaneFirme.Enabled = false; } this.parent = parent; this.FormBorderStyle = FormBorderStyle.FixedDialog; if (this.monitoring.saljeSeMail == "1") { chkSaljeSeMail.Checked = true; } else { chkSaljeSeMail.Checked = false; } }
public static List <ZaGenerisanje> getListZaGenerisanje() { SqlDataReader innerReader; string innerQuery; SqlCommand innerCommand; SqlConnection innerConnection; List <ZaGenerisanje> listZaGenerisanje = new List <ZaGenerisanje>(); List <Klijent> lstKlijent = new List <Klijent>(); query = "SELECT IDKlijent, MaticniBroj, Naziv FROM Klijent"; command = new SqlCommand(query, DBZaGenerisanje.connection); reader = command.ExecuteReader(); while (reader.Read()) { lstKlijent.Add(new Klijent(reader[0].ToString().Trim(), reader[1].ToString().Trim(), reader[2].ToString().Trim())); } reader.Close(); int i = 0; foreach (Klijent k in lstKlijent) { listZaGenerisanje.Add(new ZaGenerisanje()); listZaGenerisanje[i].klijent = k; query = "SELECT IDMonitoring, IDKlijent, IDVrstaMonitoringa, IDTipFajla, Naziv, SaljeSeMail " + "FROM Monitoring WHERE IDKlijent = @idKlijent"; command = new SqlCommand(query, DBZaGenerisanje.connection); command.Parameters.AddWithValue("@idKlijent", k.idKlijent); reader = command.ExecuteReader(); while (reader.Read()) { tblMonitoring m = new tblMonitoring(); m.idMonitoring = reader[0].ToString().Trim(); m.idKlijent = reader[1].ToString().Trim(); m.idVrstaMonitoringa = reader[2].ToString().Trim(); m.idTipFajla = reader[3].ToString().Trim(); m.naziv = reader[4].ToString().Trim(); m.saljeSeMail = reader[5].ToString().Trim(); innerConnection = new SqlConnection(DBZaGenerisanje.connectionString); innerConnection.Open(); innerQuery = "SELECT Mail FROM Mail WHERE IDMonitoring = @idMonitoring"; innerCommand = new SqlCommand(innerQuery, innerConnection); innerCommand.Parameters.AddWithValue("@idMonitoring", m.idMonitoring); innerReader = innerCommand.ExecuteReader(); while (innerReader.Read()) { m.lstMail.Add(innerReader[0].ToString().Trim()); } innerReader.Close(); innerQuery = "SELECT MaticniBroj FROM NadgledanaFirma INNER JOIN MonitoringFirma on NadgledanaFirma.IDNadgledanaFirma = MonitoringFirma.IDNadgledanaFirma WHERE IDMonitoring = @idMonitoring"; innerCommand = new SqlCommand(innerQuery, innerConnection); innerCommand.Parameters.AddWithValue("@idMonitoring", m.idMonitoring); innerReader = innerCommand.ExecuteReader(); while (innerReader.Read()) { m.lstMaticniBrojevi.Add(innerReader[0].ToString().Trim()); } innerReader.Close(); innerConnection.Close(); listZaGenerisanje[i].monitoring.Add(m); } reader.Close(); i++; } return(listZaGenerisanje); }
private void generisi() { UcitavanjeGenerisanje.generisiIzvestaj(selectedKlijent, selectedMonitoring, txtConsole, txtConsole); selectedMonitoring = null; selectedKlijent = null; }