Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">申请者信息</param>
        /// <returns>是否添加成功</returns>
        public bool Add(Model.UInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UInfo(");
            strSql.Append("Name,Number,Birthday,CommunityID,PWD)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Number,@Birthday,@CommunityID,@PWD)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.NVarChar,  30),
                new SqlParameter("@Number",      SqlDbType.NVarChar,  18),
                new SqlParameter("@Birthday",    SqlDbType.DateTime),
                new SqlParameter("@CommunityID", SqlDbType.Int),
                new SqlParameter("@PWD",         SqlDbType.Char, 6)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Number;
            parameters[2].Value = model.Birthday;
            parameters[3].Value = model.CommunityID;
            parameters[4].Value = model.PWD;

            int rows = DB.DbHelperSQL.ExecuteSql(strSql.ToString(), parameters, DB.DbHelperSQL.maindataConnectionString);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.UInfo DataRowToModel(DataRow row)
 {
     Model.UInfo model = new Model.UInfo();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.Id = (int)row["ID"];
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Number"] != null)
         {
             model.Number = row["Number"].ToString();
         }
         if (row["Birthday"] != null && row["Birthday"].ToString() != "")
         {
             model.Birthday = DateTime.Parse(row["Birthday"].ToString());
         }
         if (row["CommunityID"] != null)
         {
             model.CommunityID = (int)row["CommunityID"];
         }
         if (row["PWD"] != null)
         {
             model.PWD = row["PWD"].ToString();
         }
     }
     return(model);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         BLL.B_UInfo b_uinfo = new BLL.B_UInfo();
         Model.UInfo model   = b_uinfo.GetUInfo((int)Session["UID"]);
         if (model != null)
         {
             BLL.B_Community b_com         = new BLL.B_Community();
             string          CommunityName = b_com.GetCommunityName(model.CommunityID);
             //给页面赋值
             tb_Name.Text      = model.Name;
             tb_Number.Text    = model.Number;
             tb_Birthday.Text  = model.Birthday.ToShortDateString().ToString();
             tb_Community.Text = CommunityName;
         }
     }
 }
Пример #4
0
        /// <summary>
        /// 获取用户申请信息
        /// </summary>
        /// <param name="strSql"></param>
        /// <returns></returns>
        public Model.ApplyInfo GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 * from ApplyInfo ");
            strSql.Append(" where ");
            strSql.Append(strWhere);
            Model.UInfo model = new Model.UInfo();
            DataSet     ds    = DB.DbHelperSQL.Query(strSql.ToString(), DB.DbHelperSQL.maindataConnectionString);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// 登陆
 /// </summary>
 /// <param name="name">姓名</param>
 /// <param name="password">密码-身份证后六位</param>
 /// <returns>返回ID 若为-1则不存在用户 0密码错误</returns>
 public int login(string name, string pWD)
 {
     if (d_UInfo.Exists("Name='" + name + "'"))
     {
         Model.UInfo model = d_UInfo.GetModel("Name='" + name + "' and PWD='" + pWD + "'");
         if (model != null)
         {
             return(model.Id);
         }
         else
         {
             return(0);
         }
     }
     else
     {
         return(-1);
     }
 }
Пример #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">申请者信息</param>
        /// <returns>是否更新成功</returns>
        public bool Update(Model.UInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UInfo set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Number=@Number,");
            strSql.Append("Birthday=@Birthday,");
            strSql.Append("CommunityID=@CommunityID");
            strSql.Append("PWD=@PWD");
            strSql.Append(" Where ID=@ID");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.NVarChar,  30),
                new SqlParameter("@Number",      SqlDbType.NVarChar,  18),
                new SqlParameter("@Birthday",    SqlDbType.DateTime),
                new SqlParameter("@CommunityID", SqlDbType.Int),
                new SqlParameter("@PWD",         SqlDbType.Char,       6),
                new SqlParameter("@ID",          SqlDbType.Int),
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Number;
            parameters[2].Value = model.Birthday;
            parameters[3].Value = model.CommunityID;
            parameters[4].Value = model.PWD;
            parameters[5].Value = model.Id;

            int rows = DB.DbHelperSQL.ExecuteSql(strSql.ToString(), parameters, DB.DbHelperSQL.maindataConnectionString);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="id">申请人ID</param>
        /// <returns>申请人信息</returns>
        public Model.UInfo GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 * from UInfo ");
            strSql.Append(" where ID=@ID  ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int)
            };
            parameters[0].Value = id;

            Model.UInfo model = new Model.UInfo();
            DataSet     ds    = DB.DbHelperSQL.Query(strSql.ToString(), parameters, DB.DbHelperSQL.maindataConnectionString);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ddl_Age.Items.Clear();
         ddl_Age.Items.Add(" ");
         for (int i = 65; i < 150; i++)
         {
             ddl_Age.Items.Add(i.ToString());
         }
         BLL.B_ApplyInfo b_apply = new BLL.B_ApplyInfo();
         model = b_apply.getInfo((int)Session["UID"], (int)Session["ApplyTypes"]);
         if (model != null)
         {
             for (int i = 0; i < ddl_Age.Items.Count; i++)
             {
                 if (ddl_Age.Items[i].Value == model.Age.ToString())
                 {
                     ddl_Age.SelectedIndex = i;
                 }
             }
             BLL.B_UInfo b_uinfo = new BLL.B_UInfo();
             Model.UInfo uinfo   = b_uinfo.GetUInfo(model.UID);
             if (uinfo != null)
             {
                 tb_Name.Text   = uinfo.Name;
                 tb_Number.Text = uinfo.Number;
             }
             tb_Addr.Text             = model.Address;
             rbl_Gender.SelectedValue = model.Gender;
             tb_Job.Text   = model.Job;
             tb_Money.Text = model.Money.ToString();
             tb_Tel.Text   = model.Tel;
         }
     }
 }