Beispiel #1
0
        public static SYS_OrganizationView GetOrganization(string org_id, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            return((from c in dc.SYS_OrganizationViews where c.OrgID == org_id && c.Active == true select c).FirstOrDefault());
        }
Beispiel #2
0
        public static List <SYS_GetOrganizationMenuGroupResult> GetOrganizationMenuGroup(string org_id, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            return(dc.SYS_GetOrganizationMenuGroup(org_id).ToList());
        }
Beispiel #3
0
        public static Mst_PositionView GetPosition(string pos_id, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_MasterDataContext dc = new LINQ_MasterDataContext();

            return((from c in dc.Mst_PositionViews where c.PositionID == pos_id && c.Active == true select c).FirstOrDefault());
        }
Beispiel #4
0
        public static MET_AgendaView GetAgendaByID(string agendaID, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_MeetingDataContext dc = new LINQ_MeetingDataContext();

            return((from c in dc.MET_AgendaViews where c.AgendaID == agendaID && c.Active == true select c).FirstOrDefault());
        }
        public static string GetAllMenuTreeViewByRole(string RoleID, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            string result                    = "";
            LINQ_SystemDataContext dc        = new LINQ_SystemDataContext();
            List <SYS_MenuView>    Menus     = (from c in dc.SYS_MenuViews where c.Active == true orderby c.MenuName descending select c).ToList();
            List <string>          roleMenus = (from c in dc.SYS_UserRoleMenus where c.RoleID == RoleID select c.MenuID).ToList();

            List <SYS_MenuView> GroupMenus = (from c in Menus where c.IsNode == true orderby c.MenuSeq select c).ToList();

            foreach (SYS_MenuView groupMenu in GroupMenus)
            {
                string classes = "";
                if (roleMenus.Contains(groupMenu.MenuID))
                {
                    result += "<ul ><li aria-selected='true' class='jstree-open'  id='" + groupMenu.MenuID + "' >" + groupMenu.MenuName;
                }
                else
                {
                    result += "<ul >  <li aria-selected='false' class='jstree-open'  id='" + groupMenu.MenuID + "' >" + groupMenu.MenuName;
                }
                List <SYS_MenuView> childMenus = (from c in Menus where c.NoteMenuID == groupMenu.MenuID && c.IsNode == false orderby c.MenuSeq select c).ToList();
                if (childMenus.Count > 0)
                {
                    result += "<ul>";


                    foreach (SYS_MenuView childMenu in childMenus)
                    {
                        if (roleMenus.Contains(childMenu.MenuID))
                        {
                            result += "<li data-jstree ='{\"opened\":true,\"selected\":true}' selected='selected' id='" + childMenu.MenuID + "' seq='" + childMenu.MenuSeq + "' > " + childMenu.MenuName + " </li>";
                        }
                        else
                        {
                            result += "<li data-jstree = '{\"type\":\"html\"}' id='" + childMenu.MenuID + "' seq='" + childMenu.MenuSeq + "' > " + childMenu.MenuName + " </li>";
                        }
                    }
                    result += "  </ul>";
                }
                result += "  </li>";
                result += "  </ul>";
            }
            return(result);
        }
Beispiel #6
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~");
            }
        }
Beispiel #7
0
        public static List <SYS_UserView> GetAllUserByOrganization(string orgId, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            return((from c in dc.SYS_UserViews
                    where c.Active == true && c.OrgID == orgId
                    orderby c.UserName
                    select c).ToList());
        }
Beispiel #8
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());
        }
Beispiel #9
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());
        }
Beispiel #10
0
        public static List <Object> GetLog(string RecordID, string RequestID, string PageNoString)
        {
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            int pageNo = 0;

            int.TryParse(PageNoString, out pageNo);

            //Get Skip Count
            int skip_count = (pageNo - 1) * RecordCountPerPage;

            var Query = (from c in dc.SysLogViews where c.RecordID == RecordID select c).OrderByDescending(x => x.LogDateTime);

            //Get Total Record Count
            int TotalCount = Query.Count();
            //GetTotal Number of Page
            int           TotalPage = (TotalCount / RecordCountPerPage) + (TotalCount % RecordCountPerPage == 0 ? 0 : 1);
            List <Object> result    = new List <object>();
            //Add overall pagination info on Index 0
            string previous_button = "y";

            if (pageNo == 1 || TotalPage == 1)
            {
                previous_button = "n";
            }
            string next_button = "y";

            if (pageNo == TotalPage)
            {
                next_button = "n";
            }
            if (TotalPage == 1)
            {
                previous_button = "n"; next_button = "n";
            }

            result.Add(TotalCount.ToString() + "~" + TotalPage.ToString() + "~" + pageNo.ToString() + "~" + previous_button + "~" + next_button);

            //Add Real Record Data from Index 1
            result.AddRange(new List <Object>(
                                Query
                                .Skip(skip_count).Take(RecordCountPerPage) // Add Skip and Take Function
                                .ToList()));
            return(result);
        }
