Beispiel #1
0
        private int DeleteTblCostDimSetupHeader(TblCostDimSetupHeader row, string company)
        {
            using (var context = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var oldRow = (from e in context.TblCostDimSetupHeaders
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
Beispiel #2
0
 private TblCostDimSetupHeader UpdateOrInsertTblCostDimSetupHeader(TblCostDimSetupHeader newRow, bool save, int index, out int outindex, string company)
 {
     outindex = index;
     using (var context = new ccnewEntities(GetSqlConnectionString(company)))
     {
         if (save)
         {
             context.TblCostDimSetupHeaders.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.TblCostDimSetupHeaders
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }
Beispiel #3
0
        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 (AllowUpdate != true && !save)
                    {
                        MessageBox.Show(strings.AllowUpdateMsg);
                        return;
                    }
                    var saveRow = new TblCostDimSetupHeader();
                    saveRow.InjectFrom(SelectedMainRow);
                    Glclient.UpdateOrInsertTblCostDimSetupHeaderAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow),
                                                                      LoggedUserInfo.DatabasEname);
                }
            }
        }
Beispiel #4
0
 private TblCostDimHeader GetTblCostDimSetupHeaderForAccount(int tblJournalAccountType, int?iserial, string company, out TblCostDimSetupHeader HeaderRow, out int tblJournalAccType)
 {
     using (var entity = new ccnewEntities(GetSqlConnectionString(company)))
     {
         tblJournalAccType = tblJournalAccountType;
         if (iserial == null)
         {
             HeaderRow = entity.TblCostDimSetupHeaders.Include("TblCostDimSetupDetails.TblCostCenterOption1").Include("TblCostDimSetupDetails.TblCostCenterType1").FirstOrDefault(x => x.TblJournalAccountType == tblJournalAccountType);
             return(null);
         }
         HeaderRow = null;
         return(entity.TblCostDimHeaders.Include("TblCostDimDetails.TblCostCenter1").FirstOrDefault(x => x.Iserial == iserial));
     }
 }