예제 #1
0
        public static string GetAllPositionJSON(string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            LINQ_MasterDataContext dc = new LINQ_MasterDataContext();
            //Get current user info
            SYS_UserView current_user = Controller_User.GetUser(RequestID, RequestID);
            //Add into Query Statment
            var Query = (from c in dc.Mst_PositionViews
                         where c.Active == true
                         orderby c.PositionName
                         select new Mst_PositionView
            {
                PositionID = c.PositionID,
                PositionName = c.PositionName,
                PositionCode = c.PositionCode,
                Protocol = c.Protocol,
                Description = c.Description,
                Remark = c.Remark,
            }).ToList();
            string return_str = new JavaScriptSerializer().Serialize(Query);

            return(return_str);
        }
예제 #2
0
        public static string GetAllDepartmentJSON(string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            LINQ_MasterDataContext dc = new LINQ_MasterDataContext();
            //Get current user info
            SYS_UserView current_user = Controller_User.GetUser(RequestID, RequestID);
            //Security Check For AllDepartment
            string departmentID = "";

            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "allDepartment"))
            {
                departmentID = current_user.DepartmentID;
            }
            //Add into Query Statment
            var Query = (from c in dc.Mst_DepartmentViews
                         where c.Active == true && (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID))
                         orderby c.DepartmentName
                         select new Mst_DepartmentView
            {
                DepartmentID = c.DepartmentID,
                DepartmentName = c.DepartmentName,
                NotifyEmail = c.NotifyEmail,
                Protocol = c.Protocol,
                Description = c.Description,
                Remark = c.Remark,
            }).ToList();
            string return_str = new JavaScriptSerializer().Serialize(Query);

            return(return_str);
        }
예제 #3
0
        public static List <SYS_UserView> GetAllUser(string search_text, string org_id, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            SYS_UserView current_user = Controller_User.GetUser(RequestID, RequestID);
            //Security Check For AllDepartment
            string departmentID = "";

            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "allDepartment"))
            {
                departmentID = current_user.DepartmentID;
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            return((from c in dc.SYS_UserViews
                    where c.Active == true && (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID)) &&

                    ((search_text == "") ||
                     (search_text != "" && (
                          c.UserID.Contains(search_text) ||
                          c.UserCode.Contains(search_text) ||
                          c.UserName.Contains(search_text) ||
                          c.Email.Contains(search_text)
                          )))

                    orderby c.UserName
                    select c).ToList());
        }
예제 #4
0
        public static string GetAllRequestJSON(string search_text, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            //Get current user info
            SYS_UserView            current_user = Controller_User.GetUser(RequestID, RequestID);
            LINQ_MeetingDataContext dc           = new LINQ_MeetingDataContext();

            //Security Check For AllDepartment
            string departmentID = "";

            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "allDepartment"))
            {
                departmentID = current_user.DepartmentID;
            }

            List <MET_RequestView> the_requestlist = (from c in dc.MET_RequestViews
                                                      where c.Active == true && (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID)) &&
                                                      ((search_text == "") ||
                                                       (search_text != "" && (

                                                            c.RequestNo.Contains(search_text) ||
                                                            c.RequestStatus.Contains(search_text) ||
                                                            c.RequestTitle.Contains(search_text) ||
                                                            c.RequestType.Contains(search_text) ||
                                                            c.Description.Contains(search_text) ||
                                                            c.Remark.Contains(search_text) ||
                                                            c.DepartmentName.Contains(search_text))))
                                                      orderby c.CreatedOn descending
                                                      select c
                                                      ).ToList();
            var lists = new Newtonsoft.Json.Linq.JArray() as dynamic;

            foreach (var row in the_requestlist)
            {
                dynamic request = new Newtonsoft.Json.Linq.JObject();

                request.RequestID       = row.RequestID;
                request.DepartmentID    = row.DepartmentID;
                request.RequestType     = row.RequestType;
                request.RequestNo       = row.RequestNo;
                request.RequestUserName = row.RequestUserName;
                request.RequestTitle    = row.RequestTitle;
                request.RequestStatus   = row.RequestStatus;
                request.RequestOn       = row.RequestOn;
                request.DepartmentName  = row.DepartmentName;
                request.ApprovalStatus  = row.ApprovalStatus;
                lists.Add(request);
            }

            return(lists.ToString());
        }
