Beispiel #1
0
 static public bool AddTask(ref DdTaskExt item, RevisionInfo revisionInfo)
 {
   DaTask da = new DaTask(DataStore.DbConnection);
   da.Clear();
   da.Description = item.Description;
   da.DueDate = item.DueDate;
   da.EstHours = item.EstHours;
   da.Modified = item.Modified;
   da.ModifiedBy = item.ModifiedBy;
   da.TaskHeadingREF = item.TaskHeadingREF;
   da.TaskID = item.TaskID;
   da.Title = item.Title;
   bool ok = da.Insert();
   if (ok) AddChangeLog(da.TableName, da.Id, da.Timestamp, revisionInfo); //add
   if (ok) item = new DdTaskExt(da.GetBuffer());
   return ok;
 }
Beispiel #2
0
 static public void UpdateTask(BindingSource binding, int taskHeadingREF, RevisionInfo revInfo)
 {
   BindingList<DdTaskExt> list = (BindingList<DdTaskExt>)binding.DataSource;
   try
   {
     using (TransactionScope scope = new TransactionScope())
     {
     DaTask da = new DaTask(DataStore.CloneDbConnection());
     foreach (DdTaskExt 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 (DdTaskExt item in list)
     {
       if (item.DeleteFlag) continue; // already done above
       //if (item.TaskID == string.Empty) continue; // already done above
       bool existing = da.GetById(item.Id);
       if (!existing)
       {
         da.Clear();
       }
       da.Description = item.Description;
       da.DueDate = item.DueDate;
       da.EstHours = item.EstHours;
       da.TaskHeadingREF = item.TaskHeadingREF;
       da.TaskID = item.TaskID;
       da.Title = item.Title;
       if (!existing)
       {
         da.TaskHeadingREF = taskHeadingREF;
         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 = GetTaskList(taskHeadingREF);
   }
   catch (AppEx)
   {
     throw;
   }
   catch (Exception exc)
   {
     throw new AppEx(exc, "Error updating Task");
   }
 }