Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Zakaznik c = (Zakaznik)Session["login"];

            if (!Page.IsPostBack)
            {
                Collection <Zbran>   zbrane   = Zbran.SelectAll();
                Collection <Prostor> prostory = Prostor.SelectAll();

                DropDownList1.DataSource     = zbrane;
                DropDownList1.DataTextField  = "Nazev";
                DropDownList1.DataValueField = "Id";

                DropDownList2.DataSource     = prostory;
                DropDownList2.DataTextField  = "Vzdalenost";
                DropDownList2.DataValueField = "Id";

                DropDownList1.DataBind();
                DropDownList2.DataBind();
            }



            if (IsPostBack)
            {
                Bul0056.Aggregates.Rezervace rez = new Bul0056.Aggregates.Rezervace();
                rez.Start     = DateTime.Parse(TextBox1.Text);
                rez.Vytvoreni = DateTime.Now;
                rez.Zakaznik  = c;
                rez.Zbran     = Zbran.getById(Int32.Parse(DropDownList1.SelectedValue));
                rez.Prostor   = Prostor.getById(Int32.Parse(DropDownList2.SelectedValue));
                Bul0056.Aggregates.Rezervace.insert(rez);
            }
        }
Esempio n. 2
0
 private Prostor GetSelectedSpr()
 {
     // The "SelectionMode" property of the data grid view must be set to "FullRowSelect".
     if (SprGrid.SelectedRows.Count == 1)
     {
         Prostor prostor = SprGrid.SelectedRows[0].DataBoundItem as Prostor;
         return(prostor);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 3
0
        protected void EditRecord()
        {
            Prostor selectedSpr = GetSelectedSpr();

            if (selectedSpr != null)
            {
                DetailProstor form = new DetailProstor();
                if (form.OpenRecord(selectedSpr.idSpr))
                {
                    form.ShowDialog();
                    GetData();
                }
            }
        }
Esempio n. 4
0
        private void BindData()
        {
            comboBox1.Items.Clear();
            comboBox2.Items.Clear();
            comboBox3.Items.Clear();
            comboBox4.Items.Clear();

            Collection <Prostor>     prostory    = Prostor.SelectAll();
            Collection <Zbran>       zbrane      = Zbran.SelectAvailable(strelba.Zacatek, strelba.Zacatek.AddMinutes(double.Parse(txtMin.Text)));
            Collection <Zakaznik>    zakaznici   = Zakaznik.SelectAll();
            Collection <Zamestnanec> zamestnanci = Zamestnanec.SelectAll();

            foreach (Prostor prostor in prostory)
            {
                comboBox1.Items.Add(prostor.Id.ToString() + " " + prostor.Vzdalenost.ToString() + "m");
                if (prostor.Id == strelba.Prostor.Id)
                {
                    comboBox1.SelectedIndex = comboBox1.Items.Count - 1;
                }
            }


            foreach (Zbran zbran in zbrane)
            {
                comboBox2.Items.Add(zbran.Nazev);
                if (zbran.Id == strelba.Zbran.Id)
                {
                    comboBox2.SelectedIndex = comboBox2.Items.Count - 1;
                }
            }

            foreach (Zakaznik zakaznik in zakaznici)
            {
                comboBox3.Items.Add(zakaznik.Email);
                if (zakaznik.Id == strelba.Zakaznik.Id)
                {
                    comboBox3.SelectedIndex = comboBox3.Items.Count - 1;
                }
            }

            foreach (Zamestnanec zamestnanec in zamestnanci)
            {
                comboBox4.Items.Add(zamestnanec.Email);
                if (zamestnanec.Id == strelba.Zamestnanec.Id)
                {
                    comboBox4.SelectedIndex = comboBox4.Items.Count - 1;
                }
            }
        }
Esempio n. 5
0
 public bool OpenRecord(object primaryKey)
 {
     if (primaryKey != null)
     {
         int idSpr = (int)primaryKey;
         prostor   = ProstorTable.select(idSpr);
         newRecord = false;
     }
     else
     {
         prostor   = new Prostor();
         newRecord = true;
     }
     BindData();
     return(true);
 }
Esempio n. 6
0
        private bool GetData()
        {
            Collection <Zakaznik>    zakaznici   = Zakaznik.SelectAll();
            Collection <Zamestnanec> zamestnanci = Zamestnanec.SelectAll();
            Collection <Zbran>       zbrane      = Zbran.SelectAvailable(DateTime.Now, DateTime.Now.AddMinutes(double.Parse(txtMin.Text)));
            Collection <Prostor>     prostory    = Prostor.SelectAll();

            strelba.Zacatek     = DateTime.Now;
            strelba.Konec       = DateTime.Now.AddMinutes(Double.Parse(txtMin.Text));
            strelba.Zakaznik    = zakaznici[comboBox3.SelectedIndex];
            strelba.Zamestnanec = zamestnanci[comboBox4.SelectedIndex];
            strelba.Prostor     = prostory[comboBox1.SelectedIndex];
            strelba.Zbran       = zbrane[comboBox2.SelectedIndex];

            return(true);
        }