// Update Seccao public static int U2() { Console.WriteLine("Update Seccao"); Console.Write("Sigla? = "); var sigla = Console.ReadLine(); Console.Write("Departamento? = "); var dep = Console.ReadLine(); Console.Write("Coordenador? = "); var coo = Console.ReadLine(); Console.Write("Descricao? = "); var desc = Console.ReadLine(); Seccao s = new Seccao(); Seccao ans = new Seccao(); s.Sigla = sigla; s.Departamento = dep; s.Coordenador = coo; s.Descricao = desc; ans = UpdateFunctions.UpdateSeccao(s); if (ans == null) { Console.WriteLine("An error has ocurred. Seccao wasn't updated."); return(-1); } else { Console.WriteLine("Seccao {0} updated.", ans.Sigla); return(0); } }
// Insert Seccao public static int I2() { Console.WriteLine("Create Seccao"); Console.Write("Sigla? = "); var sigla = Console.ReadLine(); Console.Write("Departamento? = "); var dep = Console.ReadLine(); Console.Write("Coordenador? = "); var c = Console.ReadLine(); Console.Write("Descricao? = "); var desc = Console.ReadLine(); Seccao d = new Seccao { Sigla = sigla, Departamento = dep, Coordenador = c, Descricao = desc }; Seccao ans = InsertFuncions.CreateSeccao(d); if (ans.Sigla == null) { Console.WriteLine("An error has ocurred. Seccao wasn't created."); return(-1); } else { Console.WriteLine("Seccao {0} was created, with the following parameters : {1}, {2}, {3}.", ans.Sigla, ans.Departamento, ans.Coordenador, ans.Descricao); return(0); } }
public ActionResult DeleteConfirmed(int id) { Seccao seccao = db.Seccaos.Find(id); db.Seccaos.Remove(seccao); db.SaveChanges(); return(RedirectToAction("Index")); }
public static Seccao DeleteSeccao(Seccao s) { using (Context ctx = new Context(connectionString)) { MapperSeccao md = new MapperSeccao(ctx); s = md.Delete(s); } return(s); }
public static Seccao UpdateSeccao(Seccao dp) { using (Context ctx = new Context(connectionString)) { MapperSeccao md = new MapperSeccao(ctx); dp = md.Update(dp); } return(dp); }
public static void DeleteSeccao(string sigla) { Seccao s = new Seccao(); s.Sigla = sigla; s = DeleteFunctions.DeleteSeccao(s); Console.WriteLine("Seccao " + s.Sigla + "\t" + "deleted"); }
public ActionResult Edit([Bind(Include = "Seccao_id,designacao")] Seccao seccao) { if (ModelState.IsValid) { db.Entry(seccao).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seccao)); }
public ActionResult Create([Bind(Include = "Seccao_id,designacao")] Seccao seccao) { if (ModelState.IsValid) { db.Seccaos.Add(seccao); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seccao)); }
public static void CreateSeccao(string sigla, string departamento, string coordenador, string descricao) { Seccao s = new Seccao(); s.Sigla = sigla; s.Departamento = departamento; s.Coordenador = coordenador; s.Descricao = descricao; s = InsertFuncions.CreateSeccao(s); Console.WriteLine("Seccao " + s.Sigla + "\t" + " created"); }
public static void UpdateSeccao(string sigla, string departamento, string coordenador, string desc) { Seccao s = new Seccao(); s.Sigla = sigla; s.Departamento = departamento; s.Coordenador = coordenador; s.Descricao = desc; s = UpdateFunctions.UpdateSeccao(s); Console.WriteLine("Seccao " + s.Sigla + "\t" + " updated"); }
private void btnNew_Click(object sender, EventArgs e) { tbId.Text = Seccao.GetNewId().ToString(); tbNome.Text = string.Empty; tbNome.Enabled = true; // btnEdit.Visible = false; btnDelete.Visible = false; btnNew.Visible = false; btnClose.Visible = false; btnCancelar.Visible = true; btnGuardar.Visible = true; tbDefault.SelectedIndex = 1; }
// GET: Seccaos/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Seccao seccao = db.Seccaos.Find(id); if (seccao == null) { return(HttpNotFound()); } return(View(seccao)); }
private void UpdateGrid() { dgvList.DataSource = Funcionario.GetAllFuncionarios(); cbSeccao.DataSource = Seccao.GetAllSeccoes(); //Default Seccao Search cbSeccaoSearch.Items.Clear(); cbSeccaoSearch.Items.Add("Todos"); foreach (DataRow row in Seccao.GetAllSeccoes().Rows) { cbSeccaoSearch.Items.Add(row[1]); } cbSeccaoSearch.SelectedIndex = 0; }
private void btnGuardar_Click(object sender, EventArgs e) { bool check = false; int id = -1; foreach (DataGridViewRow row in dgvList.Rows) { if (row.Cells[0].Value.ToString().Equals(tbId.Text)) { check = true; id = Convert.ToInt32(row.Cells[0].Value); } } if (!check) { if (Seccao.NewSeccao(tbNome.Text)) { MessageBox.Show("Secção adicionada com sucesso."); } else { MessageBox.Show("Não foi possivel adicionar a nova secção."); } } else if (id != -1) { if (Seccao.UpdateSeccao(id, tbNome.Text)) { MessageBox.Show("Secção atualizada com sucesso."); } else { MessageBox.Show("Não foi possivel atualizar a secção."); } } tbNome.Enabled = false; btnEdit.Visible = true; btnDelete.Visible = true; btnNew.Visible = true; btnClose.Visible = true; btnCancelar.Visible = false; btnGuardar.Visible = false; tbDefault.SelectedIndex = 0; }
private void btnDelete_Click(object sender, EventArgs e) { /*Obter o veiculo*/ if (dgvList.SelectedRows.Count != 0 && MessageBox.Show(string.Format("Secção: {0}\n\nTem certeza que deseja eliminar esta secção?", dgvList.SelectedRows[0].Cells[1].Value.ToString()), "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { /*Eliminar o veiculo*/ if (Seccao.DeleteSeccao(Convert.ToInt32(dgvList.SelectedRows[0].Cells[0].Value.ToString()))) { MessageBox.Show("Secção eliminada com sucesso.", "Resultado", MessageBoxButtons.OK, MessageBoxIcon.Information); UpdateGrid(); } else { MessageBox.Show("Não foi possivel eliminar esta secção.", "Resultado", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
// Delete Seccao public static int D2() { Console.WriteLine("Delete Seccao"); Console.Write("Sigla? = "); var sigla = Console.ReadLine(); Seccao s = new Seccao(); s.Sigla = sigla; s = DeleteFunctions.DeleteSeccao(s); if (s == null) { Console.WriteLine("Seccao {0} was deleted.", sigla); return(0); } else { Console.WriteLine("An error has ocurred. Seccao wasn't deleted."); return(-1); } }
private void UpdateGrid() { dgvList.DataSource = Seccao.GetAllSeccoes(); }