public static BG_DataRecord AddBG_DataRecord(BG_DataRecord bG_DataRecord)
        {
            string sql =
                "INSERT BG_DataRecord (DRType, DRTime, DRName, IsBackUp)" +
                "VALUES (@DRType, @DRTime, @DRName, @IsBackUp)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@DRType", bG_DataRecord.DRType),
                    new SqlParameter("@DRTime", bG_DataRecord.DRTime),
                    new SqlParameter("@DRName", bG_DataRecord.DRName),
                    new SqlParameter("@IsBackUp", bG_DataRecord.IsBackUp)
                };

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

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
        public static BG_DataRecord GetBG_DataRecordByDRID(int dRID)
        {
            string sql = "SELECT * FROM BG_DataRecord WHERE DRID = @DRID";

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

                if(dt.Rows.Count > 0)
                {
                    BG_DataRecord bG_DataRecord = new BG_DataRecord();

                    bG_DataRecord.DRID = dt.Rows[0]["DRID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["DRID"];
                    bG_DataRecord.DRType = dt.Rows[0]["DRType"] == DBNull.Value ? "" : (string)dt.Rows[0]["DRType"];
                    bG_DataRecord.DRTime = dt.Rows[0]["DRTime"] == DBNull.Value ? DateTime.MinValue : (DateTime)dt.Rows[0]["DRTime"];
                    bG_DataRecord.DRName = dt.Rows[0]["DRName"] == DBNull.Value ? "" : (string)dt.Rows[0]["DRName"];
                    bG_DataRecord.IsBackUp = dt.Rows[0]["IsBackUp"] == DBNull.Value ? "" : (string)dt.Rows[0]["IsBackUp"];

                    return bG_DataRecord;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 public static bool DeleteBG_DataRecord(BG_DataRecord bG_DataRecord)
 {
     return DeleteBG_DataRecordByDRID( bG_DataRecord.DRID );
 }
        public static bool ModifyBG_DataRecord(BG_DataRecord bG_DataRecord)
        {
            string sql =
                "UPDATE BG_DataRecord " +
                "SET " +
                    "DRType = @DRType, " +
                    "DRTime = @DRTime, " +
                    "DRName = @DRName, " +
                    "IsBackUp = @IsBackUp " +
                "WHERE DRID = @DRID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@DRID", bG_DataRecord.DRID),
                    new SqlParameter("@DRType", bG_DataRecord.DRType),
                    new SqlParameter("@DRTime", bG_DataRecord.DRTime),
                    new SqlParameter("@DRName", bG_DataRecord.DRName),
                    new SqlParameter("@IsBackUp", bG_DataRecord.IsBackUp)
                };

                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;
            }
        }
 public static bool ModifyBG_DataRecord(BG_DataRecord bG_DataRecord)
 {
     return BG_DataRecordService.ModifyBG_DataRecord(bG_DataRecord);
 }
 public static bool DeleteBG_DataRecord(BG_DataRecord bG_DataRecord)
 {
     return BG_DataRecordService.DeleteBG_DataRecord(bG_DataRecord);
 }
 public static BG_DataRecord AddBG_DataRecord(BG_DataRecord bG_DataRecord)
 {
     return BG_DataRecordService.AddBG_DataRecord(bG_DataRecord);
 }