Beispiel #11
0
        public static string GetAllRequestDecisionJson(string meeting_requsetID, string org_id, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_MeetingDataContext        dc = new LINQ_MeetingDataContext();
            List <MET_RequestDecisionView> reqdecision_list = (from c in dc.MET_RequestDecisionViews
                                                               where c.Active == true && c.RequestID == meeting_requsetID
                                                               orderby c.Seq
                                                               select c).ToList();
            string return_str = new JavaScriptSerializer().Serialize(reqdecision_list);

            return(return_str);
        }
Beispiel #12
0
        public static string GetAllUserByOrganizationJson(string orgId, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            List <SYS_UserView>    return_userlist = (from c in dc.SYS_UserViews
                                                      where c.Active == true && c.OrgID == orgId
                                                      orderby c.UserName
                                                      select c).ToList();

            string return_str = new JavaScriptSerializer().Serialize(return_userlist);

            return(return_str);
        }
Beispiel #13
0
        public static string DeleteAgenda(string agendaID, string user_id, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "delete"))
            {
                throw new Exception("No Access.");
            }

            LINQ_MeetingDataContext dc = new LINQ_MeetingDataContext();

            try
            {
                MET_Agenda agenda_record = new MET_Agenda();
                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");
                }
                agenda_record.Active     = false;
                agenda_record.ModifiedOn = DateTime.Now;
                agenda_record.ModifiedBy = user_id;
                agenda_record.LastAction = Guid.NewGuid().ToString();

                #region Request in agenda
                List <MET_Request> req_list = new List <MET_Request>();
                req_list = (from c in dc.MET_Requests where c.AgendaID == agendaID && c.Active == true select c).ToList();
                foreach (MET_Request i in req_list)
                {
                    i.AgendaID      = "";
                    i.RequestStatus = "Complete";
                    i.ModifiedBy    = RequestID;
                    i.ModifiedOn    = DateTime.Now;
                }
                #endregion

                dc.SubmitChanges(ConflictMode.ContinueOnConflict);
                return("Success~");
            }
            catch (ChangeConflictException ex)
            {
                return("Success~");
            }
        }
Beispiel #14
0
        public static string RequestApprove(string meetingreq_id, string status, string remark, string user_id)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, user_id, "decision"))
            {
                throw new Exception("No Access.");
            }
            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.ApprovalStatus = status;
                request_record.ApprovedBy     = user_id;
                request_record.ApprovedOn     = DateTime.Now;
                request_record.ApprovedRemark = remark;
                request_record.ModifiedOn     = DateTime.Now;
                request_record.ModifiedBy     = user_id;
                request_record.LastAction     = Guid.NewGuid().ToString();


                dc.SubmitChanges(ConflictMode.ContinueOnConflict);
                return("Success~" + request_record.ApprovalStatus + "~" + request_record.ApprovedRemark);
            }
            catch (ChangeConflictException ex)
            {
                return("Success~" + status + "~" + remark);
            }
        }
        public static string DeleteSysMenu(string menu_id, string user_id, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "delete"))
            {
                throw new Exception("No Access.");
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            SYS_Menu the_record       = (from sysm in dc.SYS_Menus where sysm.MenuID == menu_id && sysm.Active == true select sysm).FirstOrDefault();

            if (the_record == null)
            {
                return("Error ~ We can't find");
            }
            the_record.Active     = false;
            the_record.ModifiedOn = DateTime.Now;
            the_record.ModifiedBy = user_id;
            the_record.LastAction = Guid.NewGuid().ToString();
            dc.SubmitChanges();
            return("Success~");
        }
Beispiel #16
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~");
            }
        }
Beispiel #17
0
        public static List <SYS_ProgramView> GetAllProgram(string search_text, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            return((from c in dc.SYS_ProgramViews
                    where c.Active == true &&

                    ((search_text == "") ||
                     (search_text != "" && (
                          c.ProgramID.Contains(search_text) ||
                          c.ProgramName.Contains(search_text) ||
                          c.ProgramCode.Contains(search_text)
                          )))

                    orderby c.ProgramName
                    select c).ToList());
        }
Beispiel #18
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());
        }
Beispiel #19
0
        public static List <SYS_UserView> GetAllUserByAgent(string search_text, string agent_id, string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            return((from c in dc.SYS_UserViews
                    where c.Active == true &&
                    c.Ref_Type == "Agent" && c.Ref_ID == agent_id &&
                    ((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());
        }
Beispiel #20
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);
        }
        public static string SaveSysMenu(string menu_id, string user_id, string menu_name, string menu_label, string menu_icon,
                                         string menu_linkpage, string menu_onclick, string menu_seq, string is_node, string noteMenuID, string RequestID)
        {
            try
            {
                LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
                SYS_Menu the_record       = new SYS_Menu();
                if (menu_id == "" || menu_id == null)
                {
                    the_record = (from sysm in dc.SYS_Menus where sysm.MenuID == menu_id && sysm.Active == true select sysm).FirstOrDefault();
                    if (the_record == null)
                    {
                        //Security Check
                        if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "create"))
                        {
                            throw new Exception("No Access.");
                        }

                        the_record = new SYS_Menu()
                        {
                            CreatedBy  = user_id,
                            CreatedOn  = DateTime.Now,
                            Active     = true,
                            MenuID     = Guid.NewGuid().ToString(),
                            LastAction = Guid.NewGuid().ToString(),
                            NoteMenuID = Guid.NewGuid().ToString()
                        };
                        dc.SYS_Menus.InsertOnSubmit(the_record);
                    }
                }
                else
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = (from sysm in dc.SYS_Menus where sysm.MenuID == menu_id && sysm.Active == true select sysm).FirstOrDefault();
                    if (the_record == null)
                    {
                        throw new Exception("System cannot find the record");
                    }
                }
                the_record.ModifiedBy = user_id;
                the_record.ModifiedOn = DateTime.Now;
                the_record.LastAction = Guid.NewGuid().ToString();

                the_record.MenuName     = menu_name;
                the_record.MenuLabel    = menu_label;
                the_record.IconClass    = menu_icon;
                the_record.MenuLinkPage = menu_linkpage;
                the_record.MenuOnClick  = menu_onclick;
                the_record.MenuSeq      = Convert.ToDecimal(menu_seq.ToString());

                if (is_node == "true")
                {
                    the_record.IsNode     = true;
                    the_record.NoteMenuID = "";
                }
                else
                {
                    the_record.IsNode     = false;
                    the_record.NoteMenuID = noteMenuID;
                }

                dc.SubmitChanges();
                return("Success~" + the_record.MenuName);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
