// GET: SqlDataReaderObject public ActionResult Index() { List <Tecaj> lstTecajevi = new List <Tecaj>(); string connString = ConfigurationManager.ConnectionStrings["dbAlgebraConnStrSql"].ConnectionString; using (SqlConnection conn = new SqlConnection(connString)) { string cmdText = ""; cmdText += "SELECT * FROM [dbo].[tblTecajevi]"; SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { if (reader.HasRows) { while (reader.Read()) { Tecaj t1 = new Tecaj(); t1.Id = (int)reader["id"]; t1.Naziv = (string)reader["naziv"]; t1.Opis = (string)reader["opis"]; lstTecajevi.Add(t1); } } } reader.Close(); } return(View(lstTecajevi)); }
private void PrikaziPodatke(string uri) { List <Tecaj> lista = Tecaj.DohvatiRESTPodatke(uri); dgvTecajnaLista.DataSource = null; dgvTecajnaLista.DataSource = lista; }
private void NapuniCombobox() { List <Tecaj> lista = Tecaj.DohvatiRESTPodatke("http://api.hnb.hr/tecajn/v1"); cbValute.DisplayMember = "Valuta"; cbValute.SelectedValue = "Valuta"; cbValute.DataSource = null; cbValute.DataSource = lista; }
private void uibtnPretvori_Click(object sender, EventArgs e) { if (Tecaj.ProvjeraUnosa(txtStranaValuta.Text).Equals(false)) { MessageBox.Show("Provjerite jeste li uniejli broj", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { uiIznosUKunama.Text = ((dgvTecajnaLista.SelectedRows[0].DataBoundItem) as Tecaj).KonvertirajIznosUKune(txtStranaValuta.Text).ToString(); } }
// GET: SqlDataReaderObjekt public ActionResult Index() { //kreiramo connectionString i Connection objekt List <Tecaj> lstTecajevi = new List <Tecaj>(); string connString = ConfigurationManager.ConnectionStrings["dbAlgebraConnString"].ConnectionString; using (SqlConnection conn = new SqlConnection(connString)) { //Kreiramo SQL naredbu za upis string cmdText = "SELECT * FROM tblTecajevi"; //Kreiramo Command objekt i otvaramo vezu s bazom SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.Connection.Open(); //Komandu izvršavamo pozivom ExecuteReader(); //koja kreira SqlDataReader objekt SqlDataReader reader = cmd.ExecuteReader(); //Ako je pozivom metode kreiran SqlDataReader objekt if (reader != null) { //i ako ima redaka za čitanje if (reader.HasRows) { //Dok ima podataka u readeru, dodajemo ih u listu while (reader.Read()) { //Kreiramo novi Tecaj objekt Tecaj tecaj = new Tecaj(); //Postavljamo mu svojstva tecaj.Id = int.Parse(reader["IdTecaj"].ToString()); tecaj.Naziv = reader["Naziv"].ToString(); tecaj.Opis = reader["Opis"].ToString(); //Dodajemo tecaj u listu lstTecajevi lstTecajevi.Add(tecaj); } } } reader.Close(); } return(View(lstTecajevi)); }
public TecajEditModel(Tecaj tecaj) { Id = tecaj.TecajId; VrstaTecajaId = tecaj.VrstaTecajaId; Opis = tecaj.Opis; CenaEur = tecaj.CenaEur; Posebnosti = tecaj.Posebnosti; Zabelezke = tecaj.Zabelezke; DatumZacetka = tecaj.DatumZacetka; Prijavljanje = tecaj.Prijavljanje; Vrsta = tecaj.Vrsta; UrlPoUspesniPrijavi = tecaj.UrlPoUspesniPrijavi; DodatnoBesediloPoUspesniPrijavi = tecaj.DodatnoBesediloPoUspesniPrijavi; OmejitevVpisa = tecaj.OmejitevVpisa; Termini = new TerminiTecajaEditModel() { TecajId = Id }; Termini.Termini = tecaj.Termini.ToList(); }
public ActionResult Read() { string connString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=dbAlgebra;Integrated Security=True"; //priprema prazne liste za kasniji ispis List <Tecaj> lstTecaj = new List <Tecaj>(); using (SqlConnection conn = new SqlConnection(connString)) { string cmdTxt = ""; cmdTxt += "SELECT (*) FROM [dbo].[tblTecajevi] "; SqlCommand cmd = new SqlCommand(cmdTxt, conn); cmd.Connection.Open(); //vraca prvi redak, u ovom slucaju broj zapisa SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Tecaj t1 = new Tecaj(); t1.Id = (int)reader["id"]; t1.Naziv = (string)reader["naziv"]; t1.Opis = (string)reader["opis"]; lstTecaj.Add(t1); } } else { ViewBag.Message = "U tablici nema zapisa!"; } return(View("Index", lstTecaj)); } }
// GET: SqlDataReaderObject public ActionResult Index() { // Prvo kreiramo conn string // string connString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=dbAlgebra;Integrated Security=True"; string connString = ConfigurationManager.ConnectionStrings["dbAlgebraConnString"].ConnectionString; // pripremimi praznu listu tecajeva List <Tecaj> lstTecaj = new List <Tecaj>(); // Nakon toga instanca Sqlconnection using (SqlConnection conn = new SqlConnection(connString)) { string cmdTxt = ""; cmdTxt += "SELECT * FROM [dbo].[tbltecajevi] "; SqlCommand cmd = new SqlCommand(cmdTxt, conn); cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Tecaj t1 = new Tecaj(); t1.Id = (int)reader["id"]; t1.Naziv = (string)reader["naziv"]; t1.Opis = (string)reader["opis"]; lstTecaj.Add(t1); } } else { ViewBag.Message = "Zapis nije pronadjen ili nije izmjenjen"; } } return(View("Index", lstTecaj)); }
// GET: SqlDataReaderObjekt public ActionResult Index() { // Prvo kreiramo conn string //string connString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=dbAlgebra;Integrated Security=True"; string connString = ConfigurationManager.ConnectionStrings["dbAlgebraConnString"].ConnectionString; // pripremi praznu listu tecajeva List <Tecaj> lstTecaj = new List <Tecaj>(); // Nakon toga instanca SQL connection using (SqlConnection conn = new SqlConnection(connString)) { string cmdText = "SELECT * from tbltecajevi"; //Kreiramo command objekt i otvaramo vezu s bazom SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { if (reader.HasRows) { while (reader.Read()) { Tecaj t1 = new Tecaj(); t1.Id = reader["id"]; t1.Naziv = reader["naziv"]; t1.Opis = reader["opis"]; lstTecaj.Add(t1); } } } reader.Close(); } return(View("Index", lstTecaj)); }
// GET: SqlDataReaderObjekt public ActionResult Index() { //upisivanje connectionstringa u web.config string connString = ConfigurationManager.ConnectionStrings["dbAlgebraConnString"].ConnectionString; //pripremim praznu listu tecajeva List <Tecaj> lstTecaj = new List <Tecaj>(); using (SqlConnection conn = new SqlConnection(connString)) { string cmdTxt = ""; cmdTxt += "SELECT * FROM [dbo].[tbltecajevi] "; SqlCommand cmd = new SqlCommand(cmdTxt, conn); cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Tecaj t1 = new Tecaj(); t1.Id = (int)reader["id"]; t1.Naziv = (string)reader["naziv"]; t1.Opis = (string)reader["opis"]; lstTecaj.Add(t1); } } else { ViewBag.Message = "Dogodila se greška!"; } } return(View(lstTecaj)); }
public virtual ActionResult ShraniTecaj(TecajEditModel t) { if (!ModelState.IsValid) return View("UrediTecaj", enritch(t)); var tecaj = solaService.Tecaj(t.Id); if (tecaj == null) { // INSERT tecaj = new Tecaj(); t.Tecaj(ref tecaj); solaService.Dodaj(tecaj); // Dodaj še termine var vrsta = solaService.VrstaTecaja(tecaj.VrstaTecajaId); DateTime kdaj = tecaj.DatumZacetka; for (int i = 0; i < vrsta.SteviloVaj; i++) { tecaj.Termini.Add(new TerminTecaja() { Zacetek = kdaj, Entered = DateTime.Now, Guid = Guid.NewGuid(), TrajanjeMin = vrsta.TrajanjeMin } ); kdaj = kdaj.AddDays(7); } solaService.SaveChanges(); } else { // UPDATE t.Tecaj(ref tecaj); solaService.SaveChanges(); } return Redirect("~/TangoSola"); }
public void Tecaj(ref Tecaj tecaj) { tecaj.TecajId = Id; tecaj.VrstaTecajaId = VrstaTecajaId; tecaj.Opis = Opis; tecaj.CenaEur = CenaEur; tecaj.Posebnosti = Posebnosti; tecaj.Zabelezke = Zabelezke; tecaj.DatumZacetka = DatumZacetka; tecaj.Vrsta = Vrsta; tecaj.Prijavljanje = Prijavljanje; tecaj.UrlPoUspesniPrijavi = UrlPoUspesniPrijavi; tecaj.DodatnoBesediloPoUspesniPrijavi = DodatnoBesediloPoUspesniPrijavi; tecaj.OmejitevVpisa = OmejitevVpisa; tecaj.Termini = Termini.Termini; }
public ProstePrijaveViewModel(IEnumerable<ProstaPrijava> prostePrijave, Tecaj tecaj) { ProstePrijave = prostePrijave; Tecaj = tecaj; }