vendoraccessor.cs.svn-base

来自「MIED是用于个人帐务管理的小型软件」· SVN-BASE 代码 · 共 98 行

SVN-BASE
98
字号
using System.Collections;
using System.Collections.Generic;
using Mied.BusinessObject;
using Mied.DAL.Cache;
using System.Data.Common;
using CommonUtil;

namespace Mied.DAL.Accesses
{
    public class VendorAccessor : ContactAccessor
    {
        public VendorAccessor(MiedDatabase database)
            : base(database, typeof(Vendor), ContactType.Vendor)
        {
        }

        public Vendor SelectVendor(int id)
        {
            return (Vendor)base.Select(id);
        }

        public Vendor SelectVendor(ContactKey contactKey)
        {
            return (Vendor)base.SelectContact(contactKey);
        }

        public VendorList SelectVendorList()
        {
            return (VendorList)SelectList();
        }

        protected override IList CreateEntityList()
        {
            return new VendorList();
        }

        protected override IList CreateCacheListObject()
        {
            return new VendorCacheList(this);
        }

        protected override void SaveAfter(Entity entity, Entity entityOld, DbTransaction transaction)
        {
            base.SaveAfter(entity, entityOld, transaction);

            if (null == entityOld) //insert action
            {
                Vendor vendor = (Vendor)entity;

                string strLastActivity = CommonHelper.LastActivity_VendorCreated;
                string strNote = vendor.Note;

                CommonHelper.ConstructLastActivityAndNote(ref strLastActivity, ref strNote);

                if (vendor.VendorCreditLimit != 0)
                {
                    strLastActivity = string.Format(CommonHelper.LastActivity_VendorCreditLimit, vendor.VendorCreditLimit);
                    CommonHelper.ConstructLastActivityAndNote(ref strLastActivity, ref strNote);
                }

                if (vendor.VendorDiscount != 0)
                {
                    strLastActivity = string.Format(CommonHelper.LastActivity_VendorDiscount, vendor.VendorDiscount);
                    CommonHelper.ConstructLastActivityAndNote(ref strLastActivity, ref strNote);
                }

                this.UpdateLastActivity(vendor.ID.Value, strLastActivity, strNote, transaction);
            }
            else  //update action
            {
                Vendor vendor = (Vendor)entity;
                Vendor vendorOld = (Vendor)entityOld;

                string strLastActivity = "";
                string strNote = vendor.Note;

                if (vendor.VendorCreditLimit != vendorOld.VendorCreditLimit)
                {
                    strLastActivity = string.Format(CommonHelper.LastActivity_VendorCreditLimit, vendor.VendorCreditLimit);
                    CommonHelper.ConstructLastActivityAndNote(ref strLastActivity, ref strNote);
                }

                if (vendor.VendorDiscount != vendorOld.VendorDiscount)
                {
                    strLastActivity = string.Format(CommonHelper.LastActivity_VendorDiscount, vendor.VendorDiscount);
                    CommonHelper.ConstructLastActivityAndNote(ref strLastActivity, ref strNote);
                }

                if (!string.IsNullOrEmpty(strLastActivity))
                {
                    this.UpdateLastActivity(vendor.ID.Value, strLastActivity, strNote, transaction);
                }
            }
        }        

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?