コード例 #1
0
        public Response IsExist([FromBody] T_Users value)
        {
            var userlist = dalObj.T_Users.ToList();
            var User     = (from u in userlist
                            where u.EmailId == value.EmailId
                            select u).SingleOrDefault();

            if (User != null)
            {
                Response RC    = new Response();
                string   mails = GetOTP();

                T_OTP_Details otp = new T_OTP_Details();
                otp.UserId     = User.UserId;
                otp.ValidTill  = DateTime.Now;
                otp.GenratedOn = DateTime.Now;
                otp.OTP        = mails;
                dalObj.T_OTP_Details.Add(otp);
                dalObj.SaveChanges();


                RC.Status = "success";
                RC.Error  = null;
                RC.Data   = mails;
                return(RC);
            }
            else
            {
                Response RC = new Response();
                RC.Status = "fail";
                RC.Error  = null;
                RC.Data   = false;
                return(RC);
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["Menu_ID"] != null && Request["Menu_ID"].ToString() != "" && Request["Menu_ID"].ToString() != String.Empty)
            {
                if (CommonLib.IsNumeric(Request["Menu_ID"]) == true)
                {
                    if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
                    {
                        Response.Redirect("~/Errors/AccessDenied.aspx");
                    }
                    _user = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
                    _Role = _NguoidungDAL.GetRole4UserMenu(_user.UserID, Convert.ToInt32(Request["Menu_ID"]));

                    this.LinkDelete.Visible = _Role.R_Delete;
                    this.LinkDelete.Attributes.Add("onclick", "return ConfirmQuestion('Bạn có chắc muốn xóa?','ctl00_MainContent_grdListTemplate_ctl01_chkAll');");
                    if (!IsPostBack)
                    {
                        if (Session["CurrentPage"] != null)
                        {
                            pages.PageIndex = int.Parse(Session["CurrentPage"].ToString());
                            LoadData();
                            Session["CurrentPage"] = null;
                        }
                        else
                        {
                            LoadData();
                        }
                    }
                }
            }
        }
コード例 #3
0
    protected void updateUser_Click(object sender, EventArgs e)
    {
        T_Users user = new T_Users();

        user.Roles = fanTranslateRoles(DropDownCheckBoxList1.Text);
        user.Name  = txtName.Text.Trim();
        if (string.IsNullOrEmpty(user.Name))
        {
            Label1.Text = "姓名不能为空";
            return;
        }
        user.Username = txtUsername.Text.Trim();
        user.Password = txtPassword.Text.Trim();
        if (string.IsNullOrEmpty(user.Password))
        {
            Label1.Text = "密码不能为空";
            return;
        }
        user.Derpartment = txtDerparment.Text.Trim();
        user.PersonId    = HiddenField1.Value;


        try
        {
            ua.UpdateUserInfo(user);
            init();
            Label1.Text = "更新成功";
            show();
        }
        catch (Exception ex)
        {
            Label1.Text = ex.Message;
        }
    }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["Menu_ID"] != null && Request["Menu_ID"].ToString() != "" && Request["Menu_ID"].ToString() != String.Empty)
     {
         if (UltilFunc.IsNumeric(Request["Menu_ID"]))
         {
             if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
             {
                 Response.Redirect("~/Errors/AccessDenied.aspx");
             }
             _user          = _userDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
             _Role          = _userDAL.GetRole4UserMenu(_user.UserID, Convert.ToInt32(Request["Menu_ID"]));
             btnAdd.Visible = _Role.R_Read;
             if (!IsPostBack)
             {
                 lblMessError.Text = "";
                 if (Session["CurrentPage"] != null)
                 {
                     pages.PageIndex = int.Parse(Session["CurrentPage"].ToString());
                     BindList_Phongban();
                 }
                 else
                 {
                     BindList_Phongban();
                 }
             }
         }
     }
 }
コード例 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (UltilFunc.IsNumeric(Request["Menu_ID"]))
     {
         if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
         {
             Response.Redirect("~/Admin/Errors/AccessDenied.aspx");
         }
         _user = _userDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
         _Role = _userDAL.GetRole4UserMenu(_user.UserID, MenuID);
         this.btnAdd.Visible = _Role.R_Read;
         if (!IsPostBack)
         {
             if (Session["CurrentPage"] != null)
             {
                 pages.PageIndex        = int.Parse(Session["CurrentPage"].ToString());
                 Session["CurrentPage"] = null;
                 Danhsach_Yeucau();
             }
             else
             {
                 Danhsach_Yeucau();
             }
         }
     }
 }
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            _user = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
            string prefixText = context.Request.QueryString["q"];

            string userid = HPCSecurity.CurrentUser.Identity.ID.ToString();

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            string    sql = "select top 20 Ma_Nguoidung, LTRIM(RTRIM(Ten_Dangnhap))+case when Loai=1 then ' (CTV)' when Loai=0 then '' end as Ten_Dangnhap from T_Nguoidung where  (Trangthai_Xoa=0 or Trangthai_Xoa is null) and Ten_Dangnhap LIKE N'%" + prefixText + "%' and Ten_Dangnhap is not null ";
            DataTable dt  = new DataTable();

            dt = ulti.ExecSqlDataSet(sql).Tables[0];
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sb.Append(string.Format("{0}|{1}", dt.Rows[i]["Ten_Dangnhap"].ToString(), dt.Rows[i]["Ma_Nguoidung"].ToString())).Append(Environment.NewLine);
                }
                context.Response.Write(sb.ToString());
            }
            else
            {
                sb.Append(string.Format("{0}|{1}", prefixText, "0")).Append(Environment.NewLine);
                context.Response.Write("Không có tác giả này!");
            }
        }
コード例 #7
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            var items = filterContext.RouteData.Values;

            if (isCheckUserLogin)
            {
                if (Request.Cookies["userLoginId"] == null)
                {
                    filterContext.HttpContext.Response.Redirect("/UserLogin/Index");
                }
                else
                {
                    string  userGuid = Request.Cookies["userLoginId"].Value;
                    T_Users userInfo = CacheHelper.GetCache(userGuid) as T_Users;
                    if (userInfo == null)
                    {
                        filterContext.HttpContext.Response.Redirect("/UserLogin/Index");
                    }
                    CacheHelper.SetCache(userGuid, userInfo, DateTime.Now.AddMinutes(20));
                }


                //if (filterContext.HttpContext.Session["loginUser"] == null)
                //    filterContext.HttpContext.Response.Redirect("/UserLogin/Index");
                //else
                //    loginUser = filterContext.HttpContext.Session["loginUser"] as T_Users;
            }
        }
コード例 #8
0
    protected void img_clicked(object sender, ImageClickEventArgs e)
    {
        T_Users entity = new T_Users();

        entity.Username = username.Text.Trim();
        entity.Password = password1.Text.Trim();
        if (entity.Password.Length < 6)
        {
            errorTxt.Text = "密码长度不能少于6位";
            return;
        }
        entity.Name        = name.Text.Trim();
        entity.Derpartment = derparment.Text.Trim() ?? "";

        UsersAdapter ua = new UsersAdapter();

        try
        {
            string person_id = ua.register(entity);
            //自动登录
            HttpContext.Current.Session["PersonId"] = person_id;
            Common.LoginCheck();

            Response.Redirect("UI/security/default.aspx");
        }
        catch (Exception ex)
        {
            errorTxt.Text = ex.Message;
        }
    }
コード例 #9
0
        public Response Post([FromBody] T_Users data)
        {
            if (data.EmailId != null && data.Password != null)
            {
                string encrypttext = Encrypt(data.Password);
                data.Password = encrypttext;
                List <T_Users> user = dalobject.T_Users.ToList();

                T_Users validuser = (from u in user
                                     where u.EmailId == data.EmailId && u.Password == data.Password
                                     select u).SingleOrDefault();
                if (validuser != null)
                {
                    statusonline(validuser.UserId);
                    response.Data   = validuser;
                    response.Error  = null;
                    response.Status = "Success";
                    return(response);
                }
                else
                {
                    response.Error  = null;
                    response.Status = "Fail";
                    return(response);
                }
            }
            else
            {
                response.Error  = null;
                response.Status = "Fail";
                return(response);
            }
        }
コード例 #10
0
        protected void lb_Exit_Click(object sender, EventArgs e)
        {
            Session["capchaimgvna"] = null;
            string       _name    = HPCSecurity.CurrentUser.Identity.Name;
            NguoidungDAL _userDAL = new NguoidungDAL();

            user = _userDAL.GetUserByUserName(_name);
            if (user != null)
            {
                UltilFunc ulti      = new UltilFunc();
                string    sqlupdate = " update T_TinBai set Nguoi_Khoa=0 where Nguoi_Khoa=" + user.UserID;
                ulti.ExecSql(sqlupdate);
                string sqlupdateT_news = " UPDATE T_News SET News_EditorID=0,News_Lock =0 WHERE News_EditorID=" + user.UserID;
                ulti.ExecSql(sqlupdateT_news);
                string sqlupdateUserLogin = "******" + user.UserName + "'";
                ulti.ExecSql(sqlupdateUserLogin);
            }
            Session.RemoveAll();
            Session.Clear();
            Session.Abandon();
            Page.Response.Cookies.Clear();
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            FormsAuthentication.SignOut();
            Page.Response.Cookies.Remove("hpcinfomation");
            Page.Response.Cookies["hpcinfomation"].Expires = DateTime.Now.AddMilliseconds(-1);
            UltilFunc.Log_Action(user.UserID, user.UserFullName, DateTime.Now, 0, "Thoát khỏi hệ thống");
            Page.Response.Redirect(Global.ApplicationPath + "/Login.aspx");
        }
コード例 #11
0
        public Response Registration(T_Users data)
        {
            Console.WriteLine(data);
            data.RoleId = 1;

            string encrypttext = Encrypt(data.Password);

            data.Password = encrypttext;
            dalobject.T_Users.Add(data);
            //dalobject.SaveChanges();
            try
            {
                dalobject.SaveChanges();
                response.Data   = data;
                response.Error  = null;
                response.Status = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Data   = null;
                response.Error  = ex;
                response.Status = "Fail";
                return(response);
            }
        }
コード例 #12
0
        public void statusonline(int UserId)
        {
            T_Users user = dalobject.T_Users.Find(UserId);

            user.IsOnline = true;
            dalobject.SaveChanges();
        }
コード例 #13
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // 这不会计入到为执行帐户锁定而统计的登录失败次数中
            // 若要在多次输入错误密码的情况下触发帐户锁定,请更改为 shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, false, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                using (var db = new TravelEntities())
                {
                    T_Users user = db.T_Users.Where(a => a.LoginName.Equals(model.UserName)).FirstOrDefault();
                    if (user != null)
                    {
                        Session["UserId"]   = user.UserID;
                        Session["UserName"] = user.UserName;
                    }
                }
                AuthenticationManager.SignIn(new AuthenticationProperties(), new ClaimsIdentity());
                return(RedirectToLocal(returnUrl));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "无效的登录尝试。");
                return(View(model));
            }
        }
コード例 #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["Menu_ID"] != null && Request["Menu_ID"].ToString() != "" && Request["Menu_ID"].ToString() != String.Empty)
     {
         if (CommonLib.IsNumeric(Request["Menu_ID"]) == true)
         {
             if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
             {
                 Response.Redirect("~/Errors/AccessDenied.aspx");
             }
             _user = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
             ActiverPermission();
             if (!IsPostBack)
             {
                 int tab_id = 0;
                 if (Request["Tab"] != null)
                 {
                     tab_id = Convert.ToInt32(Request["Tab"].ToString());
                 }
                 if (tab_id == -1)
                 {
                     this.TabContainer1.ActiveTabIndex = 0;
                     this.TabContainer1_ActiveTabChanged(sender, e);
                 }
                 else
                 {
                     this.TabContainer1.ActiveTabIndex = tab_id;
                     this.TabContainer1_ActiveTabChanged(sender, e);
                 }
                 LoadCombox();
             }
         }
     }
 }
コード例 #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (HttpContext.Current.Request.QueryString["vType"] != null)
     {
         strNumberArg = HttpContext.Current.Request.QueryString["vType"].ToString();
     }
     _user = _DAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
     if (_user == null)
     {
         Response.Redirect(Global.ApplicationPath + "/Login.aspx");
     }
     if (!this.IsPostBack)
     {
         if (_user != null)
         {
             LoadCM();
             txt_FromDate.Text = DateTime.Now.AddDays(-1).ToString("dd'/'MM'/'yyyy");
             txt_ToDate.Text   = DateTime.Now.ToString("dd'/'MM'/'yyyy");
             ListImages();
         }
     }
     else
     {
         string EventName = Request.Form["__EVENTTARGET"].ToString();
         if (EventName == "UploadSuccess")
         {
             ListImages();
         }
     }
 }
コード例 #16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["Menu_ID"] != null && Request["Menu_ID"].ToString() != "" && Request["Menu_ID"].ToString() != String.Empty)
     {
         if (CommonLib.IsNumeric(Request["Menu_ID"]) == true)
         {
             if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
             {
                 Response.Redirect("~/Errors/AccessDenied.aspx");
             }
             _user   = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
             _Role   = _NguoidungDAL.GetRole4UserMenu(_user.UserID, Convert.ToInt32(Request["Menu_ID"]));
             Ma_QTBT = UltilFunc.GetColumnValuesOne("T_NguoidungQTBT", "Ma_QTBT", "Ma_Nguoidung=" + _user.UserID);
             if (!IsPostBack)
             {
                 if (Ma_QTBT != 0)
                 {
                     LoadData();
                 }
                 else
                 {
                     Page.Response.Redirect("~/login.aspx", true);
                 }
             }
         }
     }
 }
コード例 #17
0
 public string Delete_DoiTuong_AnPham(string ID, string Name, string Ma_Anpham, string MenuID, string IpAddress)
 {
     try
     {
         _user = _userDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
         #region GhiLog
         action.Ma_Nguoidung = _user.UserID;
         action.TenDaydu     = _user.UserName;
         action.HostIP       = IpAddress;
         action.NgayThaotac  = DateTime.Now;
         action.Ma_Chucnang  = int.Parse(MenuID);
         #endregion
         int _id       = Convert.ToInt32(ID);
         int _maanpham = Convert.ToInt32(Ma_Anpham);
         _DTDAL.DeleteOneFromT_Doituong_AnPham(_id, _maanpham);
         thaotac        = "Xóa đối tượng trong ấn phẩm'" + Name + "'";
         action.Thaotac = thaotac;
         actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
         return("Item Saved,,");
     }
     catch
     {
         return("Error,,");
     }
 }
コード例 #18
0
 public Response Post([FromBody] T_Users data)
 {
     if (data.EmailId != null && data.Password != null)
     {
         List <T_Users> user      = dalObj.T_Users.ToList();
         T_Users        validuser = (from u in user
                                     where u.EmailId == data.EmailId && u.Password == data.Password
                                     select u).SingleOrDefault();
         if (validuser != null)
         {
             response.Data   = validuser;
             response.Error  = null;
             response.Status = "Success";
             return(response);
         }
         else
         {
             response.Error  = null;
             response.Status = "Invalid Data !!";
             return(response);
         }
     }
     else
     {
         response.Error  = null;
         response.Status = "Fields are empty !!";
         return(response);
     }
 }
