Пример #1
0
        //public bool IsValidName(string name)
        //{
        //    using (LoanPriceEntities context = new LoanPriceEntities())
        //    {
        //        int count = context.CreditRatings.Where(s => s. == name).Count();
        //        if (count == 0)
        //            return true;
        //        else
        //            return false;
        //    }
        //}
        public string SaveAgency(CreditAgency agency)
        {
            using (LoanPriceEntities context = new LoanPriceEntities())
            {
                if (agency.ID <= 0)
                {

                    //if (context.CreditRatings.Where(s => s.CreditAgency == rating.CreditAgency).Count() == 0)
                    //{
                    context.AddToCreditAgencies(agency);
                    context.SaveChanges();
                    return "Credit Agency is added successfully";
                    //}
                    //else
                    //    return "Entry of the same Currency is already exists.";
                }
                else
                {
                    //if (context.Currencies.Where(s => s.Currancy == currency.Currancy && s.ID != currency.ID).Count() == 0)
                    //{
                    context.CreditAgencies.Attach(agency);
                    context.ObjectStateManager.ChangeObjectState(agency, System.Data.EntityState.Modified);
                    context.SaveChanges();
                    return "Credit Agency is Updated successfully";
                    //}
                    //else
                    //    return "Entry of the same Currency is already exists.";
                }
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the CreditAgencies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCreditAgencies(CreditAgency creditAgency)
 {
     base.AddObject("CreditAgencies", creditAgency);
 }
 /// <summary>
 /// Create a new CreditAgency object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static CreditAgency CreateCreditAgency(global::System.Int32 id)
 {
     CreditAgency creditAgency = new CreditAgency();
     creditAgency.ID = id;
     return creditAgency;
 }
        protected void btnSaveAgency_Click(object sender, EventArgs e)
        {
            CreditAgency model = new CreditAgency();
            CreditAgencyBL bl = new CreditAgencyBL();
            if (txtCreditAgency.Text.Trim() == string.Empty)
            {
                RadWindowManager1.RadAlert("Agency name is required", 330, 180, "realedge associates", "alertCallBackFn"); return;
            }

            else
            {
                model.CreditAgency1 = txtCreditAgency.Text.Trim();

                if (!string.IsNullOrEmpty(hdnCreditAgency.Value))
                {
                    model.ID = Convert.ToInt32(hdnCreditAgency.Value);
                    LogActivity("Agency Updated", "Currency has been updated", string.Empty);
                }
                else
                {
                    LogActivity("Agency Created", "Currency has been created", string.Empty);
                }

                string str = bl.SaveAgency(model);
                BindCreditAgencies();
                if (str != "Entry of the same Agency Name is already exists.")
                {
                    hdnCreditAgency.Value = string.Empty;
                }

                RadWindowManager1.RadAlert(str, 330, 180, "realedge associates", "alertCallBackFn");
            }
        }