コード例 #1
0
 static public bool AddUser(ref DdUserExt item, RevisionInfo revisionInfo)
 {
   DaUser da = new DaUser(DataStore.DbConnection);
   da.Clear();
   da.Comment = item.Comment;
   da.Credentials = item.Credentials;
   da.FullName = item.FullName;
   da.Inactive = item.Inactive;
   da.Modified = item.Modified;
   da.ModifiedBy = item.ModifiedBy;
   da.UserID = item.UserID;
   da.Title = item.Title;
   bool ok = da.Insert();
   if (ok) AddChangeLog(da.TableName, da.Id, da.Timestamp, revisionInfo); //add
   if (ok) item = new DdUserExt(da.GetBuffer());
   return ok;
 }
コード例 #2
0
 static public void UpdateUser(BindingSource binding, RevisionInfo revInfo)
 {
   BindingList<DdUserExt> list = (BindingList<DdUserExt>)binding.DataSource;
   try
   {
     using (TransactionScope scope = new TransactionScope())
     {
     DaUser da = new DaUser(DataStore.CloneDbConnection());
     foreach (DdUserExt 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 (DdUserExt item in list)
     {
       if (item.DeleteFlag) continue; // already done above
       //if (item.UserID == string.Empty) continue; // already done above
       bool existing = da.GetById(item.Id);
       if (!existing)
       {
         da.Clear();
       }
       da.Comment = item.Comment;
       da.Credentials = item.Credentials;
       da.FullName = item.FullName;
       da.Inactive = item.Inactive;
       da.UserID = item.UserID;
       da.Title = item.Title;
       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 = GetUserList();
   }
   catch (AppEx)
   {
     throw;
   }
   catch (Exception exc)
   {
     throw new AppEx(exc, "Error updating User");
   }
 }