Beispiel #22
0
        public static string SaveImage(string ImageURL, string ImagePath, string ImageName, string RefID, string RefType, string UserID)
        {
            try
            {
                LINQ_MasterDataContext dc = new LINQ_MasterDataContext();
                Mst_Image the_record      = new Mst_Image();
                //Security Check
                if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, UserID, "create"))
                {
                    throw new Exception("No Access.");
                }
                string delete_result = "";
                switch (RefType)
                {
                case "user":
                    delete_result = DeleteImages(RefID, RefType, UserID);
                    break;

                case "department":
                    delete_result = DeleteImages(RefID, RefType, UserID);
                    break;

                default:
                    delete_result = "Success~";
                    break;
                }
                if (delete_result == "Success~")
                {
                    the_record = new Mst_Image()
                    {
                        CreatedBy  = UserID,
                        CreatedOn  = DateTime.Now,
                        Active     = true,
                        ImageID    = Guid.NewGuid().ToString(),
                        ModifiedBy = UserID,
                        ModifiedOn = DateTime.Now,
                        LastAction = Guid.NewGuid().ToString(),
                        ImageName  = ImageName,
                        ImageURL   = ImageURL,
                        ImagePath  = ImagePath,
                        RefID      = RefID,
                        RefType    = RefType,
                    };
                    dc.Mst_Images.InsertOnSubmit(the_record);
                    dc.SubmitChanges();

                    if (RefType == "Logo")
                    {
                        the_record.ImageData = ImageToBinary(ImagePath);
                    }
                    dc.SubmitChanges();
                    return("Success~");
                }
                else
                {
                    return("Error~" + delete_result);
                }
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
Beispiel #23
0
        public static string SaveOrganization(string org_id, string user_id, string org_name, string org_code, string orgType,
                                              string joint_date, string expiry_date, string InvoiceAccountName, string InvoiceAccountNo, string user_count, string orgplan,
                                              string Website, string Facebook, string Email, string PhoneNo, string Address, string InvoiceType,
                                              string remark, string remark1, string RequestID)
        {
            try
            {
                LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

                DateTime Joint_Date = DateTime.Today;
                DateTime.TryParseExact(joint_date, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out Joint_Date);

                DateTime Expiry_Date = DateTime.Today;
                DateTime.TryParseExact(expiry_date, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out Expiry_Date);


                SYS_Organization the_record = new SYS_Organization();
                if (org_id == "" || org_id == null)
                {
                    the_record = (from c in dc.SYS_Organizations where c.OrgID == org_id && c.Active == true select c).FirstOrDefault();
                    if (the_record == null)
                    {
                        //Security Check
                        if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "create"))
                        {
                            throw new Exception("No Access.");
                        }

                        the_record = new SYS_Organization()
                        {
                            CreatedBy  = user_id,
                            CreatedOn  = DateTime.Now,
                            Active     = true,
                            OrgID      = Guid.NewGuid().ToString(),
                            LastAction = Guid.NewGuid().ToString()
                        };
                        dc.SYS_Organizations.InsertOnSubmit(the_record);
                    }
                    else
                    {
                        return("Error~Duplicate Organization Name");
                    }
                }
                else
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = (from c in dc.SYS_Organizations where c.OrgID == org_id select c).FirstOrDefault();
                    if (the_record == null)
                    {
                        throw new Exception("System cannot find the record");
                    }
                }
                the_record.ModifiedBy = user_id;
                the_record.ModifiedOn = DateTime.Now;
                the_record.LastAction = Guid.NewGuid().ToString();
                the_record.OrgType    = orgType;

                the_record.OrgName = org_name;
                the_record.OrgCode = org_code;

                the_record.JointDate  = Joint_Date;
                the_record.ExpiryDate = Expiry_Date;
                the_record.UserCount  = user_count;
                the_record.OrgPlan    = org_code;

                the_record.Website     = Website;
                the_record.Facebook    = Facebook;
                the_record.Email       = Email;
                the_record.PhoneNo     = PhoneNo;
                the_record.Address     = Address;
                the_record.InvoiceType = InvoiceType;

                the_record.Remark             = remark;
                the_record.Remark1            = remark1;
                the_record.InvoiceAccountName = InvoiceAccountName;
                the_record.InvoiceAccountNo   = InvoiceAccountNo;

                #region update the log

                SYS_Organization log_obj = dc.GetChangeSet().Updates.OfType <SYS_Organization>().FirstOrDefault();
                if (log_obj != null)
                {
                    if (Controller_SystemLog.WirteUpdateLog(dc.SYS_Organizations.GetModifiedMembers(log_obj).ToList(), org_id, RequestID) == false)
                    {
                        //Error fail to log.
                    }
                }
                #endregion


                dc.SubmitChanges();
                return("Success~" + the_record.OrgID);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
        public static List <Object> GetAllSysMenuWithPagination(string search_text, string search_sysmenu, string RequestID, string PageNoString)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }

            int pageNo = 0; int.TryParse(PageNoString, out pageNo);

            //Get Skip Count
            int skip_count = (pageNo - 1) * RecordCountPerPage;

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            //Add into Query Statment
            var Query = (from sysm in dc.SYS_MenuViews
                         where sysm.Active == true &&
                         ((search_text == "") ||
                          (search_text != "" && (
                               sysm.MenuName.Contains(search_text) ||
                               sysm.MenuLabel.ToString().Contains(search_text)
                               ))) &&
                         ((search_sysmenu == "") ||
                          (search_sysmenu != "" && (
                               sysm.MenuName.Contains(search_sysmenu) ||
                               sysm.MenuLabel.ToString().Contains(search_sysmenu)
                               )))
                         orderby sysm.MenuName
                         select sysm);

            //Get Total Record Count
            int TotalCount = Query.Count();
            //Get Total Number of Page
            int TotalPage = (TotalCount / RecordCountPerPage) + (TotalCount % RecordCountPerPage == 0 ? 0 : 1);

            List <Object> result = new List <object>();
            //Add overall pagination info on Index 0
            string previous_button = "y";

            if (pageNo == 1 || TotalPage == 1)
            {
                previous_button = "n";
            }
            string next_button = "y";

            if (pageNo == TotalPage)
            {
                next_button = "n";
            }
            if (TotalPage == 1)
            {
                previous_button = "n"; next_button = "n";
            }

            result.Add(TotalCount.ToString() + "~" + TotalPage.ToString() + "~" + pageNo.ToString() + "~" + previous_button + "~" + next_button);

            //Add Real Record Data from Index 1
            result.AddRange(new List <Object>(
                                Query
                                .Skip(skip_count).Take(RecordCountPerPage) // Add Skip and Take Function
                                .ToList()));
            return(result);
        }
