public List <Thana> GetSelectedThanas(int districtId) { List <Thana> thanaList = new List <Thana>(); string query = "SELECT * FROM tbl_thana WHERE district_id='" + districtId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); Thana aThana; while (ASqlDataReader.Read()) { aThana = new Thana(); aThana.Id = (int)ASqlDataReader["id"]; aThana.Name = ASqlDataReader["name"].ToString(); aThana.DistrictId = (int)ASqlDataReader["district_id"]; thanaList.Add(aThana); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(thanaList); }
public List <Thana> LoadThana(string district) { int districtID = GetDistrictIDByThanaName(district); SqlConnection connection = new SqlConnection(connectionString); string query = "select * from tbl_Thana where DistrictID = '" + districtID + "'"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <Thana> thanaList = new List <Thana>(); while (reader.Read()) { Thana aThana = new Thana(); aThana.ID = int.Parse(reader["ID"].ToString()); aThana.ThanaName = reader["ThanaName"].ToString(); aThana.DistrictID = int.Parse(reader["DistrictID"].ToString()); thanaList.Add(aThana); } reader.Close(); connection.Close(); return(thanaList); }
public List <Thana> GetAllThanas(int distId) { List <Thana> thanas = new List <Thana>(); connection = new SqlConnection(connectionString); string query = "SELECT * FROM thana WHERE dist_id = @distid"; SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@distid", distId); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Thana aThana = new Thana() { Id = int.Parse(reader["id"].ToString()), Name = reader["name"].ToString(), DistrictId = int.Parse(reader["dist_id"].ToString()) }; thanas.Add(aThana); } reader.Close(); connection.Close(); return(thanas); }
public async Task <ActionResult <IEnumerable <Thana> > > LoadThanaListByDistrictId(int id) { List <Thana> ObjThanaList = new List <Thana>(); var ThanaListByDistrictId = await db.Thana.Where(d => d.DistrictId == id).Select(t => new { t.DistrictId, t.ThanaId, t.ThanaName }).ToListAsync(); foreach (var data in ThanaListByDistrictId) { Thana ObjOfthana = new Thana() { DistrictId = data.DistrictId, ThanaId = data.ThanaId, ThanaName = data.ThanaName }; ObjThanaList.Add(ObjOfthana); } if (ObjThanaList == null) { return(NotFound()); } return(ObjThanaList); }
public List <Thana> GetAllThanaByRangeId(int RangeId) { List <Thana> listThana = new List <Thana>(); using (SqlConnection SqlConn = new SqlConnection(connectionString)) { using (SqlCommand SqlCmd = new SqlCommand("GetThanaByRangeId", SqlConn)) { SqlConn.Open(); SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.Parameters.Add(new SqlParameter("pRangeId", SqlDbType.VarChar)).Value = RangeId; SqlDataAdapter da = new SqlDataAdapter(SqlCmd); DataSet ds = new DataSet(); da.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { Thana thana = new Thana(); thana.ThanaId = Convert.ToInt32(dr["ThanaId"]); thana.ThanaName = dr["ThanaName"].ToString(); listThana.Add(thana); } } } return(listThana); }
public List <Thana> GetThanaAccordingToDistrict(int id) { List <Thana> thanas = new List <Thana>(); SqlConnection connection = new SqlConnection(connectionstring); string query = "SELECT t.thana_Id,t.thana_Name FROM Table_Thana as t join Table_District as d on t.thana_DistrictId=d.district_Id WHERE thana_DistrictId='" + id + "'"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Thana thana = new Thana(); thana.Id = int.Parse(reader["thana_Id"].ToString()); thana.Name = reader["thana_Name"].ToString(); thanas.Add(thana); } reader.Close(); connection.Close(); return(thanas); }
public List <Thana> GeThanas() { List <Thana> thanas = new List <Thana>(); SqlConnection connection = new SqlConnection(connectionstring); string query = "SELECT * FROM Table_Thana ORDER BY ASC"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Thana thana = new Thana(); thana.Id = int.Parse(reader["thana_Id"].ToString()); thana.Name = reader["thana_Name"].ToString(); thana.DistrictId = int.Parse(reader["thana_DistrictId"].ToString()); thanas.Add(thana); } reader.Close(); connection.Close(); return(thanas); }
public ActionResult Create([Bind(Include = "Id,Name,DistrictId")] Thana thana) { if (ModelState.IsValid) { db.Thanas.Add(thana); db.SaveChanges(); int parentId = 0; var parent = db.Treeviews.Where(i => i.HierarchyTypeId == (int)Enums.District && i.KeyOfThatHierarchy == thana.DistrictId); if (parent != null) { parentId = parent.FirstOrDefault().Id; } var treeview = new Treeview { HierarchyTypeId = (int)Enums.Thana, KeyOfThatHierarchy = thana.Id, Label = thana.Name, ParentId = parentId }; db.Treeviews.Add(treeview); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DistrictId = new SelectList(db.Districts, "Id", "Name", thana.DistrictId); return(View(thana)); }
// GET: Thana/Create public ActionResult Create(int?id) { ViewBag.DistrictId = new SelectList(db.Districts, "Id", "Name"); var model = new Thana(); model.DistrictId = id.HasValue?id.Value:0; return(View(model)); }
public ActionResult DeleteConfirmed(int id) { Thana thana = db.Thanas.Find(id); db.Thanas.Remove(thana); db.SaveChanges(); return(RedirectToAction("Index")); }
public void ThanasLoad() { LgThanasViewModel vmmmm; //this.BindingContext = vmm = new LgDivisionsViewModel(); Thana.BindingContext = new LgThanasViewModel(); Thana.SetBinding(Picker.ItemsSourceProperty, "ItemsThana"); Thana.ItemDisplayBinding = new Binding("ThanaName"); }
public IHttpActionResult Get(int id) { Thana thana = repo.Get(id); if (thana == null) { return(StatusCode(HttpStatusCode.NoContent)); } return(Ok(thana)); }
public ActionResult Edit([Bind(Include = "ThanaId,Name,DistrictId")] Thana thana) { if (ModelState.IsValid) { db.Entry(thana).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "Name", thana.DistrictId); return(View(thana)); }
public ActionResult Create([Bind(Include = "ThanaId,Name,DistrictId")] Thana thana) { if (ModelState.IsValid) { db.Thanas.Add(thana); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "Name", thana.DistrictId); return(View(thana)); }
public async Task <bool> SaveThana(Thana thana) { if (thana.Id != 0) { _context.Thanas.Update(thana); } else { _context.Thanas.Add(thana); } return(1 == await _context.SaveChangesAsync()); }
private void districtbox_SelectedIndexChanged(object sender, EventArgs e) { Thana t = new Thana(); District d = new District(); try { thanabox.DataSource = t.getThanaList(d.getDistrictNo(districtbox.Text.ToString())); district_no.Text = d.getDistrictNo(districtbox.Text.ToString()).ToString(); thanabox.Select(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
// GET: /Thana/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Thana thana = db.Thanas.Find(id); if (thana == null) { return(HttpNotFound()); } return(View(thana)); }
// GET: /Thana/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Thana thana = db.Thanas.Find(id); if (thana == null) { return(HttpNotFound()); } ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "Name", thana.DistrictId); return(View(thana)); }
private void district_no_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { try { District d = new District(); Thana t = new Thana(); districtbox.Text = d.getDistrictName(Convert.ToInt32(district_no.Text)); thanabox.DataSource = t.getThanaList(d.getDistrictNo(districtbox.Text.ToString())); thana_no.Select(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void thana_no_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { try { Thana t = new Thana(); thanabox.Text = t.getThanaName(t.generateThanaID(Convert.ToInt32(district_no.Text), Convert.ToInt32(thana_no.Text))); Union u = new Union(); unionbox.DataSource = u.getUnionList(t.generateThanaID(Convert.ToInt32(district_no.Text), Convert.ToInt32(thana_no.Text))); union_no.Select(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void thanabox_SelectedIndexChanged(object sender, EventArgs e) { Union u = new Union(); Thana t = new Thana(); District d = new District(); try { thana_no.Text = t.getThanaNo(thanabox.Text.ToString(), d.getDistrictNo(districtbox.Text)).ToString(); String thanaid = "D" + district_no.Text + "T" + thana_no.Text + ""; unionbox.DataSource = u.getUnionList(thanaid); unionbox.Select(); } catch (Exception ex) { } }
public ActionResult Add(VmThana vmThana) { if (ModelState.IsValid) { var newrecord = new Thana { ThanaHeaderId = vmThana.ThanaHeaderId, ThanaName = vmThana.ThanaName, DistrictHeaderId = vmThana.DistrictHeaderId }; db.Thanas.Add(newrecord); db.SaveChanges(); return(RedirectToAction("Add", "Thana")); } return(View(vmThana)); }
public Thana Find(int id) { Thana aThana = new Thana(); string query = "SELECT *FROM tbl_thana WHERE id = '" + id + "'"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); while (ASqlDataReader.Read()) { aThana.Id = Convert.ToInt32(ASqlDataReader["id"]); aThana.Name = ASqlDataReader["name"].ToString(); } ASqlDataReader.Close(); ASqlConnection.Close(); return(aThana); }
// GET: Thana/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Thana thana = _thanaManager.GetById((int)id); ThanaViewModel thanaVM = new ThanaViewModel() { Id = thana.Id, Name = thana.Name, DistrictId = thana.DistrictId }; ViewBag.DistrictId = new SelectList(_districtManager.GetAll(), "Id", "Name", thana.DistrictId); return(View(thanaVM)); }
// GET: Thana/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var district = _districtManager.GetAll(); Thana thana = _thanaManager.GetById((int)id); ThanaViewModel thanaVM = new ThanaViewModel() { Id = thana.Id, Name = thana.Name, District = district.Where(x => x.Id == thana.DistrictId).FirstOrDefault() }; return(View(thanaVM)); }
public ActionResult Edit(ThanaViewModel thanaViewModel) { try { Thana thana = new Thana(); thana.Id = thanaViewModel.Id; thana.Name = thanaViewModel.Name; thana.DistrictId = thanaViewModel.DistrictId; _thanaManager.Update(thana); return(RedirectToAction("Index")); } catch { return(View()); } }
public string GetThana(int thanaId) { string searchMedicine = "SELECT * FROM tbl_thana where id='" + thanaId + "'"; sqlConnection.Open(); sqlCommand.CommandText = searchMedicine; SqlDataReader reader = sqlCommand.ExecuteReader(); Thana aThana = new Thana(); while (reader.Read()) { aThana.Name = reader["Thana"].ToString(); } reader.Close(); sqlConnection.Close(); return(aThana.Name); }
internal List <Thana> GetTheThana(int districtId) { List <Thana> aThanaList = new List <Thana>(); string sqlQuery = "SELECT * FROM tbl_thanas WHERE district_id = " + districtId + ""; aSqlCommand = new SqlCommand(sqlQuery, aConnectionManager.GetConnection()); aReader = aSqlCommand.ExecuteReader(); while (aReader.Read()) { Thana aThana = new Thana(); aThana.ThanaId = Convert.ToInt32(aReader["id"]); aThana.ThanaName = aReader["name"].ToString(); aThanaList.Add(aThana); } aConnectionManager.CloseConnection(); return(aThanaList); }
public List <Thana> GetAllThanasByDistrict(int DistrictID) { aGateway.command.CommandText = "SELECT * FROM Thana_tbl WHERE DistrictID='" + DistrictID + "'"; aGateway.sqlConnection.Open(); SqlDataReader reader = aGateway.command.ExecuteReader(); List <Thana> thanasList = new List <Thana>(); while (reader.Read()) { Thana aThana = new Thana(); aThana.ID = Convert.ToInt16(reader["ID"].ToString()); aThana.Name = reader["Name"].ToString(); aThana.DistrictID = Convert.ToInt16(reader["DistrictID"].ToString()); thanasList.Add(aThana); } reader.Close(); aGateway.sqlConnection.Close(); return(thanasList); }
// GET: Thana/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Thana thana = _thanaManager.GetById((int)id); if (thana == null) { return(HttpNotFound()); } bool isRemove = _thanaManager.Remove(thana); if (isRemove) { return(RedirectToAction("Index")); } return(View(thana)); }