public void BindCreditRatingTree()
        {
            CreditAgencyBL agencyBL = new CreditAgencyBL();
            List<CreditAgency> agency = agencyBL.GetAgencies();

            List<TreeViewData> treeData = new List<TreeViewData>();
            //treeData.Add(new TreeViewData(1,null, "Credit Rating","Credit Rating"));
            int i = 1;
            int j = 1;
            foreach (var item in agency)
            {
                treeData.Add(new TreeViewData(i.ToString(), null, item.CreditAgency1, item.CreditAgency1));

                i++;

                CreditRatingsBL ratingbl = new CreditRatingsBL();
                List<CreditRating> rating = ratingbl.GetRatingsByAgencyID(item.ID);
                int innerVal = 0;
                int totalCount = rating.Count;
                foreach (var a in rating)
                {

                    treeData.Add(new TreeViewData(i.ToString(), j.ToString(), a.Rating, a.ID.ToString()));
                    innerVal++;
                    if (innerVal == totalCount)
                    {
                        j = i;
                    }
                    i++;

                }
                j++;
            }

            tvCreditRating.DataTextField = "Text";
            tvCreditRating.DataFieldID = "ID";
            tvCreditRating.DataFieldParentID = "ParentID";

            tvCreditRating.DataValueField = "Val";
            tvCreditRating.DataSource = treeData;

            // tvCreditRating.DataBindings.Add(binding1);
            //tvCreditRating.CheckBoxes = true;
            tvCreditRating.DataBind();
        }
        protected void grdAgency_ItemCommand(object sender, GridCommandEventArgs e)
        {
            CreditAgencyBL bll = new CreditAgencyBL();
            if (e.CommandName == "RemoveA")
            {
                int id = Convert.ToInt32(e.CommandArgument);
                bll.Delete(id);
                BindCreditRatings();
                LogActivity("Agency Removed", "Currency has been removed", string.Empty);
            }
            else if (e.CommandName == "EditA")
            {
                int id = Convert.ToInt32(e.CommandArgument);
                CreditAgency model = bll.GetByID(id);
                txtCreditAgency.Text = model.CreditAgency1;

                hdnCreditAgency.Value = model.ID.ToString();

            }

            BindCreditAgencies();
        }
        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");
            }
        }
 private void BindCreditAgencies()
 {
     CreditAgencyBL bl = new CreditAgencyBL();
     grdAgency.DataSource = bl.GetAgencies().OrderBy(c => c.CreditAgency1).ToList();
     grdAgency.DataBind();
 }
 private void BindAgencyDropDown()
 {
     CreditAgencyBL bl = new CreditAgencyBL();
     ddlAgency.DataSource = bl.GetAgencies().OrderBy(c => c.CreditAgency1).ToList();
     ddlAgency.DataTextField = "CreditAgency1";
     ddlAgency.DataValueField = "ID";
     ddlAgency.DataBind();
 }
 protected void grdCreditRatings_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if ((e.Item is GridDataItem))
     {
         int id = ((DAL.CreditRating)((e.Item).DataItem)).CreditAgencyID.Value;
         CreditAgencyBL agencyBL = new CreditAgencyBL();
         Label lbl = (Label)e.Item.FindControl("lblAgencyName");
         lbl.Text = agencyBL.GetByID(id).CreditAgency1;
     }
 }