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); } }
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; } } }
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); }