コード例 #19
0
        // POST: api/Login
        public Response Post([FromBody] T_Users data)
        {
            List <T_Users> user = dalobj.T_Users.ToList();

            if ((data.EmailId != null && data.Password != null))
            {
                var validUser = (from u in user
                                 where u.EmailId == data.EmailId && u.Password == data.Password
                                 select u).SingleOrDefault();
                if (validUser != null)
                {
                    response.Status = "success";
                    response.Err    = null;
                    response.Data   = validUser;
                    logger.Log("Login Successfull.");
                }
                else
                {
                    response.Status = "failed! Invalid Credentials";
                    response.Err    = null;
                    response.Data   = null;
                    logger.Log("Login Failed!");
                }

                return(response);
            }
            else
            {
                response.Status = "Plz enter Credentials";
                response.Err    = null;
                return(response);
            }
        }
コード例 #20
0
        public Response Post1([FromBody] T_Users data)
        {
            if (data != null)
            {
                var added = dalobj.T_Users.Add(data);

                try
                {
                    dalobj.SaveChanges();
                    response.Data   = added;
                    response.Status = "success";
                    response.Err    = null;
                    logger.Log("Register Successfull.");
                    var res = SendEmail(added.EmailId, "Registration Successful", "Dear " + added.Name + " your registration is successfully done on ONLINE EXAMINATION PORTAL. Please Login now on link http://Shiksha.kdac.org/Login");
                    return(response);
                }
                catch (Exception e)
                {
                    response.Status = "Exception Occured! Check credentials...";
                    //    response.Err = null;
                    response.Err  = e;
                    response.Data = null;
                    logger.Log("Exception occured!");
                    return(response);
                }
            }
            else
            {
                response.Data   = null;
                response.Status = "Empty Fileds";
                response.Err    = null;
                return(response);
            }
        }
コード例 #21
0
        public Response IsExist([FromBody] T_Users value)
        {
            var userlist = dalobj.T_Users.ToList();
            var User     = (from u in userlist
                            where u.EmailId == value.EmailId
                            select u).SingleOrDefault();

            if (User != null)
            {
                Response RC    = new Response();
                string   mails = GetOTP();

                T_OTP_Details otp = new T_OTP_Details();
                otp.UserId      = User.UserId;
                otp.ValidTill   = (DateTime.Now).AddMinutes(5);
                otp.GeneratedOn = DateTime.Now;
                otp.OTP         = mails;
                dalobj.T_OTP_Details.Add(otp);
                dalobj.SaveChanges();
                var res = SendEmail(User.EmailId, "Generated OTP", "Your One Time Password is " + mails + ". Valid till " + otp.ValidTill + ".");

                RC.Status = "success";
                RC.Err    = null;
                RC.Data   = mails;
                return(RC);
            }
            else
            {
                Response RC = new Response();
                RC.Status = "fail";
                RC.Err    = null;
                RC.Data   = false;
                return(RC);
            }
        }
コード例 #22
0
        public Response updatepassword([FromBody] T_Users value)
        {
            var userlist = dalobj.T_Users.ToList();
            var User     = (from u in userlist
                            where u.EmailId == value.EmailId
                            select u).SingleOrDefault();

            if (User != null)
            {
                User.Password = value.Password;
                dalobj.SaveChanges();
                Response rc = new Response();
                rc.Status = "success";
                rc.Err    = null;
                rc.Data   = User;
                return(rc);
            }
            else
            {
                Response rc = new Response();
                rc.Status = "fail";
                rc.Err    = null;
                rc.Data   = null;
                return(rc);
            }
        }
コード例 #23
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["Menu_ID"] != null && Request["Menu_ID"].ToString() != "" && Request["Menu_ID"].ToString() != String.Empty)
     {
         if (UltilFunc.IsNumeric(Request["Menu_ID"]))
         {
             if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
             {
                 Response.Redirect("~/Errors/AccessDenied.aspx");
             }
             _user = _userDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
             if (!IsPostBack)
             {
                 if (Session["CurrentPage"] != null)
                 {
                     pages.PageIndex = int.Parse(Session["CurrentPage"].ToString());
                     BindList_AnphamMau();
                 }
                 else
                 {
                     BindList_AnphamMau();
                 }
             }
         }
     }
 }
