Beispiel #1
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);
        }
Beispiel #2
0
        public string editaddressinfo(string contact, string userid, string saddress, string tel, string mobile, string p1id, string p2id, string addressid)
        {
            int d1id = TypeParse.DbObjToInt(p1id, 0);
            int d2id = TypeParse.DbObjToInt(p2id, 0);
            int id   = TypeParse.DbObjToInt(addressid, 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;
            item.addressid    = id;

            bool result = address.editaddress(item);

            if (result)
            {
                return("t");
            }
            else
            {
                return("f");
            }
        }
Beispiel #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);
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (RouteData.Values["addressid"] != null)
            {
                int         addressid = TypeParse.DbObjToInt(RouteData.Values["addressid"], 0);
                addressinfo data      = address.getaddressinfo(addressid);
                if (!Page.IsPostBack)
                {
                    txtaddress.Value  = data.address;
                    txtcontact.Value  = data.contact;
                    txtmobile.Value   = data.mobile;
                    txttel.Value      = data.tel;
                    hdaddressid.Value = data.addressid.ToString();

                    //配送区域I
                    List <categoryinfo> ntlist = category.getdeliveryI();
                    ddldeliveryIid.DataSource     = ntlist;
                    ddldeliveryIid.DataTextField  = "deliveryI";
                    ddldeliveryIid.DataValueField = "deliveryIid";
                    ddldeliveryIid.DataBind();
                    for (int i = 0; i < ddldeliveryIid.Items.Count; i++)
                    {
                        if (ddldeliveryIid.Items[i].Value == data.deliveryIid.ToString())
                        {
                            ddldeliveryIid.SelectedIndex = i;
                        }
                    }

                    //配送区域II
                    List <categoryinfo> ntlist2 = category.getdeliveryII();
                    ddldeliveryIIid.DataSource     = ntlist2;
                    ddldeliveryIIid.DataTextField  = "deliveryII";
                    ddldeliveryIIid.DataValueField = "deliveryIIid";
                    ddldeliveryIIid.DataBind();
                    for (int k = 0; k < ddldeliveryIIid.Items.Count; k++)
                    {
                        if (ddldeliveryIIid.Items[k].Value == data.deliveryIIid.ToString())
                        {
                            ddldeliveryIIid.SelectedIndex = k;
                        }
                    }
                }
            }
        }
Beispiel #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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public string editaddress(string addressid)
        {
            int         id   = TypeParse.DbObjToInt(addressid, 0);
            addressinfo data = address.getaddressinfo(id);

            //大区下拉菜单
            List <categoryinfo> d1list = category.getdeliveryI();
            string        str;
            StringBuilder d1sb = new StringBuilder();

            d1sb.Append("<select id=\"d1select\" class=\"orderselect\"  onchange=\"changed1()\">");
            foreach (categoryinfo pitem in d1list)
            {
                string template;

                if (data.deliveryIid == pitem.deliveryIid)
                {
                    template = "<option value=\"{0}\" selected=\"selected\">{1}</option>";
                }
                else
                {
                    template = "<option value=\"{0}\">{1}</option>";
                }

                d1sb.AppendFormat(template, pitem.deliveryIid, pitem.deliveryI);
            }
            d1sb.Append("</select>");

            StringBuilder       d2sb   = new StringBuilder();
            List <categoryinfo> d2list = category.getdeliveryIIbyID(data.deliveryIid);

            d2sb.Append("<select id=\"d2select\" class=\"orderselect\">");
            foreach (categoryinfo pitem in d2list)
            {
                string template;

                if (data.deliveryIIid == pitem.deliveryIIid)
                {
                    template = "<option value=\"{0}\" selected=\"selected\">{1}</option>";
                }
                else
                {
                    template = "<option value=\"{0}\">{1}</option>";
                }

                d2sb.AppendFormat(template, pitem.deliveryIIid, pitem.deliveryII);
            }
            d2sb.Append("</select>");


            str  = " <h3>添加新的收货地址  <a href=\"javascript:refresh()\">[关闭]</a> </h3><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"ordertb\"><tr><td class=\"tdleft\">收 货 人:</td><td><input type=\"text\" id=\"txtcontact\" value=\"{0}\" class=\"ordertxt\" /></td></tr><tr><td class=\"tdleft\">配送大区:</td><td>";
            str += d1sb.ToString();
            str += "</td></tr><tr><td class=\"tdleft\"> 配送小区:</td><td><label id=\"d2selectlabel\">";
            str += d2sb.ToString();
            str += "</label></td></tr><tr><td class=\"tdleft\">详细地址:</td><td><input type=\"text\" id=\"txtaddress\" value=\"{1}\"  class=\"ordertxt w300\" />&nbsp;如:上海市XX区XX路XX弄XX号XX室</td></tr><tr><td class=\"tdleft\">手机号码:</td><td><input type=\"text\" id=\"txtmobile\" value=\"{2}\" class=\"ordertxt\"/></td></tr><tr><td class=\"tdleft\">固定电话:</td><td><input type=\"text\" id=\"txttel\" value=\"{3}\" class=\"ordertxt\"/></td></tr></table><p><input type=\"button\" value=\"修改地址\" onclick=\"editaddressinfo('{4}')\"  class=\"orderbtn\" /></p> ";

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(str, data.contact, data.address, data.mobile, data.tel, data.addressid);

            return(sb.ToString());
        }
