Click here to Skip to main content
15,893,381 members
Articles / Web Development / ASP.NET

Developing Next Generation Smart Clients using .NET 2.0 working with Existing .NET 1.1 SOA-based XML Web Services

Rate me:
Please Sign up or sign in to vote.
4.96/5 (134 votes)
16 Aug 200540 min read 1.2M   3.9K   462  
Comprehensive guide to development of .NET 2.0 Smart Clients working with existing Service Oriented Architecture based XML web services, fully utilizing the Enterprise Library
#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SmartInstitute.Client.Automation.Views;
using SmartInstitute.Automation.Commands.Framework;
using SmartInstitute.Client.Automation.Commands.Students;
using SmartInstitute;
using SmartInstitute.Client.Automation.Helpers;

#endregion

namespace SmartInstitute.Client.Automation.Documents.StudentDocuments
{
	public partial class StudentAssessmentUI : StudentDocumentUIBase
	{
		private int _SemesterID;

		private Assessment _Assessment = null;

		private bool _ForceCalculate;

		public int SemesterID
		{
			get { return _SemesterID; }
			set { _SemesterID = value; }
		}

		public StudentAssessmentUI()
		{
			InitializeComponent();
		}

		private void DisableAssessmentModification()
		{
			foreach (Control c in this.Controls)
			{
				if( c is TextBox )
					(c as TextBox).ReadOnly = true;
			}
		}


		public void PopulateUI( )
		{
			if (base.Document.StudentModel.Profile.AssessmentCollection.Count == 0) return;
			Assessment ass = base.Document.StudentModel.Profile.AssessmentCollection[0];

			this.admissionFeeLabel.Text = ass.AdmissionFee.ToString();
			this.tuitionFeeLabel.Text = ass.TuitionFee.ToString();
			this.computerFeeLabel.Text = ass.ComputerLabFee.ToString();
			this.scienceFeeLabel.Text = ass.ScienceLabFee.ToString();

			this.annualDevtFeeTextBox.Text = ass.DevelopmentFee.ToString();
			this.activityFeeTextBox.Text = ass.ActivityFee.ToString();
			this.miscFeeTextBox.Text = ass.MiscFee.ToString();

			this.totalFeeLabel.Text = ass.NetTotal.ToString();

			this.discountPercentTextBox.Text = ass.DiscountInPercent.ToString();
			this.discountTextBox.Text = ass.Discount.ToString();

			this.scholarshipPercentTextBox.Text = ass.ScholarshipInPercent.ToString();
			this.scholarshipTextBox.Text = ass.Scholarship.ToString();

			this.otherDiscountTextBox.Text = ass.OtherDiscount.ToString();

			decimal grandTotal = ass.NetTotal;
            
            this.other1TextBox.Text = ass.OtherFee1Desc;
			this.other1FeeTextBox.Text = ass.OtherFee1.ToString();

			this.other2FeeTextBox.Text = ass.OtherFee2.ToString();
			this.other2TextBox.Text = ass.OtherFee2Desc;

			decimal netTotal = ass.NetTotal;
            this.netTotalLabel.Text = ass.NetTotal.ToString();
            
			this.paymentTypeCombo.SelectedIndex = ass.PaymentType - 1;

			//this.notesTextBox.Text = ass.Notes;
            
			this.Unmodified();
		}

		private void recalculateButton_Click(object sender, EventArgs e)
		{
			try
			{
				this.Recalculate();
			}
			catch (ApplicationException x)
			{
				MessageBox.Show(this, x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}

		private void Recalculate()
		{
			if (null == this._Assessment) return;
			decimal activityFee;
			decimal annualDevFee;
			decimal otherFee1, otherFee2, discountAmount, discountRate, scholarshipAmount, scholarshipRate;
			decimal otherDiscountAmount;
			decimal miscFee;

			if (!decimal.TryParse(activityFeeTextBox.Text, out activityFee))
				throw new ApplicationException("Invalid activity development fee");

			if (!decimal.TryParse(annualDevtFeeTextBox.Text, out annualDevFee))
				throw new ApplicationException("Invalid annual development fee");

			if (!decimal.TryParse(miscFeeTextBox.Text, out miscFee))
				throw new ApplicationException("Invalid miscellaneous fee");

			if (!decimal.TryParse(other1FeeTextBox.Text, out otherFee1))
				throw new ApplicationException("Invalid other fee 1");

			if (!decimal.TryParse(other2FeeTextBox.Text, out otherFee2))
				throw new ApplicationException("Invalid other fee 2");

			if (!decimal.TryParse(discountTextBox.Text, out discountAmount))
				throw new ApplicationException("Invalid discount amount fee");

			if (!decimal.TryParse(discountPercentTextBox.Text, out discountRate))
				throw new ApplicationException("Invalid discount rate fee");

			if (!decimal.TryParse(scholarshipTextBox.Text, out scholarshipAmount))
				throw new ApplicationException("Invalid scholarhsip amount");
			
			if (!decimal.TryParse(scholarshipPercentTextBox.Text, out scholarshipRate))
				throw new ApplicationException("Invalid scholarship rate");

			if (!decimal.TryParse(otherDiscountTextBox.Text, out otherDiscountAmount))
				throw new ApplicationException("Invalid other discount");


			this._Assessment.DevelopmentFee = annualDevFee;
			this._Assessment.ActivityFee = activityFee;
			this._Assessment.MiscFee = miscFee;
			this._Assessment.OtherFee1Desc = other1TextBox.Text;
			this._Assessment.OtherFee1 = otherFee1;
			this._Assessment.OtherFee2Desc = other2TextBox.Text;
			this._Assessment.OtherFee2 = otherFee2;
			this._Assessment.Discount = discountAmount;
			this._Assessment.DiscountInPercent = (int)discountRate;
			this._Assessment.Scholarship = scholarshipAmount;
			this._Assessment.ScholarshipInPercent = (int)scholarshipRate;
			this._Assessment.OtherDiscount = otherDiscountAmount;
			this._Assessment.OtherDiscountDesc = otherDiscountDescTextBox.Text;
			this._Assessment.PaymentType = paymentTypeCombo.SelectedIndex + 1;

		}

		private void calculateNewButton_Click(object sender, EventArgs e)
		{
			this._Assessment = null;
            this._ForceCalculate = true;
		}

		private void ManualOverride(object sender, EventArgs e)
		{
			this.Modified();
		}

		private void paymentTypeCombo_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.Modified();
		}

		private void Modified()
		{
			this.recalculateWaningLabel.Visible = true;
			recalculateButton.Enabled = true;
			calculateNewButton.Enabled = true;
		}

		private void Unmodified()
		{
			this.recalculateWaningLabel.Visible = false;
			//recalculateButton.Enabled = false;
			//calculateNewButton.Enabled = false;
		}

		private void DiscountPercentChanged(object sender, EventArgs e)
		{
			this.Modified();
			this.discountTextBox.Text = "0";
		}

		private void ScholarshipPercentChanged(object sender, EventArgs e)
		{
			this.Modified();
			this.scholarshipTextBox.Text = "0";
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

Comments and Discussions