Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / XML

netTierGenerator

Rate me:
Please Sign up or sign in to vote.
4.81/5 (20 votes)
30 Nov 2008CPOL14 min read 67.4K   2.8K   108  
A 3-tier application framework and code generation tool - the way for rapid and effective development.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Sample.Model.Store;
using Sample.BusinessLogic;
using WinGUI.Utils;
using Sample.Common.Util;

namespace WinGUI.Controls.Store
{
    public partial class StoreItem : UserControl, IItemControl, ICustomControl
    {
        private GoodInfoModel goodInfoModel;

        public StoreItem()
        {
            InitializeComponent();
        }

        #region base handlers
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.SaveInfoModel();
            this.OnActionComplete();
        }
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.OnActionComplete();
        }
        #endregion base handlers

        #region helper methods
        private void SaveInfoModel()
        {
            if (this.goodInfoModel == null)
            {
                this.goodInfoModel = new GoodInfoModel();
            }

            this.goodInfoModel.Name = this.tbName.Text;
            this.goodInfoModel.Cost = FormatHelper.ParseDecimal(this.tbCost.Text);
            this.goodInfoModel.Quantity = FormatHelper.ParseInt32(this.tbQuantity.Text);

            if (this.goodInfoModel.Id == Guid.Empty)
            {
                ServiceFacade.GoodService.InsertGoodInfo(this.goodInfoModel);
            }
            else
            {
                ServiceFacade.GoodService.UpdateGoodInfo(this.goodInfoModel);
            }
        }
        #endregion helper methods

        #region IItemControl Members
        public void LoadInfoModel(Guid id)
        {
            this.goodInfoModel = ServiceFacade.GoodService.GetGoodInfoById(id);

            if (this.goodInfoModel != null)
            {
                this.tbName.Text = this.goodInfoModel.Name;
                this.tbCost.Text = FormatHelper.FormatNumberN2(this.goodInfoModel.Cost);
                this.tbQuantity.Text = FormatHelper.FormatNumber(this.goodInfoModel.Quantity);
            }
        }
        #endregion

        #region ICustomControl Members
        public event EventHandler<ActionCompleteEventArgs> ActionComplete;
        protected virtual void OnActionComplete()
        {
            ActionCompleteEventArgs args;
            if (this.goodInfoModel != null)
            {
                args = new ActionCompleteEventArgs();
                args.ItemInfoID = this.goodInfoModel.Id;
            }
            else
            {
                args = ActionCompleteEventArgs.Empty;
            }
            this.OnActionComplete(args);
        }
        protected virtual void OnActionComplete(ActionCompleteEventArgs args)
        {
            if (this.ActionComplete != null)
            {
                this.ActionComplete(this, args);
            }
        }
        #endregion
    }
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions