protected void ibAdd_Click(object sender, ImageClickEventArgs e) { GridViewRow gvr = ((GridViewRow)(((ImageButton)(sender)).NamingContainer)); string name = ((TextBox)gvr.FindControl("txtName")).Text; int districtId = Convert.ToInt32(((DropDownList)gvr.FindControl("ddlDistrict")).SelectedValue); Tehsil fd = new Tehsil(); fd.TehsilName = name; fd.DistrictId = districtId; try { tMethods.Add(fd); BindGrid(); js.ShowAlert(this, "Tehsil created succesfully!"); } catch (Exception ex) { if (ex.InnerException.InnerException.Message.Contains("UNIQUE")) { js.ShowAlert(this, "Tehsil already exists! Please try another name."); } else { js.ShowAlert(this, ex.Message); } } }
public async Task <IActionResult> Edit(int id, [Bind("TehsilID,DistrictID,TehsilName,Tehsilcode")] Tehsil tehsil) { if (id != tehsil.TehsilID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tehsil); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TehsilExists(tehsil.TehsilID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DistrictID"] = new SelectList(_context.Districts, "DistrictID", "DistrictName", tehsil.DistrictID); return(View(tehsil)); }
public async Task <ActionResult <Tehsil> > PostTehsil(Tehsil tehsil) { _context.Tehsils.Add(tehsil); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTehsil", new { id = tehsil.TehsilID }, tehsil)); }
public async Task <IActionResult> PutTehsil(int id, Tehsil tehsil) { if (id != tehsil.TehsilID) { return(BadRequest()); } _context.Entry(tehsil).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TehsilExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("TehsilID,DistrictID,TehsilName,Tehsilcode")] Tehsil tehsil) { if (ModelState.IsValid) { _context.Add(tehsil); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DistrictID"] = new SelectList(_context.Districts, "DistrictID", "DistrictName", tehsil.DistrictID); return(View(tehsil)); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int gvr = e.RowIndex; string name = ((TextBox)GridView1.Rows[gvr].FindControl("txtName")).Text; GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex]; HiddenField lblid = (HiddenField)row.FindControl("lblId"); int id = Convert.ToInt32(lblid.Value); int districtId = Convert.ToInt32(((DropDownList)row.FindControl("ddlDistrict")).SelectedValue); Tehsil fd = new Tehsil(); fd.Id = id; fd.TehsilName = name; fd.DistrictId = districtId; try { tMethods.Update(fd); GridView1.EditIndex = -1; BindGrid(); js.ShowAlert(this, "Record updated succesfully!"); } catch (Exception ex) { if (ex.InnerException.InnerException.Message.Contains("UNIQUE")) { js.ShowAlert(this, "Tehsil already exists! Please try another name."); } else { js.ShowAlert(this, ex.Message); } } }
public async Task <WmsdsResponse <int> > AddTehsil(Tehsil tehsil) { throw new NotImplementedException(); }