コード例 #24
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.Lbt_Delete.Attributes.Add("onclick", "return CheckConfirmDelete();");
     this.lbDelete.Attributes.Add("onclick", "return CheckConfirmDeleteDXL();");
     this.lbDuyet.Attributes.Add("onclick", "return CheckConfirmGuiTKTS();");
     this.Lbt_Send_Duyet.Attributes.Add("onclick", "return CheckConfirmGuiDuyet();");
     this.Lbt_TraLai.Attributes.Add("onclick", "return CheckConfirmTralai();");
     this.lbTralai.Attributes.Add("onclick", "return CheckConfirmTralaireturn();");
     this.lbDelet.Attributes.Add("onclick", "return CheckConfirmDeletereturn();");
     if (Request["Menu_ID"] != null && Request["Menu_ID"].ToString() != "" && Request["Menu_ID"].ToString() != String.Empty)
     {
         if (CommonLib.IsNumeric(Request["Menu_ID"]) == true)
         {
             if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
             {
                 Response.Redirect("~/Errors/AccessDenied.aspx");
             }
             _user = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
             if (!IsPostBack)
             {
                 int tab_id = 0;
                 LoadCombox();
                 if (Request["Tab"] != null)
                 {
                     tab_id = Convert.ToInt32(Request["Tab"].ToString());
                 }
                 this.TabContainer1.ActiveTabIndex = tab_id;
                 this.TabContainer1_ActiveTabChanged(sender, e);
             }
         }
     }
 }
コード例 #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["Menu_ID"] != null && Request["Menu_ID"].ToString() != "" && Request["Menu_ID"].ToString() != String.Empty)
            {
                if (CommonLib.IsNumeric(Request["Menu_ID"]) == true)
                {
                    if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
                    {
                        Response.Redirect("~/Errors/AccessDenied.aspx");
                    }
                    _user = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
                    _Role = _NguoidungDAL.GetRole4UserMenu(_user.UserID, Convert.ToInt32(Request["Menu_ID"]));


                    if (!IsPostBack)
                    {
                        LoadCombox();
                    }
                    else
                    {
                        string EventName = Request.Form["__EVENTTARGET"].ToString();
                        if (EventName == "UploadImageSuccess")
                        {
                            LoadData_FilePDF();
                        }
                    }
                }
            }
        }
コード例 #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["Menu_ID"] != null && Request["Menu_ID"].ToString() != "" && Request["Menu_ID"].ToString() != String.Empty)
     {
         if (UltilFunc.IsNumeric(Request["Menu_ID"]))
         {
             if (!HPCSecurity.IsAccept(Convert.ToInt32(Request["Menu_ID"])))
             {
                 Response.Redirect("~/Errors/AccessDenied.aspx");
             }
             _user             = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
             _Role             = _NguoidungDAL.GetRole4UserMenu(_user.UserID, MenuID);
             btnUpload.Enabled = _Role.R_Write;
             btnDelete.Enabled = _Role.R_Delete;
             if (!IsPostBack)
             {
                 if (Session["CurrentPage"] != null)
                 {
                     pageappro.PageIndex = int.Parse(Session["CurrentPage"].ToString());
                     LoadDataApprovied();
                 }
                 else
                 {
                     LoadDataApprovied();
                 }
             }
         }
     }
 }
コード例 #27
0
ファイル: AutoSave.asmx.cs プロジェクト: tungdang130991/MyGit
        public ChuyenmucDetails[] BindDatatoDropdownChuyenmuc(object AnphamID)
        {
            _user = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
            DataTable dt = new DataTable();

            string _sql = string.Empty;

            _sql = "set dateformat dmy; SELECT Ma_ChuyenMuc,Ten_ChuyenMuc FROM T_ChuyenMuc where Hoatdong=1 and Ma_ChuyenMuc in (select Ma_ChuyenMuc from T_Nguoidung_Chuyenmuc where Ma_Nguoidung = " + _user.UserID.ToString() + ") and Ma_AnPham= " + AnphamID + " AND Ma_Chuyenmuc_Cha = 0 ";
            int Rank = 0;

            try
            {
                dt = ulti.ExecSqlDataSet(_sql).Tables[0];
                foreach (DataRow dtrow in dt.Rows)
                {
                    ChuyenmucDetails _listchuyenmuc = new ChuyenmucDetails();

                    _listchuyenmuc.Ma_ChuyenMuc  = Convert.ToInt32(dtrow["Ma_ChuyenMuc"].ToString());
                    _listchuyenmuc.Ten_ChuyenMuc = dtrow["Ten_ChuyenMuc"].ToString();
                    details.Add(_listchuyenmuc);
                    BinTreeCategorys(Rank, dtrow["Ma_ChuyenMuc"].ToString());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(details.ToArray());
        }
コード例 #28
0
        public Response Register([FromBody] T_Users data)
        {
            Response response = new Response();

            if (data != null)
            {
                try
                {
                    dalObj.T_Users.Add(data);
                    dalObj.SaveChanges();
                    response.Data   = data;
                    response.Error  = null;
                    response.Status = "Registered successfully, login here";
                    return(response);
                }
                catch (Exception e)
                {
                    response.Data   = null;
                    response.Error  = null;
                    response.Status = "Check credentials";
                    return(response);
                }
            }
            else
            {
                response.Data   = null;
                response.Error  = null;
                response.Status = "Fields are empty";
                return(response);
            }
        }
コード例 #29
0
        public Response Post([FromBody] T_Users user)
        {
            Response       response = new Response();
            List <T_Users> users    = dalObj.T_Users.ToList();

            if (user.EmailId != null && user.Password != null)
            {
                var validate = (from u in users
                                where u.EmailId == user.EmailId && u.Password ==
                                user.Password
                                select u).SingleOrDefault();
                if (validate != null)
                {
                    response.Data   = validate;
                    response.Error  = null;
                    response.Status = "Success";
                    return(response);
                }
                else
                {
                    response.Data   = null;
                    response.Error  = null;
                    response.Status = "Incorrect email or password";
                    return(response);
                }
            }
            else
            {
                response.Data   = null;
                response.Error  = null;
                response.Status = "Fields are empty";
                return(response);
            }
        }
コード例 #30
0
        public Response Registration(T_Users data)
        {
            Console.WriteLine(data);
            // data.RoleId = 2;
            dalObj.T_Users.Add(data);
            //dalobject.SaveChanges();
            try
            {
                dalObj.SaveChanges();
                response.Data   = data;
                response.Error  = null;
                response.Status = "Success";
                return(response);
            }
            catch (DbEntityValidationException ex)
            {
                //foreach (var entityValidationErrors in ex.EntityValidationErrors)
                //{
                //    foreach (var validationError in entityValidationErrors.ValidationErrors)
                //    {
                //        Console.WriteLine("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                //    }
                //}

                response.Data   = null;
                response.Error  = ex;
                response.Status = "Error";
                return(response);
            }
        }
コード例 #31
0
 //Parsing done before inserting in the database
 private T_Users InsertParse(User user)
 {
     T_Users t_user = new T_Users();
     t_user.Firstname = user.Firstname;
     t_user.Lastname = user.Lastname;
     t_user.RoleId = user.RoleId;
     t_user.DepartmentId = user.DepartmentId;
     t_user.Username = user.Username;
     t_user.Password = user.Password;
     t_user.Email = user.Email;
     t_user.Phone = user.Phone;
     t_user.Fax = user.Fax;
     t_user.Mobile = user.Mobile;
     t_user.Status = user.Status;
     t_user.CreateDate = user.CreateDate;
     t_user.LastUpdateDate = user.LastUpdateDate;
     t_user.CreatedBy = user.CreatedBy;
     t_user.LastUpdatedBy = user.LastUpdatedBy;
     t_user.EmployeeNumber = user.EmployeeNumber;
     t_user.Shift = user.Shift;
     return t_user;
 }
コード例 #32
0
 //Parsing done before updating record in the database
 private void UpdateParse(T_Users t_user, User user)
 {
     t_user.Firstname = user.Firstname;
     t_user.Lastname = user.Lastname;
     t_user.RoleId = user.RoleId;
     t_user.DepartmentId = user.DepartmentId;
     t_user.Username = user.Username;
     t_user.Password = user.Password;
     t_user.Email = user.Email;
     t_user.Phone = user.Phone;
     t_user.Fax = user.Fax;
     t_user.Mobile = user.Mobile;
     t_user.Status = user.Status;
     t_user.LastUpdateDate = user.LastUpdateDate;
     t_user.LastUpdatedBy = user.LastUpdatedBy;
     t_user.EmployeeNumber = user.EmployeeNumber;
     t_user.Shift = user.Shift;
 }
コード例 #33
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (operatorID.Text == "")
         {
             if (operatorName.Text != "" && operatorHlpMsg.Text != "" && operatorPwd.Text != "")
             {
                 using (IdentityCertifyDataContext conn = new IdentityCertifyDataContext())
                 {
                     T_Users table = new T_Users();
                     string uid = SerialGenerator.GenerateSerialNumber();
                     table.userID = uid;
                     table.userName = operatorName.Text;
                     table.hlpMsg = operatorHlpMsg.Text;
                     table.userPassword = EncryptAndDecrypt.EncryptDES(operatorPwd.Text);
                     table.roleType = operatorRoleType.SelectedIndex == 0 ? "1" : "2";
                     conn.T_Users.InsertOnSubmit(table);
                     conn.SubmitChanges();
                     MessageBox.Show(string.Format("添加操作员成功!\n用户身份:{0}\n用户姓名:{1}\n用户ID:{2}\n助记码:{3}\n可使用用户ID或助记码进行身份认证。"
                         , table.roleType == "1" ? "管理员" : "普通用户", table.userName, table.userID, table.hlpMsg), "添加成功",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
                     btnClr_Click(null, null);
                 }
             }
         }
         else
         {
             using(IdentityCertifyDataContext conn=new IdentityCertifyDataContext())
             {
                 var table = conn.T_Users.Where(o => o.userID == operatorID.Text).FirstOrDefault();
                 table.userName = operatorName.Text;
                 table.hlpMsg = operatorHlpMsg.Text;
                 table.userPassword = EncryptAndDecrypt.EncryptDES(operatorPwd.Text);
                 table.roleType = operatorRoleType.SelectedIndex == 0 ? "1" : "2";
                 conn.SubmitChanges();
                 MessageBox.Show(string.Format("修改操作员成功!\n用户身份:{0}\n用户姓名:{1}\n用户ID:{2}\n助记码:{3}\n可使用用户ID或助记码进行身份认证。"
                     , table.roleType == "1" ? "管理员" : "普通用户", table.userName, table.userID, table.hlpMsg), "添加成功",
                     MessageBoxButtons.OK, MessageBoxIcon.Information);
                 btnClr_Click(null, null);
             }
         }
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         UserManage_Load(null, null);
         btnClr_Click(null, null);
     }
 }
コード例 #34
0
 //Delete user in the database
 public void Delete(int id)
 {
     using (TimeTrackerEntities db = new TimeTrackerEntities())
     {
         try
         {
             T_Users t_user = new T_Users();
             t_user = db.T_Users.FirstOrDefault(u => u.Id == id);
             db.T_Users.Remove(t_user);
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             string msg = ex.Message;
         }
     }
 }