Ejemplo n.º 1
0
        public string AcceptRejectDL(int id, string Option, string reason)
        {
            Request RequestObj = new Request();

            try
            {
                using (TrainingManagementEntities1 entityObject = new TrainingManagementEntities1())
                {
                    if (Option == "Accept")
                    {
                        RequestObj        = entityObject.Requests.Where(a => a.RequestID == id).Single();
                        RequestObj.Status = "Accepted";
                        RequestObj.Reason = reason;

                        entityObject.SaveChanges();
                    }
                    if (Option == "Reject")
                    {
                        RequestObj        = entityObject.Requests.Where(a => a.RequestID == id).Single();
                        RequestObj.Status = "Rejected";
                        RequestObj.Reason = reason;

                        entityObject.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return("Done");
        }
        public void ChangePasswordEmployee(int id, string pass)
        {
            try
            {
                Employee employeeobj = (from data in entityObject.Employees where data.EID == id select data).Single();
                employeeobj.Pwd = pass;

                entityObject.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 3
0
        public string  ChangePasswordDL(int ID, string OldPass, string NewPass)
        {
            string result = "";

            try
            {
                managerObject     = entityObj.Managers.Where(a => a.MID == ID && a.Pwd == OldPass).Single();
                managerObject.Pwd = NewPass;
                entityObj.SaveChanges();
                result = "changed";
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
        public int AddManager(string UserName, string Password, string Designition)
        {
            try
            {
                loginObject.UserName      = UserName;
                loginObject.Pwd           = Password;
                loginObject.Designation   = Designition;
                managerObject.UserName    = UserName;
                managerObject.Designation = Designition;

                contextObject.Logins.Add(loginObject);
                contextObject.Managers.Add(managerObject);
                contextObject.SaveChanges();
                return(1);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public void UpdateDatabase(int EmpID)
        {
            DateTime todayDate = System.DateTime.Now;

            try
            {
                List <Request> requestList = (from data in entityObject.Requests where data.EmployeeID == EmpID && (data.Status != "Requested" || data.Status != "Rejected" || data.Status != "Cancelled") select data).ToList();

                foreach (Request data in requestList)
                {
                    if (todayDate >= data.StartDate && todayDate < data.EndDate && data.Status != "Requested" && data.Status != "Rejected" && data.Status != "Cancelled")
                    {
                        data.Status = "On Going";
                    }
                    else if (todayDate >= data.EndDate && data.Status != "Requested" && data.Status != "Rejected" && data.Status != "Cancelled")
                    {
                        data.Status = "Completed";
                    }
                    else if (todayDate < data.StartDate && data.Status != "Requested" && data.Status != "Rejected" && data.Status != "Cancelled")
                    {
                        data.Status = "Accepted";
                    }
                    else
                    {
                    }
                }
                entityObject.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }