Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(zhangte.Model.zt_yonghubiao model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into zt_yonghubiao(");
            strSql.Append("用户名,密码,联系方式,收货地址)  values (");
            strSql.Append("@用户名,@密码,@联系方式,@收货地址)");
            strSql.Append(";");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@用户名",  MySqlDbType.VarChar, 255),
                new MySqlParameter("@密码",   MySqlDbType.VarChar, 255),
                new MySqlParameter("@联系方式", MySqlDbType.VarChar, 255),
                new MySqlParameter("@收货地址", MySqlDbType.VarChar, 255)
            };
            parameters[0].Value = model.用户名;
            parameters[1].Value = model.密码;
            parameters[2].Value = model.联系方式;
            parameters[3].Value = model.收货地址;


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

            if (rows > 0)
            {
                return(rows);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 2
0
        private string savezl(string yonghuming, HttpContext context)
        {
            string mima           = context.Request.QueryString["mima"].ToString();
            string lianxifangshi1 = context.Request.QueryString["lianxifangshi1"].ToString();
            string shouhuodizhi1  = context.Request.QueryString["shouhuodizhi1"].ToString();


            zhangte.BLL.zt_yonghubiao bll1 = new zhangte.BLL.zt_yonghubiao();



            DataTable dt1 = bll1.GetList("用户名='" + yonghuming + "'").Tables[0];

            zhangte.Model.zt_yonghubiao md1 = new zhangte.Model.zt_yonghubiao();
            md1.Id   = int.Parse(dt1.Rows[0]["id"].ToString());
            md1.用户名  = yonghuming;
            md1.密码   = mima;
            md1.联系方式 = lianxifangshi1;
            md1.收货地址 = shouhuodizhi1;
            bll1.Update1(md1);


            string strret = "OK";

            return(strret);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public zhangte.Model.zt_yonghubiao DataRowToModel(DataRow row)
 {
     zhangte.Model.zt_yonghubiao model = new zhangte.Model.zt_yonghubiao();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["用户名"] != null)
         {
             model.用户名 = row["用户名"].ToString();
         }
         if (row["密码"] != null)
         {
             model.密码 = row["密码"].ToString();
         }
         if (row["联系方式"] != null)
         {
             model.联系方式 = row["联系方式"].ToString();
         }
         if (row["收货地址"] != null)
         {
             model.收货地址 = row["收货地址"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public zhangte.Model.zt_yonghubiao GetModel(int Id)
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   * from zt_yonghubiao ");
            strSql.Append(" where Id=@Id LIMIT 1");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Id", MySql.Data.MySqlClient.MySqlDbType.Int16, 11)
            };
            parameters[0].Value = Id;

            zhangte.Model.zt_yonghubiao model = new zhangte.Model.zt_yonghubiao();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            string yonghuming    = context.Request.Form["yonghuming"].ToString().Trim();
            string mima          = context.Request.Form["mima"].ToString();
            string chongfumima   = context.Request.Form["chongfumima"].ToString();
            string lianxifangshi = context.Request.Form["lianxifangshi"].ToString();
            string shouhuodizhi  = context.Request.Form["shouhuodizhi"].ToString();

            if (mima.Equals(chongfumima) == false)
            {
                context.Response.Write("两次密码不一致");
                return;
            }
            if (yonghuming == "" || mima == "" || chongfumima == "" || lianxifangshi == "" || shouhuodizhi == "")
            {
                context.Response.Write("还有信息未填写");
                return;
            }
            zhangte.BLL.zt_yonghubiao bll1 = new zhangte.BLL.zt_yonghubiao();


            DataTable dt1 = bll1.GetList("用户名='" + yonghuming + "'").Tables[0];

            if (dt1.Rows.Count > 0)
            {
                context.Response.Write("用户名已存在");
                return;
            }
            zhangte.Model.zt_yonghubiao md1 = new zhangte.Model.zt_yonghubiao();

            md1.用户名  = yonghuming;
            md1.密码   = mima;
            md1.联系方式 = lianxifangshi;
            md1.收货地址 = shouhuodizhi;
            bll1.Add1(md1);

            context.Response.Write("注册成功");
        }
Ejemplo n.º 6
0
        private string readzl(string yonghuming, HttpContext context)
        {
            zhangte.BLL.zt_yonghubiao   bll1   = new zhangte.BLL.zt_yonghubiao(context);
            zhangte.Model.zt_yonghubiao model1 = new zhangte.Model.zt_yonghubiao();
            yonghuming = context.Session["用户名"].ToString();
            DataSet ds1 = bll1.GetList(" 用户名 = '" + yonghuming + "'");

            string strif = " order by id desc";

            if (yonghuming != "")
            {
                strif = " where 用户名 = " + yonghuming + " order by id desc";
            }

            string strret = "";

            if (ds1.Tables[0].Rows.Count > 0)
            {
                strret = ds1.Tables[0].Rows[0]["用户名"].ToString() + "|" + ds1.Tables[0].Rows[0]["密码"].ToString() + "|" + ds1.Tables[0].Rows[0]["联系方式"].ToString() + "|" + ds1.Tables[0].Rows[0]["收货地址"].ToString() + "|";
            }

            return(strret);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(zhangte.Model.zt_yonghubiao model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update zt_yonghubiao set ");
            strSql.Append("用户名=@用户名,");
            strSql.Append("密码=@密码,");
            strSql.Append("联系方式=@联系方式,");
            strSql.Append("收货地址=@收货地址");
            strSql.Append(" where Id=@Id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@用户名",  MySqlDbType.VarChar, 255),
                new MySqlParameter("@密码",   MySqlDbType.VarChar, 255),
                new MySqlParameter("@联系方式", MySqlDbType.VarChar, 255),
                new MySqlParameter("@收货地址", MySqlDbType.VarChar, 255),
                new MySqlParameter("@Id",   MySqlDbType.Int16, 6)
            };
            parameters[0].Value = model.用户名;
            parameters[1].Value = model.密码;
            parameters[2].Value = model.联系方式;
            parameters[3].Value = model.收货地址;
            parameters[4].Value = model.Id;



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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }