Example #1
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            WattsALoanServiceReference.LoanAllocation loanAllocation = new WattsALoanServiceReference.LoanAllocation();
            loanAllocation.DatePrepared  = DateTime.Now;
            loanAllocation.EmployeeID    = int.Parse(DdlEmployee.SelectedValue);
            loanAllocation.CustomerID    = int.Parse(DdlCustomer.SelectedValue);
            loanAllocation.AccountNumber = TbxAccountNumber.Text;
            loanAllocation.LoanTypeID    = int.Parse(DdlLoanType.SelectedValue);
            loanAllocation.LoanAmount    = double.Parse(TbxLoanAmount.Text);
            loanAllocation.InterestRate  = double.Parse(TbxInterestRate.Text);
            loanAllocation.Periods       = double.Parse(TbxPeriods.Text);

            WattsALoanServiceReference.WattsALoanServiceClient client = new WattsALoanServiceReference.WattsALoanServiceClient();
            bool result = client.InsertLoanAllocation(loanAllocation);

            client.Close();

            string script = @"alert(""Add customer " + DdlEmployee.SelectedItem.Text + " " + DdlLoanType.SelectedItem.Text + " loan allocation";

            if (result)
            {
                script += @" success."");";
                DdlEmployee.SelectedIndex = 0;
                DdlCustomer.SelectedIndex = 0;
                TbxAccountNumber.Text     = "";
                DdlLoanType.SelectedIndex = 0;
                TbxLoanAmount.Text        = "";
                TbxInterestRate.Text      = "";
                TbxPeriods.Text           = "";
            }
            else
            {
                script += @" failed."");";
            }
            ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
        }