Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(VipScore model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Shop_VipScore set ");
            strSql.Append("CardNumber=@CardNumber,");
            strSql.Append("Score=@Score,");
            strSql.Append("VipName=@VipName,");
            strSql.Append("VipPhone=@VipPhone,");
            strSql.Append("VipSex=@VipSex,");
            strSql.Append("VipRemark=@VipRemark,");
            strSql.Append("Status=@Status,");
            strSql.Append("VipLevelId=@VipLevelId,");
            strSql.Append("CreateBy=@CreateBy,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("UpdateBy=@UpdateBy,");
            strSql.Append("UpdateDate=@UpdateDate");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CardNumber", SqlDbType.NVarChar,         -1),
                new SqlParameter("@Score",      SqlDbType.Int,               4),
                new SqlParameter("@VipName",    SqlDbType.NVarChar,         -1),
                new SqlParameter("@VipPhone",   SqlDbType.NVarChar,         -1),
                new SqlParameter("@VipSex",     SqlDbType.NVarChar,         -1),
                new SqlParameter("@VipRemark",  SqlDbType.NVarChar,         -1),
                new SqlParameter("@Status",     SqlDbType.NVarChar,         -1),
                new SqlParameter("@VipLevelId", SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@CreateBy",   SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@UpdateBy",   SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@UpdateDate", SqlDbType.DateTime),
                new SqlParameter("@Id",         SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value  = model.CardNumber;
            parameters[1].Value  = model.Score;
            parameters[2].Value  = model.VipName;
            parameters[3].Value  = model.VipPhone;
            parameters[4].Value  = model.VipSex;
            parameters[5].Value  = model.VipRemark;
            parameters[6].Value  = model.Status;
            parameters[7].Value  = model.VipLevelId;
            parameters[8].Value  = model.CreateBy;
            parameters[9].Value  = model.CreateDate;
            parameters[10].Value = model.UpdateBy;
            parameters[11].Value = model.UpdateDate;
            parameters[12].Value = model.Id;

            int rows = _db.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(VipScore model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Shop_VipScore(");
            strSql.Append("Id,CardNumber,Score,VipName,VipPhone,VipSex,VipRemark,Status,VipLevelId,CreateBy,CreateDate,UpdateBy,UpdateDate)");
            strSql.Append(" values (");
            strSql.Append("@Id,@CardNumber,@Score,@VipName,@VipPhone,@VipSex,@VipRemark,@Status,@VipLevelId,@CreateBy,@CreateDate,@UpdateBy,@UpdateDate)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",         SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@CardNumber", SqlDbType.NVarChar,         -1),
                new SqlParameter("@Score",      SqlDbType.Int,               4),
                new SqlParameter("@VipName",    SqlDbType.NVarChar,         -1),
                new SqlParameter("@VipPhone",   SqlDbType.NVarChar,         -1),
                new SqlParameter("@VipSex",     SqlDbType.NVarChar,         -1),
                new SqlParameter("@VipRemark",  SqlDbType.NVarChar,         -1),
                new SqlParameter("@Status",     SqlDbType.NVarChar,         -1),
                new SqlParameter("@VipLevelId", SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@CreateBy",   SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@UpdateBy",   SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@UpdateDate", SqlDbType.DateTime)
            };
            parameters[0].Value  = Guid.NewGuid();
            parameters[1].Value  = model.CardNumber;
            parameters[2].Value  = model.Score;
            parameters[3].Value  = model.VipName;
            parameters[4].Value  = model.VipPhone;
            parameters[5].Value  = model.VipSex;
            parameters[6].Value  = model.VipRemark;
            parameters[7].Value  = model.Status;
            parameters[8].Value  = Guid.NewGuid();
            parameters[9].Value  = Guid.NewGuid();
            parameters[10].Value = model.CreateDate;
            parameters[11].Value = Guid.NewGuid();
            parameters[12].Value = model.UpdateDate;

            int rows = _db.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        public ActionResult AddVipData(string Id)
        {
            var vipEntity = new VipScore();

            if (!string.IsNullOrEmpty(Id))
            {
                vipEntity         = VipScoreBLL.Instance.GetVipScroeModel(Guid.Parse(Id));
                ViewBag.ShowTitle = "VIP信息编辑";
            }
            else
            {
                //自动生成vip卡号
                var cardNumber = RandomNumber.Instance.GetRandom3();
                ViewBag.VipCode   = cardNumber;
                ViewBag.ShowTitle = "VIP信息添加";
            }
            return(View(vipEntity));
        }
Пример #4
0
        public List <VipScore> GetVipscoreListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            List <VipScore> stockLs    = new List <VipScore>();
            DataSet         ds_StockLs = GetListByPage(strWhere, orderby, startIndex, endIndex);

            if (ds_StockLs != null && ds_StockLs.Tables[0] != null && ds_StockLs.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds_StockLs.Tables[0].Rows)
                {
                    VipScore stockModel = null;
                    stockModel = DataRowToModel(dr);
                    if (stockModel != null)
                    {
                        stockLs.Add(stockModel);
                    }
                }
            }
            return(stockLs);
        }
Пример #5
0
 public JsonResult SaveVipData(VipScore model)
 {
     if (GetUserInfoEntity() == null)
     {
         Response.Status     = "301 Moved Permanently";
         Response.StatusCode = 301;
         Response.AppendHeader("Location", "/Login");
     }
     else
     {
         if (model.Id != Guid.Empty)
         {
             //得到vip信息
             var vipmodle = VipScoreBLL.Instance.GetModel(model.Id);
             if (vipmodle != null)
             {
                 vipmodle.Score      = model.Score;
                 vipmodle.VipName    = model.VipName;
                 vipmodle.VipPhone   = model.VipPhone;
                 vipmodle.VipSex     = model.VipSex;
                 vipmodle.VipRemark  = model.VipRemark;
                 vipmodle.UpdateBy   = GetUserInfoEntity().Id;
                 vipmodle.UpdateDate = DateTime.Now;
                 if (VipScoreBLL.Instance.Update(vipmodle))
                 {
                     return(Json(new { success = true, error = new { code = 202, message = "保存成功" } }));
                 }
                 return(Json(new { success = false, error = new { code = 301, message = "保存失败" } }));
             }
         }
         else
         {
             model.CreateBy   = GetUserInfoEntity().Id;
             model.CreateDate = DateTime.Now;
             model.UpdateBy   = GetUserInfoEntity().Id;
             model.UpdateDate = DateTime.Now;
             model.Status     = "ACTIVE";
             VipScoreBLL.Instance.Add(model);
         }
         return(Json(new { success = true, error = new { code = 202, message = "保存成功" } }));
     }
     return(Json(new { success = false, error = new { code = 301, message = "保存失败" } }));
 }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipScore GetModel(Guid Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,CardNumber,Score,VipName,VipPhone,VipSex,VipRemark,Status,VipLevelId,CreateBy,CreateDate,UpdateBy,UpdateDate from Shop_VipScore ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = Id;

            VipScore model = new VipScore();
            DataSet  ds    = _db.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipScore DataRowToModel(DataRow row)
        {
            VipScore model = new VipScore();

            if (row != null)
            {
                if (row["Id"] != null && row["Id"].ToString() != "")
                {
                    model.Id = new Guid(row["Id"].ToString());
                }
                if (row["CardNumber"] != null)
                {
                    model.CardNumber = row["CardNumber"].ToString();
                }
                if (row["Score"] != null && row["Score"].ToString() != "")
                {
                    model.Score = int.Parse(row["Score"].ToString());
                }
                if (row["VipName"] != null)
                {
                    model.VipName = row["VipName"].ToString();
                }
                if (row["VipPhone"] != null)
                {
                    model.VipPhone = row["VipPhone"].ToString();
                }
                if (row["VipSex"] != null)
                {
                    model.VipSex = row["VipSex"].ToString();
                }
                if (row["VipRemark"] != null)
                {
                    model.VipRemark = row["VipRemark"].ToString();
                }
                if (row["Status"] != null)
                {
                    model.Status = row["Status"].ToString();
                }
                if (row["VipLevelId"] != null && row["VipLevelId"].ToString() != "")
                {
                    model.VipLevelId = new Guid(row["VipLevelId"].ToString());
                }
                if (row["CreateBy"] != null && row["CreateBy"].ToString() != "")
                {
                    model.CreateBy = new Guid(row["CreateBy"].ToString());
                }
                if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                }
                if (row["UpdateBy"] != null && row["UpdateBy"].ToString() != "")
                {
                    model.UpdateBy = new Guid(row["UpdateBy"].ToString());
                }
                if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "")
                {
                    model.UpdateDate = DateTime.Parse(row["UpdateDate"].ToString());
                }
            }
            return(model);
        }
Пример #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(VipScore model)
 {
     return(VipScoreDAL.instance.Update(model));
 }
Пример #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(VipScore model)
 {
     return(VipScoreDAL.instance.Add(model));
 }