示例#1
0
        public static SYS_UserView Do_Agent_Login(string usercode, string password)
        {
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            string encryptpassword    = Controller_TextEncryption.Encrypt(password, "");

            return((from c in dc.SYS_UserViews where (c.Email.ToLower() == usercode.ToLower() || c.UserCode.ToLower() == usercode.ToLower()) && c.Active == true && c.Password == encryptpassword select c).FirstOrDefault());
        }
示例#2
0
        public static string GetAllUserJson(string RequestID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "read"))
            {
                throw new Exception("No Access.");
            }
            SYS_UserView current_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();
            List <SYS_UserView>    user_list = (from c in dc.SYS_UserViews
                                                where c.Active == true && (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID))
                                                orderby c.UserName
                                                select new SYS_UserView
            {
                UserID = c.UserID,
                UserCode = c.UserCode,
                UserName = c.UserName,
                RoleName = c.RoleName,
                Email = c.Email,
                PositionName = c.PositionName,
                DepartmentName = c.DepartmentName
            }).ToList();
            string return_str = new JavaScriptSerializer().Serialize(user_list);

            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());
        }
        public static string DeleteSysMenuGroup(string menugp_id, string user_id, string RequestID)
        {
            try
            {
                //Security Check
                if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "delete"))
                {
                    throw new Exception("No Access.");
                }

                LINQ_SystemDataContext dc         = new LINQ_SystemDataContext();
                SYS_MenuGroup          the_record = (from sysmgp in dc.SYS_MenuGroups where sysmgp.MenuGroupID == menugp_id && sysmgp.Active == true select sysmgp).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~");
            }
            catch (ChangeConflictException ex)
            {
                return("Error~" + ex.Message);
            }
        }
示例#5
0
        public static string SaveProgram(string record_id, string user_id, string program_name, string program_code, string RequestID)
        {
            try
            {
                LINQ_SystemDataContext dc         = new LINQ_SystemDataContext();
                SYS_Program            the_record = new SYS_Program();
                if (record_id == "" || record_id == null)
                {
                    the_record = (from c in dc.SYS_Programs where c.ProgramCode == program_code && 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_Program()
                        {
                            CreatedBy  = user_id,
                            CreatedOn  = DateTime.Now,
                            Active     = true,
                            ProgramID  = Guid.NewGuid().ToString(),
                            LastAction = Guid.NewGuid().ToString()
                        };
                        dc.SYS_Programs.InsertOnSubmit(the_record);
                    }
                    else
                    {
                        return("Error~Duplicate Country Code");
                    }
                }
                else
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = (from c in dc.SYS_Programs where c.ProgramID == 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.ProgramName = program_name;
                the_record.ProgramCode = program_code;
                dc.SubmitChanges();
                return("Success~" + the_record.ProgramID);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
示例#6
0
        public static string GetAllMenuTreeView(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 <SYS_MenuView> GroupMenus = (from c in Menus where c.IsNode == true orderby c.MenuSeq select c).ToList();

            foreach (SYS_MenuView groupMenu in GroupMenus)
            {
                result += "<ul >  <li 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)
                    {
                        result += "<li data-jstree = '{\"type\":\"html\"}' id='" + childMenu.MenuID + "' seq='" + childMenu.MenuSeq + "' > " + childMenu.MenuName + " </li>";
                    }
                    result += "  </ul>";
                }
                result += "  </li>";
                result += "  </ul>";
            }
            return(result);
        }
示例#7
0
        public static string DeleteUser(string record_id, string user_id, string RequestID)
        {
            try
            {
                //Security Check
                if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "delete"))
                {
                    throw new Exception("No Access.");
                }

                LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
                SYS_User the_record       = (from c in dc.SYS_Users where c.UserID == record_id && c.Active == true select c).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(ConflictMode.ContinueOnConflict);
                return("Success~");
            }
            catch (ChangeConflictException ex)
            {
                return("Success~");
            }
        }
示例#8
0
        public static String SendEmail(string to_mail_address, string subject, string body, List <Attachment> the_attachments, string bcc)
        {
            try
            {
                LINQ_SystemDataContext dc         = new LINQ_SystemDataContext();
                SYS_Config             the_config = (from c in dc.SYS_Configs select c).FirstOrDefault();
                if (the_config == null)
                {
                    return("Error: No Config.");
                }

                string Smtp_ClientValue         = the_config.DefaultEmailClient;
                string Smtp_Credential_Password = the_config.DefaultEmailPassword;
                string Smtp_Credential_UserName = the_config.DefaultEmailAddress;

                MailMessage mailObj = new MailMessage(Smtp_Credential_UserName, to_mail_address, subject, body);


                if (!string.IsNullOrEmpty(bcc))
                {
                    mailObj.Bcc.Add(bcc);
                }

                mailObj.Priority     = MailPriority.High;
                mailObj.BodyEncoding = System.Text.Encoding.UTF8;
                if (the_attachments != null)
                {
                    foreach (Attachment the_attachment in the_attachments)
                    {
                        mailObj.Attachments.Add(the_attachment);
                    }
                }

                mailObj.IsBodyHtml = true;
                SmtpClient SMTPServer = new SmtpClient(Smtp_ClientValue);
                SMTPServer.Port                  = 587;
                SMTPServer.EnableSsl             = true;
                SMTPServer.Timeout               = 10000;
                SMTPServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
                SMTPServer.UseDefaultCredentials = true;

                SMTPServer.Credentials = new NetworkCredential(Smtp_Credential_UserName, Smtp_Credential_Password);
                try
                {
                    SMTPServer.Send(mailObj);
                    return("success");
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
示例#9
0
        public static List <SYS_Organization> GetOrganizations()
        {
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            var the_organizations     = (from c in dc.SYS_Organizations
                                         where c.Active == true
                                         select c).ToList();

            return(the_organizations);
        }
示例#10
0
        public static List <SYS_UserRoleMenu> GetUserRoleMenu(string role_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_UserRoleMenus where c.RoleID == role_id select c).ToList());
        }
示例#11
0
        public static string do_getorganization(string email)
        {
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            var org = (from c in dc.SYS_UserViews where c.Email == email select c).FirstOrDefault();

            if (org != null)
            {
                return("Success~" + org.OrgID);
            }
            return(string.Empty);
        }
示例#12
0
        private static bool IsSystemUserAlreadyExistByEmail(string email)
        {
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            SYS_User result           = (from c in dc.SYS_Users where c.Active && c.Email == email select c).FirstOrDefault();

            if (result != null)
            {
                return(true);
            }
            return(false);
        }
示例#13
0
        public static SYS_MenuView GetSysMenu(string menu_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 sysm in dc.SYS_MenuViews where sysm.MenuID == menu_id && sysm.Active == true select sysm).FirstOrDefault());
        }
示例#14
0
        public static SYS_ProgramView GetProgram(string record_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_ProgramViews where c.ProgramID == record_id && c.Active == true select c).FirstOrDefault());
        }
示例#15
0
        public static SYS_UserView GetProfileUser(string userID)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, userID, "read"))
            {
                throw new Exception("No Access.");
            }

            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            return((from c in dc.SYS_UserViews where c.UserID == userID && c.Active == true select c).FirstOrDefault());
        }
示例#16
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());
        }
示例#17
0
        public static List <SYS_MenuView> GetAllMenu(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_MenuViews where c.Active == true orderby c.MenuName descending select c).ToList());
        }
示例#18
0
        public static string do_signup(string fname, string lname, string orgid, string email, string password, string provider)
        {
            var result = Controllers.Controller_Common.do_verifyemail(email);

            if (result != "ok")
            {
                return("Error~ Your email address is invalid!");
            }

            if (IsSystemUserAlreadyExistByEmail(email))
            {
                return("Error~ This email address is already registered!");
            }

            try
            {
                string encryptpassword    = provider == "sbs"? Controller_TextEncryption.Encrypt(password, ""):string.Empty;
                LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
                SYS_User the_record       = new SYS_User
                {
                    UserID      = Guid.NewGuid().ToString(),
                    UserName    = fname.Trim() + " " + lname.Trim(),
                    UserCode    = string.Empty,
                    Email       = email,
                    OrgID       = orgid,
                    Password    = encryptpassword,
                    ContactInfo = string.Empty,
                    CreatedBy   = "4",
                    CreatedOn   = DateTime.Now,
                    ModifiedBy  = "4",
                    ModifiedOn  = DateTime.Now,
                    RoleID      = "32232403-daa3-4a09-9615-a88285ba3735",
                    LastAction  = Guid.NewGuid().ToString(),
                    LastLogin   = DateTime.Now,
                    Active      = true,
                    Note        = string.Empty,
                    Ref_ID      = string.Empty,
                    Ref_Type    = string.Empty
                };

                dc.SYS_Users.InsertOnSubmit(the_record);
                dc.SubmitChanges();

                return("Success~" + the_record.UserID);
            } catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
示例#19
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());
        }
