예제 #1
0
        protected void GetData()
        {
            Collection <Zbran>  zbrane      = Zbran.SelectAll();
            BindingList <Zbran> bindingList = new BindingList <Zbran>(zbrane);

            dataGridView1.DataSource = bindingList;
        }
예제 #2
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);
            }
        }
 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;
 }
예제 #4
0
 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;
 }
예제 #5
0
 protected void DeleteRecord()
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         Zbran zbran = dataGridView1.SelectedRows[0].DataBoundItem as Zbran;
         Zbran.delete(zbran);
         GetData();
     }
 }
예제 #6
0
 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);
     }
 }
예제 #7
0
        protected void EditRecord()
        {
            Zbran selectedZbr = GetSelectedZbr();

            if (selectedZbr != null)
            {
                DetailZbran form = new DetailZbran();
                if (form.OpenRecord(selectedZbr.idZbr))
                {
                    form.ShowDialog();
                    GetData();
                }
            }
        }
예제 #8
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;
                }
            }
        }
예제 #9
0
 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);
 }
예제 #10
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);
        }
예제 #11
0
 protected bool SaveRecord()
 {
     if (GetData())
     {
         if (newRecord)
         {
             Zbran.insert(zbran);
         }
         else
         {
             Zbran.update(zbran);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }