private PolicySettingInfo SaveInfo() { PolicySettingInfo setting = new PolicySettingInfo(); if (!string.IsNullOrWhiteSpace(ddlAirLine.SelectedValue)) { setting.Airline = ddlAirLine.SelectedValue; } setting.Departure = txtDeparture.Code; setting.Arrivals = AirLines.AirportsCode.Join("/"); if (!string.IsNullOrWhiteSpace(txtStartTime.Text)) { setting.EffectiveTimeStart = DateTime.Parse(this.txtStartTime.Text); } if (!string.IsNullOrWhiteSpace(txtEndTime.Text)) { setting.EffectiveTimeEnd = DateTime.Parse(this.txtEndTime.Text).AddDays(1).AddMilliseconds(-3); } setting.Berths = this.hidBunks.Value; //扣点 if (hidKoudianOrTiedian.Value.Trim() == "1") { var rangeList = this.hidRanges.Value.Split(','); var ranges = new List <PolicySettingPeriod>(); foreach (var item in rangeList) { string[] range = item.Split('|'); PolicySettingPeriod period = new PolicySettingPeriod(); if (!string.IsNullOrWhiteSpace(range[0])) { period.PeriodStart = decimal.Parse(range[0]) / 100; } if (!string.IsNullOrWhiteSpace(range[1])) { period.PeriodEnd = decimal.Parse(range[1]) / 100; } if (!string.IsNullOrWhiteSpace(range[2])) { period.Rebate = decimal.Parse(range[2]) / 100; } period.MaxRebate = 0; ranges.Add(period); } setting.Periods = ranges; } else { //贴点 setting.Periods = new List <PolicySettingPeriod>() { new PolicySettingPeriod() { PeriodStart = 0, PeriodEnd = 0, Rebate = -(decimal.Parse(txtTiedian.Text) / 100), MaxRebate = -(decimal.Parse(txtMaxTiedian.Text) / 100) } }; //setting.MountStart = DateTime.Parse(txtTiedianStart.Text); //setting.MountEnd = DateTime.Parse(txtTiedianEnd.Text); } setting.Enable = radEnable.Checked; setting.RebateType = hidKoudianOrTiedian.Value.Trim() == "1"; setting.Remark = this.txtRemark.InnerText; return(setting); }
public IEnumerable <PolicySettingInfo> QueryPolicySettingList(PolicySettingQueryParameter parameter, Pagination pagination) { if (parameter == null) { throw new ArgumentException("parameter"); } if (pagination == null) { throw new ArgumentException("pagination"); } var result = new List <PolicySettingInfo>(); ClearParameters(); if (parameter.Airline != null) { AddParameter("@iAirline", parameter.Airline); } else { AddParameter("@iAirline", DBNull.Value); } if (parameter.Departure != null) { AddParameter("@iDeparture", parameter.Departure); } else { AddParameter("@iDeparture", DBNull.Value); } if (parameter.Arrival != null) { AddParameter("@iArrival", parameter.Arrival); } else { AddParameter("@iArrival", DBNull.Value); } if (parameter.Rebate.HasValue) { AddParameter("@iRebate", parameter.Rebate); } else { AddParameter("@iRebate", DBNull.Value); } if (parameter.EffectiveTimeStart.HasValue) { AddParameter("@iEffectiveTimeStart", parameter.EffectiveTimeStart); } else { AddParameter("@iEffectiveTimeStart", DBNull.Value); } if (parameter.EffectiveTimeEnd.HasValue) { AddParameter("@iEffectiveTimeEnd", parameter.EffectiveTimeEnd); } else { AddParameter("@iEffectiveTimeEnd", DBNull.Value); } AddParameter("@iPageIndex", pagination.PageIndex); AddParameter("@iPageSize", pagination.PageSize); AddParameter("@iGetCount", pagination.GetRowCount); var totalCount = AddParameter("@oTotalCount"); totalCount.DbType = System.Data.DbType.Int32; totalCount.Direction = System.Data.ParameterDirection.Output; using (var reader = ExecuteReader("P_QueryPolicySettings", System.Data.CommandType.StoredProcedure)) { while (reader.Read()) { var item = new PolicySettingInfo { Id = reader.GetGuid(0), Airline = reader.GetString(1), Departure = reader.GetString(2), Arrivals = reader.GetString(3), RebateType = reader.GetBoolean(4), Berths = reader.GetString(5), EffectiveTimeStart = reader.GetDateTime(6), EffectiveTimeEnd = reader.GetDateTime(7), Enable = reader.GetBoolean(8), Remark = reader.GetString(9), Creator = reader.GetString(10), CreateTime = reader.GetDateTime(11), LastModifyTime = reader.GetDateTime(12), Periods = new List <PolicySettingPeriod>() }; var period = new PolicySettingPeriod() { PolicySetting = reader.GetGuid(13), PeriodStart = reader.GetDecimal(14), PeriodEnd = reader.GetDecimal(15), Rebate = reader.GetDecimal(16) }; ((List <PolicySettingPeriod>)item.Periods).Add(period); if (result.Any(p => p.Id == item.Id)) { ((List <PolicySettingPeriod>)result.First(p => p.Id == item.Id).Periods).Add(period); } else { result.Add(item); } } } if (pagination.GetRowCount) { pagination.RowCount = (int)totalCount.Value; } return(result); }