逆水行船

别人的天堂,是我的异乡;无端的繁华,倍添我的惆怅

 

是把取得花销类型ID和添加花销记录合起来

1:修改后的RecorderDT:
/// <copyright>Xumingxsh  1999-2006</copyright>
/// <version>1.0</version>
/// <author>Xuming</author>
/// <email>Xumingxsh21@126.com</email>
/// <log date="2006-05-30">创建</log>

using System;
using System.Data;

namespace Data
{
 /// <summary>
 /// Recorder表的描述类。
 /// </summary>
 /// <author>Xuming</author>
 /// <log date="2006-05-30">创建</log>
 public class RecorderDT : BaseDataDT
 {
  public RecorderDT() : base()
  {
  }

  /// <summary>
  /// 记录ID。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  private int _RedId;

  /// <summary>
  /// 记录时间。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  private string _CreateDate;

  /// <summary>
  /// 花销日期。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  private string _RecDate;

  /// <summary>
  /// 花销类型。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  private int _RecType;

  /// <summary>
  /// 花销金额。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  private decimal _RecValue;

  /// <summary>
  /// 备注。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  private string _Remark;

        // ADD 003 Xumr 2007-02-01 NHibernate BEGIN

        /// <summary>
        /// 花销类型对象。
        /// </summary>
        private RectypeDT _recTypeDT;
        // ADD 003 Xumr 2007-02-01 NHibernate END

  /// <summary>
  /// 记录ID。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  public int RedId
  {
   set
   {
    _RedId = value;
   }
   get
   {
    return _RedId;
   }
  }

  /// <summary>
  /// 记录时间。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  public string CreateDate
  {
   set
   {

    _CreateDate = value;
   }
   get
   {
    return _CreateDate;
   }
  }

  /// <summary>
  /// 花销日期。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  public string RecDate
  {
   set
   {

    _RecDate = value;
   }
   get
   {
    return _RecDate;
   }
  }

  /// <summary>
  /// 花销类型。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  public int RecType
  {
   set
   {

    _RecType = value;
   }
   get
   {
    return _RecType;
   }
  }

  /// <summary>
  /// 花销金额。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  public decimal RecValue
  {
   set
   {
    _RecValue = value;
   }
   get
   {
    return _RecValue;
   }
  }

  /// <summary>
  /// 备注。
  /// </summary>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  public string Remark
  {
   set
   {

    _Remark = value;
   }
   get
   {
    return _Remark;
   }
  }

        // ADD 003 Xumr 2007-02-01 NHibernate BEGIN

        /// <summary>
        /// 花销类型对象。
        /// </summary>
        public RectypeDT RecTypeDT
        {
            set
            {
                _recTypeDT = value;
            }
            get
            {
                return _recTypeDT;
            }
        }
        // ADD 003 Xumr 2007-02-01 NHibernate END
 }
}


 




2:修改后的RecorderDT.hbm.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="Data.RecorderDT, Data" table="Recorder" discriminator-value="C">
    <id name="RedId" type="Int32" column="RedId" unsaved-value="0">
      <generator class="identity"/>
    </id>
    <property name="CreateDate" type="String" column="CreateDate" insert="false" />
    <property name="RecDate" type="String" column="RecDate" />
    <property name="RecType" type="Int32" column="RecType" />
    <property name="RecValue" type="Decimal" column="RecValue" />
    <property name="Remark" type="String(250)" column="Remark" />
    <one-to-one name="RecTypeDT" class="RectypeDT" />
  </class>
</hibernate-mapping>

3:修改前的前台代码:
/// <summary>
  /// 取得前台数据
  /// </summary>
  /// <returns>存储前台数据的对象</returns>
  /// <author>Xuming</author>
  /// <log date="2006-05-30">创建</log>
  public RecorderDV GetDetail()
  {
   RecorderDV detail = new RecorderDV();

   /// <summary>
   /// 花销日期
   /// </summary>
   detail.RecDate = uiDateRecDate.Text;

   /// <summary>
   /// 花销类型
   /// </summary>
   detail.RecTypeName = uiFindRecTypeControl.Value;

   /// <summary>
   /// 花销金额
   /// </summary>
   detail.RecValue = Convert.ToDecimal(txtRecValue.Text);

   /// <summary>
   /// 备注
   /// </summary>
   detail.Remark = txtRemark.Text;

   return detail;
  }  

  protected void btnSubmit_Click(object sender, System.EventArgs e)
  {
   try
   {
    RecorderDV detail = GetDetail();

    using (IRecorderable recorder =
         (IRecorderable)BNFactory.SetBN(typeof(IRecorderable)))
    {
     recorder.AddRecorder(detail,
      BaseConfManager.GetValue("smtp"),
      txtMailPwd.Text,
      BaseConfManager.GetValue("sendMail"),
      BaseConfManager.GetValue("sendName"),
      BaseConfManager.GetValue("getMail"),
      BaseConfManager.GetValue("getName"));
//     Response.Write("<script>alert('添加成功!');</script>");
     SetSourceEvent();
    }
   }
   catch (Exception ex)
   {
    OnException(ex);
   }
  }

修改后的前台代码:
 /// <summary>
        /// 取得前台数据
        /// </summary>
        /// <returns>存储前台数据的对象</returns>
        /// <author>Xuming</author>
        /// <log date="2006-05-30">创建</log>
        public RecorderDT GetDetail()
        {
            RecorderDT detail = new RecorderDT();

            /// <summary>
            /// 花销日期
            /// </summary>
            detail.RecDate = uiDateRecDate.Text;

            /// <summary>
            /// 花销类型
            /// </summary>
            detail.RecTypeDT = new RectypeDT();
            detail.RecTypeDT.RecTypeName = uiFindRecTypeControl.Value;

            /// <summary>
            /// 花销金额
            /// </summary>
            detail.RecValue = Convert.ToDecimal(txtRecValue.Text);

            /// <summary>
            /// 备注
            /// </summary>
            detail.Remark = txtRemark.Text;

            return detail;
        }

        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            try
            {
                RecorderDT detail = GetDetail();

                using (IRecorderable recorder =
                           (IRecorderable)BNFactory.SetBN(typeof(IRecorderable)))
                {
                    recorder.AddRecorder(detail,
                        BaseConfManager.GetValue("smtp"),
                        txtMailPwd.Text,
                        BaseConfManager.GetValue("sendMail"),
                        BaseConfManager.GetValue("sendName"),
                        BaseConfManager.GetValue("getMail"),
                        BaseConfManager.GetValue("getName"));
                    //     Response.Write("<script>alert('添加成功!');</script>");
                    SetSourceEvent();
                }
            }
            catch (Exception ex)
            {
                OnException(ex);
            }
        }

3:修改后的BN层代码:

posted on 2007-02-02 00:00  荣-  阅读(210)  评论(0编辑  收藏  举报

导航