public static BG_ReimDocuments AddBG_ReimDocuments(BG_ReimDocuments bG_ReimDocuments)
        {
            string sql =
                "INSERT BG_ReimDocuments (ARID, RDType, RDCont, RDTime)" +
                "VALUES (@ARID, @RDType, @RDCont, @RDTime)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@ARID", bG_ReimDocuments.ARID),
                    new SqlParameter("@RDType", bG_ReimDocuments.RDType),
                    new SqlParameter("@RDCont", bG_ReimDocuments.RDCont),
                    new SqlParameter("@RDTime", bG_ReimDocuments.RDTime)
                };

                string IdStr = DBUnity.ExecuteScalar(CommandType.Text, sql, para);
                int newId = Convert.ToInt32(IdStr);
                return GetBG_ReimDocumentsByRDID(newId);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 /// <summary>
 /// 添加一条报销单据
 /// </summary>
 /// <param name="arid">报销单据</param>
 /// <returns>bool</returns>
 public static bool AddARID(BG_ReimDocuments arid)
 {
     bool falg = false;
     try
     {
         string sqlStr = @"insert into BG_ReimDocuments(ARID,RDType,RDCont,RDTime)values(@ARID,@RDType,@RDCont,@RDTime)";
         SqlParameter[] Pars = new SqlParameter[] {
                 new SqlParameter("@ARID",arid.ARID),
                 new SqlParameter("@RDType",arid.RDType),
                 new SqlParameter("@RDCont",arid.RDCont),
                 new SqlParameter("@RDTime",arid.RDTime)
                 };
         falg = DBUnity.ExecuteNonQuery(CommandType.Text, sqlStr, Pars) > 0;
     }
     catch (Exception ex)
     {
         falg = false;
         Log.WriteLog(ex.Message, "BudgetSys.DAL.BGReimDocumentsService.AddARID");
     }
     return falg;
 }
        /// <summary>
        /// 查询一条指定报销单据
        /// </summary>
        /// <param name="arid">报销单据ID</param>
        /// <returns>BGReimDocuments</returns>
        public static BG_ReimDocuments GetReimDocByArid(string arid)
        {
            BG_ReimDocuments rm = new BG_ReimDocuments();
             try
             {
                 string sqlStr = "select * from BG_ReimDocuments where ARID={0} ";
                 sqlStr = string.Format(sqlStr, arid);
                 DataTable dt = DBUnity.AdapterToTab(sqlStr);
                 if (dt.Rows.Count > 0)
                 {
                     rm.ARID = common.IntSafeConvert(dt.Rows[0]["ARID"]);
                     rm.RDCont = dt.Rows[0]["RdCont"].ToString();
                     rm.RDTime = DateTime.Parse(dt.Rows[0]["RDTime"].ToString());
                     rm.RDType = dt.Rows[0]["RdType"].ToString();
                 }
             }
             catch (Exception ex)
             {
                 rm = new BG_ReimDocuments();
                 Log.WriteLog(ex.Message, "BudgetSys.DAL.BGReimDocumentsService.GetReimDocByArid");
             }

             return rm;
        }
 public static bool ModifyBG_ReimDocuments(BG_ReimDocuments bG_ReimDocuments)
 {
     return BG_ReimDocumentsService.ModifyBG_ReimDocuments(bG_ReimDocuments);
 }
 public static bool DeleteBG_ReimDocuments(BG_ReimDocuments bG_ReimDocuments)
 {
     return BG_ReimDocumentsService.DeleteBG_ReimDocuments(bG_ReimDocuments);
 }
 public static BG_ReimDocuments AddBG_ReimDocuments(BG_ReimDocuments bG_ReimDocuments)
 {
     return BG_ReimDocumentsService.AddBG_ReimDocuments(bG_ReimDocuments);
 }
        /// <summary>
        /// 修改指定报销单据
        /// </summary>
        /// <param name="arid">报销单据</param>
        /// <returns>bool</returns>
        public static bool UpdReimDocuments(BG_ReimDocuments arid)
        {
            bool flag = false;
             try
             {
                 string sqlStr = @"update BG_ReimDocuments set RDType=@RDType,RDCont=@RDCont,RDTime=@RDTime  where ARID=@ARID";
                 SqlParameter[] Pars = new SqlParameter[] {
                        new SqlParameter("@ARID",arid.ARID),
                        new SqlParameter("@RDType",arid.RDType),
                        new SqlParameter("@RDCont",arid.RDCont),
                        new SqlParameter("@RDTime",arid.RDTime)
                        };
                 flag = DBUnity.ExecuteNonQuery(CommandType.Text, sqlStr, Pars) > 0;
             }
             catch (Exception ex)
             {
                 flag = false;
                 Log.WriteLog(ex.Message, "BudgetSys.DAL.BGReimDocumentsService.UpdReimDocuments");
             }

             return flag;
        }
 /// <summary>
 /// 修改指定报销单据
 /// </summary>
 /// <param name="arid">报销单据</param>
 /// <returns>bool</returns>
 public static bool UpdReimDocuments(BG_ReimDocuments arid)
 {
     return BGReimDocumentsService.UpdReimDocuments(arid);
 }
 /// <summary>
 /// 添加一条报销单据
 /// </summary>
 /// <param name="arid">报销单据</param>
 /// <returns>bool</returns>
 public static bool AddARID(BG_ReimDocuments arid)
 {
     return BGReimDocumentsService.AddARID(arid);
 }
        public static BG_ReimDocuments GetBG_ReimDocumentsByRDID(int rDID)
        {
            string sql = "SELECT * FROM BG_ReimDocuments WHERE RDID = @RDID";

            try
            {
                SqlParameter para = new SqlParameter("@RDID", rDID);
                DataTable dt = DBUnity.AdapterToTab(sql, para);

                if(dt.Rows.Count > 0)
                {
                    BG_ReimDocuments bG_ReimDocuments = new BG_ReimDocuments();

                    bG_ReimDocuments.RDID = dt.Rows[0]["RDID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["RDID"];
                    bG_ReimDocuments.ARID = dt.Rows[0]["ARID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["ARID"];
                    bG_ReimDocuments.RDType = dt.Rows[0]["RDType"] == DBNull.Value ? "" : (string)dt.Rows[0]["RDType"];
                    bG_ReimDocuments.RDCont = dt.Rows[0]["RDCont"] == DBNull.Value ? "" : (string)dt.Rows[0]["RDCont"];
                    bG_ReimDocuments.RDTime = dt.Rows[0]["RDTime"] == DBNull.Value ? DateTime.MinValue : (DateTime)dt.Rows[0]["RDTime"];

                    return bG_ReimDocuments;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 public static bool DeleteBG_ReimDocuments(BG_ReimDocuments bG_ReimDocuments)
 {
     return DeleteBG_ReimDocumentsByRDID( bG_ReimDocuments.RDID );
 }
        public static bool ModifyBG_ReimDocuments(BG_ReimDocuments bG_ReimDocuments)
        {
            string sql =
                "UPDATE BG_ReimDocuments " +
                "SET " +
                    "ARID = @ARID, " +
                    "RDType = @RDType, " +
                    "RDCont = @RDCont, " +
                    "RDTime = @RDTime " +
                "WHERE RDID = @RDID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@RDID", bG_ReimDocuments.RDID),
                    new SqlParameter("@ARID", bG_ReimDocuments.ARID),
                    new SqlParameter("@RDType", bG_ReimDocuments.RDType),
                    new SqlParameter("@RDCont", bG_ReimDocuments.RDCont),
                    new SqlParameter("@RDTime", bG_ReimDocuments.RDTime)
                };

                int t = DBUnity.ExecuteNonQuery(CommandType.Text, sql, para);
                if(t>0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }