protected void BtnAddCity_Click(object sender, EventArgs e) { try { var city = from item in db.tbl_cities where item.City == TxtCity.Text select item; if (city.Count() > 0) { TxtCity.Text = ""; //if (Session["Language"].ToString() == "Auto") //{ RegisterStartupScript("", "<Script Language=JavaScript>swal('Already exist')</Script>"); //} //else //{ // RegisterStartupScript("", "<Script Language=JavaScript>swal('موجود مسبقا')</Script>"); //} } else { tbl_city t_city = new tbl_city() { City = TxtCity.Text, }; db.tbl_cities.InsertOnSubmit(t_city); db.SubmitChanges(); //TxtCity.Text = ""; LoadGrvCities(); } } catch (Exception ex) { } }
public void Delete(tbl_city obj) //Upadate single records { tbl_city city = db.tbl_city.Find(obj); db.tbl_city.Remove(city); save(); }
public ActionResult Delete(Int32 id) { tbl_city tb = db.tbl_cities.Where(x => x.city_id == id).Single <tbl_city>(); db.tbl_cities.DeleteOnSubmit(tb); db.SubmitChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Model_city obj) { tbl_city tb = db.tbl_cities.Where(x => x.city_id == obj.city_id).Single <tbl_city>(); tb.city_id = obj.city_id; tb.state_id = obj.state_id; tb.country_id = obj.country_id; tb.city_name = obj.city_name; db.SubmitChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Model_city obj) { tbl_city tb = new tbl_city(); tb.state_id = obj.state_id; tb.country_id = obj.country_id; tb.city_name = obj.city_name; db.tbl_cities.InsertOnSubmit(tb); db.SubmitChanges(); return(RedirectToAction("Index")); }
partial void Deletetbl_city(tbl_city instance);
partial void Updatetbl_city(tbl_city instance);
partial void Inserttbl_city(tbl_city instance);
private void detach_tbl_cities(tbl_city entity) { this.SendPropertyChanging(); entity.tbl_state = null; }
private void attach_tbl_cities(tbl_city entity) { this.SendPropertyChanging(); entity.tbl_state = this; }
public void Upadate(tbl_city obj) //Upadate single records { db.Entry(obj).State = System.Data.Entity.EntityState.Modified; save(); }
public void Insert(tbl_city obj) //Insert single records { db.tbl_city.Add(obj); save(); }