예제 #1
0
    /// <summary>
    /// 更新信息
    /// </summary>
    public void SaveData()
    {
        var json         = Request["data"];
        var areaData     = Request["areaData"];
        var roleValue    = Request["roleValue"];
        var provinceData = areaData.Split('|')[0];
        var cityData     = areaData.Split('|')[1];
        var area         = areaData.Split('|')[2];
        var rows         = (ArrayList)PluSoft.Utils.JSON.Decode(json);
        var bll          = new Sys.BLL.UserInfo();

        Sys.Model.UserInfo model;
        foreach (Hashtable row in rows)
        {
            var id = row["ID"] != null ? row["ID"].ToString() : "";
            //根据记录状态,进行不同的增加、删除、修改操作
            var state = row["_state"] != null ? row["_state"].ToString() : "";
            if (state == "added" || id == "")           //新增:id为空,或_state为added
            {
                model              = new Sys.Model.UserInfo();
                model.UserName     = row["UserName"].ToString();
                model.RealName     = row["RealName"].ToString();
                model.CompanyName  = row["CompanyName"].ToString();
                model.ProvinceId   = Utils.StrToInt(row["ProvinceId"], 0);
                model.ProvinceName = provinceData.Split(':')[1];
                model.CityId       = Utils.StrToInt(row["CityId"], 0);
                model.CityName     = cityData.Split(':')[1];
                model.AreaId       = Utils.StrToInt(row["AreaId"], 0);
                model.AreaName     = area.Split(':')[1];
                model.Address      = row["Address"].ToString();
                model.RoleId       = Utils.StrToInt(row["RoleId"], 0);
                model.TypeKey      = row["TypeKey"].ToString();
                model.TypeValue    = roleValue.Split(':')[1];
                model.CreateTime   = DateTime.Now;

                var result = new Sys.BLL.UserInfo().Add(model, Utils.MD5(row["Password"].ToString()));
            }
            else if (state == "modified" || state == "") //更新:_state为空或modified
            {
                model = bll.GetModel(Utils.StrToInt(row["ID"], 0));
                if (model != null)
                {
                    model.UserName     = row["UserName"].ToString();
                    model.RealName     = row["RealName"].ToString();
                    model.CompanyName  = row["CompanyName"].ToString();
                    model.ProvinceId   = Utils.StrToInt(row["ProvinceId"], 0);
                    model.ProvinceName = provinceData.Split(':')[1];
                    model.CityId       = Utils.StrToInt(row["CityId"], 0);
                    model.CityName     = cityData.Split(':')[1];
                    model.AreaId       = Utils.StrToInt(row["AreaId"], 0);
                    model.AreaName     = area.Split(':')[1];
                    model.Address      = row["Address"].ToString();
                    model.RoleId       = Utils.StrToInt(row["RoleId"], 0);
                    model.TypeKey      = row["TypeKey"].ToString();
                    model.TypeValue    = roleValue.Split(':')[1];
                    bll.Update(model);
                }
            }
        }
    }
예제 #2
0
    /// <summary>
    /// 注册
    /// </summary>
    /// <param name="dicParams"></param>
    /// <returns></returns>
    public Dictionary <string, object> Register(Dictionary <string, object> dicParams)
    {
        Dictionary <string, object> dicResult = new Dictionary <string, object>();
        var dt = JsonHelper.JsonToDataTable(dicParams["user_info"].ToString());

        if (dt != null && dt.Rows.Count > 0)
        {
            var row    = dt.Rows[0];
            var dtUser = new Sys.BLL.Account().GetUserInfoByUserLoginId(row["USERLOGINID"].ToString());
            if (dtUser != null && dtUser.Rows.Count > 0)
            {
                dicResult.Add("response_id", 0);
                dicResult.Add("response_msg", "手机号重复,不能注册!");
                return(dicResult);
            }

            var modelUserInfo = new Sys.Model.UserInfo()
            {
                UserName     = row["USERLOGINID"].ToString(),
                RealName     = row["USERNAME"].ToString(),
                CompanyName  = row["CompanyName"].ToString(),
                ProvinceId   = !string.IsNullOrEmpty(row["ProvinceId"].ToString()) ? Convert.ToInt32(row["ProvinceId"].ToString()) : 0,
                ProvinceName = row["ProvinceName"].ToString(),
                CityId       = !string.IsNullOrEmpty(row["CityId"].ToString()) ? Convert.ToInt32(row["CityId"].ToString()) : 0,
                CityName     = row["CityName"].ToString(),
                AreaId       = !string.IsNullOrEmpty(row["AreaId"].ToString()) ? Convert.ToInt32(row["AreaId"].ToString()) : 0,
                AreaName     = row["AreaName"].ToString(),
                Address      = row["Address"].ToString(),
                contact      = row["contact"].ToString(),
                TypeKey      = row["TypeKey"].ToString(),
                TypeValue    = row["TypeValue"].ToString(),
                RoleId       = !string.IsNullOrEmpty(row["RoleId"].ToString()) ? Convert.ToInt32(row["RoleId"].ToString()) : 0,
            };
            var result = new Sys.BLL.UserInfo().Add(modelUserInfo, Utils.MD5(row["PASSWORD"].ToString()));
            if (result > 0)
            {
                dicResult.Add("response_id", 1);
                dicResult.Add("response_msg", "注册成功!");
            }
            else
            {
                dicResult.Add("response_id", 0);
                dicResult.Add("response_msg", "注册失败!");
            }
        }

        return(dicResult);
    }
예제 #3
0
파일: UserInfo.cs 프로젝트: ttrr1/Midea
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Sys.Model.UserInfo model)
 {
     return(dal.Update(model));
 }
예제 #4
0
파일: UserInfo.cs 프로젝트: ttrr1/Midea
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Sys.Model.UserInfo model)
 {
     return(dal.Add(model));
 }
예제 #5
0
파일: UserInfo.cs 프로젝트: ttrr1/Midea
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Sys.Model.UserInfo> DataTableToList(DataTable dt)
        {
            List <Sys.Model.UserInfo> modelList = new List <Sys.Model.UserInfo>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Sys.Model.UserInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Sys.Model.UserInfo();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["UserId"] != null && dt.Rows[n]["UserId"].ToString() != "")
                    {
                        model.UserId = int.Parse(dt.Rows[n]["UserId"].ToString());
                    }
                    if (dt.Rows[n]["UserCode"] != null && dt.Rows[n]["UserCode"].ToString() != "")
                    {
                        model.UserCode = dt.Rows[n]["UserCode"].ToString();
                    }
                    if (dt.Rows[n]["UserName"] != null && dt.Rows[n]["UserName"].ToString() != "")
                    {
                        model.UserName = dt.Rows[n]["UserName"].ToString();
                    }
                    if (dt.Rows[n]["RealName"] != null && dt.Rows[n]["RealName"].ToString() != "")
                    {
                        model.RealName = dt.Rows[n]["RealName"].ToString();
                    }
                    if (dt.Rows[n]["CreateTime"] != null && dt.Rows[n]["CreateTime"].ToString() != "")
                    {
                        model.CreateTime = DateTime.Parse(dt.Rows[n]["CreateTime"].ToString());
                    }
                    if (dt.Rows[n]["Sex"] != null && dt.Rows[n]["Sex"].ToString() != "")
                    {
                        model.Sex = int.Parse(dt.Rows[n]["Sex"].ToString());
                    }
                    if (dt.Rows[n]["Address"] != null && dt.Rows[n]["Address"].ToString() != "")
                    {
                        model.Address = dt.Rows[n]["Address"].ToString();
                    }
                    if (dt.Rows[n]["Introduction"] != null && dt.Rows[n]["Introduction"].ToString() != "")
                    {
                        model.Introduction = dt.Rows[n]["Introduction"].ToString();
                    }
                    if (dt.Rows[n]["SMSMobile"] != null && dt.Rows[n]["SMSMobile"].ToString() != "")
                    {
                        model.SMSMobile = dt.Rows[n]["SMSMobile"].ToString();
                    }
                    if (dt.Rows[n]["Mobile"] != null && dt.Rows[n]["Mobile"].ToString() != "")
                    {
                        model.Mobile = dt.Rows[n]["Mobile"].ToString();
                    }
                    if (dt.Rows[n]["SId"] != null && dt.Rows[n]["SId"].ToString() != "")
                    {
                        model.SId = int.Parse(dt.Rows[n]["SId"].ToString());
                    }
                    if (dt.Rows[n]["User_RId"] != null && dt.Rows[n]["User_RId"].ToString() != "")
                    {
                        model.User_RId = int.Parse(dt.Rows[n]["User_RId"].ToString());
                    }
                    if (dt.Rows[n]["MotionSend"] != null && dt.Rows[n]["MotionSend"].ToString() != "")
                    {
                        model.MotionSend = int.Parse(dt.Rows[n]["MotionSend"].ToString());
                    }
                    if (dt.Rows[n]["CId"] != null && dt.Rows[n]["CId"].ToString() != "")
                    {
                        model.CId = int.Parse(dt.Rows[n]["CId"].ToString());
                    }
                    if (dt.Rows[n]["GId"] != null && dt.Rows[n]["GId"].ToString() != "")
                    {
                        model.GId = int.Parse(dt.Rows[n]["GId"].ToString());
                    }
                    if (dt.Rows[n]["EnrollmentTime"] != null && dt.Rows[n]["EnrollmentTime"].ToString() != "")
                    {
                        model.EnrollmentTime = DateTime.Parse(dt.Rows[n]["EnrollmentTime"].ToString());
                    }
                    if (dt.Rows[n]["Logo"] != null && dt.Rows[n]["Logo"].ToString() != "")
                    {
                        model.Logo = dt.Rows[n]["Logo"].ToString();
                    }
                    if (dt.Rows[n]["CompanyName"] != null && dt.Rows[n]["CompanyName"].ToString() != "")
                    {
                        model.CompanyName = dt.Rows[n]["CompanyName"].ToString();
                    }
                    if (dt.Rows[n]["ProvinceId"] != null && dt.Rows[n]["ProvinceId"].ToString() != "")
                    {
                        model.ProvinceId = int.Parse(dt.Rows[n]["ProvinceId"].ToString());
                    }
                    if (dt.Rows[n]["ProvinceName"] != null && dt.Rows[n]["ProvinceName"].ToString() != "")
                    {
                        model.ProvinceName = dt.Rows[n]["ProvinceName"].ToString();
                    }
                    if (dt.Rows[n]["CityId"] != null && dt.Rows[n]["CityId"].ToString() != "")
                    {
                        model.CityId = int.Parse(dt.Rows[n]["CityId"].ToString());
                    }
                    if (dt.Rows[n]["CityName"] != null && dt.Rows[n]["CityName"].ToString() != "")
                    {
                        model.CityName = dt.Rows[n]["CityName"].ToString();
                    }
                    if (dt.Rows[n]["AreaId"] != null && dt.Rows[n]["AreaId"].ToString() != "")
                    {
                        model.AreaId = int.Parse(dt.Rows[n]["AreaId"].ToString());
                    }
                    if (dt.Rows[n]["AreaName"] != null && dt.Rows[n]["AreaName"].ToString() != "")
                    {
                        model.AreaName = dt.Rows[n]["AreaName"].ToString();
                    }
                    if (dt.Rows[n]["sAreaId"] != null && dt.Rows[n]["sAreaId"].ToString() != "")
                    {
                        model.sAreaId = int.Parse(dt.Rows[n]["sAreaId"].ToString());
                    }
                    if (dt.Rows[n]["sAreaName"] != null && dt.Rows[n]["sAreaName"].ToString() != "")
                    {
                        model.sAreaName = dt.Rows[n]["sAreaName"].ToString();
                    }
                    if (dt.Rows[n]["contact"] != null && dt.Rows[n]["contact"].ToString() != "")
                    {
                        model.contact = dt.Rows[n]["contact"].ToString();
                    }
                    if (dt.Rows[n]["TypeKey"] != null && dt.Rows[n]["TypeKey"].ToString() != "")
                    {
                        model.TypeKey = dt.Rows[n]["TypeKey"].ToString();
                    }
                    if (dt.Rows[n]["TypeValue"] != null && dt.Rows[n]["TypeValue"].ToString() != "")
                    {
                        model.TypeValue = dt.Rows[n]["TypeValue"].ToString();
                    }
                    if (dt.Rows[n]["RoleId"] != null && dt.Rows[n]["RoleId"].ToString() != "")
                    {
                        model.RoleId = int.Parse(dt.Rows[n]["RoleId"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
예제 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Sys.Model.UserInfo model, string password)
 {
     return(dal.Add(model, password));
 }