protected void btnSave_Click(object sender, EventArgs e) { representant = new Representant(); manager = new RepresentantManager(this); // // Clone the original representant for the linq track changes // if (Page.ViewState["RepresentantId"] != null) { original_representant = manager.GetRepresentant(Convert.ToInt32(Page.ViewState["RepresentantId"])); representant.CopyPropertiesFrom(original_representant); } representant.ModifiedDate = DateTime.Now; representant.CompanyId = Company.CompanyId; // //fill fields of account // if (!String.IsNullOrEmpty(cboBank.SelectedValue)) representant.BankId = Convert.ToInt32(cboBank.SelectedValue); else representant.BankId = null; if (!String.IsNullOrEmpty(txtAccountNumber.Text)) representant.AccountNumber = txtAccountNumber.Text; else representant.AccountNumber = null; if (!String.IsNullOrEmpty(txtAgency.Text)) representant.Agency = txtAgency.Text; else representant.Agency = null; // //fill rating value // representant.Rating = rtnRating.CurrentRating; if (Profile1.ProfileEntity != null) { representant.ProfileId = Profile1.ProfileEntity.ProfileId; if (representant.ProfileId == 0) representant.Profile = Profile1.ProfileEntity; } else { representant.LegalEntityProfileId = Profile1.CompanyProfileEntity.LegalEntityProfileId; if (representant.LegalEntityProfileId == 0) representant.LegalEntityProfile = Profile1.CompanyProfileEntity; } if (Page.ViewState["RepresentantId"] == null && Page.ViewState["ProfileExists"] != "0") manager.Insert(representant); else manager.update(original_representant, representant); if (!String.IsNullOrEmpty(Request["RepresentantId"])) Response.Redirect("Representants.aspx"); else Response.Redirect("Representant.aspx?RepresentantId=" + representant.RepresentantId); }
/// <summary> /// this method updates a Representant /// </summary> /// <param name="original_entity"></param> /// <param name="entity"></param> public void update(Representant original_entity, Representant entity) { original_entity.CopyPropertiesFrom(entity); DbContext.SubmitChanges(); }
protected void btnSave_Click(object sender, EventArgs e) { representant = new Representant(); manager = new RepresentantManager(this); // // Clone the original representant for the linq track changes // if (Page.ViewState["RepresentantId"] != null) { original_representant = manager.GetRepresentant(Convert.ToInt32(Page.ViewState["RepresentantId"])); representant.CopyPropertiesFrom(original_representant); } representant.ModifiedDate = DateTime.Now; representant.CompanyId = Company.CompanyId; // //fill fields of account // if (!String.IsNullOrEmpty(cboBank.SelectedValue)) { representant.BankId = Convert.ToInt32(cboBank.SelectedValue); } else { representant.BankId = null; } if (!String.IsNullOrEmpty(txtAccountNumber.Text)) { representant.AccountNumber = txtAccountNumber.Text; } else { representant.AccountNumber = null; } if (!String.IsNullOrEmpty(txtAgency.Text)) { representant.Agency = txtAgency.Text; } else { representant.Agency = null; } // //fill rating value // representant.Rating = rtnRating.CurrentRating; if (Profile1.ProfileEntity != null) { representant.ProfileId = Profile1.ProfileEntity.ProfileId; if (representant.ProfileId == 0) { representant.Profile = Profile1.ProfileEntity; } } else { representant.LegalEntityProfileId = Profile1.CompanyProfileEntity.LegalEntityProfileId; if (representant.LegalEntityProfileId == 0) { representant.LegalEntityProfile = Profile1.CompanyProfileEntity; } } if (Page.ViewState["RepresentantId"] == null && Page.ViewState["ProfileExists"] != "0") { manager.Insert(representant); } else { manager.update(original_representant, representant); } if (!String.IsNullOrEmpty(Request["RepresentantId"])) { Response.Redirect("Representants.aspx"); } else { Response.Redirect("Representant.aspx?RepresentantId=" + representant.RepresentantId); } }