Ejemplo n.º 1
0
        //判断是否自动登录
        void Autologin()
        {
            if (Daiv_OA.Utils.Cookie.GetValue("oa_user") != null)
            {
                if (Daiv_OA.Utils.Cookie.GetValue("oa_user", "ip") == Request.UserHostAddress)
                {
                    Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity();
                    model = new Daiv_OA.BLL.UserBLL().GetEntity(Convert.ToInt32(Daiv_OA.Utils.Cookie.GetValue("oa_user", "id")));
                    int pid = model.Pid;
                    new BLL.UserBLL().UpdateTime(model.Uid);
                    switch (pid)
                    {
                    case 1:
                        Session["UserName"] = model.Uname;
                        Response.Redirect("Index.aspx");
                        break;

                    case 2:
                        Session["UserName"] = model.Uname;
                        Response.Redirect("Index.aspx");
                        break;

                    case 3:
                        Session["UserName"] = model.Uname;
                        Response.Redirect("Index.aspx");
                        break;

                    case 4:
                        Session["UserName"] = model.Uname;
                        Response.Redirect("Index.aspx");
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 验证登陆
 /// </summary>
 private void chkLogin(string go2Url, int BackStep)
 {
     if (Daiv_OA.Utils.Cookie.GetValue("oa_user") != null)
     {
         UserId   = Validator.StrToInt(Daiv_OA.Utils.Cookie.GetValue("oa_user", "id"), 0);
         UserName = Daiv_OA.Utils.Cookie.GetValue("oa_user", "name");
         if (UserId != 0 && UserName.Length != 0)
         {
             Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity();
             model = new BLL.UserBLL().GetEntity(UserId);
             if (model.Uipaddress.Length > 0)
             {
                 if (Request.UserHostAddress != model.Uipaddress)
                 {
                     showErrMsg("非法IP地址登录", go2Url, BackStep);
                     return;
                 }
             }
             this.UserIsLogin = true;
             UserPosition     = model.Position;
             UserPowerId      = model.Pid;
             UserDepartmentId = model.Did;
             UserSetting      = model.Setting;
         }
     }
 }
Ejemplo n.º 3
0
        //数据绑定
        void Bind()
        {
            int uid = Str2Int(q("id"), 0);

            Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity();
            model = new Daiv_OA.BLL.UserBLL().GetEntity(uid);
            this.txtUname.Text = model.Uname;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Daiv_OA.Entity.UserEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [OA_User] set ");
            strSql.Append("Pid=" + model.Pid + ",");
            strSql.Append("Uname='" + model.Uname + "',");
            strSql.Append("Did='" + model.Did + "',");
            strSql.Append("Upwd='" + model.Upwd + "',");
            strSql.Append("Position='" + model.Position + "',");
            strSql.Append("Setting='" + model.Setting + "',");
            strSql.Append("Uipaddress='" + model.Uipaddress + "',");
            strSql.Append("UClassID=" + model.UClassID + ",");
            strSql.Append("UClassName='" + model.UClassName + "',");
            strSql.Append("Mphone='" + model.Mphone + "',");
            strSql.Append("ULongName='" + model.ULongName + "'");
            strSql.Append(" where Uid=" + model.Uid + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 构造实体对象
 /// </summary>
 /// <param name="dt"></param>
 /// <param name="rowindex"></param>
 /// <returns></returns>
 public Daiv_OA.Entity.UserEntity ConvertModel(DataTable dt, int rowindex)
 {
     Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity();
     try
     {
         if (dt.Rows[rowindex]["Uid"].ToString() != "")
         {
             model.Uid = int.Parse(dt.Rows[rowindex]["Uid"].ToString());
         }
         if (dt.Rows[rowindex]["Did"].ToString() != "")
         {
             model.Did = int.Parse(dt.Rows[rowindex]["Did"].ToString());
         }
         if (dt.Rows[rowindex]["Pid"].ToString() != "")
         {
             model.Pid = int.Parse(dt.Rows[rowindex]["Pid"].ToString());
         }
         model.Uname      = dt.Rows[rowindex]["Uname"].ToString();
         model.Upwd       = dt.Rows[rowindex]["Upwd"].ToString();
         model.Uipaddress = dt.Rows[rowindex]["Uipaddress"].ToString();
         model.Position   = dt.Rows[rowindex]["Position"].ToString();
         model.Setting    = dt.Rows[rowindex]["Setting"].ToString();
         model.UClassName = dt.Rows[rowindex]["UClassName"].ToString();
         model.Mphone     = dt.Rows[rowindex]["Mphone"].ToString();
         model.ULongName  = dt.Rows[rowindex]["ULongName"].ToString();
         if (dt.Rows[rowindex]["UClassID"].ToString() != "")
         {
             model.UClassID = int.Parse(dt.Rows[rowindex]["UClassID"].ToString());
         }
         if (dt.Rows[rowindex]["IsDeleted"].ToString() != "")
         {
             model.IsDeleted = int.Parse(dt.Rows[rowindex]["IsDeleted"].ToString());
         }
     }
     catch (Exception ex)
     {
         log.Info("转换成用户对象失败!原因:" + ex.Message);
         return(new Entity.UserEntity());
     }
     return(model);
 }
Ejemplo n.º 6
0
        //信息绑定
        void Bind()
        {
            Daiv_OA.Entity.TaskEntity model = new Daiv_OA.Entity.TaskEntity();
            model = new BLL.TaskBLL().GetEntity(Str2Int(q("id")));
            if (model.Ttype == "锁定")
            {
                Response.Redirect("Locked.aspx");

            }
            Daiv_OA.Entity.UserEntity userEntity = new Daiv_OA.Entity.UserEntity();
            userEntity = new BLL.UserBLL().GetEntity(model.Uid);
            this.txtBegintime.Text = model.Nowtime.ToString();
            this.txtEndtime.Text = model.Plantime.ToString();
            this.txtTitle.Text = model.Tasktitle;
            this.ddlWorker.SelectedValue = userEntity.Uid.ToString();
            txt.Text = model.Content;
            questext.Text = model.Question;
            this.ddlWorker.Enabled = false;
            this.classse.SelectedValue = model.Classse;

        }
Ejemplo n.º 7
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Daiv_OA.Entity.UserEntity userEntity = new Daiv_OA.Entity.UserEntity();

            //可以添加
            Daiv_OA.Entity.MessageEntity message = new Daiv_OA.Entity.MessageEntity();
            message.Content = this.kindeditor.Value;
            message.FromUid = UserId;
            message.Addtime = System.DateTime.Now;
            message.Mtitle  = this.txtTitle.Text;
            if (mes != 0)
            {
                message.ToUid = _uid;
            }
            else
            {
                if (DropDownList1.SelectedValue == "-1")
                {
                    System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler;
                    page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript", "<script language='javascript'>alert('请选择收信人!');</script>");
                    return;
                }
                else
                {
                    message.ToUid = Convert.ToInt32(DropDownList2.SelectedValue.ToString());
                }
            }
            int i = new Daiv_OA.BLL.MessageBLL().Add(message);

            if (i > 0)
            {
                Daiv_OA.BLL.OA_SysMessageIn.ADDsysMessage(0, "," + message.ToUid + ",", "新短信", Daiv_OA.Utils.Strings.Left(Daiv_OA.Utils.Strings.delhtml(txtTitle.Text.Trim()), 53), "Message_Show.aspx?id=" + i.ToString());
                FinalMessage("短信发送成功", "Message_MySend.aspx", 0);
            }
            else
            {
                FinalMessage("短信发送失败", "Message_MySend.aspx", 0);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Daiv_OA.Entity.UserEntity GetEntity(int Uid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" Uid,Pid,Did,Uname,Upwd,Uipaddress,Position,Setting,UClassID,UClassName,Mphone,ULongName,IsDeleted ");
            strSql.Append(" FROM [OA_User] ");
            strSql.Append(" where Uid=" + Uid + " ");
            Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                //if (ds.Tables[0].Rows[0]["Uid"].ToString() != "")
                //{
                //    model.Uid = int.Parse(ds.Tables[0].Rows[0]["Uid"].ToString());
                //}
                //if (ds.Tables[0].Rows[0]["Did"].ToString() != "")
                //{
                //    model.Did = int.Parse(ds.Tables[0].Rows[0]["Did"].ToString());
                //}
                //if (ds.Tables[0].Rows[0]["Pid"].ToString() != "")
                //{
                //    model.Pid = int.Parse(ds.Tables[0].Rows[0]["Pid"].ToString());
                //}
                //model.Uname = ds.Tables[0].Rows[0]["Uname"].ToString();
                //model.Upwd = ds.Tables[0].Rows[0]["Upwd"].ToString();
                //model.Uipaddress = ds.Tables[0].Rows[0]["Uipaddress"].ToString();
                //model.Position = ds.Tables[0].Rows[0]["Position"].ToString();
                //model.Setting = ds.Tables[0].Rows[0]["Setting"].ToString();
                //return model;
                return(ConvertModel(ds.Tables[0], 0));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 9
0
 void showlist()
 {
     if (txtid.Text.Trim() != "")
     {
         qs.Visible = true;
         Daiv_OA.Entity.TaskEntity model = new Daiv_OA.Entity.TaskEntity();
         int id = Convert.ToInt32(txtid.Text.Trim());
         model = new BLL.TaskBLL().GetEntity(id);
         if (id == 4 || id == 8)
         {
             Workprogress.SelectedValue = model.Workprogress.ToString();
         }
         this.txtBegintime.Text = model.Nowtime.ToString();
         this.txtEndtime.Text   = model.Plantime.ToString();
         this.txtTitle.Text     = model.Tasktitle.ToString();
         Daiv_OA.Entity.UserEntity userEntity = new Daiv_OA.Entity.UserEntity();
         userEntity  = new BLL.UserBLL().GetEntity(model.Uid);
         Uidtxt.Text = userEntity.Uname.ToString();
     }
     else
     {
         qs.Visible = false;
     }
 }
Ejemplo n.º 10
0
        //数据绑定
        void Bind()
        {
            int uid = Str2Int(q("id"), 0);

            department();
            roless();

            Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity();
            model = new Daiv_OA.BLL.UserBLL().GetEntity(uid);
            this.txtUname.Text     = model.Uname;
            this.txtUname.ReadOnly = true;
            // this.txtPosition.Text = model.Position; //职位
            this.txtIpaddress.Text = model.Uipaddress;
            //this.UClassID.Text = model.UClassID.ToString();
            this.ULongName.Text = model.ULongName;
            //this.UClassName.Text = model.UClassName ;
            this.Mphone.Text = model.Mphone;
            string user_setting = "";

            string[,] menu = null;
            if (pidtxt.Text != "")
            {
                Entity.PowerEntity powerEntity = new BLL.PowerBLL().GetEntity(Convert.ToInt32(pidtxt.Text.Trim()));
                user_setting = powerEntity.Setting;
                int pid = Convert.ToInt32(pidtxt.Text);

                if (depid.Text != "")
                {
                    DropDownList1.SelectedValue = depid.Text.ToString();
                }
                else
                {
                    DropDownList1.SelectedValue = model.Did.ToString();
                }
                DropDownList2.SelectedValue = pid.ToString();
                if (pid == 1)
                {
                    menu = powerMenu1();
                }
                if (pid == 2)
                {
                    menu = powerMenu2();
                }
                else if (pid == 3)
                {
                    menu = powerMenu3();
                }
                else if (pid == 4)
                {
                    menu = powerMenu4();
                }
            }
            else
            {
                DropDownList1.SelectedValue = model.Did.ToString();

                DropDownList2.SelectedValue = model.Pid.ToString();
                user_setting = model.Setting;
                if (model.Pid == 1)
                {
                    menu = powerMenu1();
                }
                if (model.Pid == 2)
                {
                    menu = powerMenu2();
                }
                else if (model.Pid == 3)
                {
                    menu = powerMenu3();
                }
                else if (model.Pid == 4)
                {
                    menu = powerMenu4();
                }
            }

            //绑定班级
            Daiv_OA.BLL.GradeBLL dp = new Daiv_OA.BLL.GradeBLL();
            DataSet ds = dp.GetList("");

            for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
            {
                ListItem listItem = new ListItem();
                listItem.Text  = ds.Tables[0].Rows[j]["Gname"].ToString();
                listItem.Value = ds.Tables[0].Rows[j]["Gid"].ToString();
                this.ddlGid.Items.Add(listItem);
            }
            this.ddlGid.SelectedValue = model.UClassID.ToString();
            ds.Clear();

            StringBuilder sb = new StringBuilder();

            sb.Append("<table cellspacing=\"0\" width=\"100%\" cellpadding=\"0\" align=\"center\">");
            for (int i = 0; i < menu.GetLength(0); i++)
            {
                sb.Append("<tr><td width=\"260\" align=\"right\"><strong>" + menu[i, 0] + "</strong></td>");
                sb.Append("<td width=\"*\">");
                for (int j = 1; j < menu.GetLength(1); j++)
                {
                    if (menu[i, j] == null)
                    {
                        break;
                    }
                    string[] _split = menu[i, j].Split('|');
                    sb.Append("<span style='float:left;height:30px;margin-left:10px;padding-top:5px;' scope='col'><input id=\"user_setting_" + i + "_" + j + "\" type=checkbox class='checkbox' name=\"user_setting\" value=\"");
                    string tPower = _split[1];
                    sb.Append(tPower + "\"");
                    if (_split.Length > 2 && _split[2] == "1")
                    {
                        sb.Append(" onclick='if(!this.checked){this.checked=true;}else{this.checked=false;}'");
                    }
                    if (user_setting.Contains("," + tPower + ","))
                    {
                        sb.Append(" checked");
                    }
                    sb.Append("><label for=\"user_setting_" + i + "_" + j + "\">" + _split[0] + "</label>");
                    sb.Append("</span>\r\n");
                }
                sb.Append("</td></tr>");
            }
            sb.Append("</td></tr>");
            sb.Append("</table>");
            this.ltMasterSetting.Text = sb.ToString();
        }
Ejemplo n.º 11
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            // 记录其IP地址,下次登录时验证,IP为空则记录,IP不为空则验证
            string uname = this.txtUserName.Text.Trim();
            string upwd  = this.txtUserPwd.Text.Trim();
            string code  = txtCode.Text.Trim();

            if (uname.Equals("") || upwd.Equals(""))
            {
                lblTip.Visible = true;
                lblTip.Text    = "请输入用户名或密码";
                return;
            }
            if (code.Equals(""))
            {
                lblTip.Visible = true;
                lblTip.Text    = "请输入验证码";
                return;
            }
            if (Session[verify_code.SESSION_CODE] == null)
            {
                lblTip.Visible = true;
                lblTip.Text    = "系统找不到验证码";
                return;
            }
            if (code.ToLower() != Session[verify_code.SESSION_CODE].ToString().ToLower())
            {
                lblTip.Visible = true;
                lblTip.Text    = "验证码输入不正确";
                return;
            }


            string uid = new Daiv_OA.BLL.UserBLL().Existslongin(uname, Daiv_OA.Utils.MD5.Lower32(upwd));

            if (uid != "")
            {
                Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity();
                model = new Daiv_OA.BLL.UserBLL().GetEntity(int.Parse(uid));
                if (model.Uipaddress != "")
                {
                    if (model.Uipaddress != Page.Request.UserHostAddress)
                    {
                        Response.Write("<script>alert('非法IP,请在本机登陆!');</script>");
                        Response.End();
                    }
                }
                int iExpires = 0;
                //设置Cookies
                //System.Collections.Specialized.NameValueCollection myCol = new System.Collections.Specialized.NameValueCollection();
                //myCol.Add("id", uid.ToString());
                //myCol.Add("name", uname);
                //myCol.Add("ip", Request.UserHostAddress);
                //new BLL.UserBLL().UpdateTime(model.Uid);
                int pid = model.Pid;
                //myCol.Add("Powerid", pid.ToString());
                //Daiv_OA.Utils.Cookie.SetObj("oa_user", 60 * 60 * 15 * iExpires, myCol, "", "/");

                new BLL.UserBLL().SetUserCookies(model, Request.UserHostAddress, iExpires);

                switch (pid)
                {
                case 1:
                    Session["UserName"] = uname;
                    Response.Redirect("Index.aspx");    //管理员
                    break;

                case 2:
                    Session["UserName"] = uname;
                    Response.Redirect("Index.aspx");    //管理组织层
                    break;

                case 3:
                    Session["UserName"] = uname;
                    Response.Redirect("Index.aspx");    //网站编辑
                    break;

                case 4:
                    Session["UserName"] = uname;
                    Response.Redirect("Index.aspx");    //美工和程序员
                    break;
                }
            }
            else
            {
                this.txtUserName.Text = "";
                this.txtUserPwd.Text  = "";
                System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler;
                page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript", "<script language='javascript'>alert('请正确填写用户名和密码!');</script>");
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Daiv_OA.Entity.UserEntity model)
        {
            if (Exists(model.Uname))//已经存在该用户
            {
                return(0);
            }
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            strSql1.Append("Pid,");
            strSql2.Append("" + model.Pid + ",");
            strSql1.Append("Did,");
            strSql2.Append("" + model.Did + ",");

            if (model.Uname != null)
            {
                strSql1.Append("Uname,");
                strSql2.Append("'" + model.Uname + "',");
            }
            if (model.Upwd != null)
            {
                strSql1.Append("Upwd,");
                strSql2.Append("'" + model.Upwd + "',");
            }
            if (model.Uipaddress != null)
            {
                strSql1.Append("Uipaddress,");
                strSql2.Append("'" + model.Uipaddress + "',");
            }
            if (model.Position != null)
            {
                strSql1.Append("Position,");
                strSql2.Append("'" + model.Position + "',");
            }
            if (model.Setting != null)
            {
                strSql1.Append("Setting,");
                strSql2.Append("'" + model.Setting + "',");
            }
            if (model.UClassID > 0)
            {
                strSql1.Append("UClassID,");
                strSql2.Append("" + model.UClassID + ",");
            }
            if (model.Mphone != null)
            {
                strSql1.Append("Mphone,");
                strSql2.Append("'" + model.Mphone + "',");
            }
            if (model.UClassName != null)
            {
                strSql1.Append("UClassName,");
                strSql2.Append("'" + model.UClassName + "',");
            }
            if (model.ULongName != null)
            {
                strSql1.Append("ULongName,");
                strSql2.Append("'" + model.ULongName + "',");
            }
            if (model.IsDeleted >= 0)
            {
                strSql1.Append("IsDeleted,");
                strSql2.Append("" + model.IsDeleted + ",");
            }
            strSql.Append("insert into [OA_User](");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }