Beispiel #1
0
        public SqlDataReader  readaddress(Model.address myaddress)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select * from address where _user_id=@userid");
            SqlParameter[] par = { new SqlParameter("@userid", SqlDbType.Int, 4) };
            par[0].Value = myaddress.userid;
            return(Common.DbHelperSQL.ExecuteReader(sql.ToString(), par));
        }
Beispiel #2
0
        public int insert(Model.address aa)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into address (_user_id) values(@id)");
            SqlParameter[] par =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            par[0].Value = aa.userid;
            return(Common.DbHelperSQL.ExecuteSql(sql.ToString(), par));
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.address model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into td_address(");
            strSql.Append("user_id,province,city,distract,content,add_time,is_default,zipcode,consignee,consignee_mobile,consignee_phone,company_address");
            strSql.Append(") values (");
            strSql.Append("@user_id,@province,@city,@distract,@content,@add_time,@is_default,@zipcode,@consignee,@consignee_mobile,@consignee_phone,@company_address");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",          SqlDbType.Int,        4),
                new SqlParameter("@province",         SqlDbType.Int,        4),
                new SqlParameter("@city",             SqlDbType.Int,        4),
                new SqlParameter("@distract",         SqlDbType.Int,        4),
                new SqlParameter("@content",          SqlDbType.NVarChar,  50),
                new SqlParameter("@add_time",         SqlDbType.DateTime),
                new SqlParameter("@is_default",       SqlDbType.Int,        4),
                new SqlParameter("@zipcode",          SqlDbType.NVarChar,  50),
                new SqlParameter("@consignee",        SqlDbType.NVarChar,  50),
                new SqlParameter("@consignee_mobile", SqlDbType.NVarChar,  50),
                new SqlParameter("@consignee_phone",  SqlDbType.NVarChar,  50),
                new SqlParameter("@company_address",  SqlDbType.NVarChar, 100)
            };

            parameters[0].Value  = model.user_id;
            parameters[1].Value  = model.province;
            parameters[2].Value  = model.city;
            parameters[3].Value  = model.distract;
            parameters[4].Value  = model.content;
            parameters[5].Value  = model.add_time;
            parameters[6].Value  = model.is_default;
            parameters[7].Value  = model.zipcode;
            parameters[8].Value  = model.consignee;
            parameters[9].Value  = model.consignee_mobile;
            parameters[10].Value = model.consignee_phone;
            parameters[11].Value = model.company_address;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #4
0
        //填写送货地址
        public int addre(Model.address aa)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into address (_telephone,_mobilephone, _address_text ,_vip_name, _postcode) values(@tel,@mobile,@address,@name,@mail)");
            SqlParameter[] par =
            {
                new SqlParameter("@tel",     SqlDbType.VarChar,  50),
                new SqlParameter("@mobile",  SqlDbType.VarChar,  50),
                new SqlParameter("@address", SqlDbType.VarChar, 150),
                new SqlParameter("@name",    SqlDbType.VarChar, 150),
                new SqlParameter("@mail",    SqlDbType.VarChar, 50)
            };

            par[0].Value = aa.tel;
            par[0].Value = aa.mobile;
            par[0].Value = aa.Address;
            par[0].Value = aa.name;
            par[0].Value = aa.mail;
            return(Common.DbHelperSQL.ExecuteSql(sql.ToString(), par));
        }
Beispiel #5
0
        //更新地址
        public int upad(Model.address aa)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update address set _postcode=@mail,_vip_name=@name,_mobilephone=@mobile,_telephone=@tel,_address_text=@addr where _user_id=@id");
            SqlParameter[] par =
            {
                new   SqlParameter("@mail",   SqlDbType.VarChar, 50),
                new   SqlParameter("@name",   SqlDbType.VarChar, 50),
                new   SqlParameter("@mobile", SqlDbType.VarChar, 50),
                new   SqlParameter("@tel",    SqlDbType.VarChar, 50),
                new   SqlParameter("@addr",   SqlDbType.VarChar, 50),
                new   SqlParameter("@id",     SqlDbType.Int, 4)
            };
            par[0].Value = aa.mail;
            par[1].Value = aa.name;
            par[2].Value = aa.mobile;
            par[3].Value = aa.tel;
            par[4].Value = aa.Address;
            par[5].Value = aa.userid;
            return(Common.DbHelperSQL.ExecuteSql(sql.ToString(), par));
        }
Beispiel #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.address GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, user_id, province, city, distract, content, add_time, is_default, zipcode, consignee, consignee_mobile, consignee_phone,company_address  ");
            strSql.Append("  from td_address ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["province"].ToString() != "")
                {
                    model.province = int.Parse(ds.Tables[0].Rows[0]["province"].ToString());
                }
                if (ds.Tables[0].Rows[0]["city"].ToString() != "")
                {
                    model.city = int.Parse(ds.Tables[0].Rows[0]["city"].ToString());
                }
                if (ds.Tables[0].Rows[0]["distract"].ToString() != "")
                {
                    model.distract = int.Parse(ds.Tables[0].Rows[0]["distract"].ToString());
                }
                model.content = ds.Tables[0].Rows[0]["content"].ToString();
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_default"].ToString() != "")
                {
                    model.is_default = int.Parse(ds.Tables[0].Rows[0]["is_default"].ToString());
                }
                model.zipcode          = ds.Tables[0].Rows[0]["zipcode"].ToString();
                model.consignee        = ds.Tables[0].Rows[0]["consignee"].ToString();
                model.consignee_mobile = ds.Tables[0].Rows[0]["consignee_mobile"].ToString();
                model.consignee_phone  = ds.Tables[0].Rows[0]["consignee_phone"].ToString();
                model.company_address  = ds.Tables[0].Rows[0]["company_address"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.address model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update td_address set ");

            strSql.Append(" user_id = @user_id , ");
            strSql.Append(" province = @province , ");
            strSql.Append(" city = @city , ");
            strSql.Append(" distract = @distract , ");
            strSql.Append(" content = @content , ");
            strSql.Append(" add_time = @add_time , ");
            strSql.Append(" is_default = @is_default , ");
            strSql.Append(" zipcode = @zipcode , ");
            strSql.Append(" consignee = @consignee , ");
            strSql.Append(" consignee_mobile = @consignee_mobile , ");
            strSql.Append(" consignee_phone = @consignee_phone , ");
            strSql.Append(" company_address=@company_address ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",               SqlDbType.Int,        4),
                new SqlParameter("@user_id",          SqlDbType.Int,        4),
                new SqlParameter("@province",         SqlDbType.Int,        4),
                new SqlParameter("@city",             SqlDbType.Int,        4),
                new SqlParameter("@distract",         SqlDbType.Int,        4),
                new SqlParameter("@content",          SqlDbType.NVarChar,  50),
                new SqlParameter("@add_time",         SqlDbType.DateTime),
                new SqlParameter("@is_default",       SqlDbType.Int,        4),
                new SqlParameter("@zipcode",          SqlDbType.NVarChar,  50),
                new SqlParameter("@consignee",        SqlDbType.NVarChar,  50),
                new SqlParameter("@consignee_mobile", SqlDbType.NVarChar,  50),
                new SqlParameter("@consignee_phone",  SqlDbType.NVarChar,  50),
                new SqlParameter("@company_address",  SqlDbType.NVarChar, 100)
            };

            parameters[0].Value  = model.id;
            parameters[1].Value  = model.user_id;
            parameters[2].Value  = model.province;
            parameters[3].Value  = model.city;
            parameters[4].Value  = model.distract;
            parameters[5].Value  = model.content;
            parameters[6].Value  = model.add_time;
            parameters[7].Value  = model.is_default;
            parameters[8].Value  = model.zipcode;
            parameters[9].Value  = model.consignee;
            parameters[10].Value = model.consignee_mobile;
            parameters[11].Value = model.consignee_phone;
            parameters[12].Value = model.company_address;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
        private void car_add_address(HttpContext context)
        {
            Model.users model = new BasePage().GetUserInfo();
            if (model == null)
            {
                context.Response.Write("Lost");
                return;
            }
            int province = DTRequest.GetFormInt("car_province");
            int city = DTRequest.GetFormInt("car_city");
            int district = DTRequest.GetFormInt("car_district");
            string address = DTRequest.GetFormString("car_address");
            string consignee = DTRequest.GetFormString("car_consignee");
            string consignee_mobile = DTRequest.GetFormString("car_consignee_mobile");
            string consignee_company = DTRequest.GetFormString("car_consignee_company");
            //非必填
            string zip_phone = DTRequest.GetFormString("car_zip_phone");
            string phone = DTRequest.GetFormString("car_phone");

            BLL.address bll = new BLL.address();
            Model.address model_address = new Model.address();
            model_address.user_id = model.id;
            model_address.province = province;
            model_address.city = city;
            model_address.distract = district;
            model_address.content = address;

            model_address.consignee = consignee;
            model_address.consignee_mobile = consignee_mobile;
            model_address.add_time = DateTime.Now;
            model_address.company_address = consignee_company;
            model_address.consignee_phone = zip_phone + "-" + phone;

            int new_id = bll.Add(model_address);
            if (new_id <= 0)
            {
                context.Response.Write("Error");
                return;
            }
            DataTable dt = bll.GetList("user_id=" + model.id).Tables[0];
            DataTable ret_dt = new DataTable();
            ret_dt.Columns.Add("id");
            ret_dt.Columns.Add("address");
            ret_dt.Columns.Add("selected");
            ret_dt.PrimaryKey = new DataColumn[] { ret_dt.Columns["id"] };

            foreach (DataRow dr in dt.Rows)
            {
                DataRow ret_dr = ret_dt.NewRow();
                ret_dr["id"] = dr["id"];
                string province1 = new BasePage().get_province_title(Convert.ToInt32(dr["province"]));
                string city1 = new BasePage().get_city_title(Convert.ToInt32(dr["city"]));
                string district1 = new BasePage().get_district_title(Convert.ToInt32(dr["distract"]));
                string address1 = dr["content"].ToString();
                string consignee1 = dr["consignee"].ToString();
                string consignee_mobile1 = dr["consignee_mobile"].ToString();
                string company_address = dr["company_address"].ToString();
                ret_dr["address"] = province1 + " " + city1 + " " + district1 + " " + address1 + "(公司地址:" + company_address + ")" + " " + consignee1 + ":" + consignee_mobile1;
                if (Convert.ToInt32(dr["id"]) == new_id)
                {
                    ret_dr["selected"] = 1;
                }
                else
                {
                    ret_dr["selected"] = 0;
                }
                ret_dt.Rows.Add(ret_dr);
            }

            if (ret_dt != null && ret_dt.Rows.Count > 0)
            {
                context.Response.Write(myJson.getJson(ret_dt));
                return;
            }
            else
            {
                context.Response.Write("Null");
                return;
            }
        }
Beispiel #9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.address model)
 {
     return(dal.Update(model));
 }
Beispiel #10
0
 public int upad(Model.address aa)
 {
     DAL.address dala = new DAL.address();
     return(dala.insert(aa));
 }
Beispiel #11
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.address GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id, user_id, province, city, distract, content, add_time, is_default, zipcode, consignee, consignee_mobile, consignee_phone,company_address  ");
            strSql.Append("  from td_address ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["province"].ToString() != "")
                {
                    model.province = int.Parse(ds.Tables[0].Rows[0]["province"].ToString());
                }
                if (ds.Tables[0].Rows[0]["city"].ToString() != "")
                {
                    model.city = int.Parse(ds.Tables[0].Rows[0]["city"].ToString());
                }
                if (ds.Tables[0].Rows[0]["distract"].ToString() != "")
                {
                    model.distract = int.Parse(ds.Tables[0].Rows[0]["distract"].ToString());
                }
                model.content = ds.Tables[0].Rows[0]["content"].ToString();
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_default"].ToString() != "")
                {
                    model.is_default = int.Parse(ds.Tables[0].Rows[0]["is_default"].ToString());
                }
                model.zipcode = ds.Tables[0].Rows[0]["zipcode"].ToString();
                model.consignee = ds.Tables[0].Rows[0]["consignee"].ToString();
                model.consignee_mobile = ds.Tables[0].Rows[0]["consignee_mobile"].ToString();
                model.consignee_phone = ds.Tables[0].Rows[0]["consignee_phone"].ToString();
                model.company_address = ds.Tables[0].Rows[0]["company_address"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }
Beispiel #12
0
 public SqlDataReader dra(Model.address aa)
 {
     DAL.daladdress dsa = new DAL.daladdress();
     return(dsa.adr(aa));
 }
Beispiel #13
0
 public int inserid(Model.address aa)
 {
     DAL.daladdress daa = new DAL.daladdress();
     return(daa.insert(aa));
 }
Beispiel #14
0
 public int addre(Model.address aa)
 {
     DAL.daladdress dal = new  DAL.daladdress();
     return(dal.addre(aa));
 }
Beispiel #15
0
 public int upad(Model.address aa)
 {
     DAL.daladdress ad = new  DAL.daladdress();
     return(ad.upad(aa));
 }
Beispiel #16
0
 public SqlDataReader drad(Model.address aa)
 {
     DAL.daladdress dll = new  DAL.daladdress();
     return(dll.drad(aa));
 }
Beispiel #17
0
 public SqlDataReader  readaddress(Model.address myaddress)
 {
     DAL.DALshoplist2 dall = new DAL.DALshoplist2();
     return(dall.readaddress(myaddress));
 }
Beispiel #18
0
        private void add_address(HttpContext context)
        {
            int province = DTRequest.GetFormInt("province");
            int city = DTRequest.GetFormInt("city");
            int district = DTRequest.GetFormInt("district");
            string address = DTRequest.GetFormString("address");
            string zipcode = DTRequest.GetFormString("zipcode");
            string consignee = DTRequest.GetFormString("consignee");
            string consignee_mobile = DTRequest.GetFormString("consignee_mobile");
            string company_address = DTRequest.GetFormString("consignee_company");
            //非必填
            string zip_phone = DTRequest.GetFormString("zip_phone");
            string phone = DTRequest.GetFormString("phone");

            Model.users model = new BasePage().GetUserInfo();
            if (model == null)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,请重新登录!\"}");
                return;
            }

            BLL.address bll = new BLL.address();
            Model.address model_address = new Model.address();
            model_address.user_id = model.id;
            model_address.province = province;
            model_address.city = city;
            model_address.distract = district;
            model_address.content = address;

            model_address.consignee = consignee;
            model_address.consignee_mobile = consignee_mobile;
            model_address.add_time = DateTime.Now;
            model_address.company_address = company_address;

            model_address.consignee_phone = zip_phone + "-" + phone;
            model_address.zipcode = zipcode;

            if (bll.Add(model_address) > 0)
            {
                context.Response.Write("{\"status\":\"1\", \"msg\":\"新增收货地址成功!\"}");
                return;
            }
            else
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"新增收货地址失败!\"}");
                return;
            }
        }
Beispiel #19
0
        private void save_user_info(HttpContext context)
        {
            string nick_name = DTRequest.GetFormString("nick_name");
            string email = DTRequest.GetFormString("email");
            string mobile = DTRequest.GetFormString("mobile");
            string sex = DTRequest.GetFormString("sex");
            string txtBirthday = DTRequest.GetFormString("txtBirthday");
            int province = DTRequest.GetFormInt("province");
            int city = DTRequest.GetFormInt("city");
            int district = DTRequest.GetFormInt("district");
            string address = DTRequest.GetFormString("address");

            string purchase = DTRequest.GetFormString("purchase");
            string purchase_mobile = DTRequest.GetFormString("purchase_mobile");

            Model.users model = new BasePage().GetUserInfo();
            if (model == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请重新登录!\"}");
                return;
            }
            BLL.users bll = new BLL.users();

            model.nick_name = nick_name;
            model.email = email;
            model.mobile = mobile;
            if (!string.IsNullOrEmpty(sex))
            {
                model.sex = sex;
            }
            else
            {
                model.sex = "保密";
            }
            if (!string.IsNullOrEmpty(txtBirthday))
            {
                model.birthday = Convert.ToDateTime(txtBirthday);
            }
            model.province = province;
            model.city = city;
            model.district = district;
            model.address = address;
            model.purchase = purchase;
            model.purchase_mobile = purchase_mobile;
            if (bll.Update(model))
            {
                BLL.address bll_address = new BLL.address();
                if (bll_address.GetList("user_id=" + model.id).Tables[0].Rows.Count <= 0)
                {
                    Model.address model_address = new Model.address();

                    if (model.user_type == 2)
                    {
                        model_address.consignee = purchase;
                        model_address.consignee_mobile = purchase_mobile;
                    }
                    else
                    {
                        model_address.consignee = nick_name;
                        model_address.consignee_mobile = mobile;
                    }
                    model_address.user_id = model.id;
                    model_address.province = model.province;
                    model_address.city = model.city;
                    model_address.distract = model.district;
                    model_address.content = model.address;
                    model_address.add_time = DateTime.Now;

                    bll_address.Add(model_address);
                }
                context.Response.Write("{\"status\":1, \"msg\":\"保存成功!\"}");
                return;
            }
            else
            {
                context.Response.Write("{\"status\":0, \"msg\":\"保存失败!\"}");
                return;
            }
        }
Beispiel #20
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.address model)
 {
     return(dal.Add(model));
 }