Ejemplo n.º 1
0
        protected void BindGrid(int CurrentPage)
        {
            try
            {
                Dictionary <string, string> genDictParent = new Dictionary <string, string>();
                Dictionary <string, string> genDictCity   = new Dictionary <string, string>();

                rmVo = (RMVo)Session["rmVo"];
                int count = 0;
                lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                // advisorStaffBo.GetCustomerList(rmVo.RMId, "C").ToString();
                if (customerVo.RelationShip == "SELF")
                {
                    customerList = advisorStaffBo.GetCustomerForAssociation(customerVo.CustomerId, rmVo.RMId, mypager.CurrentPage, hdnSort.Value.ToString(), out count);
                }
                else
                {
                    customerList = null;
                }
                lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                if (customerList == null)
                {
                    lblMessage.Text        = "Customer already associated, cannot make more associations";
                    mypager.Visible        = false;
                    btnAssociate.Visible   = false;
                    lblCurrentPage.Visible = false;
                    lblTotalRows.Visible   = false;
                    trRelationShip.Visible = false;
                }
                else
                {
                    trRelationShip.Visible = true;
                    lblMessage.Text        = "Customer List";
                    lblMessage.CssClass    = "HeaderText";
                    mypager.Visible        = true;
                    btnAssociate.Visible   = true;
                    lblCurrentPage.Visible = true;
                    lblTotalRows.Visible   = true;
                    DataTable dtRMCustomer = new DataTable();

                    dtRMCustomer.Columns.Add("CustomerId");
                    dtRMCustomer.Columns.Add("AssociationId");

                    dtRMCustomer.Columns.Add("Customer Name");
                    dtRMCustomer.Columns.Add("Email");

                    DataRow drRMCustomer;


                    for (int i = 0; i < customerList.Count; i++)
                    {
                        drRMCustomer    = dtRMCustomer.NewRow();
                        customerVo      = new CustomerVo();
                        customerVo      = customerList[i];
                        drRMCustomer[0] = customerVo.CustomerId.ToString();
                        drRMCustomer[1] = customerVo.AssociationId.ToString();
                        drRMCustomer[2] = customerVo.FirstName.ToString() + " " + customerVo.MiddleName.ToString() + " " + customerVo.LastName.ToString();
                        drRMCustomer[3] = customerVo.Email.ToString();

                        dtRMCustomer.Rows.Add(drRMCustomer);
                    }
                    gvCustomers.DataSource = dtRMCustomer;
                    gvCustomers.DataBind();
                    this.GetPageCount();
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "CustomerAssociatesAdd.ascx:BindGrid()");
                object[] objects = new object[5];
                objects[0]   = CurrentPage;
                objects[1]   = rmVo;
                objects[2]   = customerVo;
                objects[3]   = customerList;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }