Esempio n. 1
0
        private TblContractPaymentByPeriod UpdateOrInsertContractPaymentDetail(
            TblContractPaymentByPeriod newRow, int userIserial, int index, out int outindex)
        {
            outindex = index;
            newRow.TblContractHeader1 = null;
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblContractPaymentByPeriods
                              where e.Iserial == newRow.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    //context.Entry(oldRow).CurrentValues.SetValues(newRow);
                    var result = SharedOperation.GenericUpdate(oldRow, newRow, context);
                    if (result.Count() > 0)
                    {
                        oldRow.LastChangeDate = DateTime.Now;
                        oldRow.LastChangeUser = userIserial;
                    }
                }
                else
                {
                    newRow.CreatedBy      = userIserial;
                    newRow.LastChangeUser = userIserial;
                    newRow.CreationDate   = DateTime.Now;
                    newRow.LastChangeDate = DateTime.Now;
                    context.TblContractPaymentByPeriods.AddObject(newRow);
                }

                context.SaveChanges();
                return(newRow);
            }
        }
Esempio n. 2
0
        private TblContractPaymentByPeriod DeleteContractPaymentDetail(TblContractPaymentByPeriod row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblContractPaymentByPeriods
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row);
        }