示例#20
0
        public static string ForgotPassword(string to_mail)
        {
            string result = string.Empty;

            try
            {
                if (!IsSystemUserAlreadyExistByEmail(to_mail))
                {
                    result = "This email didn't register yet!";
                }
                else
                {
                    var      password         = Controllers.Controller_Common.GeneratePassword();
                    string   encryptpassword  = Controllers.Controller_TextEncryption.Encrypt(password, "");
                    SYS_User user             = new SYS_User();
                    LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

                    user = (from c in dc.SYS_Users
                            where c.Email == to_mail && c.Active
                            select c).FirstOrDefault();
                    user.Password   = encryptpassword;
                    user.LastAction = Guid.NewGuid().ToString();
                    user.ModifiedBy = "4";
                    user.ModifiedOn = DateTime.Now;
                    dc.SubmitChanges();

                    string EmailSubject = "Password Recovery";
                    string email_body   = "Hi <UserName>,<br/><br/>Thank you for using Systematic Business Solution System.<br/<br/>You can login your account by new password <b><Password><b>.<br/<br/> Thank you. <br/><br/> ";

                    email_body = email_body.Replace("<UserName>", user.UserName).Replace("<Password>", password);

                    var result1 = Controllers.Controller_EmailHelper.SendEmail(to_mail, EmailSubject, email_body, null, null);
                    if (result1 != "success")
                    {
                        throw new Exception(result1);
                    }

                    result = "success";
                }
            }
            catch (Exception ex)
            {
                //Controller_SysLog.CreateSysLog("System User Forgot Password", to_mail, ex.Message, ex.Message);
                result = "Please try again!";
            }

            return(result);
        }
示例#21
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);
        }
示例#22
0
        public static bool WirteUpdateLog(List <ModifiedMemberInfo> updated_fields, string record_id, string action_by)
        {
            try
            {
                LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
                SysLog log = new SysLog()
                {
                    LogBy       = action_by,
                    LogDateTime = DateTime.Now,
                    RecordID    = record_id,
                    Remark      = "",
                    SystemLogID = Guid.NewGuid().ToString()
                };
                dc.SysLogs.InsertOnSubmit(log);

                List <SysLogItem> log_items = new List <SysLogItem>();
                foreach (ModifiedMemberInfo memberInfo in updated_fields)
                {
                    SysLogItem new_item = new SysLogItem()
                    {
                        SystemLogID     = log.SystemLogID,
                        SystemLogItemID = Guid.NewGuid().ToString(),
                        FieldName       = memberInfo.Member.Name
                    };
                    try
                    {
                        new_item.NewValue = memberInfo.CurrentValue.ToString();
                    }
                    catch (Exception ex) { new_item.NewValue = ""; }

                    try
                    {
                        new_item.OldValue = memberInfo.OriginalValue.ToString();
                    }
                    catch (Exception ex) { new_item.OldValue = ""; }
                    log_items.Add(new_item);
                }

                dc.SysLogItems.InsertAllOnSubmit(log_items);
                dc.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#23
0
        private static bool isAlreadyLoggedIn(SYS_User the_user)
        {
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            DateTime now = DateTime.Now;

            TimeSpan duration = now - the_user.LastLogin;

            if (duration.TotalMinutes > 15) // after login
            {
                return(false);
            }
            else if (the_user.IsLoggedIn)
            {
                return(true);
            }
            return(false);
        }
示例#24
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);
        }
示例#25
0
        private void load_report()
        {
            dxrpt_sale_by_customer report = new dxrpt_sale_by_customer();
            DateTime from_date            = DateTime.Today;
            DateTime to_date = DateTime.Today;

            DateTime.TryParseExact(tb_search_date.Value, "yyyy/MM/d", CultureInfo.InvariantCulture, DateTimeStyles.None, out from_date);
            DateTime.TryParseExact(tb_search_to_date.Value, "yyyy/MM/d", CultureInfo.InvariantCulture, DateTimeStyles.None, out to_date);

            #region filtering text
            string filter_text = "";
            if (from_date == to_date)
            {
                filter_text = from_date.ToString("dd/MM/yyyy");
            }
            else
            {
                filter_text = from_date.ToString("dd/MM/yyyy") + " <-> " + to_date.ToString("dd/MM/yyyy");
            }

            report.Parameters["parFiltering"].Value = filter_text;
            #endregion

            #region Company Information
            LINQ_SystemDataContext dc_sys = new LINQ_SystemDataContext();
            SYS_Get_Organization_From_UserResult the_org = dc_sys.SYS_Get_Organization_From_User(hf_current_user.Value).FirstOrDefault();
            if (the_org != null)
            {
                report.Parameters["parCompanyName"].Value = the_org.OrgName;
            }
            #endregion


            LINQ_POSDataContext dc_pos = new LINQ_POSDataContext();
            List <POS_REPORT_SUMMARY_BY_CUSTOMERResult> result = dc_pos.POS_REPORT_SUMMARY_BY_CUSTOMER(
                from_date, to_date, tb_search_text.Value, "", "", "", "", "", hf_current_user.Value).ToList();


            report.DataSource = result;
            report.CreateDocument(false);

            myReportViwer.OpenReport(report);
        }
