• 是把取得花销类型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层代码:

  • 相关阅读:
    基于Jquery+Ajax+Json+高效分页
    前端购物车框架(精髓篇)
    基于C#操作Word文档中的Bookmark
    C# 方法中的this参数
    Asp.Net 全局变量
    winform 多表头的实现
    2012年2月
    在UpdatePanel上使用FileUpload上传文件(转载)
    2011年总结和2012年计划
    javascript备注
  • 原文地址:https://www.cnblogs.com/admin11/p/637601.html
Copyright © 2020-2023  润新知