//cap nhat so tiep nhap TNTX trong nam
 //day la tong so tiep nhap TNTX trong nam
 public static long updateTotalReceiveNumber()
 {
     tblApplicationObject appObj = ApplicationObjectFactory.getByName(TOTAL_TEMP_RECEIVE_NUMBER_IN_YEAR);
     DateTime currentDate = CommonFactory.GetCurrentDate();
     if (appObj == null)
     {
         appObj = new tblApplicationObject();
         appObj.ApplicationObjectName = TOTAL_TEMP_RECEIVE_NUMBER_IN_YEAR;
         appObj.ApplicationObjectValueDatetime = CommonFactory.GetCurrentDate();
         appObj.ApplicationObjectValueLong = 1;
         ApplicationObjectFactory.Insert(appObj);
     }
     else
     {
         if (currentDate.Year != ((DateTime)appObj.ApplicationObjectValueDatetime).Year)
         {
             appObj.ApplicationObjectValueDatetime = currentDate;
             appObj.ApplicationObjectValueLong = 1;
         }
         else
         {
             appObj.ApplicationObjectValueLong = appObj.ApplicationObjectValueLong + 1;
         }
         ApplicationObjectFactory.Update(appObj);
     }
     long applicationObjectValueLong = appObj.ApplicationObjectValueLong.GetValueOrDefault();
     return applicationObjectValueLong;
 }
 //cap nhat so thu tu cua ticket
 //day la tong so lan in ticket trong 1 ngay
 public static long updateTotalTicketPrint(string ticketType)
 {
     tblApplicationObject appObj = ApplicationObjectFactory.getByName(ticketType);
     DateTime currentDate = CommonFactory.GetCurrentDate();
     if (appObj == null)
     {
         appObj = new tblApplicationObject();
         appObj.ApplicationObjectName = ticketType;
         appObj.ApplicationObjectValueDatetime = CommonFactory.GetCurrentDate();
         appObj.ApplicationObjectValueLong = 1;
         ApplicationObjectFactory.Insert(appObj);
     }
     else
     {
         if (currentDate.DayOfYear != ((DateTime)appObj.ApplicationObjectValueDatetime).DayOfYear)
         {
             appObj.ApplicationObjectValueDatetime = currentDate;
             appObj.ApplicationObjectValueLong = 1;
         }
         else
         {
             appObj.ApplicationObjectValueLong = appObj.ApplicationObjectValueLong + 1;
         }
         ApplicationObjectFactory.Update(appObj);
     }
     long applicationObjectValueLong = appObj.ApplicationObjectValueLong.GetValueOrDefault();
     return applicationObjectValueLong;
 }
 public static int Update(tblApplicationObject appObject)
 {
     try
     {
         _db.Connection.Open();
         var updateAppObject = new tblApplicationObject();
         updateAppObject = _db.tblApplicationObjects.Where(g => g.ApplicationObjectID == appObject.ApplicationObjectID).FirstOrDefault();
         updateAppObject.ApplicationObjectValueFloat = appObject.ApplicationObjectValueFloat;
         updateAppObject.ApplicationObjectValueLong = appObject.ApplicationObjectValueLong;
         updateAppObject.ApplicationObjectValueString = appObject.ApplicationObjectValueString;
         updateAppObject.ApplicationObjectValueDatetime = appObject.ApplicationObjectValueDatetime;
         return _db.SaveChanges();
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
         throw;
     }
     finally
     {
         _db.Connection.Close();
     }
 }
 public static void Insert(tblApplicationObject appObject)
 {
     try
     {
         _db.Connection.Open();
         _db.AddTotblApplicationObjects(appObject);
         _db.SaveChanges();
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
         throw;
     }
     finally
     {
         _db.Connection.Close();
     }
 }