示例#26
0
        public static string do_saveorganization(string orgid, string org_name, string org_code)
        {
            try
            {
                LINQ_SystemDataContext dc         = new LINQ_SystemDataContext();
                SYS_Organization       the_record = new SYS_Organization();
                if (string.IsNullOrEmpty(orgid))
                {
                    the_record = new SYS_Organization
                    {
                        OrgID      = Guid.NewGuid().ToString(),
                        OrgName    = org_name,
                        OrgCode    = org_code,
                        OrgPlan    = string.Empty,
                        JointDate  = DateTime.Now,
                        ExpiryDate = DateTime.Now,
                        Remark1    = string.Empty,
                        Active     = true,
                        UserCount  = "5",
                        Remark     = string.Empty,
                        CreatedBy  = "4",
                        CreatedOn  = DateTime.Now,
                        ModifiedBy = "4",
                        ModifiedOn = DateTime.Now,
                        LastAction = Guid.NewGuid().ToString()
                    };

                    dc.SYS_Organizations.InsertOnSubmit(the_record);
                }
                else
                {
                    the_record         = (from org in dc.SYS_Organizations where org.OrgID == orgid && org.Active == true select org).FirstOrDefault();
                    the_record.OrgName = org_name;
                    the_record.OrgCode = org_code;
                }
                dc.SubmitChanges();
                return("Success~" + the_record.OrgID);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
示例#27
0
        public static string Do_Change_Password(string userid, string oldpassword, string newpassword)
        {
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
            SYS_User currentuser      = (from c in dc.SYS_Users where c.UserID == userid && c.Password == Controller_TextEncryption.Encrypt(oldpassword, "") && c.Active == true select c).FirstOrDefault();

            if (currentuser != null)
            {
                currentuser.Password   = Controller_TextEncryption.Encrypt(newpassword, "");
                currentuser.ModifiedOn = DateTime.Now;
                currentuser.ModifiedBy = userid;
                currentuser.LastAction = Guid.NewGuid().ToString();
                dc.SubmitChanges();

                return("Success~");
            }
            else
            {
                return("Error~Your Old Password Is Not Valid Please Chack Your Old Password And Try Again");
            }
        }
示例#28
0
        public static string do_logout(bool isclicklogout, string userid)
        {
            try
            {
                LINQ_SystemDataContext dc = new LINQ_SystemDataContext();
                SYS_User the_user         = new SYS_User();
                the_user            = (from u in dc.SYS_Users where u.UserID == userid select u).FirstOrDefault();
                the_user.IsLoggedIn = false;
                dc.SubmitChanges();
                if (isclicklogout)
                {
                    HttpContext.Current.Session["userid"] = string.Empty;
                    HttpContext.Current.Session.Clear();
                }

                return("Success~");
            } catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
示例#29
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());
        }
示例#30
0
        public static string ChangeSysMenu(string menu_ids, string oldnoteMenuID, string noteMenuID, string RequestID)
        {
            LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

            //List<SYS_MenuView> childMenus = (from c in dc.SYS_MenuViews where c.NoteMenuID == noteMenuID && c.Active == true orderby c.MenuSeq select c).ToList();
            string[] menu_child_ids = menu_ids.Split(',');
            for (int i = 0; i < menu_child_ids.Length; i++)
            {
                SYS_Menu child_menu = (from c in dc.SYS_Menus where c.MenuID == menu_child_ids[i] && c.Active == true select c).FirstOrDefault();
                if (oldnoteMenuID != noteMenuID)
                {
                    if (noteMenuID == "#")
                    {
                        child_menu.IsNode     = true;
                        child_menu.NoteMenuID = "";
                    }
                    else
                    {
                        child_menu.NoteMenuID = noteMenuID;
                        child_menu.IsNode     = false;
                    }
                }
                child_menu.ModifiedBy = RequestID;
                child_menu.ModifiedOn = DateTime.Now;
                child_menu.MenuSeq    = i + 2;
                child_menu.LastAction = Guid.NewGuid().ToString();
                try
                {
                    dc.SubmitChanges();
                }
                catch (Exception ex)
                {
                    return("Fail~");
                }
            }
            return("Success~");
        }