static public CarrierInvoiceProfileFeeSchedule Get(int id) { CarrierInvoiceProfileFeeSchedule fee = (from x in DbContextHelper.DbContext.CarrierInvoiceProfileFeeSchedule where x.ID == id select x).FirstOrDefault <CarrierInvoiceProfileFeeSchedule>(); return(fee); }
static public CarrierInvoiceProfileFeeSchedule Save(CarrierInvoiceProfileFeeSchedule fee) { if (fee.ID == 0) { DbContextHelper.DbContext.Add(fee); } DbContextHelper.DbContext.SaveChanges(); return(fee); }
protected void btnSave_Click(object sender, EventArgs e) { CarrierInvoiceProfileFeeSchedule fee = null; int profileID = Convert.ToInt32(ViewState["profileID"]); // record id int id = Convert.ToInt32(ViewState["ID"]); if (id == 0) { fee = new CarrierInvoiceProfileFeeSchedule(); fee.CarrierInvoiceProfileID = profileID; } else { fee = CarrierInvoiceProfileFeeScheduleManager.Get(id); } if (fee != null) { try { fee.FlatFee = Convert.ToDecimal(txtFlatFee.Value == null ? "0" : txtFlatFee.Value); fee.MinimumFee = Convert.ToDecimal(txtMinimumAmount.Value == null ? "0" : txtMinimumAmount.Value); fee.PercentFee = Convert.ToDecimal(txtPercentFee.Value == null ? "0" : txtPercentFee.Value); fee.RangeAmountFrom = Convert.ToDecimal(txtAmountFrom.Value == null ? "0" : txtAmountFrom.Value); fee.RangeAmountTo = Convert.ToDecimal(txtAmountTo.Value == null ? "0" : txtAmountTo.Value); fee.FlatCatPercent = Convert.ToDecimal(txtFlatCatPercent.Value == null ? "0" : txtFlatCatPercent.Value); fee.FlatCatFee = Convert.ToDecimal(txtFlatCatFee.Value == null ? "0" : txtFlatCatFee.Value); CarrierInvoiceProfileFeeScheduleManager.Save(fee); showFeeScheduleGrid(); bindFeeSchedule(profileID); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } }
static public void Delete(int id) { CarrierInvoiceProfileFeeSchedule fee = new CarrierInvoiceProfileFeeSchedule { ID = id }; // Now attach the category stub object to the "Categories" set. // This puts the Entity into the context in the unchanged state, // This is same state it would have had if you made the query DbContextHelper.DbContext.AttachTo("CarrierInvoiceProfileFeeSchedules", fee); // Do the delete the category DbContextHelper.DbContext.DeleteObject(fee); // Apply the delete to the database DbContextHelper.DbContext.SaveChanges(); }
protected void btnSave_Click(object sender, EventArgs e) { CarrierInvoiceProfileFeeSchedule fee = null; int profileID = Convert.ToInt32(ViewState["profileID"]); // record id int id = Convert.ToInt32(ViewState["ID"]); if (id == 0) { fee = new CarrierInvoiceProfileFeeSchedule(); fee.CarrierInvoiceProfileID = profileID; } else fee = CarrierInvoiceProfileFeeScheduleManager.Get(id); if (fee != null) { try { fee.FlatFee = Convert.ToDecimal(txtFlatFee.Value == null ? "0" : txtFlatFee.Value); fee.MinimumFee = Convert.ToDecimal(txtMinimumAmount.Value == null ? "0" : txtMinimumAmount.Value); fee.PercentFee = Convert.ToDecimal(txtPercentFee.Value == null ? "0" : txtPercentFee.Value); fee.RangeAmountFrom = Convert.ToDecimal(txtAmountFrom.Value == null ? "0" : txtAmountFrom.Value); fee.RangeAmountTo = Convert.ToDecimal(txtAmountTo.Value == null ? "0" : txtAmountTo.Value); fee.FlatCatPercent = Convert.ToDecimal(txtFlatCatPercent.Value == null ? "0" : txtFlatCatPercent.Value); fee.FlatCatFee = Convert.ToDecimal(txtFlatCatFee.Value == null ? "0" : txtFlatCatFee.Value); CarrierInvoiceProfileFeeScheduleManager.Save(fee); showFeeScheduleGrid(); bindFeeSchedule(profileID); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } }
private void copyProfileFeeSchedule(List <CarrierInvoiceProfileFeeSchedule> feeSchedules, int carrierInvoiceProfileID) { if (feeSchedules != null && feeSchedules.Count > 0) { foreach (CarrierInvoiceProfileFeeSchedule feeSchedule in feeSchedules) { CarrierInvoiceProfileFeeSchedule copyFeeSchedule = new CarrierInvoiceProfileFeeSchedule(); copyFeeSchedule.CarrierInvoiceProfileID = carrierInvoiceProfileID; copyFeeSchedule.FlatFee = feeSchedule.FlatFee; copyFeeSchedule.MinimumFee = feeSchedule.MinimumFee; copyFeeSchedule.PercentFee = feeSchedule.PercentFee; copyFeeSchedule.RangeAmountFrom = feeSchedule.RangeAmountFrom; copyFeeSchedule.RangeAmountTo = feeSchedule.RangeAmountTo; CarrierInvoiceProfileFeeScheduleManager.Save(copyFeeSchedule); } } }
protected void gvInvoiceFees_RowCommand(object sender, GridViewCommandEventArgs e) { CarrierInvoiceProfileFeeSchedule fee = null; int id = Convert.ToInt32(e.CommandArgument); if (e.CommandName == "DoEdit") { ViewState["ID"] = e.CommandArgument.ToString(); fee = CarrierInvoiceProfileFeeScheduleManager.Get(id); if (fee != null) { try { showFeePanel(); txtAmountFrom.Text = fee.RangeAmountFrom.ToString("n2"); txtAmountTo.Text = fee.RangeAmountTo.ToString("n2"); txtFlatFee.Text = fee.FlatFee.ToString("n2"); if (fee.PercentFee > 0) { txtPercentFee.Text = (fee.PercentFee * 100).ToString("n2"); } txtMinimumAmount.Text = fee.MinimumFee.ToString("n2"); txtFlatCatPercent.Text = (fee.FlatCatPercent * 100).ToString(); txtFlatCatFee.Text = fee.FlatCatFee.ToString(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } } else if (e.CommandName == "DoDelete") { CarrierInvoiceProfileFeeScheduleManager.Delete(id); int profileID = Convert.ToInt32(ViewState["profileID"]); bindFeeSchedule(profileID); } }
private void copyProfileFeeSchedule(List<CarrierInvoiceProfileFeeSchedule> feeSchedules, int carrierInvoiceProfileID) { if (feeSchedules != null && feeSchedules.Count > 0) { foreach(CarrierInvoiceProfileFeeSchedule feeSchedule in feeSchedules) { CarrierInvoiceProfileFeeSchedule copyFeeSchedule = new CarrierInvoiceProfileFeeSchedule(); copyFeeSchedule.CarrierInvoiceProfileID = carrierInvoiceProfileID; copyFeeSchedule.FlatFee = feeSchedule.FlatFee; copyFeeSchedule.MinimumFee = feeSchedule.MinimumFee; copyFeeSchedule.PercentFee = feeSchedule.PercentFee; copyFeeSchedule.RangeAmountFrom = feeSchedule.RangeAmountFrom; copyFeeSchedule.RangeAmountTo = feeSchedule.RangeAmountTo; CarrierInvoiceProfileFeeScheduleManager.Save(copyFeeSchedule); } } }