protected void Page_Load(object sender, EventArgs e) { client = new MyServiceClient(); areaCodes = client.SelectAllAreaCodes(); // הגדרת עמודות columns = new GridViewColumnDefinitions(); columns.Add(new GridViewColumnDefinition( "Name", "קידומת", ColumnType.STRING_COLUMN, ColumnAligment.CENTER ) ); if (!IsPostBack) { // גריד עם אפשרויות עריכה GridViewUtilities.SetColumns <AreaCode>( // Grid-הטיפוס המוצג ב grdCities, // Grid-שם ה areaCodes, // רשימת הישובים columns, // רשימת העמודות 20, // Grid-רוחב ה true // לכלול עמודת עריכה ); } }
/// //////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// /// #region AREACODES public AreaCodes SelectAllAreaCodes() { AreaCodes areaCodes = new AreaCodes(); areaCodes.SelectAll(); return(areaCodes); }
private static void MapEntityConservationArea(GeographicalAreaDto dto, List <AreaCategory> conservationAreaCategories) { var conservationAreaCategory = conservationAreaCategories.FirstOrDefault(c => c.ShortName == dto.Category); if (conservationAreaCategory == null) { conservationAreaCategory = new AreaCategory { ShortName = dto.Category, Name = AreaCodes.CodeToName(dto.Category) }; conservationAreaCategories.Add(conservationAreaCategory); } var conservationArea = conservationAreaCategory.ConservationAreas.FirstOrDefault(c => c.Number == int.Parse(dto.Number)); if (conservationArea == null) { conservationArea = new ConservationArea { Number = int.Parse(dto.Number), Name = dto.Name }; conservationAreaCategory.ConservationAreas.Add(conservationArea); } if (dto.NatureAreaId.HasValue) { conservationArea.NatureAreaIds.Add(dto.NatureAreaId.Value); } }
public bool DeleteAreaCode(AreaCode areaCode) { AreaCodes areaCodes = new AreaCodes(); areaCodes.SelectAll(); areaCodes.Delete(areaCode); return(areaCodes.Save()); }
/// <summary> /// Generates an area code, this implimentation will most likely pick an area code associated with the given state, but /// will randomly pick a different state every so often to make it more realistic. /// </summary> /// <param name="random"> </param> /// <param name="state"> </param> /// <returns> </returns> protected virtual string GenerateAreaCode(Random random, string state) { if (random.Next(10) < 9) { var areaCodes = AreaCodes.Where(a => a.State == state).ToList(); return(areaCodes[random.Next(areaCodes.Count)].Code); } return(AreaCodes[random.Next(AreaCodes.Count)].Code); }
public bool ModifyAreaCode(AreaCode oldAreaCode, AreaCode newAreaCode) { AreaCodes areaCodes = new AreaCodes(); areaCodes.SelectAll(); if (areaCodes.Modify(oldAreaCode, newAreaCode)) { return(areaCodes.Save()); } else { return(false); } }
public bool AddAreaCode(AreaCode areaCode) { AreaCodes areaCodes = new AreaCodes(); areaCodes.SelectAll(); if (areaCodes.Add(areaCode)) { return(areaCodes.Save()); } else { return(false); } }
public void PostUpdateAccount(DtoAccount dto) { var id = dto.id; if (id == 17579) { } var acct = Accounts[id]; // sex if (dto.flags.HasFlag(DtoFlags.Sex)) { if (dto.sex) { acct.Flags |= Account.Male; } else { acct.Flags &= (byte)~Account.Male; } } // status if (dto.flags.HasFlag(DtoFlags.Status)) { bool isFree = dto.status == DtoAccount.STATUS_FREE; bool isTaken = dto.status == DtoAccount.STATUS_TAKEN; bool isComplicated = dto.status == DtoAccount.STATUS_COMPLICATED; // clear old flags acct.Flags &= (byte)~(Account.Free | Account.Taken); // add new flags if (isFree) { acct.Flags |= Account.Free; } else if (isTaken) { acct.Flags |= Account.Taken; } else { acct.Flags |= (byte)(Account.Free | Account.Taken); } } // birth date if (dto.flags.HasFlag(DtoFlags.Birth)) { // exclude from old range if (acct.BirthIdx > 0) { BirthYears[acct.BirthIdx].Exclude(id); } // store new birthday acct.Birth = dto.birth; // include into new range acct.BirthIdx = (byte)BirthYears.GetOrCreateRangeThenInclude( Utils.TimestampToDate(acct.Birth).Year, id).Index; } // joined date if (dto.flags.HasFlag(DtoFlags.Joined)) { // exclude from old range if (acct.JoinedIdx > 0) { JoinYears[acct.JoinedIdx].Exclude(id); } // include into new range acct.JoinedIdx = (byte)JoinYears.GetOrCreateRangeThenInclude( Utils.TimestampToDate(dto.joined).Year, id).Index; } // premium if (dto.flags.HasFlag(DtoFlags.Premium)) { acct.PStart = dto.premium.start; acct.PFinish = dto.premium.finish; bool premiumNow = acct.PStart <= Now && acct.PFinish >= Now; if (premiumNow) { acct.Flags |= Account.Premium; } else { acct.Flags &= (byte)~Account.Premium; } } // fname if (dto.flags.HasFlag(DtoFlags.Fname)) { // exclude from old range if (acct.FNameIdx > 0) { Fnames[acct.FNameIdx].Exclude(id); } acct.FNameIdx = dto.fnameIdx; if (acct.FNameIdx > 0) { Fnames[acct.FNameIdx].Include(id); } } // sname if (dto.flags.HasFlag(DtoFlags.Sname)) { // exclude from old range if (acct.SNameIdx != 0) { var entry = Snames[acct.SNameIdx]; Snames2.GetOrCreateRange(entry.AName[0] + (entry.AName[1] << 8)).Exclude(id); Snames2.GetOrCreateRange(entry.AName[0] + (entry.AName[1] << 8) + (entry.AName[2] << 16) + (entry.AName[3] << 24)).Exclude(id); } acct.SNameIdx = dto.snameIdx; if (acct.SNameIdx > 0) { var entry = Snames[acct.SNameIdx]; Snames2.GetOrCreateRangeThenInclude(entry.AName[0] + (entry.AName[1] << 8), id); Snames2.GetOrCreateRangeThenInclude(entry.AName[0] + (entry.AName[1] << 8) + (entry.AName[2] << 16) + (entry.AName[3] << 24), id); } } // phone if (dto.flags.HasFlag(DtoFlags.Phone)) { // exclude from old range var oldAreaCode = areaCodeFromPhone(new AString(acct.Phone)); if (!oldAreaCode.IsEmpty) { AreaCodes.GetOrCreateRange(oldAreaCode).Exclude(id); } // update the phone number acct.Phone = dto.phone.Buffer; // include into new range var newAreaCode = areaCodeFromPhone(dto.phone); if (!newAreaCode.IsEmpty) { AreaCodes.GetOrCreateRange(newAreaCode).Include(id); } } // country if (dto.flags.HasFlag(DtoFlags.Country)) { // exclude from old range if (acct.CountryIdx > 0) { Countries[acct.CountryIdx].Exclude(id); } acct.CountryIdx = dto.countryIdx; // include into new range if (acct.CountryIdx > 0) { Countries[acct.CountryIdx].Include(id); } } // city if (dto.flags.HasFlag(DtoFlags.City)) { // exclude from old range if (acct.CityIdx > 0) { Cities[acct.CityIdx].Exclude(id); } acct.CityIdx = dto.cityIdx; // include into new range if (acct.CityIdx > 0) { Cities[acct.CityIdx].Include(id); } } // interests if (dto.flags.HasFlag(DtoFlags.Interests)) { // exclude old interests for (int i = 1; i < BitMap96.MAX_BITS; i++) { if (acct.InterestMask.IsSet(i)) { Interests[i].Exclude(id); } } acct.InterestMask = dto.interests; // include new interests for (int i = 1; i < BitMap96.MAX_BITS; i++) { if (acct.InterestMask.IsSet(i)) { Interests[i].Include(id); } } } // unlink old likes if (dto.flags.HasFlag(DtoFlags.Likes)) { if (acct.LikesCount > 0) { Log.Error("Replacing existing likes on update"); } if (dto.likes != null) { addLikes(id, ref acct, dto.likes); } } // uncount old record from cube groups updateGroups(ref Accounts[id], false); // store new account info Accounts[id] = acct; // count new record in cube groups updateGroups(ref acct, true); }
/// <summary> /// 添加/编辑店长信息 /// </summary> /// <param name="isContinueAdd">isContinueAdd=true:连续保存</param> private void DoSave(bool isContinueAdd) { if (!NetUtil.CheckNetWork(CurrActivity)) { ToastUtil.ShowWarningToast(CurrActivity, "网络未连接!"); return; } try { var tname = etName.Text.Trim(); var temail = etEmail.Text.Trim(); if (string.IsNullOrEmpty(tname)) { ToastUtil.ShowWarningToast(this, "请输入姓名"); etName.RequestFocus(); return; } if (!CheckUtil.IsValidEmail(temail)) { ToastUtil.ShowWarningToast(this, "邮箱格式不正确"); etEmail.RequestFocus(); return; } if (string.IsNullOrEmpty(tvAreaCodes.Text.Trim())) { ToastUtil.ShowWarningToast(this, "请选择门店"); return; } LoadingDialogUtil.ShowLoadingDialog(this, "保存中..."); new Thread(new ThreadStart(() => { //新增操作 var model = new ManagerUserInfo(); model.Email = etEmail.Text; model.Name = etName.Text; model.UserType = Convert.ToInt32(UserType.ShopManager); model.IsCanLogin = true; model.SchoolId = CurrUserInfo.SchoolId; model.Creator = CurrUserInfo.Name; model.Modifier = CurrUserInfo.Name; model.DistrictCode = CurrUserInfo.DistrictCode; DataEntity.Result resultData = new DataEntity.Result(); if (isNewAdd) { resultData = _meService.AddShopManager(model, AreaCodes, AreaNames); } else { var codeArr = AreaCodes.Split(','); var nameArr = AreaNames.Split(','); var list = new List <UserAreaRelationModel>(); for (int i = 0; i < codeArr.Length; i++) { var relation = new UserAreaRelationModel(); relation.AreaCode = codeArr[i]; relation.AreaName = nameArr[i]; relation.Email = etEmail.Text; relation.UserType = (int)UserType.ShopManager; relation.Creator = CurrUserInfo.Name; relation.Modifier = CurrUserInfo.Name; relation.SchoolId = CurrUserInfo.SchoolId; list.Add(relation); } resultData = _meService.SaveUserArea(list); } RunOnUiThread(() => { LoadingDialogUtil.DismissLoadingDialog(); if (resultData.State == 1) { ToastUtil.ShowSuccessToast(this, "操作成功"); //保存并继续添加 if (isContinueAdd) { currShopManager = new ShopManagerList(); etName.Text = ""; etEmail.Text = ""; tvAreaNames.Text = "未设置"; } //完成 else { new Handler().PostDelayed(() => { Finish(); OverridePendingTransition(Resource.Animation.left_in, Resource.Animation.right_out); }, 1000); } } else { ToastUtil.ShowErrorToast(this, (string.IsNullOrEmpty(resultData.Error) ? "操作失败" : resultData.Error)); } }); })).Start(); } catch (Exception ex) { var msg = ex.Message.ToString(); ToastUtil.ShowErrorToast(this, "操作失败"); LoadingDialogUtil.DismissLoadingDialog(); } }
// this call is serialized public void PostNewAccount(DtoAccount dto) { var id = dto.id; var acct = Accounts[id]; // sex if (dto.sex) { acct.Flags |= Account.Male; } // status if (dto.status == DtoAccount.STATUS_FREE) { acct.Flags |= Account.Free; } else if (dto.status == DtoAccount.STATUS_TAKEN) { acct.Flags |= Account.Taken; } else { acct.Flags |= (byte)(Account.Free | Account.Taken); } // birth date and year acct.Birth = dto.birth; acct.BirthIdx = (byte)BirthYears.GetOrCreateRangeThenInclude( Utils.TimestampToDate(acct.Birth).Year, id).Index; // joined acct.JoinedIdx = (byte)JoinYears.GetOrCreateRangeThenInclude( Utils.TimestampToDate(dto.joined).Year, id).Index; // premium acct.PStart = dto.premium.start; acct.PFinish = dto.premium.finish; bool premiumNow = acct.PStart <= Now && acct.PFinish >= Now; if (premiumNow) { acct.Flags |= Account.Premium; } // fname acct.FNameIdx = dto.fnameIdx; if (acct.FNameIdx > 0) { Fnames[acct.FNameIdx].Include(id); } // sname acct.SNameIdx = dto.snameIdx; if (acct.SNameIdx > 0) { var entry = Snames[dto.snameIdx]; entry.Include(id); Snames2.GetOrCreateRangeThenInclude(entry.AName[0] + (entry.AName[1] << 8), id); Snames2.GetOrCreateRangeThenInclude(entry.AName[0] + (entry.AName[1] << 8) + (entry.AName[2] << 16) + (entry.AName[3] << 24), id); } // phone if (!dto.phone.IsEmpty) { acct.Phone = dto.phone.Buffer; // add to area code index var areaCodeStr = areaCodeFromPhone(dto.phone); if (!areaCodeStr.IsEmpty) { AreaCodes.GetOrCreateRangeThenInclude(areaCodeStr, id); } } // country acct.CountryIdx = dto.countryIdx; if (acct.CountryIdx > 0) { Countries[acct.CountryIdx].Include(id); } // city acct.CityIdx = dto.cityIdx; if (acct.CityIdx > 0) { Cities[acct.CityIdx].Include(id); } // interests acct.InterestMask = dto.interests; for (int i = 1; i < BitMap96.MAX_BITS; i++) { if (acct.InterestMask.IsSet(i)) { Interests[i].Include(id); } } // likes if (dto.likes != null) { addLikes(id, ref acct, dto.likes); } // update the group hypercube updateGroups(ref acct, true); // store it Accounts[id] = acct; }