Beispiel #25
0
        public static string SaveDepartment(string dep_id, string user_id, string department_name, string notifyemail, string protocol, string description, string remark, string RequestID)
        {
            try
            {
                LINQ_MasterDataContext dc         = new LINQ_MasterDataContext();
                Mst_Department         the_record = new Mst_Department();
                if (dep_id == "" || dep_id == null)
                {
                    the_record = (from c in dc.Mst_Departments where c.DepartmentName == department_name && c.Active == true && ((dep_id == "") || (dep_id != "" && c.DepartmentID != dep_id)) select c).FirstOrDefault();
                    if (the_record == null)
                    {
                        //Security Check
                        if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "create"))
                        {
                            throw new Exception("No Access.");
                        }

                        the_record = new Mst_Department()
                        {
                            CreatedBy    = user_id,
                            CreatedOn    = DateTime.Now,
                            Active       = true,
                            DepartmentID = Guid.NewGuid().ToString(),
                            LastAction   = Guid.NewGuid().ToString()
                        };
                        dc.Mst_Departments.InsertOnSubmit(the_record);
                        dep_id = the_record.DepartmentID;
                    }
                    else
                    {
                        return("Error~Duplicate Department Name");
                    }
                }
                else
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = (from c in dc.Mst_Departments where c.DepartmentID == dep_id select c).FirstOrDefault();
                    if (the_record == null)
                    {
                        throw new Exception("System cannot find the record");
                    }
                }
                the_record.ModifiedBy     = user_id;
                the_record.ModifiedOn     = DateTime.Now;
                the_record.LastAction     = Guid.NewGuid().ToString();
                the_record.DepartmentName = department_name;
                the_record.NotifyEmail    = notifyemail;
                the_record.Protocol       = string.IsNullOrEmpty(protocol) ? 0:Convert.ToDecimal(protocol);
                the_record.Description    = string.IsNullOrEmpty(description) ? "" : description.Replace("%27", "");
                the_record.Remark         = string.IsNullOrEmpty(remark) ? "" : remark.Replace("%27", "");
                dc.SubmitChanges();
                return("Success~" + the_record.DepartmentID);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
        public static string SaveSysMenuGroup(string menugp_id, string user_id, string menu_gpcode, string menu_gpname, string menu_gpseq, string RequestID)
        {
            try
            {
                LINQ_SystemDataContext dc         = new LINQ_SystemDataContext();
                SYS_MenuGroup          the_record = new SYS_MenuGroup();
                if (menugp_id == "" || menugp_id == null)
                {
                    the_record = (from sysmgp in dc.SYS_MenuGroups where sysmgp.MenuGroupID == menugp_id && sysmgp.Active == true select sysmgp).FirstOrDefault();
                    if (the_record == null)
                    {
                        //Security Check
                        if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "create"))
                        {
                            throw new Exception("No Access.");
                        }

                        the_record = new SYS_MenuGroup()
                        {
                            CreatedBy   = user_id,
                            CreatedOn   = DateTime.Now,
                            Active      = true,
                            MenuGroupID = Guid.NewGuid().ToString(),
                            LastAction  = Guid.NewGuid().ToString()
                        };
                        dc.SYS_MenuGroups.InsertOnSubmit(the_record);
                    }
                }
                else
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = (from sysmgp in dc.SYS_MenuGroups where sysmgp.MenuGroupID == menugp_id && sysmgp.Active == true select sysmgp).FirstOrDefault();
                    if (the_record == null)
                    {
                        throw new Exception("System cannot find the record");
                    }
                }

                the_record.ModifiedBy = user_id;
                the_record.ModifiedOn = DateTime.Now;
                the_record.LastAction = Guid.NewGuid().ToString();

                the_record.MenuGroupCode = menu_gpcode;
                the_record.MenuGroupName = menu_gpname;
                the_record.MenuGroupSeq  = Convert.ToInt32(menu_gpseq.ToString());

                #region update the log

                SYS_MenuGroup log_obj = dc.GetChangeSet().Updates.OfType <SYS_MenuGroup>().FirstOrDefault();
                if (log_obj != null)
                {
                    if (Controller_SystemLog.WirteUpdateLog(dc.SYS_MenuGroups.GetModifiedMembers(log_obj).ToList(), the_record.MenuGroupID, RequestID) == false)
                    {
                        //Error fail to log.
                    }
                }
                #endregion


                dc.SubmitChanges();
                return("Success~" + the_record.MenuGroupName);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
Beispiel #27
0
        public static string SetOrganizationMenuGroup(string org_id, string menugp_id, string type, string data, string RequestID)
        {
            try
            {
                LINQ_SystemDataContext    dc         = new LINQ_SystemDataContext();
                SYS_OrganizationMenuGroup the_record = (from c in dc.SYS_OrganizationMenuGroups where c.OrgID == org_id && c.MenuGroupID == menugp_id && c.Active == true select c).FirstOrDefault();
                if (the_record == null)
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = new SYS_OrganizationMenuGroup()
                    {
                        OrgMenuGroupID = Guid.NewGuid().ToString(),
                        OrgID          = org_id,
                        MenuGroupID    = menugp_id,
                        CreatedBy      = RequestID,
                        CreatedOn      = DateTime.Now,
                        Active         = true,
                        LastAction     = Guid.NewGuid().ToString()
                    };
                    dc.SYS_OrganizationMenuGroups.InsertOnSubmit(the_record);
                }

                if (type == "create")
                {
                    if (data == "true")
                    {
                        the_record.AllowCreate = true;
                    }
                    else
                    {
                        the_record.AllowCreate = false;
                    }
                }
                if (type == "view")
                {
                    if (data == "true")
                    {
                        the_record.AllowView = true;
                    }
                    else
                    {
                        the_record.AllowView = false;
                    }
                }
                if (type == "update")
                {
                    if (data == "true")
                    {
                        the_record.AllowUpdate = true;
                    }
                    else
                    {
                        the_record.AllowUpdate = false;
                    }
                }
                if (type == "delete")
                {
                    if (data == "true")
                    {
                        the_record.AllowDelete = true;
                    }
                    else
                    {
                        the_record.AllowDelete = false;
                    }
                }

                the_record.ModifiedBy = RequestID;
                the_record.ModifiedOn = DateTime.Now;
                the_record.LastAction = Guid.NewGuid().ToString();

                dc.SubmitChanges(ConflictMode.ContinueOnConflict);
                return("Success~");
            }
            catch (ChangeConflictException ex)
            {
                return("Error~" + ex.Message);
            }
        }
Beispiel #28
0
        public static List <Object> GetAllOrganizationWithPagination(string search_text, string search_org, string RequestID, string PageNoString)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }


            //Check Agent Access
            LINQ_SystemDataContext dc_system = new LINQ_SystemDataContext();
            SYS_UserView           the_user  = (from c in dc_system.SYS_UserViews where c.UserID == RequestID select c).FirstOrDefault();

            if (the_user == null)
            {
                throw new Exception("System cannot find the user");
            }

            int pageNo = 0; int.TryParse(PageNoString, out pageNo);

            //Get Skip Count
            int skip_count = (pageNo - 1) * RecordCountPerPage;

            LINQ_SystemDataContext dc  = new LINQ_SystemDataContext();
            SYS_Organization       org = new SYS_Organization();
            //Add into Query Statment
            var Query = (from c in dc.SYS_OrganizationViews
                         where c.Active == true &&
                         ((search_text == "") ||
                          (search_text != "" && (

                               c.LastAction.Contains(search_text) ||
                               c.OrgName.Contains(search_text) ||
                               c.OrgCode.Contains(search_text) ||
                               c.UserCount.Contains(search_text) ||
                               c.OrgPlan.Contains(search_text)

                               ))) &&
                         ((search_org == "") ||
                          (search_org != "" && (

                               c.LastAction.Contains(search_org) ||
                               c.OrgName.Contains(search_org) ||
                               c.OrgCode.Contains(search_org) ||
                               c.UserCount.Contains(search_org) ||
                               c.OrgPlan.Contains(search_org)

                               )))
                         select c).OrderByDescending(x => x.OrgName);

            //Get Total Record Count
            int TotalCount = Query.Count();
            //Get Total Number of Page
            int TotalPage = (TotalCount / RecordCountPerPage) + (TotalCount % RecordCountPerPage == 0 ? 0 : 1);

            List <Object> result = new List <object>();
            //Add overall pagination info on Index 0
            string previous_button = "y";

            if (pageNo == 1 || TotalPage == 1)
            {
                previous_button = "n";
            }
            string next_button = "y";

            if (pageNo == TotalPage)
            {
                next_button = "n";
            }
            if (TotalPage == 1)
            {
                previous_button = "n"; next_button = "n";
            }

            result.Add(TotalCount.ToString() + "~" + TotalPage.ToString() + "~" + pageNo.ToString() + "~" + previous_button + "~" + next_button);

            //Add Real Record Data from Index 1
            result.AddRange(new List <Object>(
                                Query
                                .Skip(skip_count).Take(RecordCountPerPage) // Add Skip and Take Function
                                .ToList()));
            return(result);
        }
Beispiel #29
0
        public static string SaveUser(
            string record_id, string user_id, string user_code, string user_name,
            string user_email, string password, string contactinfo, string note, string role_id, string dep_id, string pos_id,
            string RequestID)
        {
            try
            {
                LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
                SYS_User     the_record   = new SYS_User();
                SYS_UserView the_view     = new SYS_UserView();
                if (record_id == "" || record_id == null)
                {
                    the_record = (from c in dc.SYS_Users where c.UserCode == user_code && c.Active == true && ((user_id == "") || (user_id != "" && c.UserID != user_id)) select c).FirstOrDefault();
                    if (the_record == null)
                    {
                        //Security Check
                        if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "create"))
                        {
                            throw new Exception("No Access.");
                        }

                        string encryptpassword = Controller_TextEncryption.Encrypt(password, "");

                        the_record = new SYS_User()
                        {
                            Password   = encryptpassword,
                            LastLogin  = DateTime.Now,
                            CreatedBy  = user_id,
                            CreatedOn  = DateTime.Now,
                            Active     = true,
                            UserID     = Guid.NewGuid().ToString(),
                            LastAction = Guid.NewGuid().ToString(),
                            Ref_ID     = "",
                            IsLoggedIn = true,
                            Ref_Type   = "",
                            OrgID      = "",
                        };
                        dc.SYS_Users.InsertOnSubmit(the_record);
                    }
                    else
                    {
                        return("DuplicateCode~");
                    }
                }
                else
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = (from c in dc.SYS_Users where c.UserID == record_id select c).FirstOrDefault();
                    if (the_record == null)
                    {
                        throw new Exception("System cannot find the record");
                    }
                }

                the_record.ModifiedBy   = user_id;
                the_record.ModifiedOn   = DateTime.Now;
                the_record.LastAction   = Guid.NewGuid().ToString();
                the_record.UserName     = user_name;
                the_record.UserCode     = user_code;
                the_record.Email        = user_email;
                the_record.ContactInfo  = contactinfo;
                the_record.Note         = note;
                the_record.RoleID       = role_id;
                the_record.DepartmentID = dep_id;
                the_record.PositionID   = pos_id;
                dc.SubmitChanges();
                return("Success~" + the_record.UserID);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
