internal static void AddTerminationChoice(Rbr_Db pDb, int pRoutingPlanId, int pRouteId, int pCarrierRouteId) { var _terminationChoiceRow = new TerminationChoiceRow(); _terminationChoiceRow.Routing_plan_id = pRoutingPlanId; _terminationChoiceRow.Route_id = pRouteId; _terminationChoiceRow.Carrier_route_id = pCarrierRouteId; _terminationChoiceRow.Priority = 0; _terminationChoiceRow.Version = 0; pDb.TerminationChoiceCollection.Insert(_terminationChoiceRow); // updatePrioritiesManual(pDb, pRoutingPlanId, pRouteId); }
/// <summary> /// Reads data from the provided data reader and returns /// an array of mapped objects. /// </summary> /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param> /// <param name="startIndex">The index of the first record to map.</param> /// <param name="length">The number of records to map.</param> /// <param name="totalRecordCount">A reference parameter that returns the total number /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param> /// <returns>An array of <see cref="TerminationChoiceRow"/> objects.</returns> protected virtual TerminationChoiceRow[] MapRecords(IDataReader reader, int startIndex, int length, ref int totalRecordCount) { if (0 > startIndex) { throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero."); } if (0 > length) { throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero."); } int termination_choice_idColumnIndex = reader.GetOrdinal("termination_choice_id"); int routing_plan_idColumnIndex = reader.GetOrdinal("routing_plan_id"); int route_idColumnIndex = reader.GetOrdinal("route_id"); int priorityColumnIndex = reader.GetOrdinal("priority"); int carrier_route_idColumnIndex = reader.GetOrdinal("carrier_route_id"); int versionColumnIndex = reader.GetOrdinal("version"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { TerminationChoiceRow record = new TerminationChoiceRow(); recordList.Add(record); record.Termination_choice_id = Convert.ToInt32(reader.GetValue(termination_choice_idColumnIndex)); record.Routing_plan_id = Convert.ToInt32(reader.GetValue(routing_plan_idColumnIndex)); record.Route_id = Convert.ToInt32(reader.GetValue(route_idColumnIndex)); record.Priority = Convert.ToByte(reader.GetValue(priorityColumnIndex)); record.Carrier_route_id = Convert.ToInt32(reader.GetValue(carrier_route_idColumnIndex)); record.Version = Convert.ToInt32(reader.GetValue(versionColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((TerminationChoiceRow[])(recordList.ToArray(typeof(TerminationChoiceRow)))); }
public TerminationChoice(TerminationChoiceRow pTermChoiceRow) { if (pTermChoiceRow == null) { throw new Exception("TerminationChoice.Ctor, TerminationChoiceRow == null"); } terminationChoiceRow = pTermChoiceRow; using (Rbr_Db _db = new Rbr_Db()) { var _carrierRouteRow = _db.CarrierRouteCollection.GetByPrimaryKey(terminationChoiceRow.Carrier_route_id); if (_carrierRouteRow == null) { throw new RbrException(RbrResult.Carrier_NotFound, "TerminationChoice.Ctor", string.Format("CarrierRoute NOT FOUND, TerminationChoiceId={0}, CarrierRouteId={1}", terminationChoiceRow.Termination_choice_id, terminationChoiceRow.Carrier_route_id)); } carrierAcctId = _carrierRouteRow.Carrier_acct_id; } }
/// <summary> /// Updates a record in the <c>TerminationChoice</c> table. /// </summary> /// <param name="value">The <see cref="TerminationChoiceRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(TerminationChoiceRow value) { string sqlStr = "UPDATE [dbo].[TerminationChoice] SET " + "[routing_plan_id]=" + _db.CreateSqlParameterName("Routing_plan_id") + ", " + "[route_id]=" + _db.CreateSqlParameterName("Route_id") + ", " + "[priority]=" + _db.CreateSqlParameterName("Priority") + ", " + "[carrier_route_id]=" + _db.CreateSqlParameterName("Carrier_route_id") + " WHERE " + "[termination_choice_id]=" + _db.CreateSqlParameterName("Termination_choice_id"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Routing_plan_id", value.Routing_plan_id); AddParameter(cmd, "Route_id", value.Route_id); AddParameter(cmd, "Priority", value.Priority); AddParameter(cmd, "Carrier_route_id", value.Carrier_route_id); AddParameter(cmd, "Termination_choice_id", value.Termination_choice_id); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="TerminationChoiceRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="TerminationChoiceRow"/> object.</returns> protected virtual TerminationChoiceRow MapRow(DataRow row) { TerminationChoiceRow mappedObject = new TerminationChoiceRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Termination_choice_id" dataColumn = dataTable.Columns["Termination_choice_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Termination_choice_id = (int)row[dataColumn]; } // Column "Routing_plan_id" dataColumn = dataTable.Columns["Routing_plan_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Routing_plan_id = (int)row[dataColumn]; } // Column "Route_id" dataColumn = dataTable.Columns["Route_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Route_id = (int)row[dataColumn]; } // Column "Priority" dataColumn = dataTable.Columns["Priority"]; if (!row.IsNull(dataColumn)) { mappedObject.Priority = (byte)row[dataColumn]; } // Column "Carrier_route_id" dataColumn = dataTable.Columns["Carrier_route_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Carrier_route_id = (int)row[dataColumn]; } // Column "Version" dataColumn = dataTable.Columns["Version"]; if (!row.IsNull(dataColumn)) { mappedObject.Version = (int)row[dataColumn]; } return(mappedObject); }
static TerminationChoiceRow mapToTerminationChoiceRow(TerminationChoiceDto pTerminationChoice) { if (pTerminationChoice == null) { return(null); } var _terminationChoiceRow = new TerminationChoiceRow(); _terminationChoiceRow.Termination_choice_id = pTerminationChoice.TerminationChoiceId; _terminationChoiceRow.Routing_plan_id = pTerminationChoice.RoutingPlanId; _terminationChoiceRow.Route_id = pTerminationChoice.RouteId; _terminationChoiceRow.Priority = pTerminationChoice.Priority; _terminationChoiceRow.Carrier_route_id = pTerminationChoice.CarrierRouteId; _terminationChoiceRow.Version = pTerminationChoice.Version; return(_terminationChoiceRow); }
/// <summary> /// Adds a new record into the <c>TerminationChoice</c> table. /// </summary> /// <param name="value">The <see cref="TerminationChoiceRow"/> object to be inserted.</param> public virtual void Insert(TerminationChoiceRow value) { string sqlStr = "INSERT INTO [dbo].[TerminationChoice] (" + "[routing_plan_id], " + "[route_id], " + "[priority], " + "[carrier_route_id]" + ") VALUES (" + _db.CreateSqlParameterName("Routing_plan_id") + ", " + _db.CreateSqlParameterName("Route_id") + ", " + _db.CreateSqlParameterName("Priority") + ", " + _db.CreateSqlParameterName("Carrier_route_id") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Routing_plan_id", value.Routing_plan_id); AddParameter(cmd, "Route_id", value.Route_id); AddParameter(cmd, "Priority", value.Priority); AddParameter(cmd, "Carrier_route_id", value.Carrier_route_id); cmd.ExecuteNonQuery(); }
public static void CloneRoutingPlanDetails(Rbr_Db pDb, RoutingPlanDto pNewRoutingPlan, RoutingPlanDto pRoutingPlanToClone) { //1. get Details for existing RoutingPlan var _existingRoutingPlanDetailRows = pDb.RoutingPlanDetailCollection.GetByRouting_plan_id(pRoutingPlanToClone.RoutingPlanId); foreach (var _existingRoutingPlanDetailRow in _existingRoutingPlanDetailRows) { //1.1 clone/insert RoutingPlanDetail for a new RoutingPlan var _newRoutingPlanDetail = new RoutingPlanDetailRow(); _newRoutingPlanDetail.Routing_plan_id = pNewRoutingPlan.RoutingPlanId; _newRoutingPlanDetail.Route_id = _existingRoutingPlanDetailRow.Route_id; _newRoutingPlanDetail.Routing_algorithm = _existingRoutingPlanDetailRow.Routing_algorithm; pDb.RoutingPlanDetailCollection.Insert(_newRoutingPlanDetail); //1.2 get TermChoices for existing RoutingPlanDetail var _existingTermChoiceRows = pDb.TerminationChoiceCollection.GetByRoutingPlanIdRouteId_OrderByPriority(_existingRoutingPlanDetailRow.Routing_plan_id, _existingRoutingPlanDetailRow.Route_id); foreach (var _existingTermChoiceRow in _existingTermChoiceRows) { //1.2.1 clone/insert TermChoice for a new RoutingPlan var _newTermChoiceRow = new TerminationChoiceRow(); _newTermChoiceRow.Routing_plan_id = _newRoutingPlanDetail.Routing_plan_id; _newTermChoiceRow.Route_id = _newRoutingPlanDetail.Route_id; _newTermChoiceRow.Priority = _existingTermChoiceRow.Priority; _newTermChoiceRow.Carrier_route_id = _existingTermChoiceRow.Carrier_route_id; pDb.TerminationChoiceCollection.Insert(_newTermChoiceRow); } ////1.3 get LCRBlackList for existing RoutingPlanDetail //LCRBlackListRow[] _existingLCRBlackListRows = pDb.LCRBlackListCollection.GetByRouting_plan_id_Route_id(_existingRoutingPlanDetailRow.Routing_plan_id, _existingRoutingPlanDetailRow.Route_id); //foreach (LCRBlackListRow _existingLCRBlackListRow in _existingLCRBlackListRows) { // //1.3.1 clone/insert LCRBlackList for a new RoutingPlan // LCRBlackListRow _newLCRBlackListRow = new LCRBlackListRow(); // _newLCRBlackListRow.Routing_plan_id = _newRoutingPlanDetail.Routing_plan_id; // _newLCRBlackListRow.Route_id = _newRoutingPlanDetail.Route_id; // _newLCRBlackListRow.Carrier_acct_id = _existingLCRBlackListRow.Carrier_acct_id; // pDb.LCRBlackListCollection.Insert(_newLCRBlackListRow); //} } }
/// <summary> /// Deletes the specified object from the <c>TerminationChoice</c> table. /// </summary> /// <param name="value">The <see cref="TerminationChoiceRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(TerminationChoiceRow value) { return(DeleteByPrimaryKey(value.Termination_choice_id)); }