Exemplo n.º 1
0
        private int DeleteTblRequestForSample(TblRequestForSample row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblRequestForSamples
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
Exemplo n.º 2
0
 private TblRequestForSample UpdateOrInsertTblRequestForSample(TblRequestForSample newRow, int UserIserial, bool save, int index, out int outindex)
 {
     outindex = index;
     using (var context = new WorkFlowManagerDBEntities())
     {
         if (save)
         {
             var serial = GetMaxSample(newRow.TblStyle, newRow.TblSupplier);
             newRow.Code     = newRow.Code + "-" + serial;
             newRow.SerialNo = serial;
             newRow.TblRequestForSampleStatus =
                 context.TblRequestForSampleStatus.FirstOrDefault(x => x.Code == "N/A").Iserial;
             context.TblRequestForSamples.AddObject(newRow);
             context.SaveChanges();
             var newevent = new TblRequestForSampleEvent
             {
                 ApprovedBy   = UserIserial,
                 RequestDate  = newRow.CreationDate,
                 DeliveryDate = newRow.EstimatedDeliveryDate,
                 TblRequestForSampleStatus = newRow.TblRequestForSampleStatus,
                 TblSalesOrder             = newRow.Iserial
             };
             context.TblRequestForSampleEvents.AddObject(newevent);
         }
         else
         {
             var oldRow = (from e in context.TblRequestForSamples
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 if (oldRow.TblSupplier != newRow.TblSupplier)
                 {
                     var serial = GetMaxSample(newRow.TblStyle, newRow.TblSupplier);
                     newRow.Code     = newRow.Code + "-" + serial;
                     newRow.SerialNo = serial;
                 }
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }