private void DeleteUserArea(Int32 type, Int32 area) { Int32 temIndex = Int32.MaxValue; for (int i = 0; i < this.updateRateMange.UserAreaCount; i++) { StructUserArea tem = this.updateRateMange.UserAreaList[i]; if (tem.Usertype == type && tem.Areatype == area) { temIndex = tem.Index; //移除之前的设置 this.updateRateMange.SettingList.RemoveAt(temIndex); } if (tem.Index > temIndex) { StructUserArea.Builder newArea = new StructUserArea.Builder(tem); newArea.Index -= 1; this.updateRateMange.SetUserArea(i, newArea); } } if (temIndex < this.updateRateMange.UserAreaCount) { this.updateRateMange.UserAreaList.RemoveAt(temIndex); } }
//保存当前区域设置 private void SaveCurrentAreaSetting() { if (this.selectAreaLabel != null && this.selectTypeLabel != null) { Int32 area = Int32.Parse(this.selectAreaLabel.Name.Split('_')[1]); Int32 type = Int32.Parse(this.selectTypeLabel.Name.Split('_')[1]); if (!this.nDurComboBoxEdit.Text.Equals("") && !this.nDurPrieceText.Text.Equals("") && !this.nMinConsumeText.Text.Equals("") && !this.bDurComboBoxEdit.Text.Equals("") && !this.bDurPrieceText.Text.Equals("") && !this.bMinConsumeText.Text.Equals("")) { // 判断一下是否与之前的都一样 DeleteUserArea(type, area); //设置新Setting ,UserType StructBillSetting setting = this.GetSelectRateSetting().Build(); StructUserArea.Builder currentUserArea = new StructUserArea.Builder(); currentUserArea.OrdinaryInterval = Int32.Parse(this.nDurComboBoxEdit.Text); currentUserArea.OrdinaryPrice = Int32.Parse(this.nDurPrieceText.Text); currentUserArea.OrdinaryMin = Int32.Parse(this.nMinConsumeText.Text); currentUserArea.NightInterval = Int32.Parse(this.bDurComboBoxEdit.Text); currentUserArea.NightPrice = Int32.Parse(this.bDurPrieceText.Text); currentUserArea.NightMin = Int32.Parse(this.bMinConsumeText.Text); currentUserArea.Areatype = area; currentUserArea.Usertype = type; currentUserArea.Index = 0; //相对于服务器保存的进行判断是否改变 if (this.IsChangeUserArea(currentUserArea.Build(), setting)) { this.DeleteUserArea(type, area); } else { this.updateRateMange.AddSetting(setting); int index = this.updateRateMange.SettingCount - 1; currentUserArea.Index = index; this.updateRateMange.AddUserArea(currentUserArea); } } } }