Exemple #1
0
        public JsonResult UpdateUserInfo(JMP.MDL.CoBusinessPersonnel develop)
        {
            object result = new { success = 0, msg = "修改失败!" };

            int    u_id  = string.IsNullOrEmpty(Request["u_id"]) ? 0 : int.Parse(Request["u_id"]);
            string o_pwd = !string.IsNullOrEmpty(Request["upass"]) ? Request["upass"] : "";
            string n_pwd = !string.IsNullOrEmpty(Request["xpass"]) ? Request["xpass"] : "";

            var j_user = _coAgentService.FindById(UserInfo.UserId);

            //判断是否修改了密码
            if (!string.IsNullOrEmpty(o_pwd))
            {
                string temp = DESEncrypt.Encrypt(o_pwd);
                if (temp == j_user.Password)
                {
                    string u_password = DESEncrypt.Encrypt(n_pwd);
                    bool   flag       = _coAgentService.UpdatePwd(j_user.Id, u_password);
                    result = new { success = 1, msg = "修改成功!" };
                }
                else
                {
                    result = new { success = 2, msg = "原密码输入错误!" };
                }
            }

            return(Json(result));
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.CoBusinessPersonnel GetModel(string userName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * ");
            strSql.Append("  from CoBusinessPersonnel ");
            strSql.Append(" where LoginName=@LoginName");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LoginName", SqlDbType.NVarChar, -1)
            };
            parameters[0].Value = userName;


            JMP.MDL.CoBusinessPersonnel model = new JMP.MDL.CoBusinessPersonnel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreatedById"].ToString() != "")
                {
                    model.CreatedById = int.Parse(ds.Tables[0].Rows[0]["CreatedById"].ToString());
                }
                model.CreatedByName = ds.Tables[0].Rows[0]["CreatedByName"].ToString();
                if (ds.Tables[0].Rows[0]["LoginCount"].ToString() != "")
                {
                    model.LoginCount = int.Parse(ds.Tables[0].Rows[0]["LoginCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["State"].ToString() != "")
                {
                    model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString());
                }
                if (ds.Tables[0].Rows[0]["RoleId"].ToString() != "")
                {
                    model.RoleId = int.Parse(ds.Tables[0].Rows[0]["RoleId"].ToString());
                }
                model.LoginName    = ds.Tables[0].Rows[0]["LoginName"].ToString();
                model.Password     = ds.Tables[0].Rows[0]["Password"].ToString();
                model.DisplayName  = ds.Tables[0].Rows[0]["DisplayName"].ToString();
                model.EmailAddress = ds.Tables[0].Rows[0]["EmailAddress"].ToString();
                model.MobilePhone  = ds.Tables[0].Rows[0]["MobilePhone"].ToString();
                model.QQ           = ds.Tables[0].Rows[0]["QQ"].ToString();
                model.Website      = ds.Tables[0].Rows[0]["Website"].ToString();
                if (ds.Tables[0].Rows[0]["CreatedOn"].ToString() != "")
                {
                    model.CreatedOn = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedOn"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 随机获取一个当天登录过的商务姓名
        /// </summary>
        /// <returns></returns>
        public JMP.MDL.CoBusinessPersonnel getModelLoginTime()
        {
            string sql = string.Format("select top 1 DisplayName from [dbo].[CoBusinessPersonnel] where CONVERT(varchar(10),LogintTime,110)=CONVERT(varchar(10),GETDATE(),110) order by newid()");

            JMP.MDL.CoBusinessPersonnel model = new JMP.MDL.CoBusinessPersonnel();
            DataSet ds = DbHelperSQL.Query(sql);

            return(DbHelperSQL.ToModel <JMP.MDL.CoBusinessPersonnel>(ds.Tables[0]));
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(JMP.MDL.CoBusinessPersonnel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CoBusinessPersonnel(");
            strSql.Append("CreatedById,CreatedByName,LoginCount,State,RoleId,LoginName,Password,DisplayName,EmailAddress,MobilePhone,QQ,Website,CreatedOn");
            strSql.Append(") values (");
            strSql.Append("@CreatedById,@CreatedByName,@LoginCount,@State,@RoleId,@LoginName,@Password,@DisplayName,@EmailAddress,@MobilePhone,@QQ,@Website,@CreatedOn");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CreatedById",   SqlDbType.Int,        4),
                new SqlParameter("@CreatedByName", SqlDbType.NVarChar,  50),
                new SqlParameter("@LoginCount",    SqlDbType.Int,        4),
                new SqlParameter("@State",         SqlDbType.Int,        4),
                new SqlParameter("@RoleId",        SqlDbType.Int,        4),
                new SqlParameter("@LoginName",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Password",      SqlDbType.NVarChar, 255),
                new SqlParameter("@DisplayName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@EmailAddress",  SqlDbType.NVarChar, 255),
                new SqlParameter("@MobilePhone",   SqlDbType.NVarChar,  20),
                new SqlParameter("@QQ",            SqlDbType.NVarChar,  15),
                new SqlParameter("@Website",       SqlDbType.NVarChar, 255),
                new SqlParameter("@CreatedOn",     SqlDbType.DateTime)
            };

            parameters[0].Value  = model.CreatedById;
            parameters[1].Value  = model.CreatedByName;
            parameters[2].Value  = model.LoginCount;
            parameters[3].Value  = model.State;
            parameters[4].Value  = model.RoleId;
            parameters[5].Value  = model.LoginName;
            parameters[6].Value  = model.Password;
            parameters[7].Value  = model.DisplayName;
            parameters[8].Value  = model.EmailAddress;
            parameters[9].Value  = model.MobilePhone;
            parameters[10].Value = model.QQ;
            parameters[11].Value = model.Website;
            parameters[12].Value = model.CreatedOn;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #5
0
        /// <summary>
        /// 添加修改商务信息
        /// </summary>
        /// <returns></returns>
        public ActionResult BusinessPersonnelAdd()
        {
            GetListRote();
            int id = string.IsNullOrEmpty(Request["id"]) ? 0 : int.Parse(Request["id"]);

            if (id > 0)
            {
                co_model = bll_co.GetModel(id);
            }

            ViewBag.co_model = co_model;

            return(View());
        }
Exemple #6
0
        public ActionResult AppUserEdit()
        {
            int userId = !string.IsNullOrEmpty(Request["uid"]) ? int.Parse(Request["uid"]) : 0;

            JMP.BLL.jmp_user bll   = new JMP.BLL.jmp_user();
            JMP.MDL.jmp_user model = bll.GetModel(userId);
            ViewBag.UserData  = model;
            ViewBag.UploadUrl = ConfigurationManager.AppSettings["imgurl"];
            string DisplayName = "";

            //
            switch (model.relation_type)
            {
            case 1:

                co_model = bll_co.GetModel(model.relation_person_id);
                if (co_model != null)
                {
                    DisplayName = co_model.DisplayName;
                }

                break;

            case 2:

                modelAgent = bllAgent.GetModel(model.relation_person_id);

                if (modelAgent != null)
                {
                    DisplayName = modelAgent.DisplayName;
                }
                break;
            }

            ViewBag.DisplayName = DisplayName;

            return(View());
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JMP.MDL.CoBusinessPersonnel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CoBusinessPersonnel set ");

            strSql.Append(" CreatedById = @CreatedById , ");
            strSql.Append(" CreatedByName = @CreatedByName , ");
            strSql.Append(" LoginCount = @LoginCount , ");
            strSql.Append(" State = @State , ");
            strSql.Append(" RoleId = @RoleId , ");
            strSql.Append(" LoginName = @LoginName , ");
            strSql.Append(" Password = @Password , ");
            strSql.Append(" DisplayName = @DisplayName , ");
            strSql.Append(" EmailAddress = @EmailAddress , ");
            strSql.Append(" MobilePhone = @MobilePhone , ");
            strSql.Append(" QQ = @QQ , ");
            strSql.Append(" Website = @Website , ");
            strSql.Append(" CreatedOn = @CreatedOn,  ");
            strSql.Append(" LogintTime=@LogintTime");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",            SqlDbType.Int,         4),
                new SqlParameter("@CreatedById",   SqlDbType.Int,         4),
                new SqlParameter("@CreatedByName", SqlDbType.NVarChar,   50),
                new SqlParameter("@LoginCount",    SqlDbType.Int,         4),
                new SqlParameter("@State",         SqlDbType.Int,         4),
                new SqlParameter("@RoleId",        SqlDbType.Int,         4),
                new SqlParameter("@LoginName",     SqlDbType.NVarChar,   50),
                new SqlParameter("@Password",      SqlDbType.NVarChar,  255),
                new SqlParameter("@DisplayName",   SqlDbType.NVarChar,   50),
                new SqlParameter("@EmailAddress",  SqlDbType.NVarChar,  255),
                new SqlParameter("@MobilePhone",   SqlDbType.NVarChar,   20),
                new SqlParameter("@QQ",            SqlDbType.NVarChar,   15),
                new SqlParameter("@Website",       SqlDbType.NVarChar,  255),
                new SqlParameter("@CreatedOn",     SqlDbType.DateTime),
                new SqlParameter("@LogintTime",    SqlDbType.DateTime)
            };

            parameters[0].Value  = model.Id;
            parameters[1].Value  = model.CreatedById;
            parameters[2].Value  = model.CreatedByName;
            parameters[3].Value  = model.LoginCount;
            parameters[4].Value  = model.State;
            parameters[5].Value  = model.RoleId;
            parameters[6].Value  = model.LoginName;
            parameters[7].Value  = model.Password;
            parameters[8].Value  = model.DisplayName;
            parameters[9].Value  = model.EmailAddress;
            parameters[10].Value = model.MobilePhone;
            parameters[11].Value = model.QQ;
            parameters[12].Value = model.Website;
            parameters[13].Value = model.CreatedOn;
            parameters[14].Value = model.LogintTime;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #8
0
        public JsonResult InsertOrUpdateBusinessPersonnel(JMP.MDL.CoBusinessPersonnel mode)
        {
            object retJson = new { success = 0, msg = "操作失败" };

            string loname   = Request["LoginName"];
            string userName = Request["DisplayName"];

            if (mode.Id > 0)
            {
                #region 修改商务

                //修改前数据
                co_model = bll_co.GetModel(mode.Id);
                var modclone = co_model.Clone();
                JMP.MDL.CoBusinessPersonnel co_mod = new JMP.MDL.CoBusinessPersonnel();
                co_model.Password     = DESEncrypt.Encrypt(mode.Password);
                co_model.CreatedOn    = DateTime.Now;
                co_model.LoginName    = mode.LoginName;
                co_model.DisplayName  = mode.DisplayName;
                co_model.EmailAddress = mode.EmailAddress;
                co_model.MobilePhone  = mode.MobilePhone;
                co_model.QQ           = mode.QQ;
                co_model.Website      = mode.Website;
                // mode.CreatedById = UserInfo.UserId;
                // mode.CreatedByName = UserInfo.UserName;
                // mode.LoginCount = co_model.LoginCount;
                // mode.State = co_model.State;
                // mode.LogintTime = co_model.LogintTime == null ? null : co_model.LogintTime;

                if (bll_co.Update(co_model))
                {
                    Logger.ModifyLog("修改商务信息", modclone, co_model);

                    retJson = new { success = 1, msg = "修改成功" };
                }
                else
                {
                    retJson = new { success = 0, msg = "修改失败" };
                }


                #endregion
            }
            else
            {
                #region 添加商务

                JMP.MDL.CoBusinessPersonnel co_mod = new JMP.MDL.CoBusinessPersonnel();
                mode.Password      = DESEncrypt.Encrypt(mode.Password);
                mode.CreatedOn     = DateTime.Now;
                mode.CreatedById   = UserInfo.UserId;
                mode.CreatedByName = UserInfo.UserName;
                mode.LoginCount    = 0;
                int roleId;
                int.TryParse(ConfigReader.GetSettingValueByKey("RoleID"), out roleId);
                mode.RoleId = roleId;
                mode.State  = 0;
                int cg = bll_co.Add(mode);
                if (cg > 0)
                {
                    Logger.CreateLog("添加商务信息", mode);

                    retJson = new { success = 1, msg = "添加成功" };
                }
                else
                {
                    retJson = new { success = 0, msg = "添加失败" };
                }

                #endregion
            }

            return(Json(retJson));
        }