Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["UserID"] == null)
                {
                    Cpic.Cprs2010.User.User userInfo = Cpic.Cprs2010.User.UserManager.getGuestUser(Session.SessionID);
                    if (userInfo != null)
                    {
                        TbUser tbXmUser = new TbUser();
                        tbXmUser.ID = userInfo.ID;
                        tbXmUser.RealName = userInfo.Use_Name;
                        tbXmUser.YongHuLeiXing = "游客";

                        Session["UserID"] = tbXmUser.ID.ToString();
                        Session["RealName"] = tbXmUser.RealName;
                        Session["UserInfo"] = tbXmUser;
                    }
                    else
                    {
                        //Response.Write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"
                        //    + "<script>javascript:alert('服务器资源不足,请稍后再试');window.location.href = 'UserLogin.aspx';</script>");
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["UserID"] == null)
            {
                Cpic.Cprs2010.User.User userInfo = Cpic.Cprs2010.User.UserManager.getGuestUser(Session.SessionID);
                if (userInfo != null)
                {
                    TbUser tbXmUser = new TbUser();
                    tbXmUser.ID = userInfo.ID;
                    tbXmUser.RealName = userInfo.Use_Name + userInfo.ID.ToString();
                    tbXmUser.YongHuLeiXing = "游客";

                    Session["UserID"] = tbXmUser.ID.ToString();
                    Session["RealName"] = tbXmUser.RealName;
                    Session["UserInfo"] = tbXmUser;
                    Response.Redirect("SmartQuery.aspx");
                }
                else
                {
                    Response.Write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"
                        + "<script>javascript:alert('服务器资源不足,请稍后再试');window.location.href = 'UserLogin.aspx';</script>");
                }
            }else
            {
                DataSet ds = new DataSet();
                string userid = Request.QueryString["UserID"].ToString();

                string sql = "select * from TbUser Where UserName='******'";
                ds = DBA.DbAccess.GetDataSet(CommandType.Text, sql);

                if (ds.Tables[0].Rows.Count <= 0)
                {
                    Response.Redirect("../frmLogin.aspx");
                }

                Session["UserID"] = ds.Tables[0].Rows[0]["ID"].ToString().Trim();

                Session["RealName"] = ds.Tables[0].Rows[0]["RealName"].ToString().Trim();

                Session["UserInfo"] = ProXZQDLL.UserRight.getUserInfo(Session["UserID"].ToString().Trim());

                string IP = HttpContext.Current.Request.UserHostAddress.ToString(); ;//HttpContext.Current.Request.ServerVariables["HTTP_HOST"];
                ProXZQDLL.ClsLog.LogInsert(IP, Session["RealName"].ToString().Trim(), ds.Tables[0].Rows[0]["YongHuLeiXing"].ToString().Trim());

                Response.Redirect("SmartQuery.aspx");

            }
        }
Beispiel #3
0
        protected void imgBtnYk_Click(object sender, ImageClickEventArgs e)
        {
            Cpic.Cprs2010.User.User userInfo = Cpic.Cprs2010.User.UserManager.getGuestUser(Session.SessionID);
            if (userInfo != null)
            {
                TbUser tbXmUser = new TbUser();
                tbXmUser.ID = userInfo.ID;
                tbXmUser.RealName = userInfo.Use_Name + userInfo.ID.ToString();
                tbXmUser.YongHuLeiXing = "游客";

                Session["UserID"] = tbXmUser.ID.ToString();
                Session["RealName"] = tbXmUser.RealName;
                Session["UserInfo"] = tbXmUser;
                Response.Redirect("My/SmartQuery.aspx");
            }
            else
            {
                Response.Write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"
                    + "<script>javascript:alert('服务器资源不足,请稍后再试');window.location.href = 'UserLogin.aspx';</script>");
            }
        }
Beispiel #4
0
        public UserAccount Register(RegisterInf registerInf)
        {
            UserAccount userAccount = new UserAccount();
            userAccount.isLogin = false;
            userAccount.haveMsg = false;

            if (registerInf == null)
            {
                userAccount.errorMsg = "注册信息不完整,请查看!";
            }
            else
            {
                if (registerInf.txtUserName.Trim().Equals(""))
                {
                    userAccount.errorMsg = "请输入登录名称!";
                    return userAccount;
                }

                string sql = "Select * From TbUser Where UserName='******'";
                DataSet ds = DBA.DbAccess.GetDataSet(CommandType.Text, sql);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    userAccount.errorMsg = "您录入的登录名已存在,请重新输入!";
                    return userAccount;
                }
                if (registerInf.txtRealName.Trim() == "")
                {
                    userAccount.errorMsg = "请输入真实姓名!";
                    return userAccount;
                }
                if (registerInf.txtPWD.Trim() == "")
                {
                    userAccount.errorMsg = "请输入密码";
                    return userAccount;
                }
                if (registerInf.txtPWD.Trim().Length > 50)
                {
                    userAccount.errorMsg = "密码超长,请重新输入!";
                    return userAccount;
                }
                //if (txtPWD.Text.ToString().Trim() != txtQueRen.Text.ToString().Trim())
                //{
                //    return "您两次输入的密码不一致,请重新输入!";
                //}
                if (registerInf.txtYouXiang.Trim() == "")
                {
                    userAccount.errorMsg = "请输入您的邮箱地址!";
                    return userAccount;
                }

                TbUser user = new TbUser();

                user.UserName = registerInf.txtUserName.Trim();
                user.UserPWD = registerInf.txtPWD.Trim();
                user.RealName = registerInf.txtRealName.Trim();
                user.YongHuLeiXing = "个人";
                user.LianXiDianHua = registerInf.txtDianHua.Trim();
                user.ShouJi = registerInf.txtShouJi.Trim();
                user.TongXinDiZhi = registerInf.txtDiZhi.Trim();
                user.EMail = registerInf.txtYouXiang.Trim();
                user.DepartMentID = 0;
                user.SHFlag = 0;

                using (DataClasses1DataContext db = new DataClasses1DataContext())
                {
                    db.Log = Console.Out;
                    db.TbUser.InsertOnSubmit(user);
                    db.SubmitChanges();
                }

                string sqlShouCang = "insert into TLC_Albums (UserId,ParentId,Title,live,isdel,isparent) values('" + user.ID.ToString().Trim() + "',0,'收藏夹',0,0,0)";
                DBA.DbAccess.ExecNoQuery(CommandType.Text, sqlShouCang);

                userAccount.isLogin = true;
                userAccount.userId = user.ID.ToString().Trim();
                userAccount.userName = user.RealName.ToString().Trim();
            }

            return userAccount;
        }
    private string UserInsert()
    {
        string sql = "";
        DataSet ds = new DataSet();
        bool RoleFlag = false;

        if (this.txtUserName.Text.ToString().Trim() == "")
        {
            return "请输入登录名称!";
        }

        if (this.txtRealName.Text.ToString().Trim() == "")
        {
            return "请输入真实姓名!";
        }

        if (txtPWD.Text.ToString().Trim().Length > 50)
        {
            return "密码超长,请重新输入!";
        }

        if (this.txtPWD.Text.ToString().Trim() == "")
        {

            return "请输入密码";
        }

        sql = "Select * From TbUser Where UserName='******' ";

        ds = DBA.DbAccess.GetDataSet(CommandType.Text, sql);

        if (ds.Tables[0].Rows.Count > 0)
        {
            return "您录入的登录名已存在,请重新输入!";
        }

        string sqlInsert = "";

        //插入数据库项目名称,并返回当前插入行的ID
        if (false && hfUserLeiXing.Value.ToString().Trim() == "企业")
        {

        }
        else
        {
            for (int i = 0; i < chkRole.Items.Count; i++)
            {
                if (chkRole.Items[i].Selected)
                {
                    sqlInsert += "Insert Into UserRole(RoleID,UserID) Values('" + chkRole.Items[i].Value.ToString().Trim() + "','@@@'); ";
                    RoleFlag = true;
                }
            }

            if (!RoleFlag)
            {
                return "请给用户分配至少一个角色";
            }
        }

        TbUser user = new TbUser();

        user.UserName = txtUserName.Text.ToString().Trim();
        user.UserPWD = txtPWD.Text.ToString().Trim();
        user.RealName = txtRealName.Text.ToString().Trim();
        user.YongHuLeiXing = ddlYongHuLX.SelectedValue.ToString().Trim();
        user.LianXiDianHua = txtDianHua.Text.ToString().Trim();
        user.ShouJi = txtShouJi.Text.ToString().Trim();
        user.TongXinDiZhi = txtDiZhi.Text.ToString().Trim();
        user.EMail = txtYouXiang.Text.ToString().Trim();
        user.DepartMentID = 0;
        user.SHFlag = 1;

        user.QiYeMingCheng = txtQiYeMingCheng.Text.ToString().Trim();

        //插入数据库项目名称,并返回当前插入行的ID
        if (hfUserLeiXing.Value.ToString().Trim() == "企业")
        {
            user.DepartMentID = Convert.ToInt32(Session["UserID"].ToString().Trim());
            user.YongHuLeiXing = "企业";
        }
        string DepID = UserRight.getDepartMentID(Session["UserID"].ToString());

        if (DepID != "0")
        {
            user.DepartMentID = int.Parse(DepID);
        }

        using (DataClasses1DataContext db = new DataClasses1DataContext())
        {
            db.Log = Console.Out;
            db.TbUser.InsertOnSubmit(user);
            db.SubmitChanges();
        }

        // 企业用户新建出的用户角色
        if (false && hfUserLeiXing.Value.ToString().Trim() == "企业")
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            var result = from item in db.UserRole
                         where item.UserID.ToString().Trim() == Session["UserID"].ToString().Trim()
                         select item;
            foreach (var item in result)
            {
                UserRole userrole = new UserRole();
                userrole.RoleID = item.RoleID;
                userrole.UserID = user.ID;
                db.UserRole.InsertOnSubmit(userrole);
                db.SubmitChanges();
            }
        }
        else//系统用户建出的用户的角色
        {

            sqlInsert = sqlInsert.Replace("@@@", user.ID.ToString().Trim());
            DBA.DbAccess.ExecNoQuery(CommandType.Text, sqlInsert);
        }
        if (ddlYongHuLX.SelectedValue.ToString().Trim() == "企业")
        {
            string sqlZTK = "insert into ZtDbList(ztDbName,dbType,createUserId) values('企业在线数据库','1','" + user.ID + "')";
            DBA.DbAccess.ExecNoQuery(CommandType.Text, sqlZTK);
        }
        string sqlShouCang = "insert into TLC_Albums (UserId,ParentId,Title,live,isdel,isparent) values('" + user.ID + "',0,'收藏夹',0,0,0)";
        DBA.DbAccess.ExecNoQuery(CommandType.Text, sqlShouCang);
        return "";
    }
