/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(big_data.Model.UnifiedAddressLibraryUserInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UnifiedAddressLibraryUserInfo set ");
            strSql.Append("UnifiedAddressLibraryID=@UnifiedAddressLibraryID,");
            strSql.Append("UserIDList=@UserIDList,");
            strSql.Append("AddTime=@AddTime");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UnifiedAddressLibraryID", SqlDbType.Int,        4),
                new SqlParameter("@UserIDList",              SqlDbType.NVarChar,  -1),
                new SqlParameter("@AddTime",                 SqlDbType.DateTime2,  8),
                new SqlParameter("@ID",                      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UnifiedAddressLibraryID;
            parameters[1].Value = model.UserIDList;
            parameters[2].Value = model.AddTime;
            parameters[3].Value = model.ID;

            int rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(big_data.Model.UnifiedAddressLibraryUserInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UnifiedAddressLibraryUserInfo(");
            strSql.Append("UnifiedAddressLibraryID,UserIDList,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@UnifiedAddressLibraryID,@UserIDList,@AddTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UnifiedAddressLibraryID", SqlDbType.Int,        4),
                new SqlParameter("@UserIDList",              SqlDbType.NVarChar,  -1),
                new SqlParameter("@AddTime",                 SqlDbType.DateTime2, 8)
            };
            parameters[0].Value = model.UnifiedAddressLibraryID;
            parameters[1].Value = model.UserIDList;
            parameters[2].Value = model.AddTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public big_data.Model.UnifiedAddressLibraryUserInfo GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,UnifiedAddressLibraryID,UserIDList,AddTime from UnifiedAddressLibraryUserInfo ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            big_data.Model.UnifiedAddressLibraryUserInfo model = new big_data.Model.UnifiedAddressLibraryUserInfo();
            DataSet ds = DbHelperSql.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public big_data.Model.UnifiedAddressLibraryUserInfo DataRowToModel(DataRow row)
 {
     big_data.Model.UnifiedAddressLibraryUserInfo model = new big_data.Model.UnifiedAddressLibraryUserInfo();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["UnifiedAddressLibraryID"] != null && row["UnifiedAddressLibraryID"].ToString() != "")
         {
             model.UnifiedAddressLibraryID = int.Parse(row["UnifiedAddressLibraryID"].ToString());
         }
         if (row["UserIDList"] != null)
         {
             model.UserIDList = row["UserIDList"].ToString();
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = DateTime.Parse(row["AddTime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 匹配户籍信息和地址库
        /// </summary>
        public void UnifiedAddressLibraryUserInfo()
        {
            DataSet dss = userinfotybll.GetList("1=1");

            if (dss.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dss.Tables[0].Rows.Count; i++)
                {
                    string mphhm  = "";
                    string Issfpp = "0";
                    if (dss.Tables[0].Rows[i]["Domicile"].ToString() != "")
                    {
                        userinfotymodel = userinfotybll.GetModel(Convert.ToInt32(dss.Tables[0].Rows[i]["ID"].ToString()));
                        if (dss.Tables[0].Rows[i]["Domicile"].ToString().Length >= 12)
                        {
                            string[] strlist = dss.Tables[0].Rows[i]["Domicile"].ToString().Split('村');
                            if (strlist.Length > 1)
                            {
                                mphhm = ToDBC(strlist[1]);//地址
                            }
                        }
                        else
                        {
                            mphhm = ToDBC(dss.Tables[0].Rows[i]["Domicile"].ToString());//地址
                        }
                    }
                    else
                    {
                        mphhm = "户籍信息中没有地址信息";
                    }
                    string  username = dss.Tables[0].Rows[i]["RealName"].ToString();//姓名
                    DataSet dssa     = unifiedAddressLibrarybll.GetList("SOURCEADDRESS like '%" + mphhm + "%'");
                    if (dssa.Tables[0].Rows.Count > 0)
                    {
                        for (int i1 = 0; i1 < dssa.Tables[0].Rows.Count; i1++)
                        {
                            DataSet dssb = unifiedAddressLibraryUserInfobll.GetList("UnifiedAddressLibraryID=" + dssa.Tables[0].Rows[i1]["ID"]);
                            if (dssb.Tables[0].Rows.Count > 0)
                            {
                                unifiedAddressLibraryUserInfomodel = unifiedAddressLibraryUserInfobll.GetModel(Convert.ToInt32(dssb.Tables[0].Rows[0]["ID"]));
                                if (!("," + unifiedAddressLibraryUserInfomodel.UserIDList + ",").Contains("," + dss.Tables[0].Rows[i]["ID"] + ","))
                                {
                                    unifiedAddressLibraryUserInfomodel.UserIDList += "," + dss.Tables[0].Rows[i]["ID"].ToString();
                                }
                                unifiedAddressLibraryUserInfomodel.AddTime = DateTime.Now;
                                unifiedAddressLibraryUserInfobll.Update(unifiedAddressLibraryUserInfomodel);
                            }
                            else
                            {
                                unifiedAddressLibraryUserInfomodel.UnifiedAddressLibraryID = Convert.ToInt32(dssa.Tables[0].Rows[i1]["ID"]);
                                unifiedAddressLibraryUserInfomodel.UserIDList = dss.Tables[0].Rows[i]["ID"].ToString();
                                unifiedAddressLibraryUserInfomodel.AddTime    = DateTime.Now;
                                unifiedAddressLibraryUserInfobll.Add(unifiedAddressLibraryUserInfomodel);
                            }
                        }
                        Issfpp = "1";
                    }
                    else
                    {
                        DataSet dssab = unifiedAddressLibrarybll.GetList("SOURCEADDRESS like '%" + username + "%'");
                        if (dssab.Tables[0].Rows.Count > 0)
                        {
                            for (int i1 = 0; i1 < dssab.Tables[0].Rows.Count; i1++)
                            {
                                DataSet dssabb = unifiedAddressLibraryUserInfobll.GetList("UnifiedAddressLibraryID=" + dssab.Tables[0].Rows[i1]["ID"]);
                                if (dssabb.Tables[0].Rows.Count > 0)
                                {
                                    unifiedAddressLibraryUserInfomodel = unifiedAddressLibraryUserInfobll.GetModel(Convert.ToInt32(dssabb.Tables[0].Rows[0]["ID"]));
                                    if (!("," + unifiedAddressLibraryUserInfomodel.UserIDList + ",").Contains("," + dss.Tables[0].Rows[i]["ID"] + ","))
                                    {
                                        unifiedAddressLibraryUserInfomodel.UserIDList += "," + dss.Tables[0].Rows[i]["ID"].ToString();
                                    }
                                    unifiedAddressLibraryUserInfomodel.AddTime = DateTime.Now;
                                    unifiedAddressLibraryUserInfobll.Update(unifiedAddressLibraryUserInfomodel);
                                }
                                else
                                {
                                    unifiedAddressLibraryUserInfomodel.UnifiedAddressLibraryID = Convert.ToInt32(dssab.Tables[0].Rows[i1]["ID"]);
                                    unifiedAddressLibraryUserInfomodel.UserIDList = dss.Tables[0].Rows[i]["ID"].ToString();
                                    unifiedAddressLibraryUserInfomodel.AddTime    = DateTime.Now;
                                    unifiedAddressLibraryUserInfobll.Add(unifiedAddressLibraryUserInfomodel);
                                }
                            }
                            Issfpp = "1";
                        }
                    }
                    userinfotymodel.Work     = Issfpp;
                    userinfotymodel.TownUuid = townbll.GetModel(1).TownUuid;
                    userinfotybll.Update(userinfotymodel);
                }
            }
            //AlertAndStay("数据更新完成!!!");
            LogHelper.WriteLog(typeof(FrmMainServer), "数据更新完成!!!");
        }