예제 #5
0
        public static string ChangeCombineDecision(string agendaID, string meetingreq_id, string edited_decision, string user_id)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, user_id, "update"))
            {
                throw new Exception("No Access.");
            }

            LINQ_MeetingDataContext dc = new LINQ_MeetingDataContext();

            try
            {
                MET_Request request_record = new MET_Request();
                request_record = (from c in dc.MET_Requests where c.RequestID == meetingreq_id && c.Active == true select c).FirstOrDefault();
                if (request_record == null)
                {
                    return("Error~We can't find");
                }
                request_record.CombineDecision = edited_decision;
                request_record.ModifiedOn      = DateTime.Now;
                request_record.ModifiedBy      = user_id;
                request_record.LastAction      = Guid.NewGuid().ToString();

                dc.SubmitChanges(ConflictMode.ContinueOnConflict);

                #region get all request

                SYS_UserView current_user = Controller_User.GetUser(user_id, user_id);
                //Security Check For AllDepartment
                string departmentID = "";
                if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, user_id, "allDepartment"))
                {
                    departmentID = current_user.DepartmentID;
                }

                List <MET_RequestView> reqs_list = (from c in dc.MET_RequestViews
                                                    where c.Active == true && c.AgendaID == agendaID && (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID))
                                                    orderby c.Protocol ascending
                                                    select c).ToList();

                string return_str = new JavaScriptSerializer().Serialize(reqs_list);
                #endregion
                return("Success~" + return_str);
            }
            catch (ChangeConflictException ex)
            {
                return("Success~");
            }
        }
예제 #6
0
        public static List <Mst_PositionView> GetAllPosition(string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            SYS_UserView           current_user = Controller_User.GetUser(RequestID, RequestID);
            LINQ_MasterDataContext dc           = new LINQ_MasterDataContext();

            return((from c in dc.Mst_PositionViews
                    where c.Active == true
                    orderby c.PositionName
                    select c).ToList());
        }
예제 #7
0
        public static string GetAllAgendaJSON(string search_text, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            //Get current user info
            SYS_UserView            current_user = Controller_User.GetUser(RequestID, RequestID);
            LINQ_MeetingDataContext dc           = new LINQ_MeetingDataContext();

            //Security Check For AllDepartment
            string departmentID = "";

            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "allDepartment"))
            {
                departmentID = current_user.DepartmentID;
            }
            List <MET_AgendaView> the_agendalist = (from c in dc.MET_AgendaViews
                                                    where c.Active == true && (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID)) &&
                                                    ((search_text == "") ||
                                                     (search_text != "" && (

                                                          c.AgendaNo.Contains(search_text) ||
                                                          c.AgendaRemark.Contains(search_text) ||
                                                          c.AgendaStatus.Contains(search_text) ||
                                                          c.CUserCode.Contains(search_text) ||
                                                          c.MUserCode.Contains(search_text)
                                                          )))
                                                    orderby c.CreatedOn descending
                                                    select c
                                                    ).ToList();
            var lists = new Newtonsoft.Json.Linq.JArray() as dynamic;

            foreach (var row in the_agendalist)
            {
                dynamic agenda = new Newtonsoft.Json.Linq.JObject();

                agenda.AgendaID     = row.AgendaID;
                agenda.AgendaNo     = row.AgendaNo;
                agenda.AgendaDate   = row.AgendaDate.ToString();
                agenda.AgendaRemark = row.AgendaRemark;
                agenda.AgendaStatus = row.AgendaStatus;
                lists.Add(agenda);
            }

            return(lists.ToString());
        }
