protected void AddNewFreight_Click(object sender, EventArgs e) { string outMsg = string.Empty; Freight fr = null; int bookingId = DataUtil.GetBookingIdFromGiffiId(double.Parse(txtGiffRef.Text)); if (bookingId < Constants.InitBookingId) { this.Page.AlertMessage(GetType(), string.Format("Invalid bookingId={0}", bookingId)); return; } try { fr = new Freight { BookingId = bookingId, Code = ddlNewCode.SelectedValue, BS = txtNewBS.Text.Trim(), PC = ddlNewPC.SelectedValue, Units = int.Parse(txtNewUnits.Text.Trim()), Rate = decimal.Parse(txtNewRate.Text.Trim(), NumberStyles.Currency), AmtPPD = decimal.Parse(txtNewAmtPPD.Text.Trim(), NumberStyles.Currency), AmtCOL = decimal.Parse(txtNewAmtCOL.Text.Trim(), NumberStyles.Currency), BrkRate = decimal.Parse(txtNewBrkRate.Text.Trim(), NumberStyles.Currency), BrkAmt = decimal.Parse(txtNewBrkAmt.Text.Trim(), NumberStyles.Currency) }; if (!ValidateCalculation(fr, out outMsg)) { this.Page.AlertMessage(GetType(), outMsg); return; } FreightRepository repo = new FreightRepository(); if (repo.InsertFreight(fr)) { ClearFreightTextFields(); List <Freight> results = GetFreightByBookingId(bookingId); gvFreight.DataSource = results; gvFreight.DataBind(); } } catch (SqlException se) { outMsg = string.Format("Unable to insert freight to database. BookingId={0}, SQLException={1}'", bookingId, se.Message); this.Page.AlertMessage(GetType(), outMsg); } catch (Exception ex) { outMsg = string.Format("Unable to insert freight due to an invalid entry. Bookinging={0}, Exception={1}", bookingId, ex.Message); this.Page.AlertMessage(GetType(), outMsg); } }
protected void gvFreight_RowDeleting(object sender, GridViewDeleteEventArgs e) { int bookingId = DataUtil.GetBookingIdFromGiffiId(double.Parse(txtGiffRef.Text)); int freightId = (int)gvFreight.DataKeys[e.RowIndex].Value; FreightRepository repo = new FreightRepository(); repo.DeleteFreight(freightId); gvFreight.DataSource = GetFreightByBookingId(bookingId); gvFreight.EditIndex = -1; gvFreight.DataBind(); }
public ManageController( FreightRepository repo, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IEmailSender emailSender, ILogger <ManageController> logger, UrlEncoder urlEncoder) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _logger = logger; _urlEncoder = urlEncoder; _repo = repo; }
protected void gvFreight_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = gvFreight.Rows[e.RowIndex]; int freightId = (int)gvFreight.DataKeys[e.RowIndex].Value; int bookingId = DataUtil.GetBookingIdFromGiffiId(double.Parse(txtGiffRef.Text)); Freight fr = null; try { fr = new Freight { Id = freightId, BookingId = bookingId, Code = (row.FindControl("txtCode") as TextBox).Text.Trim(), BS = (row.FindControl("txtBS") as TextBox).Text.Trim(), PC = (row.FindControl("txtPC") as TextBox).Text.Trim(), Units = int.Parse((row.FindControl("txtUnits") as TextBox).Text.Trim()), Rate = decimal.Parse((row.FindControl("txtRate") as TextBox).Text.Trim()), AmtPPD = decimal.Parse((row.FindControl("txtAmtPPD") as TextBox).Text.Trim()), AmtCOL = decimal.Parse((row.FindControl("txtAmtCOL") as TextBox).Text.Trim()), BrkRate = decimal.Parse((row.FindControl("txtBrkRate") as TextBox).Text.Trim()), BrkAmt = decimal.Parse((row.FindControl("txtBrkAmt") as TextBox).Text.Trim()) }; FreightRepository repo = new FreightRepository(); repo.UpdateFreight(fr); gvFreight.EditIndex = -1; gvFreight.DataSource = GetFreightByBookingId(bookingId); gvFreight.DataBind(); } catch (SqlException se) { this.Page.AlertMessage(GetType(), string.Format("Unable to insert freight to database. SQLException={0}", bookingId, se.Message)); } catch (Exception ex) { this.Page.AlertMessage(GetType(), string.Format("Unable to insert freight due to an invalid entry. Exception={0}", bookingId, ex.Message)); } }
private List <Freight> GetFreightByBookingId(int bookingId) { FreightRepository repo = new FreightRepository(); return(repo.GetFreightByBookingId(bookingId)); }
public FreightsController(FreightRepository freight, UserManager <ApplicationUser> user) { _repo = freight; _user = user; }
public InvoicesController(InvoiceRepository invoice, FreightRepository freight) { _repo = invoice; _repoX = freight; }