Example #1
0
        public string addaddress(string contact, string userid, string saddress, string tel, string mobile, string p1id, string p2id)
        {
            int d1id = TypeParse.DbObjToInt(p1id, 0);
            int d2id = TypeParse.DbObjToInt(p2id, 0);

            addressinfo item = new addressinfo();
            item.contact = contact;
            item.address = saddress;
            item.tel = tel;
            item.mobile = mobile;
            item.deliveryIid = d1id;
            item.deliveryIIid = d2id;
            item.userid = userid;
            item.isdefault = 1;
            bool t = address.delisdefault();
            bool result = address.addaddress(item);
            if (result)
            {
                return "t";
            }
            else
            {
                return "f";
            }
        }
Example #2
0
        /// <summary>
        /// 添加送货地址
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool addaddress(addressinfo data)
        {
            SqlParameter[] parms = new SqlParameter[8];
            parms[0] = new SqlParameter("@address", SqlDbType.VarChar, 50);
            parms[0].Value = data.address;
            parms[1] = new SqlParameter("@contact", SqlDbType.VarChar, 10);
            parms[1].Value = data.contact;
            parms[2] = new SqlParameter("@mobile", SqlDbType.VarChar, 30);
            parms[2].Value = data.mobile;
            parms[3] = new SqlParameter("@tel",SqlDbType.VarChar, 30);
            parms[3].Value = data.tel;
            parms[4] = new SqlParameter("@userid", SqlDbType.VarChar, 50);
            parms[4].Value = data.userid;
            parms[5] = new SqlParameter("@deliveryIid", SqlDbType.Int);
            parms[5].Value = data.deliveryIid;
            parms[6] = new SqlParameter("@deliveryIIid", SqlDbType.Int);
            parms[6].Value = data.deliveryIIid;
            parms[7] = new SqlParameter("@isdefault", SqlDbType.Int);
            parms[7].Value = data.isdefault;

            string sql = "insert into address (address,contact,mobile,tel,userid,deliveryIid,deliveryIIid,isdefault) values(@address,@contact,@mobile,@tel,@userid,@deliveryIid,@deliveryIIid,@isdefault)";
            int result = 0;
            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return result > 0;
        }
Example #3
0
        protected void EditAddressInfo(object sender, EventArgs e)
        {
            string uid = "";
            if (Request.Cookies["tfuid"] != null)
            {
                uid = TypeParse.DbObjToString(Request.Cookies["tfuid"].Value, "");
            }
            else
            {
                Response.Redirect("/UserLog");
            }
            if (txtaddress.Value.Length < 5 || txtcontact.Value.Length < 2)
            {
                lbladdressnote.InnerText = "请完整填写下面的选项";
                return;
            }

            try
            {
                addressinfo data = new addressinfo();
                data.address = txtaddress.Value.Trim();
                data.contact = txtcontact.Value.Trim();
                data.mobile = txtmobile.Value.Trim();
                data.tel = txttel.Value;
                data.deliveryIid = TypeParse.DbObjToInt(ddldeliveryIid.SelectedValue, 1);
                data.deliveryIIid = TypeParse.DbObjToInt(ddldeliveryIIid.SelectedValue, 1);
                data.isdefault = 0;
                data.userid = uid;
                data.addressid = TypeParse.DbObjToInt(hdaddressid.Value, 0);

                bool result = address.editaddress(data);
                if (result)
                {
                    Response.Write("<script>alert('修改收货地址成功!');location.href='/Address';</script>");
                    return;
                }
                else
                {
                    Response.Write("<script>alert('修改收货地址失败!');location.href='/Address';</script>");
                    return;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #4
0
        public static addressinfo getindexaddressinfo(string  userid)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0] = new SqlParameter("@userid", SqlDbType.NVarChar,50);
            parms[0].Value = userid;

            addressinfo item = new addressinfo();
            string sql = "select a.addressid,a.address,a.contact,a.mobile,a.tel,a.userid,a.deliveryIid,a.deliveryIIid,a.isdefault,b.deliveryI,c.deliveryII from address a ,deliveryI b ,deliveryII c  where a.deliveryIid=b.deliveryIid and a.deliveryIIid=c.deliveryIIid and a.userid=@userid and a.isdefault=1";

            try
            {
                SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.connectionstring, CommandType.Text, sql, parms);
                if (dr.Read())
                {
                    item.addressid = TypeParse.DbObjToInt(dr["addressid"].ToString(), 0);
                    item.address = TypeParse.DbObjToString(dr["address"].ToString(), "");
                    item.contact = TypeParse.DbObjToString(dr["contact"].ToString(), "");
                    item.mobile = TypeParse.DbObjToString(dr["mobile"].ToString(), "");
                    item.tel = TypeParse.DbObjToString(dr["tel"].ToString(), "");
                    item.userid = TypeParse.DbObjToString(dr["userid"].ToString(), "");
                    item.deliveryIid = TypeParse.DbObjToInt(dr["deliveryIid"].ToString(), 0);
                    item.deliveryIIid = TypeParse.DbObjToInt(dr["deliveryIIid"].ToString(), 0);
                    item.deliveryI = TypeParse.DbObjToString(dr["deliveryI"].ToString(), "");
                    item.deliveryII = TypeParse.DbObjToString(dr["deliveryII"].ToString(), "");
                    item.isdefault = TypeParse.DbObjToInt(dr["isdefault"].ToString(), 0);
                    dr.Close();
                    dr.Dispose();
                }

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return item;
        }
Example #5
0
        public static List<addressinfo> getaddressinfobyuid(string userid)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0] = new SqlParameter("@userid", SqlDbType.NVarChar, 50);
            parms[0].Value = userid;

            string sql = "select a.addressid,a.address,a.contact,a.mobile,a.tel,a.userid,a.deliveryIid,a.deliveryIIid,a.isdefault,b.deliveryI,c.deliveryII from address a ,deliveryI b ,deliveryII c  where a.deliveryIid=b.deliveryIid and a.deliveryIIid=c.deliveryIIid and userid=@userid order by a.isdefault desc";

            List<addressinfo> list = new List<addressinfo>();
            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql, parms).Tables[0];
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        addressinfo item = new addressinfo();
                        item.addressid = TypeParse.DbObjToInt(dr["addressid"].ToString(), 0);
                        item.address = TypeParse.DbObjToString(dr["address"].ToString(), "");
                        item.contact = TypeParse.DbObjToString(dr["contact"].ToString(), "");
                        item.mobile = TypeParse.DbObjToString(dr["mobile"].ToString(), "");
                        item.tel = TypeParse.DbObjToString(dr["tel"].ToString(), "");
                        item.userid = TypeParse.DbObjToString(dr["userid"].ToString(), "");
                        item.deliveryIid = TypeParse.DbObjToInt(dr["deliveryIid"].ToString(), 0);
                        item.deliveryIIid = TypeParse.DbObjToInt(dr["deliveryIIid"].ToString(), 0);
                        item.isdefault = TypeParse.DbObjToInt(dr["isdefault"].ToString(), 0);
                        item.deliveryI = TypeParse.DbObjToString(dr["deliveryI"].ToString(), "");
                        item.deliveryII = TypeParse.DbObjToString(dr["deliveryII"].ToString(), "");
                        list.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return list;
        }
Example #6
0
 /// <summary>
 /// 得到送货地址
 /// </summary>
 /// <param name="pdata"></param>
 /// <returns></returns>
 public static List<addressinfo> getaddress(pageinfo pdata)
 {
     List<addressinfo> list = new List<addressinfo>();
     try
     {
         DataTable dt = pagehelper.getpagedt(pdata);
         if (dt != null)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 addressinfo item = new addressinfo();
                 item.addressid = TypeParse.DbObjToInt(dr["addressid"].ToString(), 0);
                 item.address = TypeParse.DbObjToString(dr["address"].ToString(), "");
                 item.contact = TypeParse.DbObjToString(dr["contact"].ToString(), "");
                 item.mobile = TypeParse.DbObjToString(dr["mobile"].ToString(), "");
                 item.tel = TypeParse.DbObjToString(dr["tel"].ToString(), "");
                 item.userid = TypeParse.DbObjToString(dr["userid"].ToString(), "");
                 item.deliveryIid = TypeParse.DbObjToInt(dr["deliveryIid"].ToString(), 0);
                 item.deliveryIIid = TypeParse.DbObjToInt(dr["deliveryIIid"].ToString(), 0);
                 item.isdefault = TypeParse.DbObjToInt(dr["isdefault"].ToString(), 0);
                 list.Add(item);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
     }
     return list;
 }