public bool add(diadiem entity) { if (validate(entity)) { return(diadiem.Add(entity)); } return(false); }
public bool update(diadiem _dd) { diadiem dd = diadiemrespository.First(c => c.id == _dd.id); dd.tendiadiem = _dd.tendiadiem; dd.idtt = _dd.idtt; return(diadiemrespository.Update(dd)); }
public ActionResult DeleteConfirmed(int id) { diadiem diadiem = db.diadiems.Find(id); db.diadiems.Remove(diadiem); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool add(diadiem _dd) { bool s = diadiemrespository.Add(_dd); //load du lieu reference chua co _dd.tinhthanh = tinhthanhrespository.First(c => c.id == _dd.idtt); return(s); }
public ActionResult Edit([Bind(Include = "Id,ThanhPho,Ten,MoTa")] diadiem diadiem) { if (ModelState.IsValid) { db.Entry(diadiem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(diadiem)); }
public ActionResult Create([Bind(Include = "Id,ThanhPho,Ten,MoTa")] diadiem diadiem) { if (ModelState.IsValid) { db.diadiems.Add(diadiem); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(diadiem)); }
// GET: diadiems/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } diadiem diadiem = db.diadiems.Find(id); if (diadiem == null) { return(HttpNotFound()); } return(View(diadiem)); }
private void themddbtn_Click(object sender, EventArgs e) { diadiem dd = new diadiem(); dd.tendiadiem = tenddtxt.Text; dd.idtt = Convert.ToInt32(((KeyValuePair <string, string>)tenttcbb.SelectedItem).Key); bool s = ddbus.add(dd); helpers.successorerror(s); if (s) { helpers.ClearOnlyTextBoxes(diadiempanel); loaddiadiemdgv(); } }
private void suaddbtn_Click(object sender, EventArgs e) { diadiem dd = new diadiem(); dd.id = currentid; dd.tendiadiem = tenddtxt.Text; dd.idtt = Convert.ToInt32(((KeyValuePair <string, string>)tenttcbb.SelectedItem).Key); bool s = ddbus.update(dd); helpers.successorerror(s); if (s) { exiteditingmode(); loaddiadiemdgv(); } }
public bool sua(int id, string tendd, int idtt) { try { diadiem d = db.diadiems.First(o => o.id == id); d.tendiadiem = tendd; d.idtt = idtt; db.Entry(d).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception ex) { MessageBox.Show("Lỗi : " + ex); return(false); } }
public bool them(string tendd, int idtt) { try { diadiem d = new diadiem(); d.tendiadiem = tendd; d.idtt = idtt; db.diadiems.Add(d); db.SaveChanges(); return(true); } catch (Exception ex) { MessageBox.Show("Lỗi :" + ex); return(false); } }
public bool validate(diadiem entity) { if (entity.tendiadiem.Trim().Length == 0) { validatedictionary.Add("TENDIADIEM", "Không được để trống tên địa điểm"); } if (entity.idtinh == 0) { validatedictionary.Add("TENTINH", "Chưa chọn tên tỉnh"); } if (find(entity.tendiadiem, entity.idtinh) == false) { validatedictionary.Add("DATONTAI", "Đã tồn tại địa điểm trong CSDL"); } if (validatedictionary.Count() <= 0) { return(true); } return(false); }
public diadiemdto(diadiem o) { ID = o.id; tendd = o.tendiadiem; tentt = o.tinhthanh.tentt; }