Beispiel #30
0
        public static string SaveRequest(
            string RequestID,
            string DepartmentID,
            string RequestType,
            string RequestNo,
            string RequestBy,
            string RequestTitle,
            string RequestStatus,
            string RequestOn,
            string MeetingID,
            string Remark,
            string ApprovedBy,
            string ApprovedOn,
            string ApprovedRemark,
            string Description,
            string UserID,
            string Requestitems,
            string RequestDecisions)
        {
            try
            {
                //Security Check
                if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, UserID, "read"))
                {
                    throw new Exception("No Access.");
                }

                LINQ_MeetingDataContext dc          = new LINQ_MeetingDataContext();
                MET_Request             the_request = new MET_Request();

                if (RequestID == "")
                {
                    the_request = new MET_Request()
                    {
                        Active    = true,
                        CreatedBy = UserID,
                        CreatedOn = DateTime.Now,
                        RequestID = Guid.NewGuid().ToString(),
                        RequestNo = Controller_RunningNo.GetNewRunningCode("Request", UserID),


                        ApprovedBy     = "",
                        ApprovedOn     = DateTime.Now,
                        ApprovedRemark = "",
                        ApprovalStatus = ""
                    };
                    RequestID = the_request.RequestID;
                    dc.MET_Requests.InsertOnSubmit(the_request);
                }
                else
                {
                    the_request = (from c in dc.MET_Requests where c.RequestID == RequestID select c).FirstOrDefault();
                    if (the_request == null)
                    {
                        throw new Exception("System cannot find the record.");
                    }
                }

                DateTime request_on = DateTime.Today;
                DateTime.TryParseExact(RequestOn, "yyyy/M/d", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out request_on);
                the_request.RequestType  = RequestType;
                the_request.RequestBy    = RequestBy;
                the_request.RequestTitle = RequestTitle;
                the_request.DepartmentID = DepartmentID;

                the_request.RequestStatus = RequestStatus;
                the_request.RequestOn     = request_on;
                the_request.AgendaID      = MeetingID;
                the_request.Remark        = Remark.Replace("%27", "");
                the_request.Description   = Description.Replace("%27", "");

                the_request.ModifiedBy = UserID;
                the_request.ModifiedOn = DateTime.Now;
                the_request.LastAction = Guid.NewGuid().ToString();


                #region Clear previous items
                List <MET_RequestItem> req_old_items = (from c in dc.MET_RequestItems
                                                        where c.RequestID == the_request.RequestID &&
                                                        c.Active == true
                                                        select c).ToList();
                if (req_old_items != null)
                {
                    dc.MET_RequestItems.DeleteAllOnSubmit(req_old_items);
                }
                #endregion


                #region Request Items

                if (Requestitems != "")
                {
                    List <MET_RequestItem> request_items = new List <MET_RequestItem>();
                    List <string>          items         = Requestitems.Split('~').ToList();
                    foreach (string item in items)
                    {
                        if (item != "")
                        {
                            List <string> itemInfo = item.Split('^').ToList();

                            request_items.Add(new MET_RequestItem()
                            {
                                CreatedBy     = UserID,
                                CreatedOn     = DateTime.Now,
                                ModifiedBy    = UserID,
                                ModifiedOn    = DateTime.Now,
                                Active        = true,
                                LastAction    = Guid.NewGuid().ToString(),
                                RequestID     = the_request.RequestID,
                                RequestItemID = itemInfo[0],
                                RequestItem   = itemInfo[1],
                                Seq           = convertToDecimal(itemInfo[2]),
                            });
                        }
                    }
                    dc.MET_RequestItems.InsertAllOnSubmit(request_items);
                }

                #endregion

                #region Request Decision

                #region Clear previous items
                List <MET_RequestDecision> req_old_decisions = (from c in dc.MET_RequestDecisions
                                                                where c.RequestID == the_request.RequestID &&
                                                                c.Active == true
                                                                select c).ToList();
                if (req_old_decisions != null)
                {
                    dc.MET_RequestDecisions.DeleteAllOnSubmit(req_old_decisions);
                }
                #endregion
                if (RequestDecisions != "")
                {
                    List <MET_RequestDecision> request_decisions = new List <MET_RequestDecision>();
                    List <string> decisions         = RequestDecisions.Split('~').ToList();
                    string[]      combine_decisions = new string[decisions.Count];
                    int           count             = 0;
                    foreach (string decision in decisions)
                    {
                        if (decision != "")
                        {
                            List <string> decisionInfo = decision.Split('^').ToList();

                            request_decisions.Add(new MET_RequestDecision()
                            {
                                CreatedBy         = UserID,
                                CreatedOn         = DateTime.Now,
                                ModifiedBy        = UserID,
                                ModifiedOn        = DateTime.Now,
                                Active            = true,
                                LastAction        = Guid.NewGuid().ToString(),
                                RequestID         = the_request.RequestID,
                                RequestDecisionID = decisionInfo[0],
                                Description       = decisionInfo[1],
                                Seq = convertToDecimal(decisionInfo[2]),
                            });
                            combine_decisions[count] = decisionInfo[1];
                            count++;
                        }
                    }

                    dc.MET_RequestDecisions.InsertAllOnSubmit(request_decisions);
                    the_request.CombineDecision = string.Join(",", combine_decisions);
                }

                #endregion

                #region update the log for POS_SellVouncher

                MET_Request log_obj = dc.GetChangeSet().Updates.OfType <MET_Request>().FirstOrDefault();
                if (log_obj != null)
                {
                    if (Controller_SystemLog.WirteUpdateLog(dc.MET_Requests.GetModifiedMembers(log_obj).ToList(), RequestID, UserID) == false)
                    {
                        //Error fail to log.
                    }
                }
                #endregion
                dc.SubmitChanges();

                do_populate_print_description(the_request.RequestID);

                //#region Conbine Decisions
                //the_request.CombineDecision = dc.MET_CombineDecisionsOfRequest(the_request.RequestID).ToString();
                //#endregion
                //dc.SubmitChanges();

                return("Success~" + the_request.RequestID + "~" + the_request.RequestNo);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }