예제 #1
0
 static public bool SaveProject(ref DdProjectExt item, RevisionInfo revisionInfo)
 {
   DaProject da = new DaProject(DataStore.DbConnection);
   if (!da.GetById(item.Id)) return false;
   da.ClientREF = item.ClientREF;
   da.Description = item.Description;
   da.ProjectID = item.ProjectID;
   da.TaskHeadingREF = item.TaskHeadingREF;
   da.Title = item.Title;
   bool ok = true;
   if (da._IsModified)
   {
     da.Modified = DateTime.Now;
     da.ModifiedBy = Environment.UserName;
     ok = da.Save();
     if (ok) AddChangeLog(da.TableName, da.Id, da.Timestamp, revisionInfo);
     if (ok) item = new DdProjectExt(da.GetBuffer());
   }
   return ok;
 }
예제 #2
0
 static public void UpdateProject(BindingSource binding, int clientREF, RevisionInfo revInfo)
 {
   BindingList<DdProjectExt> list = (BindingList<DdProjectExt>)binding.DataSource;
   try
   {
     using (TransactionScope scope = new TransactionScope())
     {
     DaProject da = new DaProject(DataStore.CloneDbConnection());
     foreach (DdProjectExt 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 (DdProjectExt item in list)
     {
       if (item.DeleteFlag) continue; // already done above
       //if (item.ProjectID == string.Empty) continue; // already done above
       bool existing = da.GetById(item.Id);
       if (!existing)
       {
         da.Clear();
       }
       da.ClientREF = item.ClientREF;
       da.Description = item.Description;
       da.ProjectID = item.ProjectID;
       da.TaskHeadingREF = item.TaskHeadingREF;
       da.Title = item.Title;
       if (!existing)
       {
         da.ClientREF = clientREF;
         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 = GetProjectList(clientREF);
   }
   catch (AppEx)
   {
     throw;
   }
   catch (Exception exc)
   {
     throw new AppEx(exc, "Error updating Project");
   }
 }