public async Task <IActionResult> Edit(string id, [Bind("CnMa,CnTen")] Chuyennganh chuyennganh) { if (id != chuyennganh.CnMa) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(chuyennganh); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChuyennganhExists(chuyennganh.CnMa)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(chuyennganh)); }
private void s_Click(object sender, EventArgs e) { string macn, tencn; macn = txtmnganh.Text; tencn = txttennganh.Text; Chuyennganh cn = new Chuyennganh(macn, tencn); try { int i = new ChuyennganhBUS().Suachuyennganh(cn); if (i == -2) { throw new Exception(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } dgvcn.DataSource = getchuyennganh(); txtmnganh.Clear(); txttennganh.Clear(); loadCN(); }
public int addchuyennganh(Chuyennganh cn) { List <SqlParameter> paras = new List <SqlParameter>(); paras.Add(new SqlParameter("@MaCN", cn.MaNganh)); paras.Add(new SqlParameter("@TenCN", cn.TenNganh)); return(dp.ExcuteNonquery("addchuyennganh", CommandType.StoredProcedure, paras)); }
public int Suachuyennganh(Chuyennganh cn) { try { return(new ChuyennganhDAO().Suachuyennganh(cn)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Create([FromBody] Chuyennganh model) { if (model == null) { return(BadRequest()); } await chuyenNganhRepository.Create(model); return(Ok(model)); }
public async Task <IActionResult> Create([Bind("CnMa,CnTen")] Chuyennganh chuyennganh) { if (ModelState.IsValid) { _context.Add(chuyennganh); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(chuyennganh)); }
public async Task <IActionResult> Update(int id, [FromBody] Chuyennganh model) { if (id != model.Id) { return(BadRequest()); } model.Id = id; await chuyenNganhRepository.Update(model); return(Ok(model)); }
public int Suachuyennganh(Chuyennganh cn) { List <SqlParameter> list = new List <SqlParameter>(); list.Add(new SqlParameter("@MaNganh", cn.MaNganh)); list.Add(new SqlParameter("@TenNganh", cn.TenNganh)); try { return(dp.ExcuteNonquery("Suachuyennganh", CommandType.StoredProcedure, list)); } catch (SqlException ex) { throw ex; } }
private void btaddcn_Click(object sender, EventArgs e) { try { string manganh, tennganh; manganh = txtmnganh.Text; tennganh = txttennganh.Text; Chuyennganh cn = new Chuyennganh(manganh, tennganh); int i = new ChuyennganhBUS().Addchuyennganh(cn); } catch (Exception ex) { MessageBox.Show(ex.Message); } txtmnganh.Clear(); txttennganh.Clear(); loadCN(); }
public List <Chuyennganh> getchuyennganh(string sql) { try { string manganh, tennganh; List <Chuyennganh> list = new List <Chuyennganh>(); SqlDataReader dr = dp.ExecReader(sql); while (dr.Read()) { manganh = dr.GetString(0); tennganh = dr.GetString(1); Chuyennganh cn = new Chuyennganh(manganh, tennganh); list.Add(cn); } return(list); } catch (Exception ex) { throw ex; } }