protected void GetData() { Collection <Zbran> zbrane = Zbran.SelectAll(); BindingList <Zbran> bindingList = new BindingList <Zbran>(zbrane); dataGridView1.DataSource = bindingList; }
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); } }
public Bojovnik(string jmeno, int sila, int zivot, int brneni, Zbran zbran) { Jmeno = jmeno; Sila = sila >= 10 ? Sila = sila : sila = 10; Zivot = zivot >= 0 && zivot <= 100 ? Zivot = zivot : Zivot = 100; Brneni = brneni >= 0 && brneni <= 50 ? Brneni = brneni : Brneni = 50; Zbran = zbran; }
public Bojovnik(string jmeno, int sila, Zbran zbran, int zivot = 100, int brneni = 50) { Jmeno = jmeno; Sila = sila <= 10 ? 10 : sila; Zivot = zivot; Brneni = brneni; Zbran = zbran; }
protected void DeleteRecord() { if (dataGridView1.SelectedRows.Count == 1) { Zbran zbran = dataGridView1.SelectedRows[0].DataBoundItem as Zbran; Zbran.delete(zbran); GetData(); } }
private Zbran GetSelectedZbr() { // The "SelectionMode" property of the data grid view must be set to "FullRowSelect". if (dataGridView1.SelectedRows.Count == 1) { Zbran zbran = dataGridView1.SelectedRows[0].DataBoundItem as Zbran; return(zbran); } else { return(null); } }
protected void EditRecord() { Zbran selectedZbr = GetSelectedZbr(); if (selectedZbr != null) { DetailZbran form = new DetailZbran(); if (form.OpenRecord(selectedZbr.idZbr)) { form.ShowDialog(); GetData(); } } }
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; } } }
public bool OpenRecord(object primaryKey) { if (primaryKey != null) { int idZbr = (int)primaryKey; zbran = ZbranTable.select(idZbr); newRecord = false; } else { zbran = new Zbran(); newRecord = true; } BindData(); return(true); }
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); }
protected bool SaveRecord() { if (GetData()) { if (newRecord) { Zbran.insert(zbran); } else { Zbran.update(zbran); } return(true); } else { return(false); } }