コード例 #1
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            WattsALoanServiceReference.Payment payment = new WattsALoanServiceReference.Payment();
            payment.PaymentDate      = DateTime.Now;
            payment.EmployeeID       = int.Parse(DdlEmployee.SelectedValue);
            payment.LoanAllocationID = int.Parse(DdlLoanAllocation.SelectedValue);
            payment.PaymentAmount    = double.Parse(TbxPaymentAmount.Text);

            WattsALoanServiceReference.WattsALoanServiceClient client = new WattsALoanServiceReference.WattsALoanServiceClient();
            bool result = client.RecordPayment(payment);

            client.Close();

            string script = @"alert(""Record payment " + DdlEmployee.SelectedItem.Text + " " + DdlLoanAllocation.SelectedItem.Text;

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