コード例 #1
0
    static public bool DeleteTimeReport(DdTimeReportExt item, RevisionInfo revisionInfo)
    {
      DaTimeReport da = new DaTimeReport(DataStore.DbConnection);
      bool ok = da.DeleteById(item.Id);
      if (ok) AddChangeLog(da.TableName, item.Id, item.Timestamp, revisionInfo); //delete
	  return ok;
    }
コード例 #2
0
 static public void UpdateTimeReport(BindingSource binding, int personREF, RevisionInfo revInfo)
 {
   BindingList<DdTimeReportExt> list = (BindingList<DdTimeReportExt>)binding.DataSource;
   try
   {
     using (TransactionScope scope = new TransactionScope())
     {
     DaTimeReport da = new DaTimeReport(DataStore.CloneDbConnection());
     foreach (DdTimeReportExt item in list)
     {// do deletes first
       bool existing = da.GetById(item.Id);
       if (existing && item.DeleteFlag)
       {// delete here - avoid validation
         da.DeleteById(item.Id);
         AddChangeLog(da.TableName, item.Id, da.Timestamp, revInfo);  
       }
     }
     
     foreach (DdTimeReportExt item in list)
     {
       if (item.DeleteFlag) continue; // already done above
       //if (item.Id == string.Empty) continue; // already done above
       bool existing = da.GetById(item.Id);
       if (!existing)
       {
         da.Clear();
       }
       da.CalendarREF = item.CalendarREF;
       da.Description = item.Description;
       da.EffectiveDate = item.EffectiveDate;
       da.Hours = item.Hours;
       da.PersonREF = item.PersonREF;
       da.TaskChargeCodeREF = item.TaskChargeCodeREF;
       if (!existing)
       {
         da.PersonREF = personREF;
         da.Insert();
         AddChangeLog(da.TableName, da.Id, da.Timestamp, revInfo); 
       }
       else
       {
         if (!da._IsModified) continue;
         da.Modified = DateTime.Now;
         da.ModifiedBy = Environment.UserName;
         da.Save();
         AddChangeLog(da.TableName, da.Id, da.Timestamp, revInfo);           }
     }
       scope.Complete();
     }
     binding.DataSource = GetTimeReportList(personREF);
   }
   catch (AppEx)
   {
     throw;
   }
   catch (Exception exc)
   {
     throw new AppEx(exc, "Error updating TimeReport");
   }
 }