public IEnumerable <MstTownEx> SearchTownList(DataTableModel dt, TownModel model, out int total_row) { ManageTownDa dataAccess = new ManageTownDa(); IEnumerable <MstTownEx> results = dataAccess.SearchTownList(dt, model, out total_row); return(results); }
public ActionResult FilterTown(string provinceIdString, string municipalityIdString, string localMunicipalityIdString) { var townModel = new TownModel(); var townsList = townModel.GetListOfTowns(); int provinceId; if (int.TryParse(provinceIdString, out provinceId)) { townsList.RemoveAll(x => !x.Local_Municipality.District.Province_Id.Equals(provinceId)); } int municipalityId; if (int.TryParse(municipalityIdString, out municipalityId)) { townsList.RemoveAll(x => !x.Local_Municipality.District_Municipality_Id.Equals(municipalityId)); } int localMunicipalityId; if (int.TryParse(localMunicipalityIdString, out localMunicipalityId)) { townsList.RemoveAll(x => !x.Local_Municipality_Id.Equals(localMunicipalityId)); } var result = (from x in townsList select new { id = x.Town_Id, name = x.Description }).ToList(); return(Json(result, JsonRequestBehavior.AllowGet)); }
// // GET: /AdminManageTown/ #region LIST // GET: /AdminManageDistrict/ public ActionResult TownList() { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; var authorityList = currentUser != null ? currentUser.USER_AUTHORITY : 0; if (currentUser == null || authorityList != 2) { return(RedirectToAction("Login", "UserAccount")); } TownModel model = new TownModel(); CommonService comService = new CommonService(); model.CITY_LIST = comService.GetCityList().ToList().Select( f => new SelectListItem { Value = f.CITY_CD.ToString(), Text = f.CITY_NAME }).ToList(); model.CITY_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); model.DISTRICT_LIST = comService.GetDistrictList().ToList().Select( f => new SelectListItem { Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString(), Text = f.DISTRICT_NAME }).ToList(); return(View(model)); }
public long InsertTown(TownModel model) { long result = 0; //Check create new customer StringBuilder sqlinsert = new StringBuilder(); model.DEL_FLG = DeleteFlag.NON_DELETE; sqlinsert.Append(@" INSERT INTO [MstTown] ([CITY_CD] ,[DISTRICT_CD] ,[TOWN_CD] ,[TOWN_NAME] ,[DSP_ORDER] ,[DEL_FLG] ,[STATUS]) VALUES (@CITY_CD, @DISTRICT_CD, @TOWN_CD, @TOWN_NAME, @DSP_ORDER, @DEL_FLG, @STATUS)"); result = base.DbAdd(sqlinsert.ToString(), model); return(result); }
private void Awake() { _townModel = TownModel.Instance; _spawnController = SpawnController.Instance; _townModel.DroppedItems = new List <DroppedItemController>(); _townModel.TownOrders = new Queue <TownOrder>(); _townModel.WheatPlants = new List <CropController>(); }
public int Delete(TownModel model) { string sqlDelete = "DELETE FROM Town WHERE ZipCode = @ZipCode"; using (_connection) { return(_connection.Execute(sqlDelete, model)); } }
public int Update(TownModel model) { string sqlUpdate = "UPDATE Town SET Name = @Name, CountryId = @CountryId WHERE ZipCode = @ZipCode"; using (_connection) { return(_connection.Execute(sqlUpdate, model)); } }
public int Insert(TownModel model) { string sqlInsert = "INSERT INTO Town (ZipCode, Name, CountryId)" + " Values (@ZipCode, @Name, @CountryId)"; using (_connection) { return(_connection.Execute(sqlInsert, model)); } }
public int AddTown(TownModel townModel) { try { return(townRepository.AddTown(townModel)); } catch (Exception ex) { throw ex; } }
private void Awake() { _villagerModel = GetComponent <VillagerModel>(); _cellMapController = CellMapController.Instance; _villagerModel.Rigidbody2D = GetComponent <Rigidbody2D>(); _villagerModel.Orders = new Queue <OrderType>(); _townModel = TownModel.Instance; _townController = TownController.Instance; _villagerNeeds = GetComponent <VillagerNeedsController>(); _villagerStateController = GetComponent <VillagerStateController>(); }
private void EditTownForm_Load(object sender, EventArgs e) { try { TownModel townModel = managingAdministrativeBoundariesService.GetSingleTownByTownId(_townId); TownNameTextBox.Text = townModel.TownName; AddressTextBox.Text = townModel.Address; PhoneNumberTextBox.Text = townModel.PhoneNumber; FaxTextBox.Text = townModel.Fax; NoteRichTextBox.Text = townModel.Note; } catch (Exception ex) { } }
public IHttpActionResult Put(int id, TownModel model) { try { Town town = Factory.Create(model); UnitOfWork.Towns.Update(town, id); UnitOfWork.Commit(); return(Ok(Factory.Create(town))); } catch (Exception ex) { Helper.Log(ex.Message, "ERROR"); return(BadRequest(ex.Message)); } }
private void UpdateButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TownNameTextBox.Text)) { NotificationForm notificationForm = new NotificationForm("Điền tên huyện", "Cảnh báo", MessageBoxIcon.Warning); notificationForm.ShowDialog(); return; } if (string.IsNullOrEmpty(AddressTextBox.Text)) { NotificationForm notificationForm = new NotificationForm("Điền địa chỉ huyện", "Cảnh báo", MessageBoxIcon.Warning); notificationForm.ShowDialog(); return; } TownModel townModel = new TownModel(); townModel.Id = _townId; townModel.TownName = TownNameTextBox.Text; townModel.Address = AddressTextBox.Text; townModel.PhoneNumber = string.IsNullOrEmpty(PhoneNumberTextBox.Text) ? "" : PhoneNumberTextBox.Text; townModel.Fax = string.IsNullOrEmpty(FaxTextBox.Text) ? "" : FaxTextBox.Text; townModel.Note = string.IsNullOrEmpty(NoteRichTextBox.Text) ? "" : NoteRichTextBox.Text; townModel.IsDeleted = false; try { int result = managingAdministrativeBoundariesService.UpdateTown(townModel); if (result > 0) { OnTownUpdated(); NotificationForm notificationForm = new NotificationForm("Cập nhật huyện thành công", "Thông báo", MessageBoxIcon.Information); notificationForm.ShowDialog(); this.Close(); } else { NotificationForm notificationForm = new NotificationForm("Cập nhật huyện không thành công", "Cảnh báo", MessageBoxIcon.Warning); notificationForm.ShowDialog(); } } catch (Exception ex) { NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error); notificationForm.ShowDialog(); } }
public long UpdateTown(TownModel model) { long res = 0; // Declare new DataAccess object ManageTownDa dataAccess = new ManageTownDa(); using (var transaction = new TransactionScope()) { res = dataAccess.UpdateTown(model); if (res <= 0) { transaction.Dispose(); } transaction.Complete(); } return(res); }
public ActionResult FilterFromTown(string townId) { var result = string.Empty; if (string.IsNullOrEmpty(townId)) { result = "-1,-1,-1"; } else { var townModel = new TownModel(); var townItem = townModel.GetSpecificTown(int.Parse(townId)); result = townItem.Local_Municipality.District.Province_Id + "," + townItem.Local_Municipality.District_Municipality_Id + "," + townItem.Local_Municipality_Id; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult List(DataTableModel dt, TownModel condition) { if (ModelState.IsValid) { using (ManageTownService service = new ManageTownService()) { int total_row = 0; var dataList = service.SearchTownList(dt, condition, out total_row); int order = 1; int totalRowCount = dataList.Count(); int lastItem = dt.iDisplayLength + dt.iDisplayStart; var result = Json( new { sEcho = dt.sEcho, iTotalRecords = total_row, iTotalDisplayRecords = total_row, aaData = (from i in dataList select new object[] { i.CITY_CD, i.DISTRICT_CD, order++, i.CITY_NAME != null ? HttpUtility.HtmlEncode(i.CITY_NAME) : String.Empty, i.DISTRICT_NAME != null ? HttpUtility.HtmlEncode(i.DISTRICT_NAME) : String.Empty, i.TOWN_CD, i.TOWN_NAME != null ? HttpUtility.HtmlEncode(i.TOWN_NAME) : String.Empty, i.STATUS == "1"? "Hiển thị" : "Ẩn", i.DEL_FLG }) }); result.MaxJsonLength = Int32.MaxValue; return(result); } } else { var ErrorMessages = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); } return(new EmptyResult()); }
public List <TownModel> GetManyTownByName(string townName) { List <TownModel> townModels = new List <TownModel>(); using (conn = JBCertConnection.Instance) { string queryString = @"SELECT * FROM [dbo].[tblHuyen] Where [tblHuyen].[IsDeleted] = 0 and [tblHuyen].[Ten] like @Ten"; conn.Open(); SqlCommand sqlCommand = new SqlCommand(queryString, conn); sqlCommand.CommandType = CommandType.Text; sqlCommand.Parameters.AddWithValue("@Ten", "%" + townName + "%"); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); try { while (sqlDataReader.Read()) { TownModel townModel = new TownModel(); townModel.Id = int.Parse(sqlDataReader["Id"].ToString()); townModel.TownName = sqlDataReader["Ten"].ToString(); townModel.PhoneNumber = sqlDataReader["Dienthoai"].ToString(); townModel.Address = sqlDataReader["Diachi"].ToString(); townModel.Fax = sqlDataReader["Fax"].ToString(); townModel.Note = sqlDataReader["Ghichu"].ToString(); townModel.IsDeleted = false; townModels.Add(townModel); } } catch (Exception ex) { throw ex; } finally { sqlDataReader.Close(); conn.Close(); } } return(townModels); }
/// <summary> /// Get list of towns /// filter by Local municipality /// </summary> /// <param name="localMunicipalityId"></param> /// <returns></returns> public ActionResult FilterFromLocalMunicipalityAjax(string localMunicipalityId) { if (String.IsNullOrEmpty(localMunicipalityId)) { localMunicipalityId = "-1"; } var townModel = new TownModel(); var townsList = townModel.GetListOfTowns(int.Parse(localMunicipalityId)); var result = (from x in townsList select new { id = x.Town_Id, name = x.Description }).ToList(); return(Json(result, JsonRequestBehavior.AllowGet)); }
void setUpData(int townId, int customerId, int agentId, int shipperId) { townModel = new TownModel() { Id = townId }; customerModel = new InvoiceModel.InvoiceCustomer() { Id = customerId }; agentModel = new InvoiceModel.InvoiceAgent() { Id = agentId }; shipperModel = new InvoiceModel.InvoiceShipper() { Id = shipperId }; }
public ActionResult Edit(TownModel model) { try { using (ManageTownService service = new ManageTownService()) { if (ModelState.IsValid) { bool isNew = false; if (model.CITY_CD_HIDDEN == 0 && model.DISTRICT_CD_HIDDEN == 0 && model.TOWN_CD_HIDDEN == 0) { isNew = true; service.InsertTown(model); JsonResult result = Json(new { isNew = isNew }, JsonRequestBehavior.AllowGet); return(result); } else { isNew = false; service.UpdateTown(model); JsonResult result = Json(new { isNew = isNew }, JsonRequestBehavior.AllowGet); return(result); } } else { var ErrorMessages = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); } return(new EmptyResult()); } } catch (Exception ex) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; System.Web.HttpContext.Current.Session["ERROR"] = ex; return(new EmptyResult()); } }
public ActionResult TownEdit(int CityCd = 0, int DistrictCd = 0, int TownCd = 0) { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; var authorityList = currentUser != null ? currentUser.USER_AUTHORITY : 0; if (currentUser == null || authorityList != 2) { return(RedirectToAction("Login", "UserAccount")); } TownModel model = new TownModel(); CommonService comService = new CommonService(); ManageTownDa dataAccess = new ManageTownDa(); if (CityCd > 0 && DistrictCd > 0 && TownCd > 0) { TownModel infor = new TownModel(); infor = dataAccess.getInfoTown(CityCd, DistrictCd, TownCd); model = infor != null ? infor : model; } model.CITY_LIST = comService.GetCityList().ToList().Select( f => new SelectListItem { Value = f.CITY_CD.ToString(), Text = f.CITY_NAME }).ToList(); model.CITY_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); model.DISTRICT_LIST = comService.GetDistrictList().ToList().Select( f => new SelectListItem { Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString(), Text = f.DISTRICT_NAME }).ToList(); return(View(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(TownModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update Town set "); strSql.Append(" TownName = @TownName , "); strSql.Append(" TownTitle = @TownTitle , "); strSql.Append(" TownMemo = @TownMemo , "); strSql.Append(" OrderNo = @OrderNo "); strSql.Append(" where TownId=@TownId "); SqlParameter[] parameters = { new SqlParameter("@TownId", SqlDbType.Decimal, 9), new SqlParameter("@TownName", SqlDbType.VarChar, 50), new SqlParameter("@TownTitle", SqlDbType.VarChar, 250), new SqlParameter("@TownMemo", SqlDbType.VarChar, 2000), new SqlParameter("@OrderNo", SqlDbType.Decimal, 9) }; parameters[0].Value = model.TownId; parameters[1].Value = model.TownName; parameters[2].Value = model.TownTitle; parameters[3].Value = model.TownMemo; parameters[4].Value = model.OrderNo; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
public long UpdateTown(TownModel model) { long result = 0; //Check create new customer StringBuilder sqlinsert = new StringBuilder(); model.DEL_FLG = DeleteFlag.NON_DELETE; sqlinsert.Append(@" UPDATE [dbo].[MstTown] SET [TOWN_NAME] = @TOWN_NAME ,[DSP_ORDER] = @DSP_ORDER ,[DEL_FLG] = @DEL_FLG ,[STATUS] = @STATUS WHERE [CITY_CD] = @CITY_CD_HIDDEN AND DISTRICT_CD = @DISTRICT_CD_HIDDEN AND TOWN_CD = @TOWN_CD_HIDDEN"); result = base.DbUpdate(sqlinsert.ToString(), model, new { CITY_CD_HIDDEN = model.CITY_CD_HIDDEN, DISTRICT_CD_HIDDEN = model.DISTRICT_CD_HIDDEN, TOWN_CD_HIDDEN = model.TOWN_CD_HIDDEN }); return(result); }
public IHttpActionResult Put([FromUri] int id, [FromBody] TownModel model) { try { Town town = Factory.Create(model); UnitOfWork.Towns.Update(town, id); UnitOfWork.Commit(); return(Ok(Factory.Create(town))); } catch (DbEntityValidationException ex) { Logger.Log(ex.Message); return(BadRequest(ErrorGeneratorMessage.Generate(ex))); } catch (Exception ex) { Logger.Log(ex.Message, "ERROR"); return(BadRequest(ex.Message)); } }
public TownModel GetSingleTownByTownId(int townId) { TownModel townModel = new TownModel(); using (conn = JBCertConnection.Instance) { string queryString = @"SELECT * FROM [dbo].[tblHuyen] Where Id = @Id"; conn.Open(); SqlCommand sqlCommand = new SqlCommand(queryString, conn); sqlCommand.CommandType = CommandType.Text; sqlCommand.Parameters.AddWithValue("@Id", townId); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); try { while (sqlDataReader.Read()) { townModel.Id = int.Parse(sqlDataReader["Id"].ToString()); townModel.TownName = sqlDataReader["Ten"].ToString(); townModel.PhoneNumber = sqlDataReader["Dienthoai"].ToString(); townModel.Address = sqlDataReader["Diachi"].ToString(); townModel.Fax = sqlDataReader["Fax"].ToString(); townModel.Note = sqlDataReader["Ghichu"].ToString(); townModel.IsDeleted = false; } } catch (Exception ex) { throw ex; } finally { sqlDataReader.Close(); conn.Close(); } } return(townModel); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(TownModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Town("); strSql.Append("TownName,TownTitle,TownMemo,OrderNo"); strSql.Append(") values ("); strSql.Append("@TownName,@TownTitle,@TownMemo,@OrderNo"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@TownName", SqlDbType.VarChar, 50), new SqlParameter("@TownTitle", SqlDbType.VarChar, 250), new SqlParameter("@TownMemo", SqlDbType.VarChar, 2000), new SqlParameter("@OrderNo", SqlDbType.Decimal, 9) }; parameters[0].Value = model.TownName; parameters[1].Value = model.TownTitle; parameters[2].Value = model.TownMemo; parameters[3].Value = model.OrderNo; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }
public JsonResult loadTown(int districtID) { var xml = XDocument.Load(Server.MapPath(@"~/Assets/Client/data/Provinces_Data.xml")); var xElement = xml.Element("Root").Elements("Item").Elements("Item") .Single(x => x.Attribute("type").Value == "district" && int.Parse(x.Attribute("id").Value) == districtID); var lst = new List <TownModel>(); TownModel town = null; foreach (var item in xElement.Elements("Item").Where(x => x.Attribute("type").Value == "precinct")) { town = new TownModel(); town.ID = int.Parse(item.Attribute("id").Value); town.Name = item.Attribute("value").Value; // town.DistrictID = districtID; lst.Add(town); } return(Json(new { data = lst, status = true })); }
public List <TownModel> GetAllCanNotDeleteTown() { List <TownModel> townModels = new List <TownModel>(); using (conn = JBCertConnection.Instance) { string queryString = @"SELECT a.HuyenId from [dbo].[tblXa] as a where a.id in (select b.XaId from tblTruong as b where b.IsDeleted = 0) and a.IsDeleted = 0 group by a.HuyenId"; conn.Open(); SqlCommand sqlCommand = new SqlCommand(queryString, conn); sqlCommand.CommandType = CommandType.Text; SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); try { while (sqlDataReader.Read()) { TownModel townModel = new TownModel(); townModel.Id = int.Parse(sqlDataReader["HuyenId"].ToString()); townModels.Add(townModel); } } catch (Exception ex) { throw ex; } finally { sqlDataReader.Close(); conn.Close(); } } return(townModels); }
public int AddTown(TownModel townModel) { using (conn = JBCertConnection.Instance) { string queryString = @"INSERT INTO [dbo].[tblHuyen] ([Ten] ,[Diachi] ,[Dienthoai] ,[Fax] ,[Ghichu] ,[IsDeleted]) VALUES (@Ten, @Diachi, @Dienthoai, @Fax, @Ghichu, 0)"; conn.Open(); SqlCommand sqlCommand = new SqlCommand(queryString, conn); sqlCommand.CommandType = CommandType.Text; sqlCommand.Parameters.AddWithValue("@Ten", townModel.TownName); sqlCommand.Parameters.AddWithValue("@Diachi", townModel.Address); sqlCommand.Parameters.AddWithValue("@Dienthoai", townModel.PhoneNumber); sqlCommand.Parameters.AddWithValue("@Fax", townModel.Fax); sqlCommand.Parameters.AddWithValue("@Ghichu", townModel.Note); try { int result = sqlCommand.ExecuteNonQuery(); return(result); } catch (Exception ex) { throw ex; } finally { conn.Close(); } } }
public int UpdateTown(TownModel townModel) { using (conn = JBCertConnection.Instance) { string queryString = @"UPDATE [dbo].[tblHuyen] SET [Ten] = @Ten ,[Diachi] = @Diachi ,[Dienthoai] = @Dienthoai ,[Fax] = @Fax ,[Ghichu] = @Ghichu ,[IsDeleted] = 0 WHERE Id = @Id"; conn.Open(); SqlCommand sqlCommand = new SqlCommand(queryString, conn); sqlCommand.CommandType = CommandType.Text; sqlCommand.Parameters.AddWithValue("@Ten", townModel.TownName); sqlCommand.Parameters.AddWithValue("@Diachi", townModel.Address); sqlCommand.Parameters.AddWithValue("@Dienthoai", townModel.PhoneNumber); sqlCommand.Parameters.AddWithValue("@Fax", townModel.Fax); sqlCommand.Parameters.AddWithValue("@Ghichu", townModel.Note); sqlCommand.Parameters.AddWithValue("@Id", townModel.Id); try { int result = sqlCommand.ExecuteNonQuery(); return(result); } catch (Exception ex) { throw ex; } finally { conn.Close(); } } }
public TownView(TownModel model, Matrix world) { this.model = model; this.townID = model.GetTownID(); townRotation = GameMaster.Inst().GetRandomInt(6); this.pickTownColor = new Color(0.0f, 0.0f, 1.0f - townID / 256.0f); Matrix rotation; rotation = (townRotation == 0) ? Matrix.Identity : Matrix.CreateRotationY(((float)Math.PI / 3.0f) * (townRotation)); this.world = rotation * Matrix.CreateTranslation(new Vector3(0.0f, 0.01f, 0.0f)) * Matrix.CreateScale(0.00032f) * world; this.worldShape = Matrix.CreateTranslation(new Vector3(0.0f, 0.04f, 0.0f)) * Matrix.CreateScale(0.22f) * world; this.worldSphere = Matrix.CreateScale(0.0001f) * Matrix.CreateTranslation(new Vector3(0.0f, 0.15f, 0.0f)) * world; buildingIsBuild = new bool[3]; for (int loop1 = 0; loop1 < buildingIsBuild.Length; loop1++) buildingIsBuild[loop1] = false; pickVars = new PickVariables(pickTownColor); }
public void Clear() { ancestorTown = null; ancestorRoad = null; distance = INFINITY; }
internal void Set(int distance, TownModel ancestorTown, IRoad ancestorRoad) { this.distance = distance; this.ancestorTown = ancestorTown; this.ancestorRoad = ancestorRoad; }