Ejemplo n.º 1
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            DataGridViewRow currentRow = this.dataGridViewStudents.CurrentRow;

            if (currentRow == null)
            {
                return;
            }
            DtoStudent dtoStudent = currentRow.Tag as DtoStudent;

            if (dtoStudent == null)
            {
                return;
            }

            OpDeleteStudent op  = new OpDeleteStudent(dtoStudent);
            OperationResult obj = OperationManager.Singleton.executeOperation(op);

            if (obj == null || obj.Items == null)
            {
                return;
            }
            DtoStudent[] students = obj.Items.Cast <DtoStudent>().ToArray();
            FillDataGridViewStudents();
        }
Ejemplo n.º 2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string ime          = textBoxIme1.Text;
                string prezime      = textBoxPrezime1.Text;
                int    indeksBroj   = Convert.ToInt32(textBoxIndexBroj1.Text);
                int    indeksGodina = Convert.ToInt32(textBoxIndexGodina1.Text);

                DtoStudent dtoStudentNew = new DtoStudent
                {
                    IndeksBroj   = indeksBroj,
                    IndeksGodina = indeksGodina,
                    Ime          = ime,
                    Prezime      = prezime
                };

                OpAddStudent    op  = new OpAddStudent(dtoStudentNew);
                OperationResult obj = OperationManager.Singleton.executeOperation(op);
                if (obj == null || obj.Items == null)
                {
                    return;
                }
                DtoStudent[] students = obj.Items.Cast <DtoStudent>().ToArray();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            this.Close();
        }
Ejemplo n.º 3
0
 public IActionResult Put([FromBody] DtoStudent _dtoStudent)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Not a valid data"));
     }
     return(Ok(""));
 }
Ejemplo n.º 4
0
 public IActionResult Post([FromBody] DtoStudent _dtoStudent)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Not a valid data"));
     }
     return(Ok(studentCRUDService.AddItem(_dtoStudent)));
 }
Ejemplo n.º 5
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            DataGridViewRow currentRow = this.dataGridViewStudents.CurrentRow;

            if (currentRow == null)
            {
                return;
            }
            DtoStudent dtoStudent = currentRow.Tag as DtoStudent;

            if (dtoStudent == null)
            {
                return;
            }
            try
            {
                string ime     = currentRow.Cells[1].Value.ToString();
                string prezime = currentRow.Cells[2].Value.ToString();

                if ((dtoStudent.Ime == ime) &&
                    (dtoStudent.Prezime == prezime))
                {
                    return;
                }
                DtoStudent dtoStudentNew = new DtoStudent
                {
                    IdStudent = dtoStudent.IdStudent,
                    Ime       = ime,
                    Prezime   = prezime
                };

                OpUpdateStudent op  = new OpUpdateStudent(dtoStudentNew);
                OperationResult obj = OperationManager.Singleton.executeOperation(op);
                if (obj == null || obj.Items == null)
                {
                    return;
                }
                DtoStudent[] students = obj.Items.Cast <DtoStudent>().ToArray();

                FillDataGridViewStudents();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 6
0
 public IActionResult Get(int id)
 {
     try
     {
         if (id < 0)
         {
             return(BadRequest("Not a valid id"));
         }
         DtoStudent _dtoStudent = studentCRUDService.GetSingleItem(id);
         if (_dtoStudent == null)
         {
             throw new ArgumentException($"No student found against id {id}.", nameof(id));
         }
         return(Ok(_dtoStudent));
     }
     catch (Exception ex)
     {
         throw new Exception("", ex);
     }
 }
Ejemplo n.º 7
0
        private void dataGridViewStudents_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow currentRow = this.dataGridViewStudents.CurrentRow;

            if (currentRow == null)
            {
                return;
            }
            DtoStudent dtoStudent = currentRow.Tag as DtoStudent;

            if (dtoStudent == null)
            {
                return;
            }
            int idStudent = dtoStudent.IdStudent;


            OpStudentIspitSelect op  = new OpStudentIspitSelect(idStudent, 0);
            OperationResult      obj = OperationManager.Singleton.executeOperation(op);

            if (obj == null || obj.Items == null)
            {
                return;
            }
            DtoStudentIspit[] studIspiti = obj.Items.Cast <DtoStudentIspit>().ToArray();


            this.dataGridViewStudentIspit.Rows.Clear();
            int rb = 1;

            foreach (DtoStudentIspit item in studIspiti)
            {
                int indeks = this.dataGridViewStudentIspit.Rows.Add(
                    rb.ToString(), item.ImePrezime, item.IspitDatum, item.PredmetNaziv, item.Ocena,
                    item.DvPrijave);
                DataGridViewRow row = this.dataGridViewStudentIspit.Rows[indeks];
                row.Tag = item;
                rb++;
            }
        }