Ejemplo n.º 1
0
        public static bool UpdateData(x_timesheet dataForm, long modifiedBy)
        {
            x_timesheet dataBefore = GetDatabyId(dataForm.id);

            try
            {
                using (DBSpecEntities db = new DBSpecEntities())
                {
                    dataBefore.modified_by    = modifiedBy;
                    dataBefore.modified_on    = System.DateTime.Now;
                    dataBefore.overtime       = dataForm.overtime;
                    dataBefore.start          = dataForm.start;
                    dataBefore.end            = dataForm.end;
                    dataBefore.start_ot       = dataForm.start_ot;
                    dataBefore.end_ot         = dataForm.end_ot;
                    dataBefore.status         = dataForm.status;
                    dataBefore.timesheet_date = dataForm.timesheet_date;
                    dataBefore.activity       = dataForm.activity;

                    db.Entry(dataBefore).State = EntityState.Modified;
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static x_timesheet GetDatabyId(long id)
        {
            x_timesheet data = new x_timesheet();

            using (DBSpecEntities db = new DBSpecEntities())
            {
                data = db.x_timesheet.Where(a => a.id == id).FirstOrDefault();
            }
            return(data);
        }
Ejemplo n.º 3
0
 public static bool DeleteData(long id)
 {
     using (DBSpecEntities db = new DBSpecEntities())
     {
         x_timesheet data = GetDatabyId(id);
         data.is_delete       = true;
         db.Entry(data).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 4
0
        public static bool SaveData(x_timesheet Sheet, long createdBy)
        {
            //try
            //{
            using (DBSpecEntities db = new DBSpecEntities())
            {
                Sheet.timesheet_date = Sheet.timesheet_date;
                Sheet.created_by     = createdBy;
                Sheet.created_on     = System.DateTime.Now;
                Sheet.overtime       = Sheet.overtime;

                Sheet.modified_on   = null;
                Sheet.deleted_on    = null;
                Sheet.user_approval = null;
                Sheet.ero_status    = null;
                Sheet.submitted_on  = null;

                db.x_timesheet.Add(Sheet);

                db.SaveChanges();
                return(true);
            }

            //}
            //catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            //{
            //    Exception raise = dbEx;
            //    foreach (var validationErrors in dbEx.EntityValidationErrors)
            //    {
            //        foreach (var validationError in validationErrors.ValidationErrors)
            //        {
            //            string message = string.Format("{0}:{1}",
            //                validationErrors.Entry.Entity.ToString(),
            //                validationError.ErrorMessage);
            //            // raise a new exception nesting
            //            // the current instance as InnerException
            //            raise = new InvalidOperationException(message, raise);
            //        }
            //    }
            //    throw raise;
            //}
        }
Ejemplo n.º 5
0
 public static bool userApproval(string data)
 {
     string[] arr = data.Split(',');
     using (DBSpecEntities db = new DBSpecEntities())
     {
         for (int i = 1; i < arr.Length; i++)
         {
             x_timesheet dtTimesheet = new x_timesheet();
             dtTimesheet = GetDatabyId(Convert.ToInt64(arr[i]));
             if (arr[0] == "Approved")
             {
                 dtTimesheet.approved_on = System.DateTime.Now;
             }
             else
             {
                 dtTimesheet.approved_on = null;
             }
             dtTimesheet.user_approval   = arr[0];
             db.Entry(dtTimesheet).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     return(true);
 }