コード例 #1
0
ファイル: Asset.cs プロジェクト: Osama91/CCWFM
        private int DeleteTblAssetGroup(TblAssetGroup row, int index, string company)
        {
            using (var entity = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var query = (from e in entity.TblAssetGroups
                             where e.Iserial == row.Iserial
                             select e).SingleOrDefault();
                if (query != null)
                {
                    entity.DeleteObject(query);
                }

                entity.SaveChanges();
            }
            return(row.Iserial);
        }
コード例 #2
0
ファイル: AssetGroupViewModel.cs プロジェクト: Osama91/CCWFM
        public void SaveMainRow()
        {
            if (SelectedMainRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true);

                if (isvalid)
                {
                    var save = SelectedMainRow.Iserial == 0;
                    if (save)
                    {
                        if (AllowAdd != true)
                        {
                            MessageBox.Show(strings.AllowAddMsg);
                            return;
                        }
                    }
                    else
                    {
                        if (AllowUpdate != true)
                        {
                            MessageBox.Show(strings.AllowUpdateMsg);
                            return;
                        }
                    }
                    var saveRow = new TblAssetGroup();

                    saveRow.InjectFrom(SelectedMainRow);
                    Glclient.UpdateOrInsertTblAssetGroupAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow), LoggedUserInfo.DatabasEname);
                }
                else
                {
                    MessageBox.Show("Data Was Not Saved");
                }
            }
        }
コード例 #3
0
ファイル: Asset.cs プロジェクト: Osama91/CCWFM
 private TblAssetGroup UpdateOrInsertTblAssetGroup(TblAssetGroup newRow, bool save, int index, out int outindex, string company)
 {
     outindex = index;
     using (var entity = new ccnewEntities(GetSqlConnectionString(company)))
     {
         if (save)
         {
             entity.TblAssetGroups.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in entity.TblAssetGroups
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, entity);
             }
         }
         entity.SaveChanges();
         return(newRow);
     }
 }