Esempio n. 1
0
 protected void DeleteRecord()
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         StrelbaDTO strelba = dataGridView1.SelectedRows[0].DataBoundItem as StrelbaDTO;
         Strelba.delete(Strelba.getById(strelba.Id));
         GetData();
     }
 }
Esempio n. 2
0
 private Strelba GetSelectedStr()
 {
     // The "SelectionMode" property of the data grid view must be set to "FullRowSelect".
     if (dataGridView1.SelectedRows.Count == 1)
     {
         StrelbaDTO strelba = dataGridView1.SelectedRows[0].DataBoundItem as StrelbaDTO;
         return(Strelba.getById(strelba.Id));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 3
0
 private Strelba GetSelectedStr()
 {
     // The "SelectionMode" property of the data grid view must be set to "FullRowSelect".
     if (StrGrid.SelectedRows.Count == 1)
     {
         Strelba strelba = StrGrid.SelectedRows[0].DataBoundItem as Strelba;
         return(strelba);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 4
0
        protected void GetData()
        {
            Collection <Strelba>    strelby = Strelba.SelectAll();
            Collection <StrelbaDTO> vystup  = new Collection <StrelbaDTO>();

            foreach (Strelba strelba in strelby)
            {
                vystup.Add(new StrelbaDTO(strelba));
            }
            BindingList <StrelbaDTO> bindingList = new BindingList <StrelbaDTO>(vystup);

            dataGridView1.DataSource = bindingList;
        }
Esempio n. 5
0
        protected void EditRecord()
        {
            Strelba selectedStr = GetSelectedStr();

            if (selectedStr != null)
            {
                DetailStrelba form = new DetailStrelba();
                if (form.OpenRecord(selectedStr.idStr))
                {
                    form.ShowDialog();
                    GetData();
                }
            }
        }
Esempio n. 6
0
 public bool OpenRecord(object primaryKey)
 {
     if (primaryKey != null)
     {
         int idStr = (int)primaryKey;
         strelba   = StrelbaTable.select(idStr);
         newRecord = false;
     }
     else
     {
         strelba         = new Strelba();
         strelba.Zacatek = new DateTime(2000, 01, 01);
         strelba.Konec   = new DateTime(2000, 01, 01);
         newRecord       = true;
     }
     BindData();
     return(true);
 }
Esempio n. 7
0
 protected bool SaveRecord()
 {
     if (GetData())
     {
         if (newRecord)
         {
             Strelba.insert(strelba);
         }
         else
         {
             Strelba.update(strelba);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 8
0
        public bool OpenRecord(object primaryKey)
        {
            if (primaryKey != null)
            {
                int idStr = (int)primaryKey;
                strelba   = Strelba.getById(idStr);
                newRecord = false;
            }
            else
            {
                strelba   = new Strelba();
                newRecord = true;
            }

            TimeSpan span = strelba.Konec.Subtract(strelba.Zacatek);

            txtMin.Text = span.TotalMinutes.ToString();

            BindData();
            return(true);
        }
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     _strel = GetComponentInParent <Strelba>();
 }