/// <summary> /// 批量删除数据(启用事务 /// </summary> /// <param name="json"></param> /// <returns></returns> public bool DeleteBatchProvinceCity(string json) { ProvinceCity bll = new ProvinceCity(); IList <object> list = (IList <object>)JsonConvert.DeserializeObject(json); return(bll.DeleteBatch(list)); }
public string DelProvinceCity(string id) { string errorMsg = string.Empty; try { if (!HttpContext.Current.User.IsInRole("Administrators")) { return(MC.Role_InvalidError); } if (string.IsNullOrWhiteSpace(id)) { return(MC.Submit_InvalidRow); } Guid gId = Guid.Empty; Guid.TryParse(id, out gId); if (gId.Equals(Guid.Empty)) { return(MC.GetString(MC.Submit_Params_GetInvalidRegex, "对应标识值")); } ProvinceCity bll = new ProvinceCity(); bll.Delete(gId); return("1"); } catch (Exception ex) { errorMsg = ex.Message; } return(MC.GetString(MC.Submit_Ex_Error, errorMsg)); }
public ActionResult DeleteConfirmed(int id) { ProvinceCity provinceCity = db.ProvinceCities.Find(id); db.ProvinceCities.Remove(provinceCity); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MaTinh,TenTinh,TenTp")] ProvinceCity provinceCity) { if (ModelState.IsValid) { db.Entry(provinceCity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(provinceCity)); }
/// <summary> /// 获取数据列表 /// </summary> /// <returns></returns> public string GetProvinceCityList() { ProvinceCity bll = new ProvinceCity(); List <ProvinceCityInfo> list = bll.GetList(); if (list == null || list.Count == 0) { return("[]"); } return(JsonConvert.SerializeObject(list)); }
/// <summary> /// 获取对应的数据 /// </summary> /// <param name="Id"></param> /// <returns></returns> public string GetProvinceCityModel(object Id) { ProvinceCity bll = new ProvinceCity(); ProvinceCityInfo model = bll.GetModel(Id); if (model == null) { return("[]"); } return(JsonConvert.SerializeObject(model)); }
public ActionResult Create([Bind(Include = "MaTinh,TenTinh,TenTp")] ProvinceCity provinceCity) { if (ModelState.IsValid) { db.ProvinceCities.Add(provinceCity); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(provinceCity)); }
/// <summary> /// 获取数据分页列表,并返回所有记录数 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalRecords"></param> /// <param name="sqlWhere"></param> /// <param name="cmdParms"></param> /// <returns></returns> public string GetProvinceCityList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms) { ProvinceCity bll = new ProvinceCity(); List <ProvinceCityInfo> list = bll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, cmdParms); if (list == null || list.Count == 0) { return("[]"); } return(JsonConvert.SerializeObject(list)); }
/// <summary> /// 获取满足当前条件的数据列表 /// </summary> /// <param name="sqlWhere"></param> /// <param name="cmdParms"></param> /// <returns></returns> public string GetProvinceCityList(string sqlWhere, params SqlParameter[] cmdParms) { ProvinceCity bll = new ProvinceCity(); List <ProvinceCityInfo> list = bll.GetList(sqlWhere, cmdParms); if (list == null || list.Count == 0) { return("[]"); } return(JsonConvert.SerializeObject(list)); }
public string GetProvinceCityModel(Guid Id) { StringBuilder sb = new StringBuilder(); ProvinceCity bll = new ProvinceCity(); ProvinceCityInfo model = bll.GetModel(Id); if (model == null) { return("[]"); } return(sb.ToString()); }
public bool CreateProvinceCity(ProvinceCity city) { try { data.ProvinceCities.InsertOnSubmit(city); data.SubmitChanges(); return(true); } catch { return(false); } }
public string SaveProvinceCity(ProvinceCityInfo model) { if (string.IsNullOrWhiteSpace(model.Named)) { return(MessageContent.Submit_Params_InvalidError); } if (string.IsNullOrWhiteSpace(model.Pinyin)) { return(MessageContent.Submit_Params_InvalidError); } if (string.IsNullOrWhiteSpace(model.FirstChar)) { return(MessageContent.Submit_Params_InvalidError); } Guid gId = Guid.Empty; Guid.TryParse(model.Id.ToString(), out gId); model.Id = gId; Guid parentId = Guid.Empty; Guid.TryParse(model.ParentId.ToString(), out parentId); model.ParentId = parentId; model.LastUpdatedDate = DateTime.Now; ProvinceCity bll = new ProvinceCity(); int effect = -1; if (!gId.Equals(Guid.Empty)) { effect = bll.Update(model); } else { effect = bll.Insert(model); } if (effect == 110) { return(MessageContent.Submit_Exist); } if (effect > 0) { return("1"); } else { return(MessageContent.Submit_Error); } }
// GET: ProvinceCities/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProvinceCity provinceCity = db.ProvinceCities.Find(id); if (provinceCity == null) { return(HttpNotFound()); } return(View(provinceCity)); }
/// <summary> /// 获取当前市的区列表 /// </summary> /// <returns></returns> public string GetDistrict(object cityId) { ProvinceCity bll = new ProvinceCity(); SqlParameter parm = new SqlParameter("@ParentId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(cityId.ToString()); List <ProvinceCityInfo> list = bll.GetList("and ParentId = @ParentId", parm); if (list == null || list.Count == 0) { return("[]"); } return(JsonConvert.SerializeObject(list)); }
public string GetDistrict(Guid cityId) { StringBuilder sb = new StringBuilder(); ProvinceCity bll = new ProvinceCity(); SqlParameter parm = new SqlParameter("@ParentId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(cityId.ToString()); List <ProvinceCityInfo> list = bll.GetList("and ParentId = @ParentId", parm); if (list == null || list.Count == 0) { return("[]"); } return(sb.ToString()); }
public bool DeleteProvinceCity(int id) { try { ProvinceCity city = (from ProvinceCity in data.ProvinceCities where ProvinceCity.MaTinh == id select ProvinceCity).Single(); data.ProvinceCities.DeleteOnSubmit(city); return(true); } catch { return(false); } }
public string DelProvinceCity(string id) { if (string.IsNullOrWhiteSpace(id)) { return(MessageContent.Submit_InvalidRow); } Guid gId = Guid.Empty; Guid.TryParse(id, out gId); if (gId.Equals(Guid.Empty)) { return(MessageContent.GetString(MessageContent.Submit_Params_GetInvalidRegex, "对应标识值")); } ProvinceCity bll = new ProvinceCity(); bll.Delete(gId); return("1"); }
public bool UpdateProvinceCity(ProvinceCity city) { try { var t = (from ProvinceCity in data.ProvinceCities where ProvinceCity.MaTinh == city.MaTinh select ProvinceCity).Single(); t.MaTinh = city.MaTinh; t.TenTinh = city.TenTinh; t.TenTp = city.TenTp; data.SubmitChanges(); return(true); } catch { return(false); } }
/// <summary> /// 获取所有省份列表 /// </summary> /// <returns></returns> public string GetProvince() { ProvinceCity bll = new ProvinceCity(); ProvinceCityInfo parentModel = bll.GetModel("中国"); if (parentModel == null) { return("[]"); } SqlParameter parm = new SqlParameter("@ParentId", SqlDbType.UniqueIdentifier); parm.Value = parentModel.Id; List <ProvinceCityInfo> list = bll.GetList("and ParentId = @ParentId", parm); if (list == null || list.Count == 0) { return("[]"); } return(JsonConvert.SerializeObject(list)); }
public string GetProvince() { StringBuilder sb = new StringBuilder(); ProvinceCity bll = new ProvinceCity(); ProvinceCityInfo parentModel = bll.GetModel("中国"); if (parentModel == null) { return("[]"); } SqlParameter parm = new SqlParameter("@ParentId", SqlDbType.UniqueIdentifier); parm.Value = parentModel.Id; List <ProvinceCityInfo> list = bll.GetList("and ParentId = @ParentId", parm); if (list == null || list.Count == 0) { return("[]"); } return(sb.ToString()); }
/// <summary> /// 根据活动页和渠道获取配置的地区 /// </summary> /// <param name="activityId"></param> /// <param name="targetUrl"></param> /// <param name="wxappUrl"></param> /// <returns></returns> public List <ProvinceCity> GetRegionIdByActivityIdUrl(Guid activityId, string targetUrl, string wxappUrl) { List <RegionVehicleIdActivityUrlConfig> idList = null; List <ProvinceCity> pcList = new List <ProvinceCity>(); try { var client = new Service.Shop.RegionClient(); idList = ConfigurationReadDb.Execute(conn => DalCityActivityPageConfig.SelectRegionIdVehicleIdByActivityIdUrl(conn, activityId, targetUrl, wxappUrl)); var ids = idList?.Where(s => s.RegionId > 0)?.Distinct()?.ToList() ?? new List <RegionVehicleIdActivityUrlConfig>(); foreach (var id in ids) { var result = client.GetRegionByRegionId(id.RegionId); if (!result.Success) { result.ThrowIfException(true); } if (result.Result != null) { ProvinceCity pc = new ProvinceCity() { ProvinceId = result.Result.ProvinceId, ProvinceName = result.Result.ProvinceName, CityId = result.Result.CityId, CityName = result.Result.CityName }; pcList.Add(pc); } } } catch (Exception ex) { Logger.Error("SelectRegionIdVehicleIdByActivityIdUrl", ex); } return(pcList); }
public string SaveProvinceCity(ProvinceCityInfo model) { string errorMsg = string.Empty; try { if (string.IsNullOrWhiteSpace(model.Named)) { return(MC.Submit_Params_InvalidError); } if (string.IsNullOrWhiteSpace(model.Pinyin)) { return(MC.Submit_Params_InvalidError); } if (string.IsNullOrWhiteSpace(model.FirstChar)) { return(MC.Submit_Params_InvalidError); } Guid gId = Guid.Empty; Guid.TryParse(model.Id.ToString(), out gId); model.Id = gId; Guid parentId = Guid.Empty; Guid.TryParse(model.ParentId.ToString(), out parentId); model.ParentId = parentId; model.LastUpdatedDate = DateTime.Now; ProvinceCity bll = new ProvinceCity(); int effect = -1; using (TransactionScope scope = new TransactionScope()) { if (!gId.Equals(Guid.Empty)) { effect = bll.Update(model); } else { effect = bll.Insert(model); } scope.Complete(); } if (effect == 110) { return(MC.Submit_Exist); } if (effect > 0) { return("1"); } else { return(MC.Submit_Error); } } catch (Exception ex) { errorMsg = ex.Message; } return(MC.GetString(MC.Submit_Ex_Error, errorMsg)); }
public string GetJsonForProvinceCity() { ProvinceCity bll = new ProvinceCity(); return(bll.GetTreeJson()); }
/// <summary> /// 删除对应数据 /// </summary> /// <param name="Id"></param> /// <returns></returns> public int DeleteProvinceCity(object Id) { ProvinceCity bll = new ProvinceCity(); return(bll.Delete(Id)); }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int UpdateProvinceCity(ProvinceCityInfo model) { ProvinceCity bll = new ProvinceCity(); return(bll.Update(model)); }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int InsertProvinceCity(ProvinceCityInfo model) { ProvinceCity bll = new ProvinceCity(); return(bll.Insert(model)); }