예제 #1
0
 public static string GetTempTransferValue(long rowNumber, int colIndex)
 {
     using (DbEntities db = new DbEntities())
     {
         return db.TempTransfers.Where(t => t.ColIndex.Equals(colIndex) && t.RowNumber.Equals(rowNumber))
             .FirstOrDefault().Value;
     }
 }
예제 #2
0
 public static int InsertTrempTransfer(List<TempTransfer> tempTransfers)
 {
     using (DbEntities db = new DbEntities())
     {
         tempTransfers.ForEach(t => db.AddObject("TempTransfer",t));
         return db.SaveChanges();
     }
 }
예제 #3
0
 public static List<Transfer> GetTransferMapping(int reportFromId, int reportToId)
 {
     using (DbEntities db = new DbEntities())
     {
         var results = db.Transfers.Where(t => t.ReportFromId.Equals(reportFromId) && t.ReportToId.Equals(reportToId)).ToList();
         results.ForEach(t => db.Detach(t));
         return results;
     }
 }
예제 #4
0
 public static List<Column> GetColumnsByReport(int reportId)
 {
     using (DbEntities db = new DbEntities())
     {
         var results = db.Columns.Where(c => c.ReportId.Equals(reportId)).ToList();
         results.ForEach(c => db.Detach(c));
         return results;
     }
 }
예제 #5
0
 public static List<Report> GetAllReports()
 {
     using (DbEntities db = new DbEntities())
     {
         var results = db.Reports.ToList();
         results.ForEach(r => db.Detach(r));
         return results;
     }
 }
예제 #6
0
 public static int DeleteColumn(Column column)
 {
     using (DbEntities db = new DbEntities())
     {
         db.Columns.DeleteObject(column);
         //db.ObjectStateManager.ChangeObjectState(report, System.Data.EntityState.Deleted);
         return db.SaveChanges();
     }
 }
예제 #7
0
        public static int DeleteReport(Report report)
        {
            using (DbEntities db = new DbEntities())
            {
                db.Attach(report);
                db.Reports.DeleteObject(report);
                db.ObjectStateManager.ChangeObjectState(report, System.Data.EntityState.Deleted);

                //remove transfer with this report
                var transfers = db.Transfers.Where(t => t.ReportFromId.Equals(report.Id) || t.ReportToId.Equals(report.Id)).ToList();
                transfers.ForEach(t => db.DeleteObject(t));

                return db.SaveChanges();
            }
        }
예제 #8
0
 public static int UpsertColumn(Column column)
 {
     using (DbEntities db = new DbEntities())
     {
         if (column.EntityKey == null)
         {
             //new column so insert
             db.Columns.AddObject(column);
             //db.ObjectStateManager.ChangeObjectState(newReport, System.Data.EntityState.Added);
         }
         else
         {
             //update report
             db.Attach(column);
             db.ObjectStateManager.ChangeObjectState(column, System.Data.EntityState.Modified);
         }
         return db.SaveChanges();
     }
 }
예제 #9
0
        public static int UpsertTransfer(List<Transfer> transfers)
        {
            using (DbEntities db = new DbEntities())
            {
                foreach (Transfer transfer in transfers)
                {
                    if (transfer.EntityKey == null)
                    {
                        db.Transfers.AddObject(transfer);
                    }
                    else
                    {
                        db.Attach(transfer);
                        db.ObjectStateManager.ChangeObjectState(transfer, System.Data.EntityState.Modified);
                    }
                }

                return db.SaveChanges();
            }
        }
예제 #10
0
 public static int UpsertReport(Report report)
 {
     using (DbEntities db = new DbEntities())
     {
         if (report.EntityKey == null)
         {
             //new report so insert
             db.Reports.AddObject(report);
             //db.ObjectStateManager.ChangeObjectState(newReport, System.Data.EntityState.Added);
         }
         else
         {
             //update report
             db.Attach(report);
             db.ObjectStateManager.ChangeObjectState(report, System.Data.EntityState.Modified);
         }
         return db.SaveChanges();
     }
 }