/// <summary> /// Adds a new record into the <c>Rate</c> table. /// </summary> /// <param name="value">The <see cref="RateRow"/> object to be inserted.</param> public virtual void Insert(RateRow value) { string sqlStr = "INSERT INTO [dbo].[Rate] (" + "[rate_info_id], " + "[type_of_day_choice], " + "[time_of_day], " + "[first_incr_length], " + "[add_incr_length], " + "[first_incr_cost], " + "[add_incr_cost]" + ") VALUES (" + _db.CreateSqlParameterName("Rate_info_id") + ", " + _db.CreateSqlParameterName("Type_of_day_choice") + ", " + _db.CreateSqlParameterName("Time_of_day") + ", " + _db.CreateSqlParameterName("First_incr_length") + ", " + _db.CreateSqlParameterName("Add_incr_length") + ", " + _db.CreateSqlParameterName("First_incr_cost") + ", " + _db.CreateSqlParameterName("Add_incr_cost") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Rate_info_id", value.Rate_info_id); AddParameter(cmd, "Type_of_day_choice", value.Type_of_day_choice); AddParameter(cmd, "Time_of_day", value.Time_of_day); AddParameter(cmd, "First_incr_length", value.First_incr_length); AddParameter(cmd, "Add_incr_length", value.Add_incr_length); AddParameter(cmd, "First_incr_cost", value.First_incr_cost); AddParameter(cmd, "Add_incr_cost", value.Add_incr_cost); cmd.ExecuteNonQuery(); }
public ActionResult DeleteConfirmed(int id) { RateRow rateRow = db.RateRows.Find(id); db.RateRows.Remove(rateRow); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Priority,Value,RateTitleId,RatesId")] RateRow rateRow) { if (ModelState.IsValid) { db.Entry(rateRow).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rateRow)); }
public ActionResult Create([Bind(Include = "Id,Priority,Value,RateTitleId,RatesId")] RateRow rateRow) { if (ModelState.IsValid) { db.RateRows.Add(rateRow); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rateRow)); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="RateRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="RateRow"/> object.</returns> protected virtual RateRow MapRow(DataRow row) { RateRow mappedObject = new RateRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Rate_info_id" dataColumn = dataTable.Columns["Rate_info_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Rate_info_id = (int)row[dataColumn]; } // Column "Type_of_day_choice" dataColumn = dataTable.Columns["Type_of_day_choice"]; if (!row.IsNull(dataColumn)) { mappedObject.Type_of_day_choice = (byte)row[dataColumn]; } // Column "Time_of_day" dataColumn = dataTable.Columns["Time_of_day"]; if (!row.IsNull(dataColumn)) { mappedObject.Time_of_day = (byte)row[dataColumn]; } // Column "First_incr_length" dataColumn = dataTable.Columns["First_incr_length"]; if (!row.IsNull(dataColumn)) { mappedObject.First_incr_length = (byte)row[dataColumn]; } // Column "Add_incr_length" dataColumn = dataTable.Columns["Add_incr_length"]; if (!row.IsNull(dataColumn)) { mappedObject.Add_incr_length = (byte)row[dataColumn]; } // Column "First_incr_cost" dataColumn = dataTable.Columns["First_incr_cost"]; if (!row.IsNull(dataColumn)) { mappedObject.First_incr_cost = (decimal)row[dataColumn]; } // Column "Add_incr_cost" dataColumn = dataTable.Columns["Add_incr_cost"]; if (!row.IsNull(dataColumn)) { mappedObject.Add_incr_cost = (decimal)row[dataColumn]; } return(mappedObject); }
/// <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="RateRow"/> objects.</returns> protected virtual RateRow[] 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 rate_info_idColumnIndex = reader.GetOrdinal("rate_info_id"); int type_of_day_choiceColumnIndex = reader.GetOrdinal("type_of_day_choice"); int time_of_dayColumnIndex = reader.GetOrdinal("time_of_day"); int first_incr_lengthColumnIndex = reader.GetOrdinal("first_incr_length"); int add_incr_lengthColumnIndex = reader.GetOrdinal("add_incr_length"); int first_incr_costColumnIndex = reader.GetOrdinal("first_incr_cost"); int add_incr_costColumnIndex = reader.GetOrdinal("add_incr_cost"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { RateRow record = new RateRow(); recordList.Add(record); record.Rate_info_id = Convert.ToInt32(reader.GetValue(rate_info_idColumnIndex)); record.Type_of_day_choice = Convert.ToByte(reader.GetValue(type_of_day_choiceColumnIndex)); record.Time_of_day = Convert.ToByte(reader.GetValue(time_of_dayColumnIndex)); record.First_incr_length = Convert.ToByte(reader.GetValue(first_incr_lengthColumnIndex)); record.Add_incr_length = Convert.ToByte(reader.GetValue(add_incr_lengthColumnIndex)); record.First_incr_cost = Convert.ToDecimal(reader.GetValue(first_incr_costColumnIndex)); record.Add_incr_cost = Convert.ToDecimal(reader.GetValue(add_incr_costColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((RateRow[])(recordList.ToArray(typeof(RateRow)))); }
// GET: RateRows/Delete/5 public ActionResult Delete(int?id) { if (id == null) { TempData["alert"] = "Sorry, I could not find the item you were looking for. Please try again."; return(View("~/Locations")); } RateRow rateRow = db.RateRows.Find(id); if (rateRow == null) { return(HttpNotFound()); } return(View(rateRow)); }
/// <summary> /// Updates a record in the <c>Rate</c> table. /// </summary> /// <param name="value">The <see cref="RateRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(RateRow value) { string sqlStr = "UPDATE [dbo].[Rate] SET " + "[first_incr_length]=" + _db.CreateSqlParameterName("First_incr_length") + ", " + "[add_incr_length]=" + _db.CreateSqlParameterName("Add_incr_length") + ", " + "[first_incr_cost]=" + _db.CreateSqlParameterName("First_incr_cost") + ", " + "[add_incr_cost]=" + _db.CreateSqlParameterName("Add_incr_cost") + " WHERE " + "[rate_info_id]=" + _db.CreateSqlParameterName("Rate_info_id") + " AND " + "[type_of_day_choice]=" + _db.CreateSqlParameterName("Type_of_day_choice") + " AND " + "[time_of_day]=" + _db.CreateSqlParameterName("Time_of_day"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "First_incr_length", value.First_incr_length); AddParameter(cmd, "Add_incr_length", value.Add_incr_length); AddParameter(cmd, "First_incr_cost", value.First_incr_cost); AddParameter(cmd, "Add_incr_cost", value.Add_incr_cost); AddParameter(cmd, "Rate_info_id", value.Rate_info_id); AddParameter(cmd, "Type_of_day_choice", value.Type_of_day_choice); AddParameter(cmd, "Time_of_day", value.Time_of_day); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Deletes the specified object from the <c>Rate</c> table. /// </summary> /// <param name="value">The <see cref="RateRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(RateRow value) { return(DeleteByPrimaryKey(value.Rate_info_id, value.Type_of_day_choice, value.Time_of_day)); }
public RateRowChangeEvent(RateRow row, DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public void RemoveRateRow(RateRow row) { this.Rows.Remove(row); }
public void AddRateRow(RateRow row) { this.Rows.Add(row); }
private void GetIATARate(RateTable model) { model.RateRoutes.Clear(); RateManagementBL bl = new RateManagementBL(); List <RateRouting> routes = bl.GetRateRoutings(int.Parse(GetCurrentELTUser().elt_account_number), model.CustomerAccount, Convert.ToInt32(RateType.IATARate)); AddMinCol(routes); CodeListBL BL = new CodeListBL(); var list = BL.GetCarrierList(); foreach (var route in routes) { var info = bl.GetRouting(route.ID); RateRoute r = new RateRoute(RateType.IATARate) { RouteID = route.ID, Mode = RateRouteMode.Edit }; r.RouteID = route.ID; r.HeaderRow.RateType = RateType.IATARate; int data_start_index = AppConstants.IATARateHeaderColumnStartIndex; r.HeaderRow.RateHeaderColumns[0].Text = info.Origin; r.HeaderRow.RateHeaderColumns[1].Text = info.Dest; r.HeaderRow.RateHeaderColumns[2].Text = info.UnitText; r.HeaderRow.RateHeaderColumns[2].Value = info.Unit; bl.RefreshWeightBreakText(info.Rates[0].RateDefinitionColums); info.Rates[0].RateDefinitionColums = info.Rates[0].RateDefinitionColums.OrderBy(m => decimal.Parse(m.Value)).ToList(); for (int i = 0; i < info.Rates[0].RateDefinitionColums.Count; i++) { r.HeaderRow.RateHeaderColumns[data_start_index].Value = info.Rates[0].RateDefinitionColums[i].Value; r.HeaderRow.RateHeaderColumns[data_start_index].Text = info.Rates[0].RateDefinitionColums[i].Caption; data_start_index++; } foreach (var rate in route.Rates) { rate.RateDefinitionColums = rate.RateDefinitionColums.OrderBy(m => decimal.Parse(m.Value)).ToList(); data_start_index = AppConstants.IATARateDataColumnStartIndex; var data_row = new RateRow(RateType.IATARate, AppConstants.IATARateDataColumnCount); data_row.RouteId = route.ID; data_row.Id = rate.RateID; data_row.Columns[0].WeightBreakValueTag = "CarrierCode"; data_row.Columns[0].Value = rate.CarrierCode; data_row.Columns[0].Text = (from c in list where c.Value == rate.CarrierCode select c.Text).Single(); data_row.Columns[0].IsDropDown = true; data_row.Columns[0].DropDownType = ColumnDropDownType.Carrier; for (int i = 1; i < 2; i++) { data_row.Columns[i].IsDropDown = true; data_row.Columns[i].IsHidden = true; } foreach (var col in rate.RateDefinitionColums) { data_row.Columns[data_start_index].WeightBreakValueTag = col.Value; data_row.Columns[data_start_index].Value = col.Rate; data_row.Columns[data_start_index].Text = col.Rate; data_start_index++; } data_row.Columns[data_row.Columns.Count - 1].Text = rate.Share; data_row.Columns[data_row.Columns.Count - 1].Value = rate.Share; data_row.Columns[data_row.Columns.Count - 1].WeightBreakValueTag = "Share"; r.Rows.Add(data_row); } model.RateRoutes.Add(r); } foreach (var r in model.RateRoutes) { foreach (var row in r.Rows) { foreach (var col in row.Columns) { if (col.Text == null || col.Text == "") { if (col.Value == null || col.Value == "") { col.IsEmptyCell = true; } } } } } }
public ActionResult RateTable(RateTable model) { RateManagementBL bl = new RateManagementBL(); if (!string.IsNullOrEmpty(Request["ActionParam"])) { if (Convert.ToString(Request["ActionParam"]) == "SaveAll") { List <RateRouting> rRList = null; PersistViewModel(model); rRList = bl.GetRateRoutingFromSession((int)model.RateType); bool isValid = true; //모든 타입에 저장시 보아야할 것은 중복된 carrier code 이다. foreach (var r in rRList) { foreach (var rate in r.Rates) { var count = from c in r.Rates where c.CarrierCode == rate.CarrierCode select c; if (count.Count() > 1) { MsgText = "Duplicate Carrier Code exists. Save failed!"; isValid = false; break; } } if (!isValid) { break; } } if (isValid) { MsgText = "Rate table saved successfully!"; try { bl.SaveRateInfo(rRList); } catch (Exception ex) { MsgText = ex.Message; } } } if (Convert.ToString(Request["ActionParam"]) == "CancelAddRoute") { model.ClientAction = "CancelAddRoute"; } if (Convert.ToString(Request["ActionParam"]) == "SaveRoute") { var HeaderRow = model.RateRoutes[0].HeaderRow; SetMissingDropDownTextForRateHeaderRow(HeaderRow); RateRouting routing = new RateRouting(); try { GetNewRouteInfoFromView(model, routing); bl.InsertRoute(routing); } catch (Exception ex) { model.ShouldOpenAddRoute = true; MsgText = ex.Message; } } if (Convert.ToString(Request["ActionParam"]) == "AddRoute") { PersistViewModel(model); int newRateId = bl.GetNewRoutingID(); RateRoute RateRoute = new RateRoute(model.RateType) { RouteID = newRateId, Mode = RateRouteMode.Add }; model.RateRoutes.Clear(); model.RateRoutes.Add(RateRoute); model.ClientAction = "AddRoute"; return(View(model)); } if (Convert.ToString(Request["ActionParam"]) == "AddCarrier") { PersistViewModel(model); int AddCarrierRouteID = model.AddCarrierRouteID; RateRoute target = (from c in model.RateRoutes where c.RouteID == AddCarrierRouteID select c).Single(); var routing = bl.GetRouting(target.RouteID); var emptyRate = GenerateEmptyRateAndCreateHeaderText(routing, target.HeaderRow); routing.Rates.Add(emptyRate); } if (Convert.ToString(Request["ActionParam"]) == "DeleteCarrier") { PersistViewModel(model); int DeleteCarrierRouteID = model.DeleteCarrierRouteID; int DeleteCarrierID = model.DeleteCarrierID; RateRoute target_route = (from c in model.RateRoutes where c.RouteID == DeleteCarrierRouteID select c).Single(); RateRow target_row = (from c in target_route.Rows where c.Id == DeleteCarrierID select c).Single(); var routing = bl.GetRouting(target_route.RouteID); if (routing.Rates.Count == 1) { bl.DeleteRoute(routing); } else { var rate = (from c in routing.Rates where c.RateID == DeleteCarrierID select c).Single(); bl.DeleteRate(DeleteCarrierID, DeleteCarrierRouteID); } } } SetVariablesToSession(model); if (model.IsInit == "Init") { model.IsInit = ""; bl.ClearRateRoutings(); } if (model.RateType == RateType.CustomerSellingRate) { GetCustomerSellingRate(model); } if (model.RateType == RateType.AgentBuyingRate) { GetAgentBuyingRate(model); } if (model.RateType == RateType.IATARate) { GetIATARate(model); } if (model.RateType == RateType.AirLineBuyingRate) { GetAirlineBuyingRate(model); } model.Message = MsgText; return(View(model)); }