Example #1
0
		private void detach_tblCelijas(tblCelija entity)
		{
			this.SendPropertyChanging();
			entity.tblRedak = null;
		}
Example #2
0
		private void detach_tblCelijas(tblCelija entity)
		{
			this.SendPropertyChanging();
			entity.tblVrstaGrafa = null;
		}
Example #3
0
 partial void UpdatetblCelija(tblCelija instance);
Example #4
0
 partial void DeletetblCelija(tblCelija instance);
Example #5
0
 partial void InserttblCelija(tblCelija instance);
Example #6
0
		private void attach_tblCelijas(tblCelija entity)
		{
			this.SendPropertyChanging();
			entity.tblUpit = this;
		}
        protected void LinkButtonDodajStranicu_Click(object sender, EventArgs e)
        {
            //upisi stranicu semafora
            SemaforiDataContext db = new SemaforiDataContext();

            tblStranica stranica = new tblStranica();
            tblRedak redak = new tblRedak();

            stranica.semaforID = Convert.ToInt32(labelSemaforID.Text);
            stranica.naziv = "Privremeni naziv stranice";
            stranica.refreshPeriod = 10000;
            stranica.brojRedova = 1;
            db.tblStranicas.InsertOnSubmit(stranica);
            db.SubmitChanges();

            //upisi redove
            redak.stranicaID = stranica.Id;
            db.tblRedaks.InsertOnSubmit(redak);
            db.SubmitChanges();

            //po defaultu nam graID i upitID ne postoje, pa nas onda strga u null vrijednosti kod prikaza !!!

            //upisi celije
            for (int i = 0; i < 3; ++i) {
                tblCelija celija = new tblCelija();
                celija.redakID = redak.id;
                celija.upitID = 9999;
                celija.grafID = 9999;
                db.tblCelijas.InsertOnSubmit(celija);
                db.SubmitChanges();
            }

            prikaziSemafor(stranica.semaforID);
            prikaziStranicu(stranica.Id);
            oznaciTabStranice(stranica.Id);
        }
        protected void DropDownListStranicaBrojRedova_SelectedIndexChanged(object sender, EventArgs e)
        {
            //ovdje dodajemo ili brišemo redove i njihove pripadne ćelije

            SemaforiDataContext db = new SemaforiDataContext();
            var stranica = (from tblStranica in db.tblStranicas where tblStranica.Id == Convert.ToInt32(LabelStranicaID.Text) select tblStranica).Single();

            stranica.brojRedova = Convert.ToInt32(DropDownListStranicaBrojRedova.SelectedValue);

            try {
                db.SubmitChanges();
            }
            catch (Exception e1) {
                Console.WriteLine(e1);
            }

            // tu trebamo dodati ili brisati redove, zavisi da li ih ima više ili manje. Također treba dodavati ili brisati i njihove ćelije

            switch (stranica.brojRedova) {
                case 1:
                    // bili smo na 2, briši zadnji red
                    // prvo provjeri koja dva imamo pokupi redakID iz celije
                    IEnumerable<tblRedak> redovi = (from tblRedak in db.tblRedaks where tblRedak.stranicaID == Convert.ToInt32(LabelStranicaID.Text) select tblRedak).OrderByDescending(x => x.id);

                    tblRedak redZaBrisanje = redovi.First();
                    if (redovi.Count() > 1) {
                        db.tblRedaks.DeleteOnSubmit(redZaBrisanje);

                        IEnumerable<tblCelija> celije = (from tblCelija in db.tblCelijas where tblCelija.redakID == redZaBrisanje.id select tblCelija);
                        db.tblCelijas.DeleteAllOnSubmit(celije);
                        db.SubmitChanges();
                    }

                    break;
                case 2:
                    // trebamo dodati red
                    tblRedak redak = new tblRedak();
                    redak.stranicaID = stranica.Id;
                    db.tblRedaks.InsertOnSubmit(redak);
                    db.SubmitChanges();

                    // dodajemo i njegove celije
                    for (int i = 0; i < 3; ++i) {
                        tblCelija celija = new tblCelija();
                        celija.redakID = redak.id;
                        celija.upitID = 9999;
                        celija.grafID = 9999;
                        db.tblCelijas.InsertOnSubmit(celija);
                        db.SubmitChanges();
                    }

                    break;

            }

            ListViewStranice.DataBind();
            ListViewRedovi.DataBind();

            contentUpdatePanel.Update();
            oznaciTabStranice(stranica.Id);
        }
        protected void DodajSemafor_Click(object sender, EventArgs e)
        {
            /*
            dodajemo semafor
            Svaki semafor odmah dobije jednu stranicu i jedan red
            dignemo prozor sa nazivom semafora, upišemo ga i prikažemo sve na desnoj strani
            */

            SemaforiDataContext db = new SemaforiDataContext();
            string privremeniNaslovSemafora = "Novi Semafor";

            tblSemafor semafor = new tblSemafor();
            tblStranica stranica = new tblStranica();
            tblRedak redak = new tblRedak();

            // upisi semafor
            semafor.naziv = privremeniNaslovSemafora;
            db.tblSemafors.InsertOnSubmit(semafor);
            db.SubmitChanges();

            //upisi stranicu semafora
            stranica.semaforID = semafor.Id;
            stranica.naziv = "Privremeni naziv stranice";
            stranica.refreshPeriod = 10000;
            stranica.brojRedova = 1;
            db.tblStranicas.InsertOnSubmit(stranica);
            db.SubmitChanges();

            //upisi redove
            redak.stranicaID = stranica.Id;
            db.tblRedaks.InsertOnSubmit(redak);
            db.SubmitChanges();

            //dodaj retku 3 celije
            for (int i = 0; i < 3; ++i) {
                tblCelija celija = new tblCelija();
                celija.redakID = redak.id;
                celija.grafID = 9999;              //samo privremeno da ne bude problema kasnije !!!
                celija.upitID = 9999;
                db.tblCelijas.InsertOnSubmit(celija);
                db.SubmitChanges();
            }

            prikaziSemafor(semafor.Id);
        }