示例#1
0
        /// <summary>
        /// 保存出租
        /// </summary>
        private static string SaveRent(string userId, string title, string describe, string itemName, string cover,
                                       string certificate, string imgs, string source, string constitute, string price, string official)
        {
            bool       b          = false;
            RentEntity rentEntity = new RentEntity();

            rentEntity.UserId   = userId;
            rentEntity.Title    = title;
            rentEntity.Describe = describe;
            rentEntity.ItemName = itemName;
            rentEntity.Cover    = cover;
            if (certificate == null)
            {
                certificate = "";
            }
            rentEntity.Certificate = certificate;
            rentEntity.Imgs        = imgs;
            rentEntity.Source      = source;
            rentEntity.Constitute  = constitute;
            rentEntity.Price       = price;
            rentEntity.Official    = official;
            rentEntity.RentPerson  = "";
            rentEntity.AddTime     = DateTime.Now;
            rentEntity.EnterTime   = Convert.ToDateTime("1900-01-01");
            rentEntity.Examine     = "1";
            rentEntity.Status      = 1;
            b = RentBll.Instance.Add(rentEntity) > 0;
            if (b)
            {
                return("{\"status\":\"success\"}");
            }
            return("{\"status\":\"error\"}");
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(RentEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into sns_rent(");
            strSql.Append("UserId,Title,Describe,ItemName,Cover,Certificate,Imgs,Source,Constitute,Price,Official,RentPerson,AddTime,EnterTime,Examine,Status)");
            strSql.Append(" values (");
            strSql.Append("@UserId,@Title,@Describe,@ItemName,@Cover,@Certificate,@Imgs,@Source,@Constitute,@Price,@Official,@RentPerson,@AddTime,@EnterTime,@Examine,@Status)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",      SqlDbType.VarChar,    50),
                new SqlParameter("@Title",       SqlDbType.VarChar,   500),
                new SqlParameter("@Describe",    SqlDbType.Text),
                new SqlParameter("@ItemName",    SqlDbType.VarChar,   500),
                new SqlParameter("@Cover",       SqlDbType.VarChar,    50),
                new SqlParameter("@Certificate", SqlDbType.VarChar,    50),
                new SqlParameter("@Imgs",        SqlDbType.VarChar,   500),
                new SqlParameter("@Source",      SqlDbType.VarChar,   500),
                new SqlParameter("@Constitute",  SqlDbType.VarChar,   500),
                new SqlParameter("@Price",       SqlDbType.VarChar,    50),
                new SqlParameter("@Official",    SqlDbType.VarChar,    50),
                new SqlParameter("@RentPerson",  SqlDbType.VarChar,    50),
                new SqlParameter("@AddTime",     SqlDbType.DateTime),
                new SqlParameter("@EnterTime",   SqlDbType.DateTime),
                new SqlParameter("@Examine",     SqlDbType.VarChar,    50),
                new SqlParameter("@Status",      SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.UserId;
            parameters[1].Value  = model.Title;
            parameters[2].Value  = model.Describe;
            parameters[3].Value  = model.ItemName;
            parameters[4].Value  = model.Cover;
            parameters[5].Value  = model.Certificate;
            parameters[6].Value  = model.Imgs;
            parameters[7].Value  = model.Source;
            parameters[8].Value  = model.Constitute;
            parameters[9].Value  = model.Price;
            parameters[10].Value = model.Official;
            parameters[11].Value = model.RentPerson;
            parameters[12].Value = model.AddTime;
            parameters[13].Value = model.EnterTime;
            parameters[14].Value = model.Examine;
            parameters[15].Value = model.Status;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(RentEntity model)
 {
     try
     {
         return(RentDb.Instance.Update(model));
     }
     catch (System.Exception ex)
     {
         WriteLog.WriteError(ex);
         throw ex;
     }
 }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string rId = Request.QueryString["nid"];  //交换id
                rentEntity           = RentBll.Instance.GetModel(Convert.ToInt32(rId));
                uid                  = rentEntity.UserId;
                uMemberEntity        = MemberBll.Instance.GetModel(Convert.ToInt32(uid));
                PublisherInfo.UserId = uid;

                BindImage();
                BindCertificate();
            }
        }
示例#5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RentEntity GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,UserId,Title,Describe,ItemName,Cover,Certificate,Imgs,Source,Constitute,Price,Official,RentPerson,AddTime,EnterTime,Examine,Status from sns_rent ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            RentEntity model = new RentEntity();
            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);
            }
        }
示例#6
0
 public RentViewModel( )
 {
     rentBook       = new RentBook(this);
     SelectRentBook = new RentEntity();
 }
示例#7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RentEntity DataRowToModel(DataRow row)
        {
            RentEntity model = new RentEntity();

            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["Title"] != null)
                {
                    model.Title = row["Title"].ToString();
                }
                if (row["Describe"] != null)
                {
                    model.Describe = row["Describe"].ToString();
                }
                if (row["ItemName"] != null)
                {
                    model.ItemName = row["ItemName"].ToString();
                }
                if (row["Cover"] != null)
                {
                    model.Cover = row["Cover"].ToString();
                }
                if (row["Certificate"] != null)
                {
                    model.Certificate = row["Certificate"].ToString();
                }
                if (row["Imgs"] != null)
                {
                    model.Imgs = row["Imgs"].ToString();
                }
                if (row["Source"] != null)
                {
                    model.Source = row["Source"].ToString();
                }
                if (row["Constitute"] != null)
                {
                    model.Constitute = row["Constitute"].ToString();
                }
                if (row["Price"] != null)
                {
                    model.Price = row["Price"].ToString();
                }
                if (row["Official"] != null)
                {
                    model.Official = row["Official"].ToString();
                }
                if (row["RentPerson"] != null)
                {
                    model.RentPerson = row["RentPerson"].ToString();
                }
                if (row["AddTime"] != null && row["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(row["AddTime"].ToString());
                }
                if (row["EnterTime"] != null && row["EnterTime"].ToString() != "")
                {
                    model.EnterTime = DateTime.Parse(row["EnterTime"].ToString());
                }
                if (row["Examine"] != null)
                {
                    model.Examine = row["Examine"].ToString();
                }
                if (row["Status"] != null && row["Status"].ToString() != "")
                {
                    model.Status = int.Parse(row["Status"].ToString());
                }
            }
            return(model);
        }
