Beispiel #1
0
    static public bool DeleteClient(DdClientExt item, RevisionInfo revisionInfo)
    {
      DaClient da = new DaClient(DataStore.DbConnection);
      bool ok = da.DeleteById(item.Id);
      if (ok) AddChangeLog(da.TableName, item.Id, item.Timestamp, revisionInfo); //delete
	  return ok;
    }
Beispiel #2
0
 static public void UpdateClient(BindingSource binding, RevisionInfo revInfo)
 {
   BindingList<DdClientExt> list = (BindingList<DdClientExt>)binding.DataSource;
   try
   {
     using (TransactionScope scope = new TransactionScope())
     {
     DaClient da = new DaClient(DataStore.CloneDbConnection());
     foreach (DdClientExt 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 (DdClientExt item in list)
     {
       if (item.DeleteFlag) continue; // already done above
       //if (item.ClientID == string.Empty) continue; // already done above
       bool existing = da.GetById(item.Id);
       if (!existing)
       {
         da.Clear();
       }
       da.ClientID = item.ClientID;
       da.Comment = item.Comment;
       da.FullName = item.FullName;
       if (!existing)
       {
         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 = GetClientList();
   }
   catch (AppEx)
   {
     throw;
   }
   catch (Exception exc)
   {
     throw new AppEx(exc, "Error updating Client");
   }
 }