Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WattsALoanServiceReference.WattsALoanServiceClient client    = new WattsALoanServiceReference.WattsALoanServiceClient();
                IList <WattsALoanServiceReference.Employee>        employees = client.GetEmployees();

                DataTable employeeTable = new DataTable();
                employeeTable.Columns.Add(new DataColumn("EmployeeNameField", typeof(string)));
                employeeTable.Columns.Add(new DataColumn("EmployeeIDField", typeof(int)));

                foreach (WattsALoanServiceReference.Employee employee in employees)
                {
                    employeeTable.Rows.Add(CreateDataRow(employee.FirstName + " " + employee.LastName, employee.EmployeeID, employeeTable));
                }

                DdlEmployee.DataSource     = employeeTable;
                DdlEmployee.DataTextField  = "EmployeeNameField";
                DdlEmployee.DataValueField = "EmployeeIDField";
                DdlEmployee.DataBind();

                IList <WattsALoanServiceReference.Customer> customers = client.GetCustomers();

                DataTable customerTable = new DataTable();
                customerTable.Columns.Add(new DataColumn("CustomerNameField", typeof(string)));
                customerTable.Columns.Add(new DataColumn("CustomerIDField", typeof(int)));

                foreach (WattsALoanServiceReference.Customer customer in customers)
                {
                    customerTable.Rows.Add(CreateDataRow(customer.FullName, customer.CustomerID, customerTable));
                }

                DdlCustomer.DataSource     = customerTable;
                DdlCustomer.DataTextField  = "CustomerNameField";
                DdlCustomer.DataValueField = "CustomerIDField";
                DdlCustomer.DataBind();

                IList <WattsALoanServiceReference.LoanType> loanTypes = client.GetLoanTypes();

                DataTable loanTypeTable = new DataTable();
                loanTypeTable.Columns.Add(new DataColumn("LoanTypeNameField", typeof(string)));
                loanTypeTable.Columns.Add(new DataColumn("LoanTypeIDField", typeof(int)));

                foreach (WattsALoanServiceReference.LoanType loanType in loanTypes)
                {
                    loanTypeTable.Rows.Add(CreateDataRow(loanType.LoanTypeName, loanType.LoanTypeID, loanTypeTable));
                }

                DdlLoanType.DataSource     = loanTypeTable;
                DdlLoanType.DataTextField  = "LoanTypeNameField";
                DdlLoanType.DataValueField = "LoanTypeIDField";
                DdlLoanType.DataBind();

                client.Close();
            }
        }
        protected void LoadTypeNames_Init()
        {
            WattsALoanServiceReference.WattsALoanServiceClient client = new WattsALoanServiceReference.WattsALoanServiceClient();
            IList <WattsALoanServiceReference.LoanType>        types  = client.GetLoanTypes();

            loanTypeNames = new Dictionary <int, string>();
            foreach (WattsALoanServiceReference.LoanType type in types)
            {
                loanTypeNames.Add(type.LoanTypeID, type.LoanTypeName);
            }

            client.Close();
        }