示例#8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(RentEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update sns_rent set ");
            strSql.Append("UserId=@UserId,");
            strSql.Append("Title=@Title,");
            strSql.Append("Describe=@Describe,");
            strSql.Append("ItemName=@ItemName,");
            strSql.Append("Cover=@Cover,");
            strSql.Append("Certificate=@Certificate,");
            strSql.Append("Imgs=@Imgs,");
            strSql.Append("Source=@Source,");
            strSql.Append("Constitute=@Constitute,");
            strSql.Append("Price=@Price,");
            strSql.Append("Official=@Official,");
            strSql.Append("RentPerson=@RentPerson,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("EnterTime=@EnterTime,");
            strSql.Append("Examine=@Examine,");
            strSql.Append("Status=@Status");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",      SqlDbType.VarChar,    50),
                new SqlParameter("@Title",       SqlDbType.VarChar,   500),
                new SqlParameter("@Describe",    SqlDbType.Text),
                new SqlParameter("@ItemName",    SqlDbType.VarChar,   500),
                new SqlParameter("@Cover",       SqlDbType.VarChar,    50),
                new SqlParameter("@Certificate", SqlDbType.VarChar,    50),
                new SqlParameter("@Imgs",        SqlDbType.VarChar,   500),
                new SqlParameter("@Source",      SqlDbType.VarChar,   500),
                new SqlParameter("@Constitute",  SqlDbType.VarChar,   500),
                new SqlParameter("@Price",       SqlDbType.VarChar,    50),
                new SqlParameter("@Official",    SqlDbType.VarChar,    50),
                new SqlParameter("@RentPerson",  SqlDbType.VarChar,    50),
                new SqlParameter("@AddTime",     SqlDbType.DateTime),
                new SqlParameter("@EnterTime",   SqlDbType.DateTime),
                new SqlParameter("@Examine",     SqlDbType.VarChar,    50),
                new SqlParameter("@Status",      SqlDbType.Int,         4),
                new SqlParameter("@Id",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.UserId;
            parameters[1].Value  = model.Title;
            parameters[2].Value  = model.Describe;
            parameters[3].Value  = model.ItemName;
            parameters[4].Value  = model.Cover;
            parameters[5].Value  = model.Certificate;
            parameters[6].Value  = model.Imgs;
            parameters[7].Value  = model.Source;
            parameters[8].Value  = model.Constitute;
            parameters[9].Value  = model.Price;
            parameters[10].Value = model.Official;
            parameters[11].Value = model.RentPerson;
            parameters[12].Value = model.AddTime;
            parameters[13].Value = model.EnterTime;
            parameters[14].Value = model.Examine;
            parameters[15].Value = model.Status;
            parameters[16].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#9
0
        public void ProcessRequest(HttpContext context)
        {
            string userId  = context.Request.Form["UserId"];    //报名人id
            string rId     = context.Request.Form["RId"];       //出租的帖子id
            string address = context.Request.Form["AddressId"]; //收货地址id
            string s       = "{\"status\":\"error\"}";
            bool   b       = false;
            //获得帖子信息
            RentEntity rentEntity = RentBll.Instance.GetModel(int.Parse(rId));
            string     official   = rentEntity.Official;

            if (rentEntity.Examine == "1")  //兑换中状态
            {
                //取身家值
                MemberEntity memberEntity = MemberBll.Instance.GetModel(int.Parse(userId));
                if (memberEntity.Shenjia < decimal.Parse(official))
                {
                    s = "{\"status\":\"lacking\"}";
                }
                else
                {
                    //添加积分变更表
                    IntegralChangeEntity integralChangeEntity = new IntegralChangeEntity();
                    integralChangeEntity.UserId   = userId;
                    integralChangeEntity.source   = "rent"; //出租
                    integralChangeEntity.ShenJia  = -decimal.Parse(official);
                    integralChangeEntity.Cnbi     = "0";
                    integralChangeEntity.integral = 0;
                    integralChangeEntity.ardent   = 0;
                    integralChangeEntity.Growth   = 0;
                    integralChangeEntity.Bean     = "0";
                    integralChangeEntity.Status   = 1;
                    integralChangeEntity.AddTime  = DateTime.Now;
                    IntegralChangeBll.Instance.Add(integralChangeEntity);
                    //更新会员表积分
                    MemberBll.Instance.UpdateIntegral(userId, "ShenJia", integralChangeEntity.ShenJia.ToString());
                    //添加兑换表
                    RentPersonEntity rentPersonEntity = new RentPersonEntity();
                    rentPersonEntity.UserId  = userId;
                    rentPersonEntity.RId     = rId;
                    rentPersonEntity.AddTime = DateTime.Now;
                    rentPersonEntity.Address = address;
                    rentPersonEntity.Examine = "1";
                    rentPersonEntity.Status  = 1;
                    b = RentPersonBll.Instance.Add(rentPersonEntity) > 0;
                    if (b)
                    {
                        //更新出租表
                        rentEntity.RentPerson = userId;
                        rentEntity.EnterTime  = DateTime.Now;
                        rentEntity.Examine    = "0";
                        b = RentBll.Instance.Update(rentEntity);
                        if (b)
                        {
                            s = "{\"status\":\"success\"}";
                        }
                    }
                }
            }
            else
            {
                s = "{\"status\":\"other\"}";
            }
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(s);
        }