示例#1
0
        public static LeavePlan Save(LeavePlan leavePlan)
        {
            string result = string.Empty;

            try
            {
                ATSCEEntities context = new ATSCEEntities();
                if (leavePlan.LeavePlanId <= 0)
                {
                    context.LeavePlans.Add(leavePlan);
                }
                else
                {
                    context.Entry(leavePlan).State = System.Data.EntityState.Modified;
                }
                int rowAffected = context.SaveChanges();

                if (rowAffected <= 0)
                {
                    result = "Record is not saved";
                }
                return(leavePlan);
            }
            catch (Exception ex)
            {
                throw new Exception("Record is not saved [" + ex.Message + "]");
            }
        }
示例#2
0
文件: CodeTable.cs 项目: victordc/ATS
        public string Save()
        {
            string result = string.Empty;
            try
            {
                using (var context = new ATSCEEntities())
                {
                    if (this.CodeTableId <= 0)
                    {
                        context.CodeTables.Add(this);
                    }
                    else
                    {
                        context.Entry(this).State = System.Data.EntityState.Modified;
                    }
                    int rowAffected = context.SaveChanges();

                    if (rowAffected <= 0)
                        result = "Record is not saved";
                }
            }
            catch (Exception ex)
            {
                // Log Exception here.
                throw new Exception("Record is not saved");
            }

            return result;
        }
示例#3
0
        public string Save()
        {
            string result = string.Empty;

            try
            {
                using (var context = new ATSCEEntities())
                {
                    if (this.CodeTableId <= 0)
                    {
                        context.CodeTables.Add(this);
                    }
                    else
                    {
                        context.Entry(this).State = System.Data.EntityState.Modified;
                    }
                    int rowAffected = context.SaveChanges();

                    if (rowAffected <= 0)
                    {
                        result = "Record is not saved";
                    }
                }
            }
            catch (Exception ex)
            {
                // Log Exception here.
                throw new Exception("Record is not saved");
            }

            return(result);
        }
        public string Save()
        {
            string result = string.Empty;

            try
            {
                using (var context = new ATSCEEntities())
                {
                    if (this.TimeSheetMasterId <= 0)
                    {
                        context.TimeSheetMasters.Add(this);
                    }
                    else
                    {
                        context.Entry(this).State = System.Data.EntityState.Modified;
                    }

                    context.SaveChanges();

                    foreach (TimeSheetDetail detail in this.TimeSheetDetail.ToList())
                    {
                        detail.Save();
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Record is not saved");
            }

            return(result);
        }
示例#5
0
 public static bool Delete(int leavePlanId)
 {
     try
     {
         ATSCEEntities context   = new ATSCEEntities();
         LeavePlan     leaveplan = context.LeavePlans.Find(leavePlanId);
         context.LeavePlans.Remove(leaveplan);
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public static bool Delete(int id)
 {
     try
     {
         ATSCEEntities   context = new ATSCEEntities();
         TimeSheetMaster master  = context.TimeSheetMasters.Find(id);
         context.TimeSheetMasters.Remove(master);
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
示例#7
0
        public static IEnumerable <LeavePlan> AdmitOrRejectLeaves(int LeavePlanId, bool AdmitReject)
        {
            ATSCEEntities context       = new ATSCEEntities();
            LeavePlan     leaveToUpdate = context.LeavePlans.Where(lp => lp.LeavePlanId == LeavePlanId).FirstOrDefault();

            if (AdmitReject)
            {
                leaveToUpdate.Admitted = true;
            }
            else
            {
                leaveToUpdate.Admitted = false;
            }
            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception("Could not admit or reject [" + ex.Message + "]");
            }

            return(GetAllLeavePlansBySupervisorId(int.Parse((leaveToUpdate.Person as Staff).SupervisorId.ToString())));
        }