Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[sessionNames.userID_StudentOstad] == null)
            {
                Response.Redirect("login.aspx");
            }


            if (Session[sessionNames.userID_StudentOstad] == null)
            {
                Session["LogStatus"] = "0-0";

                form1.Action    = System.Configuration.ConfigurationManager.AppSettings["LMS_link"].ToString();
                LogStatus.Value = Session["LogStatus"].ToString();
                ScriptManager.RegisterStartupScript(this, GetType(), "submitform", "submitform();", true);
            }


            //****************************


            var userId  = Session[sessionNames.userID_StudentOstad];
            var isOstad = Session["IsOstad"];

            if (userId != null && isOstad != null)
            {
                //var isUserevaluated= _evaluationBusiness.IsUserevaluated(int.Parse(userId.ToString()));
                //var isQuestionExist = _evaluationBusiness.IsQuestionExist();
                //if (!isUserevaluated && isQuestionExist)
                //{
                //    ShowEvaluationQuestion();
                //}
                var groupManger = cmnb.GetGroupMangerInformation(Convert.ToInt64(userId.ToString()));
                var grpManger   = groupManger.FirstOrDefault();
                if (grpManger != null && (groupManger.Count > 0 && grpManger.IsActive.Value))
                {
                    //* for test
                    var lngB = new LoginBusiness();
                    //var userDto = lngB.Get_UserLogin(grpManger.GroupManagerUser,"");
                    var userDto = cmnb.GetProfessorUser(grpManger.GroupManagerUser);

                    if (userDto.Count > 0 && userDto[0].Enable)
                    {
                        Session["IsGroupManger"]            = true;
                        Session[sessionNames.userID_Karbar] = userDto[0].UserId;
                        Session["Enable"] = userDto[0].Enable;
                        Session[sessionNames.userName_Karbar] = userDto[0].Name;
                        Session[sessionNames.roleID]          = userDto[0].RoleId;
                        Session[sessionNames.sectionID]       = userDto[0].sectionId;
                        Session[sessionNames.user_Karbar]     = userDto[0].UserName;
                        Session["p"] = CommonBusiness.DecryptPass(userDto[0].Password);
                        headOfDepartmentPanel.Visible = true;
                    }
                }
            }

            //****************************

            usernamelbl.InnerText = Session[sessionNames.userName_StudentOstad].ToString() + " خوش آمدید ";
        }
        protected void ClickedME(object sender, EventArgs e)
        {
            List <LoginDTO> userDTO = new List <LoginDTO>();

            DataTable dt = new DataTable();

            if (Page.IsValid)
            {
                LoginBusiness lngB = new LoginBusiness();
                userDTO = lngB.Get_UserLogin(UserName.Text, password.Text);


                if (userDTO.Count > 0)
                {
                    Session[sessionNames.userID_Karbar] = userDTO[0].UserId;
                    Session["Enable"] = userDTO[0].Enable;
                    Session[sessionNames.userName_Karbar] = userDTO[0].Name;
                    Session[sessionNames.roleID]          = userDTO[0].RoleId;
                    Session[sessionNames.sectionID]       = userDTO[0].sectionId;
                    Session[sessionNames.user_Karbar]     = userDTO[0].UserName;
                    Session[sessionNames.roleText]        = userDTO[0].RoleName;
                    if (Convert.ToBoolean(Session["Enable"].ToString()))
                    {
                        var gm = CommonBusiness.GetGroupMangerInformation(userDTO[0].UserName);
                        if (gm.Count > 0)
                        {
                            Business.university.Research.ResearchBusiness Rbusiness = new Business.university.Research.ResearchBusiness();
                            Session["IsGroupManger"] = true;
                            var lgn = Rbusiness.GetTeacherUserPass(int.Parse(gm[0].ProfessorCode.ToString()));
                            Session["Password"]     = CommonBusiness.DecryptPass(lgn.Rows[0]["Password"].ToString());
                            Session["IsOstad"]      = true;
                            Session["UserType_lms"] = 2;
                        }
                        Session["p"]            = CommonBusiness.DecryptPass(userDTO[0].Password);
                        Session["UserType_lms"] = 1;
                        Response.Redirect("CommonCmsIntro.aspx");

                        //CommonBusiness.InsertIntoUserLog(int.Parse(Session[sessionNames.userID_Karbar].ToString()), DateTime.Now.Date, DateTime.Now.ToShortTimeString(), "0", 14);
                    }
                    else
                    {
                        errormsg.Visible   = true;
                        errormsg.InnerText = "نام کاربری یا رمز عبور صحیح نمی باشد";
                    }
                }
                else
                {
                    errormsg.Visible = true;
                }
                errormsg.InnerText = "نام کاربری یا رمز عبور صحیح نمی باشد";
            }
            else
            {
                errormsg.Visible   = true;
                errormsg.InnerText = "کد امنیتی صحیح وارد نشده است";
            }
        }