Beispiel #6
0
 partial void DeleteTbUser(TbUser instance);
Beispiel #7
0
 partial void UpdateTbUser(TbUser instance);
Beispiel #8
0
 partial void InsertTbUser(TbUser instance);
Beispiel #9
0
        public string RegUserinfo(string userid,  string psd,string username,string email)
        {
            DataSet ds = new DataSet();

            TbUser user = new TbUser();
            string usertype = userid.Substring(4, 1);
            user.UserName = userid.Trim();
            user.UserPWD = psd.Trim();
            user.RealName = username;
            user.YongHuLeiXing = usertype;

            user.EMail = email.Trim();
            user.DepartMentID = 0;
            user.SHFlag = 0;
            DataTable dt = new DataTable();

            string sql = "select * from tbuser where username='******'";
            dt = DBA.SqlDbAccess.GetDataTable(CommandType.Text, sql, null);

            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
                db.Log = Console.Out;
                db.TbUser.InsertOnSubmit(user);
                db.SubmitChanges();
            }
            if (dt.Rows.Count > 0)
                return "1";

            string sqlShouCang = "insert into TLC_Albums (UserId,ParentId,Title,live,isdel,isparent) values('" + user.ID.ToString().Trim() + "',0,'收藏夹',0,0,0)";
            string cusertype = "";
            if (DBA.DbAccess.ExecNoQuery(CommandType.Text, sqlShouCang) < 0)
            {
                return "-1";
            }
            switch (usertype)
            {
                case "0":
                    cusertype = "个人";
                    break;
                case "1":
                    cusertype = "企业";
                    break;
                case "2":
                    cusertype = "事业单位";
                    break;
                case "3":
                    cusertype = "政府机关";
                    break;
                case "4":
                    cusertype = "社会团体";
                    break;
                case "5":
                    cusertype = "其他类型单位";
                    break;
                case "9":
                    cusertype = "简易账户";
                    break;
            }
            sqlShouCang = "select * from TbRole where rolename='" + cusertype + "'";
            dt = DBA.SqlDbAccess.GetDataTable(CommandType.Text, sqlShouCang, null);
            if (dt.Rows.Count == 0)
            {
                return "-1";
            }
            string roleid = dt.Rows[0]["ID"].ToString();
            sqlShouCang = "insert into UserRole (roleid,userid) values ('" + roleid + "','" + user.ID.ToString() + "') ";
            if (DBA.SqlDbAccess.ExecNoQuery(CommandType.Text, sqlShouCang, null) < 0)
            {
                return "-1";
            }
            return "1";
        }