예제 #1
0
        private EmpLeavingTransaction UpdateOrInsertEmpLeavingTransaction(EmpLeavingTransaction newRow, bool save, int index, int user, out int outindex)
        {
            outindex = index;
            using (var context = new TimeAttEntities())
            {
                if (save)
                {
                    newRow.CreationBy   = user;
                    newRow.CreationDate = DateTime.Now;
                    context.EmpLeavingTransactions.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.EmpLeavingTransactions
                                  where e.Iserial == newRow.Iserial
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }
                context.SaveChanges();

                return(newRow);
            }
        }
예제 #2
0
        private int DeleteTblEmployeeShift(TblEmployeeShift row)
        {
            if (!Att.AttService.EmpCanEdit(row.TransDate, row.EmpId))
            {
                throw new Exception("Cannot edit a transaction because this period is already closed");
            }

            using (var context = new TimeAttEntities())
            {
                var oldRow = (from e in context.TblEmployeeShifts.Include("TblEmployeeShiftLookup1")
                              where
                              e.EmpId == row.EmpId &&
                              e.TransDate == row.TransDate

                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    //if (oldRow.Status == 1)
                    //{
                    //    var srv = new EmployeePayrollServiceClient();
                    //    srv.DeleteEmpCalendarDeviation(row.EmpId, row.TransDate, oldRow.TblEmployeeShiftLookup1.CalendarId);
                    //}

                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
예제 #3
0
        public TblEmployeeShift UpdateAndInsertTblEmployeeShift(TblEmployeeShift row, int index, int userIserial, out int outindex)
        {
            if (!Att.AttService.EmpCanEdit(row.TransDate, row.EmpId))
            {
                throw new Exception("Cannot edit a transaction because this period is already closed");
            }
            outindex = index;
            IEnumerable <string> changedList = null;
            bool save = row.Iserial == 0;

            using (var db = new TimeAttEntities())
            {
                var oldRow = (from e in db.TblEmployeeShifts
                              where e.EmpId == row.EmpId &&
                              e.TransDate == row.TransDate
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    if (row.CreationDate == DateTime.MinValue)
                    {
                        row.CreatedBy = userIserial;

                        row.CreationDate = DateTime.Now;
                    }
                    row.CreatedBy = userIserial;
                    row.Iserial   = oldRow.Iserial;
                    changedList   = GenericUpdate(oldRow, row, db);
                }
                else
                {
                    row.CreatedBy    = userIserial;
                    row.CreationDate = DateTime.Now;
                    db.TblEmployeeShifts.AddObject(row);
                }

                if (row.Status == 1)
                {
                    //    var srv = new EmployeePayrollServiceClient();

                    //    var listOfEmployeeShifts = new List<ServiceReference1.TblEmployeeShift>
                    //{
                    //    new ServiceReference1.TblEmployeeShift().InjectFrom(row) as ServiceReference1.TblEmployeeShift
                    //};

                    //    try
                    //    {
                    //        if (listOfEmployeeShifts.Count != 0)
                    //        {
                    //            srv.InsertEmpCalendarDeviation(listOfEmployeeShifts);
                    //        }
                    //    }
                    //    catch (Exception)
                    //    {

                    //    }
                }
                db.SaveChanges();
            }
            return(row);
        }
예제 #4
0
        private int DeleteTblPeriodLock(TblPeriodLock row)
        {
            using (var context = new TimeAttEntities())
            {
                var oldRow = (from e in context.TblPeriodLocks
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
예제 #5
0
        private int DeleteEmpLeavingTransaction(EmpLeavingTransaction row)
        {
            using (var context = new TimeAttEntities())
            {
                var oldRow = (from e in context.EmpLeavingTransactions
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
예제 #6
0
        private int DeleteTblVariableTermManual(Model.TblVariableTermManual row)
        {
            using (var context = new TimeAttEntities())
            {
                var oldRow = (from e in context.TblVariableTermManuals
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
예제 #7
0
        public List <TblEmployeeShift> UpdateAndInsertTblEmployeeShiftList(List <TblEmployeeShift> newList)
        {
            using (var db = new TimeAttEntities())
            {
                foreach (var row in newList)
                {
                    var oldRow = (from e in db.TblEmployeeShifts
                                  where e.EmpId == row.EmpId &&
                                  e.TransDate == row.TransDate
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        row.Iserial = oldRow.Iserial;
                        GenericUpdate(oldRow, row, db);
                    }
                    else
                    {
                        db.TblEmployeeShifts.AddObject(row);
                    }

                    db.SaveChanges();
                }
                //var srv = new EmployeePayrollServiceClient();

                //var listOfEmployeeShifts = new List<ServiceReference1.TblEmployeeShift>();

                //foreach (var row in newList.Where(x => x.Status == 1))
                //{
                //    listOfEmployeeShifts.Add(new ServiceReference1.TblEmployeeShift().InjectFrom(row) as ServiceReference1.TblEmployeeShift);
                //}
                //try
                //{
                //    if (listOfEmployeeShifts.Count != 0)
                //    {
                //        srv.InsertEmpCalendarDeviation(listOfEmployeeShifts);
                //    }
                //}
                //catch (Exception)
                //{
                //    throw;
                //}

                return(newList);
            }
        }
예제 #8
0
 private TblPeriodLock UpdateOrInsertTblPeriodLock(TblPeriodLock newRow, bool save, int index, out int outindex)
 {
     outindex = index;
     using (var context = new TimeAttEntities())
     {
         if (save)
         {
             context.TblPeriodLocks.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.TblPeriodLocks
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 Operations.SharedOperation.GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }
예제 #9
0
 private TblEmployeeBehalf UpdateOrInsertTblEmployeeBehalf(TblEmployeeBehalf newRow, bool save, int index, out int outindex)
 {
     outindex = index;
     using (var context = new TimeAttEntities())
     {
         if (save)
         {
             context.TblEmployeeBehalves.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.TblEmployeeBehalves
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }
예제 #10
0
 private FingerPrintTransaction UpdateOrInsertFingerPrintTransaction(FingerPrintTransaction newRow, bool save, int index, out int outindex)
 {
     outindex = index;
     using (var context = new TimeAttEntities())
     {
         if (save)
         {
             context.FingerPrintTransactions.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.FingerPrintTransactions
                           where e.GlSerial == newRow.GlSerial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }
예제 #11
0
        private Model.TblVariableTermManual UpdateOrInsertTblVariableTermManual(Model.TblVariableTermManual newRow, bool save, int index, out int outindex)
        {
            var oldRow = new Model.TblVariableTermManual();

            outindex = index;
            using (var context = new TimeAttEntities())
            {
                if (save)
                {
                    context.TblVariableTermManuals.AddObject(newRow);
                }
                else
                {
                    oldRow = (from e in context.TblVariableTermManuals
                              where e.Iserial == newRow.Iserial
                              select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }
                context.SaveChanges();

                var srv = new EmployeePayrollServiceClient();
                //newRow
                var row = new ServiceReference1.TblVariableTermManual();
                row.InjectFrom(newRow);
                srv.InsertVariableTerm(row, row);
                var selectedTerm = context.TblSalaryTerms.FirstOrDefault(w => w.Iserial == newRow.TermId).Ename;



                using (PayrollEntities payrolldb = new PayrollEntities())
                {
                    if (oldRow != null)
                    {
                        deletePayrollVr(payrolldb, oldRow, selectedTerm);
                    }

                    var emp        = payrolldb.TblEmployeePayrolls.FirstOrDefault(w => w.EmpId == newRow.Emplid);
                    var period     = getPeriodByOrganizationUnit(emp.TblOrganizationUnit ?? 0, payrolldb).Iserial;
                    var periodline = payrolldb.TblPeriodLines.FirstOrDefault(x => x.FromDate <= newRow.TransDate && x.ToDate >= newRow.TransDate && x.TblPeriod == period);

                    var exType = payrolldb.PayrollTblSalaryTerms.FirstOrDefault(w => w.Ename == selectedTerm).Iserial;
                    if (emp != null && exType != null)
                    {
                        var ExToInsert = new PayrollTblVariableTermManual()
                        {
                            TblEmployee      = emp.Iserial,
                            TblSalaryTerm    = exType,
                            Hours            = newRow.Hours,
                            AmountCUR        = 0,
                            AttHours         = 0,
                            AttType          = "0",
                            ExcuseTransRECId = null,
                            OldAmount        = 0,
                            TblAttendaceFile = null,
                            TblCalculated    = 0,
                            TblCurrency      = null,
                            TblPenalty       = null,
                            TransDate        = newRow.TransDate,
                            FromAtt          = false,
                            TblPeriodLine    = periodline.Iserial,
                        };
                        payrolldb.PayrollTblVariableTermManuals.AddObject(ExToInsert);
                    }
                    payrolldb.SaveChanges();
                }



                return(newRow);
            }
        }