예제 #8
0
        public static string LoadRequestByAgendaID(string agendaID, string user_id)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, user_id, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_MeetingDataContext dc = new LINQ_MeetingDataContext();

            try
            {
                #region get all request
                //Security Check For AllDepartment
                SYS_UserView current_user = Controller_User.GetUser(user_id, user_id);
                string       departmentID = "";
                if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, user_id, "allDepartment"))
                {
                    departmentID = current_user.DepartmentID;
                }


                List <MET_RequestView> reqs_list = (from c in dc.MET_RequestViews
                                                    where c.Active == true && c.AgendaID == agendaID && (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID))
                                                    orderby c.Protocol ascending
                                                    select c).ToList();

                string return_str = new JavaScriptSerializer().Serialize(reqs_list);
                #endregion


                return("Success~" + return_str);
            }
            catch (Exception ex)
            {
                return("Success~");
            }
        }
예제 #9
0
        public static List <Mst_DepartmentView> GetAllDepartment(string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            SYS_UserView current_user = Controller_User.GetUser(RequestID, RequestID);

            //Security Check For AllDepartment
            string departmentID = "";

            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "allDepartment"))
            {
                departmentID = current_user.DepartmentID;
            }

            LINQ_MasterDataContext dc = new LINQ_MasterDataContext();

            return((from c in dc.Mst_DepartmentViews
                    where c.Active == true && (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID))
                    orderby c.DepartmentName descending
                    select c).ToList());
        }
예제 #10
0
        public static string GetAllUserRoleJSON(string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            //Get current user info
            SYS_UserView current_user = Controller_User.GetUser(RequestID, RequestID);
            //Add into Query Statment
            var Query = (from c in dc.SYS_UserRoleViews
                         where c.Active == true
                         orderby c.RoleName
                         select new SYS_UserRoleView
            {
                RoleID = c.RoleID,
                RoleCode = c.RoleCode,
                RoleName = c.RoleName,
            }).ToList();
            string return_str = new JavaScriptSerializer().Serialize(Query);

            return(return_str);
        }
예제 #11
0
        public static string AddRequestToAgenda(string agendaID, string user_id)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess("MeetingRequest", user_id, "update"))
            {
                throw new Exception("No Access.");
            }
            SYS_UserView            current_user = Controller_User.GetUser(user_id, user_id);
            LINQ_MeetingDataContext dc           = new LINQ_MeetingDataContext();

            try
            {
                MET_Agenda agenda_record = new MET_Agenda();
                string     return_str    = "";
                agenda_record = (from c in dc.MET_Agendas where c.AgendaID == agendaID && c.Active == true select c).FirstOrDefault();
                if (agenda_record == null)
                {
                    return("Error~We can't find");
                }


                #region Request in agenda
                //Security Check For AllDepartment
                string departmentID = "";
                if (!Controller_User_Access.CheckProgramAccess("MeetingRequest", user_id, "allDepartment"))
                {
                    departmentID = current_user.DepartmentID;
                }

                List <MET_Request> req_list = new List <MET_Request>();
                req_list = (from c in dc.MET_Requests where c.ApprovalStatus == "Approved" &&
                            (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID)) &&
                            c.Active == true select c).ToList();

                if (req_list.Count > 0)
                {
                    foreach (MET_Request i in req_list)
                    {
                        i.AgendaID      = agenda_record.AgendaID;
                        i.RequestStatus = "Agenda";
                        i.ModifiedBy    = user_id;
                        i.ModifiedOn    = DateTime.Now;
                    }

                    dc.SubmitChanges(ConflictMode.ContinueOnConflict);
                    #region get all request
                    List <MET_RequestView> reqs_list = (from c in dc.MET_RequestViews
                                                        where c.Active == true && c.AgendaID == agendaID &&
                                                        (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID))
                                                        orderby c.Protocol ascending
                                                        select c).ToList();

                    return_str = new JavaScriptSerializer().Serialize(reqs_list);
                    #endregion
                    return("Success~" + return_str);
                }
                else
                {
                    return("Error~" + "There is no approved requests!");
                }
                #endregion
            }
            catch (ChangeConflictException ex)
            {
                return("Success~");
            }
        }