/// <summary> /// 公用(根据地址编号获取地址信息) /// </summary> /// <param name="address_id">用户编号</param> /// <returns></returns> public string GetAddress2(int address_id) { model = dal.GetAddress(address_id); if (model != null) { return("" + QGYHelper.FormatCode.FormatUrlEncode(model.city) + " " + QGYHelper.FormatCode.FormatUrlEncode(model.address) + " " + QGYHelper.FormatCode.FormatUrlEncode(model.address2) + " " + QGYHelper.FormatCode.FormatUrlEncode(model.province) + " " + QGYHelper.FormatCode.FormatUrlEncode(model.country) + " " + model.zipcode + ""); } return(""); }
/// <summary> /// 公用(根据地址编号获取地址信息) /// </summary> /// <param name="address_id">用户编号</param> /// <returns></returns> public string GetAddress(int address_id) { model = dal.GetAddress(address_id); if (model != null) { return("\"address_id\":\"" + model.address_id + "\",\"address\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.address) + "\",\"address2\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.address2) + "\",\"city\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.city) + "\",\"province\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.province) + "\",\"country\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.country) + "\",\"zipcode\":\"" + model.zipcode + "\",\"phone\":\"" + model.phone + "\",\"name\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.name) + "\",\"email\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.email) + "\",\"full_name\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.full_name) + "\",\"type\":\"" + model.type + "\""); } return(""); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(QAMZN.Model.tb_user_address model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_user_address("); strSql.Append("name,country,address,address2,city,province,zipcode,full_name,phone,email,user_id,createtime,updatetime,type)"); strSql.Append(" values ("); strSql.Append("@name,@country,@address,@address2,@city,@province,@zipcode,@full_name,@phone,@email,@user_id,@createtime,@updatetime,@type)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.VarChar, 100), new SqlParameter("@country", SqlDbType.VarChar, 100), new SqlParameter("@address", SqlDbType.VarChar, 100), new SqlParameter("@address2", SqlDbType.VarChar, 100), new SqlParameter("@city", SqlDbType.VarChar, 100), new SqlParameter("@province", SqlDbType.VarChar, 100), new SqlParameter("@zipcode", SqlDbType.VarChar, 10), new SqlParameter("@full_name", SqlDbType.VarChar, 50), new SqlParameter("@phone", SqlDbType.VarChar, 50), new SqlParameter("@email", SqlDbType.VarChar, 50), new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@updatetime", SqlDbType.DateTime), new SqlParameter("@type", SqlDbType.Int, 4) }; parameters[0].Value = model.name; parameters[1].Value = model.country; parameters[2].Value = model.address; parameters[3].Value = model.address2; parameters[4].Value = model.city; parameters[5].Value = model.province; parameters[6].Value = model.zipcode; parameters[7].Value = model.full_name; parameters[8].Value = model.phone; parameters[9].Value = model.email; parameters[10].Value = model.user_id; parameters[11].Value = model.createtime; parameters[12].Value = model.updatetime; parameters[13].Value = model.type; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public QAMZN.Model.tb_user_address GetModel(int address_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 address_id,name,country,address,address2,city,province,zipcode,full_name,phone,email,user_id,createtime,updatetime,type from tb_user_address "); strSql.Append(" where address_id=@address_id"); SqlParameter[] parameters = { new SqlParameter("@address_id", SqlDbType.Int, 4) }; parameters[0].Value = address_id; QAMZN.Model.tb_user_address model = new QAMZN.Model.tb_user_address(); 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 QAMZN.Model.tb_user_address DataRowToModel(DataRow row) { QAMZN.Model.tb_user_address model = new QAMZN.Model.tb_user_address(); if (row != null) { if (row["address_id"] != null && row["address_id"].ToString() != "") { model.address_id = int.Parse(row["address_id"].ToString()); } if (row["name"] != null) { model.name = row["name"].ToString(); } if (row["country"] != null) { model.country = row["country"].ToString(); } if (row["address"] != null) { model.address = row["address"].ToString(); } if (row["address2"] != null) { model.address2 = row["address2"].ToString(); } if (row["city"] != null) { model.city = row["city"].ToString(); } if (row["province"] != null) { model.province = row["province"].ToString(); } if (row["zipcode"] != null) { model.zipcode = row["zipcode"].ToString(); } if (row["full_name"] != null) { model.full_name = row["full_name"].ToString(); } if (row["phone"] != null) { model.phone = row["phone"].ToString(); } if (row["email"] != null) { model.email = row["email"].ToString(); } if (row["user_id"] != null && row["user_id"].ToString() != "") { model.user_id = int.Parse(row["user_id"].ToString()); } if (row["createtime"] != null && row["createtime"].ToString() != "") { model.createtime = DateTime.Parse(row["createtime"].ToString()); } if (row["updatetime"] != null && row["updatetime"].ToString() != "") { model.updatetime = DateTime.Parse(row["updatetime"].ToString()); } if (row["type"] != null && row["type"].ToString() != "") { model.type = int.Parse(row["type"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(QAMZN.Model.tb_user_address model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_user_address set "); strSql.Append("name=@name,"); strSql.Append("country=@country,"); strSql.Append("address=@address,"); strSql.Append("address2=@address2,"); strSql.Append("city=@city,"); strSql.Append("province=@province,"); strSql.Append("zipcode=@zipcode,"); strSql.Append("full_name=@full_name,"); strSql.Append("phone=@phone,"); strSql.Append("email=@email,"); strSql.Append("user_id=@user_id,"); strSql.Append("createtime=@createtime,"); strSql.Append("updatetime=@updatetime,"); strSql.Append("type=@type"); strSql.Append(" where address_id=@address_id"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.VarChar, 100), new SqlParameter("@country", SqlDbType.VarChar, 100), new SqlParameter("@address", SqlDbType.VarChar, 100), new SqlParameter("@address2", SqlDbType.VarChar, 100), new SqlParameter("@city", SqlDbType.VarChar, 100), new SqlParameter("@province", SqlDbType.VarChar, 100), new SqlParameter("@zipcode", SqlDbType.VarChar, 10), new SqlParameter("@full_name", SqlDbType.VarChar, 50), new SqlParameter("@phone", SqlDbType.VarChar, 50), new SqlParameter("@email", SqlDbType.VarChar, 50), new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@updatetime", SqlDbType.DateTime), new SqlParameter("@type", SqlDbType.Int, 4), new SqlParameter("@address_id", SqlDbType.Int, 4) }; parameters[0].Value = model.name; parameters[1].Value = model.country; parameters[2].Value = model.address; parameters[3].Value = model.address2; parameters[4].Value = model.city; parameters[5].Value = model.province; parameters[6].Value = model.zipcode; parameters[7].Value = model.full_name; parameters[8].Value = model.phone; parameters[9].Value = model.email; parameters[10].Value = model.user_id; parameters[11].Value = model.createtime; parameters[12].Value = model.updatetime; parameters[13].Value = model.type; parameters[14].Value = model.address_id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }