private void copyCarrierInvoiceProfiles(List <CarrierInvoiceProfile> profiles, int cloneCarrierID) { int carrierInvoiceProfileID = 0; foreach (CarrierInvoiceProfile profile in profiles) { CarrierInvoiceProfile copyProfile = new CarrierInvoiceProfile(); copyProfile.CarrierID = cloneCarrierID; //copyProfile.CarrierInvoiceProfileID = profile.CarrierInvoiceProfileID; copyProfile.CarrierInvoiceProfileTypeID = profile.CarrierInvoiceProfileTypeID; copyProfile.CoverageArea = profile.CoverageArea; copyProfile.EffiectiveDate = profile.EffiectiveDate; copyProfile.ExpirationDate = profile.ExpirationDate; copyProfile.IsActive = true; copyProfile.ProfileName = profile.ProfileName; copyProfile = CarrierInvoiceProfileManager.Save(copyProfile); carrierInvoiceProfileID = copyProfile.CarrierInvoiceProfileID; copyProfileItemizedItems(profile.CarrierInvoiceProfileFeeItemized.ToList(), carrierInvoiceProfileID); copyProfileFeeProvision(profile.CarrierInvoiceProfileFeeProvision.ToList(), carrierInvoiceProfileID); copyProfileFeeSchedule(profile.CarrierInvoiceProfileFeeSchedule.ToList(), carrierInvoiceProfileID); } }
//chetu com public void CopyProfile(int profileID) { //int profileID = 0; CarrierInvoiceProfile profile = null; CarrierInvoiceProfile profileold = null; profileold = CarrierInvoiceProfileManager.Get(profileID); profile = new CarrierInvoiceProfile(); profile.CarrierID = carrierID; profile.IsActive = true; if (profile != null) { profile.ProfileName = profileold.ProfileName; profile.CarrierInvoiceProfileTypeID = profileold.CarrierInvoiceProfileTypeID; profile.EffiectiveDate = profileold.EffiectiveDate; profile.ExpirationDate = profileold.ExpirationDate; profile.InvoiceType = profileold.InvoiceType; profile.AccountingContact = profileold.AccountingContact; profile.AccountingContactEmail = profileold.AccountingContactEmail; profile.FirmDiscountPercentage = profileold.FirmDiscountPercentage; profile.FlatCatFee = profileold.FlatCatFee; profile.FlatCatPercent = profileold.FlatCatPercent; try { CarrierInvoiceProfileManager.Save(profile); showInvoiceProfiles(); bindInvoiceProfiles(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } }
protected void gvInvoiceProfile_RowCommand(object sender, GridViewCommandEventArgs e) { int profileID = Convert.ToInt32(e.CommandArgument); CarrierInvoiceProfile profile = null; if (e.CommandName == "DoEdit") { ViewState["CarrierInvoiceProfileID"] = profileID.ToString(); profile = CarrierInvoiceProfileManager.Get(profileID); if (profile != null) { // enable edit panel showInvoiceProfilePanel(); bindInvoiceType(); txtProgramName.Text = profile.ProfileName; effetiveDate.Text = profile.EffiectiveDate == null ? "" : profile.EffiectiveDate.ToString(); expirationDate.Text = profile.ExpirationDate == null ? "" : profile.ExpirationDate.ToString(); ddlInvoiceType.SelectedValue = string.Format("{0}", profile.InvoiceType ?? 1); // 2014-04-21 //CollectionManager.SetSelectedItems(cbxCoverageArea, profile.CoverageArea); txtAccoutingContact.Text = profile.AccountingContact; txtAccoutingContactEmail.Text = profile.AccountingContactEmail; txtFirmDiscountPercentage.Value = profile.FirmDiscountPercentage; //txtFlatCatPercent.Value = profile.FlatCatPercent;//new oc // txtFlatCatFee.Value = profile.FlatCatFee;//new oc tabContainerFee.Visible = true; if (profile.CarrierInvoiceProfileTypeID != null) { ucProfileType.SelectedValue = profile.CarrierInvoiceProfileTypeID.ToString(); } ucFeeSchedule.bindFeeSchedule(profileID); // 2014-04-21 //ucFeeProvision.bindProvisions(profileID); ucFeeItemized.bindItems(profileID); } } if (e.CommandName == "DoDelete") { try { profile = CarrierInvoiceProfileManager.Get(profileID); if (profile != null) { profile.IsActive = false; CarrierInvoiceProfileManager.Save(profile); showInvoiceProfiles(); bindInvoiceProfiles(); } } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } if (e.CommandName == "DoCopy") { CopyProfile(profileID); } }
protected void btnProfileSave_Click(object sender, EventArgs e) { int profileID = 0; CarrierInvoiceProfile profile = null; Page.Validate("Profile"); if (!Page.IsValid) { return; } int.TryParse(ViewState["CarrierInvoiceProfileID"].ToString(), out profileID); try { if (profileID == 0) { // new profile profile = new CarrierInvoiceProfile(); profile.CarrierID = carrierID; profile.IsActive = true; } else { profile = CarrierInvoiceProfileManager.Get(profileID); } } catch (Exception ex) { Core.EmailHelper.emailError(ex); } if (profile != null) { profile.CarrierID = carrierID; profile.ProfileName = txtProgramName.Text; if (ucProfileType.SelectedIndex > 0) { profile.CarrierInvoiceProfileTypeID = Convert.ToInt32(ucProfileType.SelectedValue); } if (!string.IsNullOrEmpty(effetiveDate.Text)) { profile.EffiectiveDate = effetiveDate.Date; } else { profile.EffiectiveDate = null; } if (!string.IsNullOrEmpty(expirationDate.Text)) { profile.ExpirationDate = expirationDate.Date; } else { profile.ExpirationDate = null; } //profile.CoverageArea = CollectionManager.GetSelectedItemsID(cbxCoverageArea); profile.InvoiceType = Convert.ToInt32(ddlInvoiceType.SelectedValue); profile.AccountingContact = txtAccoutingContact.Text; profile.AccountingContactEmail = txtAccoutingContactEmail.Text; profile.FirmDiscountPercentage = txtFirmDiscountPercentage.ValueDecimal; // profile.FlatCatPercent = txtFlatCatPercent.ValueDecimal;//NEW OC // profile.FlatCatFee = txtFlatCatFee.ValueDecimal; // NEW OC try { CarrierInvoiceProfileManager.Save(profile); showInvoiceProfiles(); bindInvoiceProfiles(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } }