Exemplo n.º 1
0
 public object Address([FromBody] MailingAddressEntity mailingAddressEntity)
 {
     //MailingAddressEntity mailingAddressEntity = new MailingAddressEntity();
     //mailingAddressEntity.UserId = userId;
     //mailingAddressEntity.Province = province;
     //mailingAddressEntity.City = city;
     //mailingAddressEntity.County = county;
     //mailingAddressEntity.Address = address;
     //mailingAddressEntity.ZipCode = zipCode;
     //mailingAddressEntity.Name = name;
     //mailingAddressEntity.Phone = phone;
     mailingAddressEntity.AddTime = DateTime.Now;
     mailingAddressEntity.Status  = 1;
     if (MailingAddressBll.Instance.Add(mailingAddressEntity) > 0)
     {
         return(new Dictionary <string, string>()
         {
             { "status", "200" }
         });
     }
     else
     {
         return(new Dictionary <string, string>()
         {
             { "status", "500" }
         });
     }
 }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            string addId    = context.Request.Form["ctb[post-addId]"];    //地址id
            string status   = context.Request.Form["ctb[post-status]"];   //修改状态(add、update)
            string userId   = context.Request.Form["ctb[post-userId]"];   //会员id
            string province = context.Request.Form["ctb[post-province]"]; //省
            string city     = context.Request.Form["ctb[post-city]"];     //市
            string county   = context.Request.Form["ctb[post-county]"];   //区/县
            string address  = context.Request.Form["ctb[post-address]"];  //详细地址
            string zipCode  = context.Request.Form["ctb[post-zipCode]"];  //邮政编码
            string name     = context.Request.Form["ctb[post-name]"];     //姓名
            string phone    = context.Request.Form["ctb[post-phone]"];    //手机号码
            string s        = "{\"status\":\"error\"}";
            bool   b        = false;

            if (status == "add")  //增加
            {
                MailingAddressEntity mailingAddressEntity = new MailingAddressEntity();
                mailingAddressEntity.UserId   = userId;
                mailingAddressEntity.Province = province;
                mailingAddressEntity.City     = city;
                mailingAddressEntity.County   = county;
                mailingAddressEntity.Address  = address;
                mailingAddressEntity.Name     = name;
                mailingAddressEntity.ZipCode  = zipCode;
                mailingAddressEntity.Phone    = phone;
                mailingAddressEntity.AddTime  = DateTime.Now;
                mailingAddressEntity.Status   = 1;
                b = MailingAddressBll.Instance.Add(mailingAddressEntity) > 0;
            }
            else  //修改
            {
                MailingAddressEntity mailingAddressEntity = MailingAddressBll.Instance.GetModel(int.Parse(addId));
                mailingAddressEntity.UserId   = userId;
                mailingAddressEntity.Province = province;
                mailingAddressEntity.City     = city;
                mailingAddressEntity.County   = county;
                mailingAddressEntity.Address  = address;
                mailingAddressEntity.Name     = name;
                mailingAddressEntity.ZipCode  = zipCode;
                mailingAddressEntity.Phone    = phone;
                mailingAddressEntity.AddTime  = DateTime.Now;
                mailingAddressEntity.Status   = 1;
                b = MailingAddressBll.Instance.Update(mailingAddressEntity);
            }

            if (b)
            {
                s = "{\"status\":\"success\"}";
            }


            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(s);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MailingAddressEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update sns_mailingAddress set ");
            strSql.Append("UserId=@UserId,");
            strSql.Append("Province=@Province,");
            strSql.Append("City=@City,");
            strSql.Append("County=@County,");
            strSql.Append("Address=@Address,");
            strSql.Append("ZipCode=@ZipCode,");
            strSql.Append("Name=@Name,");
            strSql.Append("Phone=@Phone,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("Status=@Status");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",   SqlDbType.VarChar,   50),
                new SqlParameter("@Province", SqlDbType.VarChar,   50),
                new SqlParameter("@City",     SqlDbType.VarChar,   50),
                new SqlParameter("@County",   SqlDbType.VarChar,   50),
                new SqlParameter("@Address",  SqlDbType.VarChar,   50),
                new SqlParameter("@ZipCode",  SqlDbType.VarChar,   50),
                new SqlParameter("@Name",     SqlDbType.VarChar,   50),
                new SqlParameter("@Phone",    SqlDbType.VarChar,   50),
                new SqlParameter("@AddTime",  SqlDbType.DateTime),
                new SqlParameter("@Status",   SqlDbType.Int,        4),
                new SqlParameter("@Id",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.UserId;
            parameters[1].Value  = model.Province;
            parameters[2].Value  = model.City;
            parameters[3].Value  = model.County;
            parameters[4].Value  = model.Address;
            parameters[5].Value  = model.ZipCode;
            parameters[6].Value  = model.Name;
            parameters[7].Value  = model.Phone;
            parameters[8].Value  = model.AddTime;
            parameters[9].Value  = model.Status;
            parameters[10].Value = model.Id;

            int rows = SqlHelper.Instance.ExecSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MailingAddressEntity DataRowToModel(DataRow row)
        {
            MailingAddressEntity model = new MailingAddressEntity();

            if (row != null)
            {
                if (row["Id"] != null && row["Id"].ToString() != "")
                {
                    model.Id = int.Parse(row["Id"].ToString());
                }
                if (row["UserId"] != null)
                {
                    model.UserId = row["UserId"].ToString();
                }
                if (row["Province"] != null)
                {
                    model.Province = row["Province"].ToString();
                }
                if (row["City"] != null)
                {
                    model.City = row["City"].ToString();
                }
                if (row["County"] != null)
                {
                    model.County = row["County"].ToString();
                }
                if (row["Address"] != null)
                {
                    model.Address = row["Address"].ToString();
                }
                if (row["ZipCode"] != null)
                {
                    model.ZipCode = row["ZipCode"].ToString();
                }
                if (row["Name"] != null)
                {
                    model.Name = row["Name"].ToString();
                }
                if (row["Phone"] != null)
                {
                    model.Phone = row["Phone"].ToString();
                }
                if (row["AddTime"] != null && row["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(row["AddTime"].ToString());
                }
                if (row["Status"] != null && row["Status"].ToString() != "")
                {
                    model.Status = int.Parse(row["Status"].ToString());
                }
            }
            return(model);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MailingAddressEntity model)
 {
     try
     {
         return(MailingAddressDb.Instance.Update(model));
     }
     catch (Exception ex)
     {
         WriteLog.WriteError(ex);
         throw ex;
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MailingAddressEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into sns_mailingAddress(");
            strSql.Append("UserId,Province,City,County,Address,ZipCode,Name,Phone,AddTime,Status)");
            strSql.Append(" values (");
            strSql.Append("@UserId,@Province,@City,@County,@Address,@ZipCode,@Name,@Phone,@AddTime,@Status)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",   SqlDbType.VarChar,   50),
                new SqlParameter("@Province", SqlDbType.VarChar,   50),
                new SqlParameter("@City",     SqlDbType.VarChar,   50),
                new SqlParameter("@County",   SqlDbType.VarChar,   50),
                new SqlParameter("@Address",  SqlDbType.VarChar,   50),
                new SqlParameter("@ZipCode",  SqlDbType.VarChar,   50),
                new SqlParameter("@Name",     SqlDbType.VarChar,   50),
                new SqlParameter("@Phone",    SqlDbType.VarChar,   50),
                new SqlParameter("@AddTime",  SqlDbType.DateTime),
                new SqlParameter("@Status",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserId;
            parameters[1].Value = model.Province;
            parameters[2].Value = model.City;
            parameters[3].Value = model.County;
            parameters[4].Value = model.Address;
            parameters[5].Value = model.ZipCode;
            parameters[6].Value = model.Name;
            parameters[7].Value = model.Phone;
            parameters[8].Value = model.AddTime;
            parameters[9].Value = model.Status;

            object obj = SqlHelper.Instance.ExecSqlScalar(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 7
0
 public object UpdateAddress([FromBody] MailingAddressEntity mailingAddressEntity)
 {
     //string[] s = values.Split('/');
     //string id = s[0];
     //string userId = s[1];  //会员id会员id
     //string province = s[2];  //省
     //string city = s[3];  //市
     //string county = s[4];  //区 / 县
     //string address = s[5];  //详细地址
     //string zipCode = s[6];  //邮政编码
     //string name = s[7];  //姓名
     //string phone = s[8];  //手机号码
     //MailingAddressEntity mailingAddressEntity = MailingAddressBll.Instance.GetModel(int.Parse(id));
     //mailingAddressEntity.UserId = userId;
     //mailingAddressEntity.Province = province;
     //mailingAddressEntity.City = city;
     //mailingAddressEntity.County = county;
     //mailingAddressEntity.Address = address;
     //mailingAddressEntity.ZipCode = zipCode;
     //mailingAddressEntity.Name = name;
     //mailingAddressEntity.Phone = phone;
     mailingAddressEntity.AddTime = DateTime.Now;
     mailingAddressEntity.Status  = 1;
     if (MailingAddressBll.Instance.Update(mailingAddressEntity))
     {
         return(new Dictionary <string, string>()
         {
             { "status", "200" }
         });
     }
     else
     {
         return(new Dictionary <string, string>()
         {
             { "status", "500" }
         });
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MailingAddressEntity GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,UserId,Province,City,County,Address,ZipCode,Name,Phone,AddTime,Status from sns_mailingAddress ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            MailingAddressEntity model = new MailingAddressEntity();
            DataSet ds = SqlHelper.Instance.ExecSqlDataSet(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            string userId  = context.Request.Form["UserId"];    //报名人id
            string exId    = context.Request.Form["ExId"];      //分享的帖子id
            string address = context.Request.Form["AddressId"]; //收货地址id
            string classid = context.Request.Form["classId"];   //1表示直接兑换,2表示会员兑换
            string s       = "{\"status\":\"error\"}";
            bool   b       = false;

            DataTable epdt = ExchangePersonBll.Instance.GetList($"UserId={userId} and status=1").Tables[0];

            if (epdt.Rows.Count > 0)
            {
                s = "{\"status\":\"exist\"}";  //已有兑换,不能继续兑换
                context.Response.Write(s);
                return;
            }

            //获得帖子信息
            ExchangeEntity exchangeEntity = ExchangeBll.Instance.GetModel(int.Parse(exId));
            string         official       = exchangeEntity.Official;

            if (exchangeEntity.Examine == "4") //兑换中状态
            {
                if (classid == "2")            //会员兑换
                {
                    if (!VipExchange(int.Parse(userId)))
                    {
                        s = "{\"status\":\"lacking\"}";  //会员不足
                        context.Response.Write(s);
                        return;
                    }
                }
                else  //普通兑换
                {
                    if (!OrdinaryExchange(int.Parse(userId), official))
                    {
                        s = "{\"status\":\"lacking\"}";  //身家不足
                        context.Response.Write(s);
                        return;
                    }
                }

                //添加兑换表
                ExchangePersonEntity exchangePersonEntity = new ExchangePersonEntity();
                exchangePersonEntity.UserId  = userId;
                exchangePersonEntity.ExId    = exId;
                exchangePersonEntity.AddTime = DateTime.Now;
                exchangePersonEntity.Address = address;
                exchangePersonEntity.Examine = "1";
                exchangePersonEntity.Status  = 1;
                b = ExchangePersonBll.Instance.Add(exchangePersonEntity) > 0;
                if (b)
                {
                    //更新分享表
                    exchangeEntity.ExchangePerson = userId;
                    exchangeEntity.EnterTime      = DateTime.Now;
                    exchangeEntity.Examine        = "5";
                    b = ExchangeBll.Instance.Update(exchangeEntity);
                    if (b)
                    {
                        MailingAddressEntity mailingAddressEntity = MailingAddressBll.Instance.GetModel(int.Parse(exchangePersonEntity.Address));
                        string body = $@"id为:{exchangeEntity.Id},标题为:{exchangeEntity.Title},收货地址为:{mailingAddressEntity.Province}省{mailingAddressEntity.City}市{mailingAddressEntity.County}区/县{mailingAddressEntity.Address},
                                            邮政编码为:{mailingAddressEntity.ZipCode},兑换人:{mailingAddressEntity.Name},兑换人手机号为:{mailingAddressEntity.Phone}";

                        MailHelper.sendMail("分享被兑换", body, EmailConfig.Instance._EmailName, new List <string>()
                        {
                            EmailConfig.Instance._EmailUserName
                        }, EmailConfig.Instance._EmailAgreement, EmailConfig.Instance._EmailUserName, EmailConfig.Instance._EmailPassword);
                        s = "{\"status\":\"success\"}";
                    }
                }
            }
            else
            {
                s = "{\"status\":\"other\"}";
            }


            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(s);
        }