Beispiel #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //图片绑定
            List <webimagesinfo> webimageslist = webimages.bindwebimages(1, "企业LOGO");
            StringBuilder        webimagessb   = new StringBuilder();

            foreach (webimagesinfo item in webimageslist)
            {
                string template = "<a href=\"{0}\" target=\"_blank\"><img src=\"/Files/WebImages/{1}\" alt=\"\" target=\"_blank\"/></a>";
                webimagessb.AppendFormat(template, item.imgurl, item.imgname);
            }
            logoimgHTML = webimagessb.ToString();


            if (Request.Cookies["tfuid"] != null)
            {
                string userid = Request.Cookies["tfuid"].Value.ToString();
                uidValue = userid;
                userinfo           item  = user.getuserinfo(userid);
                List <addressinfo> alist = address.getaddressinfobyuid(userid);
                if (alist.Count < 1)
                {
                    //大区下拉菜单
                    List <categoryinfo> d1list = category.getdeliveryI();
                    StringBuilder       d1sb   = new StringBuilder();
                    d1sb.Append("<select id=\"d1select\" class=\"orderselect\"  onchange=\"changed1()\"><option value=\"0\">--请选择--</option>");
                    foreach (categoryinfo pitem in d1list)
                    {
                        string template;

                        template = "<option value=\"{0}\">{1}</option>";

                        d1sb.AppendFormat(template, pitem.deliveryIid, pitem.deliveryI);
                    }
                    d1sb.Append("</select>");
                    addressHTML  = " <h3>添加收货人信息</h3><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"ordertb\"><tr><td class=\"tdleft\">收 货 人:</td><td><input type=\"text\" id=\"txtcontact\" class=\"ordertxt\" /></td></tr><tr><td class=\"tdleft\">配送大区:</td><td>";
                    addressHTML += d1sb.ToString();
                    addressHTML += "</td></tr><tr><td class=\"tdleft\"> 配送小区:</td><td><label id=\"d2selectlabel\"><select id=\"d2select\"  class=\"orderselect\"><option value=\"0\">--请选择--</option></select></label></td></tr><tr><td class=\"tdleft\">详细地址:</td><td><input type=\"text\" id=\"txtaddress\"  class=\"ordertxt w300\" />&nbsp;如:上海市XX区XX路XX弄XX号XX室</td></tr><tr><td class=\"tdleft\">手机号码:</td><td><input type=\"text\" id=\"txtmobile\" class=\"ordertxt\"/></td></tr><tr><td class=\"tdleft\">固定电话:</td><td><input type=\"text\" id=\"txttel\"  class=\"ordertxt\"/></td></tr></table><p><input type=\"button\" value=\"确认地址\" onclick=\"addaddress()\"  class=\"orderbtn\" /></p> ";
                }
                else
                {
                    addressinfo   data     = address.getindexaddressinfo(userid);
                    StringBuilder asb      = new StringBuilder();
                    string        template = " <h3>收货人信息 <a href=\"javascript:selectaddress()\">[修改信息]</a></h3><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"ordertb\"><tr><td class=\"tdleft\">收 货 人:</td><td>{0}</td></tr><tr><td class=\"tdleft\">配送大区:</td><td>{1}</td></tr><tr><td class=\"tdleft\">配送小区:</td><td>{2}</td></tr> <tr><td class=\"tdleft\">详细地址:</td><td>{3}</td></tr><tr><td class=\"tdleft\">手机号码: </td><td>{4}</td></tr><tr><td class=\"tdleft\"> 固定电话: </td><td>{5}</td></tr></table>";
                    asb.AppendFormat(template, data.contact, data.deliveryI, data.deliveryII, data.address, data.mobile, data.tel);
                    addressHTML = asb.ToString();
                }

                if (DateTime.Now.Hour >= 16)
                {
                    deliverydateValue = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
                }
                else
                {
                    deliverydateValue = DateTime.Now.ToString("yyyy-MM-dd");
                }

                List <orderinfo> cartlist = order.getcartlist(0, userid);
                int           ccount      = cartlist.Count;
                StringBuilder csb         = new StringBuilder();
                for (int k = 0; k < ccount; k++)
                {
                    string template = "<tr style=\"height: 60px;\"><td align=\"center\">{0}</td><td class=\"buyimg\"><a href=\"/PInfo/{1}.html\"><img src=\"/Files/Product/{2}\" alt=\"\" /></a></td><td><a href=\"/PInfo/{3}.html\" title=\"{4}\">{5}</a></td><td align=\"center\">{6}</td><td align=\"center\"><a href=\"javascript:changecartordernum('{7}','minus')\" class=\"minusbtn1\">&nbsp;</a><input type=\"text\" id=\"buynum\" class=\"numtxt1\" value=\"{8}\" readonly=\"readonly\" /><a href=\"javascript:changecartordernum('{9}','add')\" class=\"addbtn1\">&nbsp;</a></td><td align=\"center\"><a href=\"javascript:delcart('{10}')\">删除</a></td></tr>";

                    csb.AppendFormat(template, k + 1, cartlist[k].productid, cartlist[k].productimg, cartlist[k].productid, cartlist[k].productname, cartlist[k].productname, cartlist[k].vipprice, cartlist[k].cartid, cartlist[k].buynum, cartlist[k].cartid, cartlist[k].cartid);
                }
                cartlistHTML = csb.ToString();

                if (ccount > 0)
                {
                    userinfo udata     = user.getuserinfo(userid);
                    decimal  udiscount = udata.atdiscount;
                    string   ac        = (udiscount * 10).ToString("F1");
                    string   atype     = udata.accountstype;
                    decimal  pmoney    = order.getallprice(userid);
                    decimal  dmoney    = pmoney - pmoney * udiscount;
                    decimal  paymoney  = pmoney * udiscount;
                    pmoneyHMTL   = pmoney.ToString("F2");
                    dmoneyHTML   = atype + ac + "折,优惠:¥" + dmoney.ToString("F2");
                    paymoneyHTML = paymoney.ToString("F2");
                }
                else
                {
                    pmoneyHMTL   = "0";
                    dmoneyHTML   = "优惠:0";
                    paymoneyHTML = "0";
                }
            }
            else
            {
                Response.Redirect("/UserLog?relurl=/PList");
            }
        }