示例#1
0
        public bool UpdateMenCard(MemCards mc)
        {
            string sql = "P_UpdateMenCard";

            SqlParameter[] para =
            {
                new SqlParameter("@CL_ID",             mc.CL_ID),
                new SqlParameter("@MC_CardID",         mc.MC_CardID),
                new SqlParameter("@MC_Password",       mc.MC_Password),
                new SqlParameter("@MC_Name",           mc.MC_Name),
                new SqlParameter("@MC_Sex",            mc.MC_Sex),
                new SqlParameter("@MC_Mobile",         mc.MC_Mobile),
                new SqlParameter("@MC_BirthdayType",   mc.MC_BirthdayType),
                new SqlParameter("@MC_Birthday_Month", mc.MC_Birthday_Month),
                new SqlParameter("@MC_Birthday_Day",   mc.MC_Birthday_Day),
                new SqlParameter("@MC_IsPast",         mc.MC_IsPast),
                new SqlParameter("@MC_PastTime",       mc.MC_PastTime),
                new SqlParameter("@MC_State",          mc.MC_State),
                new SqlParameter("@MC_Money",          mc.MC_Money),
                new SqlParameter("@MC_Point",          mc.MC_Point),
                new SqlParameter("@MC_IsPointAuto",    mc.MC_IsPointAuto),
                new SqlParameter("@MC_RefererCard",    mc.MC_RefererCard),
                new SqlParameter("@MC_RefererName",    mc.MC_RefererName)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
示例#2
0
        public void Create()
        {
            MemCards m = new MemCards();

            try
            {
                m = GetMByForm(m);
                m.MC_CreateTime = DateTime.Now;
            }
            catch (Exception ex)
            {
                Response.Write("您的输入有误,请检索,错误消息:" + ex.Message);
            }

            try
            {
                db.MemCards.InsertOnSubmit(m);
                db.SubmitChanges();
                Response.Write("添加会员成功!");
            }
            catch (Exception ex)
            {
                Response.Write("添加会员有误,请检索,错误消息:" + ex.Message);
            }
        }
示例#3
0
 //会员转账
 public void MemCardTransfer()
 {
     if (!string.IsNullOrEmpty(Request.Form["TransferMoney"]) && !string.IsNullOrEmpty(Request.Form["MC_CardID"]) && !string.IsNullOrEmpty(Request.Form["OutMC_CardID"]))
     {//
         MemCards     m     = (from i in db.MemCards where i.MC_CardID == Request.Form["MC_CardID"] select i).First();
         MemCards     out_m = (from i in db.MemCards where i.MC_CardID == Request.Form["OutMC_CardID"] select i).First();
         TransferLogs t     = new TransferLogs();
         Users        u     = Session["UserInfo"] as Users;
         t.S_ID             = u.S_ID;
         t.U_ID             = u.U_ID;
         t.TL_FromMC_ID     = m.MC_ID;
         t.TL_FromMC_CardID = m.MC_CardID.ToString();
         t.TL_ToMC_ID       = out_m.MC_ID;
         t.TL_ToMC_CardID   = out_m.MC_CardID.ToString();
         t.TL_TransferMoney = decimal.Parse(Request.Form["TransferMoney"]);
         t.TL_Remark        = (Request.Form["Remark"] ?? "");
         t.TL_CreateTime    = DateTime.Now;
         m.MC_Point        -= Convert.ToInt32(t.TL_TransferMoney);
         out_m.MC_Point    += Convert.ToInt32(t.TL_TransferMoney);
         try
         {
             db.TransferLogs.InsertOnSubmit(t);
             db.SubmitChanges();
             Response.Write("转账成功!");
         }
         catch (Exception ex)
         {
             Response.Write("异常:转账失败,错误消息:" + ex.Message);
         }
     }
     else
     {
         Response.Write("异常:参数不全");
     }
 }
示例#4
0
        //快速消费
        public ActionResult DoJffx(int MC_ID, string MC_CardID, float CO_Recash, int CO_GavePoint)
        {
            //修改消费的会员信息
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == MC_ID);

            mc.MC_Point -= CO_GavePoint;
            mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;


            //在转账记录表插入一条记录
            ConsumeOrders co = new ConsumeOrders
            {
                S_ID             = (Session["Users"] as Users).S_ID,
                U_ID             = (Session["Users"] as Users).U_ID,
                CO_OrderCode     = DateTime.Now.ToString("yyyyMMddHHmmss"),
                CO_OrderType     = 2,
                MC_ID            = MC_ID,
                MC_CardID        = MC_CardID,
                EG_ID            = 0,
                CO_TotalMoney    = 0,
                CO_DiscountMoney = 0,
                CO_GavePoint     = CO_GavePoint,
                CO_Recash        = CO_Recash,
                CO_Remark        = "积分返现",
                CO_CreateTime    = Convert.ToDateTime(Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"))
            };

            mpms.ConsumeOrders.Add(co);
            return(Json(mpms.SaveChanges() > 1, JsonRequestBehavior.AllowGet));
        }
        // 添加修改方法
        public ActionResult MemberAddOrUpdate(MemCards sj)
        {
            if (sj.MC_ID == 0)
            {//添加
                mpms.MemCards.Add(sj);
                return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
            }
            //修改
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == sj.MC_ID);

            mc.MC_CardID         = sj.MC_CardID;
            mc.MC_Name           = sj.MC_Name;
            mc.MC_Mobile         = sj.MC_Mobile;
            mc.MC_Password       = sj.MC_Password;
            mc.MC_Birthday_Month = sj.MC_Birthday_Month;
            mc.MC_Birthday_Day   = sj.MC_Birthday_Day;
            mc.MC_BirthdayType   = sj.MC_BirthdayType;
            mc.MC_IsPast         = sj.MC_IsPast;
            mc.MC_PastTime       = sj.MC_PastTime;
            mc.MC_Point          = sj.MC_Point;
            mc.MC_Money          = sj.MC_Money;
            mc.MC_State          = sj.MC_State;
            mc.MC_RefererCard    = sj.MC_RefererCard;
            mc.MC_RefererName    = sj.MC_RefererName;
            mc.MC_Sex            = sj.MC_Sex;
            mc.MC_IsPointAuto    = sj.MC_IsPointAuto;
            mc.CL_ID             = sj.CL_ID;

            mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;
            //修改
            return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        //快速消费
        public void Fastmoney()
        {
            try
            {
                ConsumeOrders co    = new ConsumeOrders();
                DataTable     Cdt   = Session["CriD"] as DataTable;
                Users         Udt   = Session["UserInfo"] as Users;
                DateTime      de    = DateTime.Now;
                string        Strde = de.ToString("yyyyMMddHHmmss");
                co.S_ID             = Udt.S_ID;
                co.U_ID             = Udt.U_ID;
                co.CO_OrderCode     = Strde;
                co.CO_OrderType     = 5;
                co.MC_ID            = int.Parse(Cdt.Rows[0]["MC_ID"].ToString());
                co.MC_CardID        = Cdt.Rows[0]["MC_CardID"].ToString();
                co.CO_TotalMoney    = decimal.Parse(Request.Form["nMoney"]);
                co.CO_DiscountMoney = decimal.Parse(Request.Form["factMoney"]);
                co.CO_GavePoint     = int.Parse(Request.Form["autoPoint"]);
                co.CO_CreateTime    = de;
                co.CO_Remark        = Request.Form["Remark"];
                db.ConsumeOrders.InsertOnSubmit(co);
                MemCards m = (from i in db.MemCards where i.MC_CardID == Cdt.Rows[0]["MC_CardID"].ToString() select i).First();

                m.MC_Point      = int.Parse(Cdt.Rows[0]["MC_Point"].ToString()) + int.Parse(Request.Form["autoPoint"]);
                m.MC_TotalMoney = (float.Parse(Cdt.Rows[0]["MC_TotalMoney"].ToString())) + (float.Parse(Request.Form["factMoney"]));
                m.MC_TotalCount = (int.Parse(Cdt.Rows[0]["MC_TotalCount"].ToString())) + 1;
                db.SubmitChanges();
                Response.Write("ok");
            }
            catch (Exception ex)
            {
                Response.Write(ex);
            }
        }
示例#7
0
        //会员升级
        public ActionResult VipUpgrade(int MC_ID, int CL_ID, int MC_Point)
        {
            var cl = from c in mpms.CardLevels
                     select new
            {
                CL_ID        = c.CL_ID,
                CL_LevelName = c.CL_LevelName,
                CL_NeedPoint = c.CL_NeedPoint,
            };
            var r            = cl.ToList();
            var isUpgrade    = false;
            var UpgradeCL_ID = 0;

            for (int i = 0; i < r.Count; i++)
            {
                if (CL_ID < Convert.ToInt32(r[i].CL_ID) && MC_Point >= Convert.ToInt32(r[i].CL_NeedPoint))
                {
                    UpgradeCL_ID = Convert.ToInt32(r[i].CL_ID);
                    isUpgrade    = true;
                }
            }

            if (isUpgrade)
            {
                MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == MC_ID);
                mc.CL_ID = UpgradeCL_ID;
                mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;
                return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
            }

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
示例#8
0
 //会员减积分
 public void ChangePoint()
 {
     try
     {
         var result = from i in db.MemCards where i.MC_CardID == Request.Form["mort"].Trim() select i;
         if (Request.Form["mort"].Trim().Length == 11)
         {
             result = from i in db.MemCards where i.MC_Mobile == Request.Form["mort"] select i;
         }
         MemCards m = result.First();
         m.MC_Point -= int.Parse(Request.Form["changePoint"]); //减积分
                                                               //添加记录
         ConsumeOrders co    = new ConsumeOrders();
         Users         Udt   = Session["UserInfo"] as Users;
         string        Strde = DateTime.Now.ToString("yyyyMMddHHmmss");
         co.S_ID             = Udt.S_ID;
         co.U_ID             = Udt.U_ID;
         co.CO_OrderCode     = Strde;
         co.CO_OrderType     = 3;
         co.MC_ID            = m.MC_ID;     //int.Parse(Cdt.Rows[0]["MC_ID"].ToString());
         co.MC_CardID        = m.MC_CardID; //Cdt.Rows[0]["MC_CardID"].ToString();
         co.CO_TotalMoney    = 0;           // decimal.Parse(Request.Form["nMoney"]);
         co.CO_DiscountMoney = 0;
         co.CO_GavePoint     = int.Parse(Request.Form["changePoint"]);
         co.CO_CreateTime    = DateTime.Now;
         co.CO_Remark        = Request.Form["Remark"].Trim();
         db.ConsumeOrders.InsertOnSubmit(co);
         db.SubmitChanges();
         Response.Write("ok");
     }
     catch (Exception ex)
     {
         Response.Write("错误消息:" + ex);
     }
 }
        // 挂失/锁定
        public ActionResult MemberReport(int MC_ID, int MC_State)
        {
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == MC_ID);

            mc.MC_State = MC_State;
            mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;
            //修改
            return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
        }
示例#10
0
        public bool DeleteMenCard(MemCards mc)
        {
            string sql = "P_DeleteMenCard";

            SqlParameter[] para =
            {
                new SqlParameter("@MC_CardID", mc.MC_CardID),
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
        // 查询老会员密码是否存在
        public ActionResult QueryVipPwd(string MC_Password)
        {
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_Password == MC_Password);

            if (mc == null)
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        // 会员换卡
        public ActionResult ChangCard(int MC_ID, string MC_CardID, string MC_Password)
        { //修改
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == MC_ID);

            mc.MC_CardID   = MC_CardID;
            mc.MC_Password = MC_Password;

            mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;

            return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
        }
        // 查询会员卡号是否存在,返回卡号的信息
        public ActionResult QueryVipIsNull(string cardNumber)
        {
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_CardID == cardNumber);

            if (mc != null)
            {
                return(Json(new { pd = true, MC_ID = mc.MC_ID, MC_CardID = mc.MC_CardID, MC_Name = mc.MC_Name, MC_Point = mc.MC_Point, MC_TotalMoney = mc.MC_TotalMoney }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { pd = false }, JsonRequestBehavior.AllowGet));
        }
示例#14
0
        public bool UpdateState(MemCards mc)
        {
            string sql = "P_UpdateState";

            SqlParameter[] para =
            {
                new SqlParameter("@MC_CardID", mc.MC_CardID),
                new SqlParameter("@MC_State",  mc.MC_State)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
示例#15
0
        public bool NewCard(MemCards mc)
        {
            string sql = "P_NewCard";

            SqlParameter[] para =
            {
                new SqlParameter("@MC_ID",       mc.MC_ID),
                new SqlParameter("@MC_CardID",   mc.MC_CardID),
                new SqlParameter("@MC_Password", mc.MC_Password)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
        // 会员转账页面
        public ActionResult MemberTransfer(int RollMC_ID, string RollCardID, float RollMC_TotalMoney, int ShiftMC_ID, string ShiftCardID, decimal TL_TransferMoney, string TL_Remark, DateTime TL_CreateTime)
        {
            var jf = Convert.ToInt32(RollMC_TotalMoney);

            using (TransactionScope transaction = new TransactionScope())//使用事务
            {
                try
                {
                    //修改转出的会员信息
                    MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == RollMC_ID);
                    mc.MC_Point -= jf;
                    if (mc.MC_Point < 0)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    mc.MC_TotalMoney += RollMC_TotalMoney;
                    mc.MC_TotalCount += 1;

                    mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;


                    //在转账记录表插入一条记录
                    TransferLogs tr = new TransferLogs
                    {
                        S_ID             = (Session["Users"] as Users).S_ID,
                        U_ID             = (Session["Users"] as Users).U_ID,
                        TL_FromMC_ID     = RollMC_ID,
                        TL_FromMC_CardID = RollCardID,
                        TL_ToMC_ID       = ShiftMC_ID,
                        TL_ToMC_CardID   = ShiftCardID,
                        TL_TransferMoney = TL_TransferMoney,
                        TL_Remark        = TL_Remark,
                        TL_CreateTime    = TL_CreateTime
                    };
                    mpms.TransferLogs.Add(tr);

                    //修改转入的会员信息
                    MemCards zr = mpms.MemCards.FirstOrDefault(x => x.MC_ID == ShiftMC_ID);
                    zr.MC_Point += jf;

                    mpms.Entry <MemCards>(zr).State = System.Data.Entity.EntityState.Modified;

                    transaction.Complete();//放在catch上面,否则不能回滚
                }
                catch
                {
                }
            }

            return(Json(mpms.SaveChanges() > 2, JsonRequestBehavior.AllowGet));
        }
示例#17
0
 //公共获取值
 public MemCards GetMByForm(MemCards m)
 {
     m.S_ID        = (Session["UserInfo"] as Users).S_ID;
     m.MC_CardID   = Request.Form["MC_CardID"];                                             //卡号
     m.MC_Name     = Request.Form["MC_Name"];                                               //姓名
     m.MC_Mobile   = Request.Form["MC_Mobile"];                                             //手机号码
     m.MC_Password = Request.Form["MC_Password"] == "" ? "1" : Request.Form["MC_Password"]; //卡片密码
     if (!string.IsNullOrEmpty(Request.Form["MC_Sex"]))
     {
         m.MC_Sex = Convert.ToBoolean(Request.Form["MC_Sex"]);                                               //会员性别
     }
     if (!string.IsNullOrEmpty(Request.Form["MC_BirthdayType"]))
     {
         m.MC_BirthdayType   = Convert.ToBoolean(Request.Form["MC_BirthdayType"]); //会员生日
         m.MC_Birthday_Month = Convert.ToInt32(Request.Form["MC_Birthday_Month"]); //会员生日-月
         m.MC_Birthday_Day   = Convert.ToInt32(Request.Form["MC_Birthday_Day"]);   //会员生日-日
     }
     if (!string.IsNullOrEmpty(Request.Form["MC_IsPast"]))
     {
         m.MC_IsPast   = Convert.ToBoolean(Request.Form["MC_IsPast"] == "0"?false:true); //是否设置卡片过期时间
         m.MC_PastTime = Convert.ToDateTime(Request.Form["MC_PastTime"]);                //过期时间
     }
     if (!string.IsNullOrEmpty(Request.Form["MC_State"]))
     {
         m.MC_State = Convert.ToInt32(Request.Form["MC_State"]);                                                 //卡片状态
     }
     if (!string.IsNullOrEmpty(Request.Form["MC_Money"]))
     {
         m.MC_Money = float.Parse(Request.Form["MC_Money"]);                                                 //卡片付费
     }
     m.MC_Point = !string.IsNullOrEmpty(Request.Form["MC_Point"]) ? int.Parse(Request.Form["MC_Point"]) : 0; //积分数量
     if (!string.IsNullOrEmpty(Request.Form["MC_IsPointAuto"]))
     {
         m.MC_IsPointAuto = Convert.ToBoolean(Request.Form["MC_IsPointAuto"]);//积分是否可以自动转换成等级
         if (m.MC_IsPointAuto.Value && !string.IsNullOrEmpty(Request.Form["CL_ID"]))
         {
             m.CL_ID = Convert.ToInt32(Request.Form["CL_ID"]);                                                                        //会员等级
         }
     }
     if (!string.IsNullOrEmpty(Request.Form["MC_RefererID"]))
     {
         m.MC_RefererID = int.Parse(Request.Form["MC_RefererID"]);                                                     //推 荐 人
     }
     if (!string.IsNullOrEmpty(Request.Form["MC_RefererName"]))
     {
         m.MC_RefererName = Request.Form["MC_RefererName"];                                                       //推荐人姓名
     }
     return(m);
 }
示例#18
0
        //快速消费 根据卡号查询
        public ActionResult GetInfoByNum()
        {
            var cardNum = Request.QueryString["num"];
            var Mobile  = "";
            var CardID  = "";

            if (cardNum.Length == 11)
            {
                var num = (from i in db.MemCards     //判断手机号是否存在
                           where i.MC_Mobile == cardNum
                           select i).Count();
                if (num > 0)
                {
                    Mobile = cardNum;
                }
                else
                {
                    Mobile = "";
                    return(null);
                }
            }
            else
            {
                var num = (from i in db.MemCards    //判断卡号是否存在
                           where i.MC_CardID == cardNum
                           select i).Count();
                if (num > 0)
                {
                    CardID = cardNum;
                }
                else
                {
                    CardID = "";
                    return(null);
                }
            }
            string        strSql = string.Format(@"select a.CL_LevelName,a.CL_Percent,b.MC_Point,b.MC_ID,b.MC_CardID,b.MC_Name,b.MC_TotalMoney from CardLevels a,MemCards b
                                           where b.MC_CardID='{0}' or b.MC_Mobile='{1}'", CardID, Mobile);
            DataTable     dt     = SqlHelper.GetDataTable(strSql);
            DataRow       dr     = dt.Rows[0];
            CardLevels    cl     = dr.ToModel <CardLevels>();
            MemCards      mc     = dr.ToModel <MemCards>();
            ConsumeOrders co     = dr.ToModel <ConsumeOrders>();

            return(Json(new { CardLevels = cl, MemCards = mc, ConsumeOrders = co }, JsonRequestBehavior.AllowGet));
        }
示例#19
0
        public MemCards GetPwd(string name)
        {
            string sql = "P_SearchPwd";

            SqlParameter[] para =
            {
                new SqlParameter("@MC_Name", name)
            };
            DataTable dt = DBHelper.ExecuteSelect(sql, true, para);
            DataRow   dr = dt.Rows[0];

            Model.MemCards m = new MemCards();
            if (dr["MC_Password"] != DBNull.Value)
            {
                m.MC_Password = (string)dr["MC_Password"];
            }
            return(m);
        }
示例#20
0
        public bool PointCash(ConsumeOrders co, MemCards m)
        {
            string sql = "P_PointCash";

            SqlParameter[] para =
            {
                new SqlParameter("@S_ID",          co.S_ID),
                new SqlParameter("@U_ID",          co.U_ID),
                new SqlParameter("@CO_OrderCode",  co.CO_OrderCode),
                new SqlParameter("@CO_OrderType",  co.CO_OrderType),
                new SqlParameter("@MC_ID",         co.MC_ID),
                new SqlParameter("@MC_CardID",     co.MC_CardID),
                new SqlParameter("@CO_Recash",     co.CO_Recash),
                new SqlParameter("@CO_GavePoint",  co.CO_GavePoint),
                new SqlParameter("@CO_CreateTime", co.CO_CreateTime),
                new SqlParameter("@MC_Point",      m.MC_Point)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
        // 查询会员卡号是否重复
        public ActionResult QueryVipCardNumber(int MC_ID, string cardNumber)
        {
            if (MC_ID == 0)
            {//添加
                if (mpms.MemCards.FirstOrDefault(x => x.MC_CardID == cardNumber) != null)
                {
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            //修改
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == MC_ID);

            if (cardNumber != mc.MC_CardID && mpms.MemCards.FirstOrDefault(x => x.MC_ID != MC_ID && x.MC_CardID == cardNumber) != null)
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
示例#22
0
        public JsonResult GetMemCardInfo()
        {
            int           i  = 0;
            StringBuilder sb = new StringBuilder("select * from MemCards left join CardLevels on MemCards.CL_ID = CardLevels.CL_ID  where S_ID =" + (Session["UserInfo"] as Users).S_ID + " ");

            if (!string.IsNullOrEmpty(Request.Form["mID"]))
            {
                sb.AppendFormat(" AND MC_CardID like '%{0}%'", Request.Form["mID"].Trim()); i++;
            }
            if (!string.IsNullOrEmpty(Request.Form["mName"]))
            {
                sb.AppendFormat(" AND MC_Name like '%{0}%'", Request.Form["mName"].Trim()); i++;
            }
            if (!string.IsNullOrEmpty(Request.Form["mMobile"]))
            {
                sb.AppendFormat(" AND MC_Mobile like '%{0}%'", Request.Form["mMobile"].Trim()); i++;
            }
            if (!string.IsNullOrEmpty(Request.Form["cID"]))
            {
                sb.AppendFormat(" AND CL_ID = {0}", Request.Form["cID"].Trim()); i++;
            }
            if (!string.IsNullOrEmpty(Request.Form["mState"]))
            {
                sb.AppendFormat(" AND MC_State = {0}", Request.Form["mState"].Trim()); i++;
            }
            if (i == 0)
            {
                sb = new StringBuilder("select * from MemCards left join CardLevels on MemCards.CL_ID = CardLevels.CL_ID  where S_ID =" + (Session["UserInfo"] as Users).S_ID + " AND MC_State = 1");
            }
            DataTable     dt = SqlHelper.GetDataTable(sb.ToString());
            List <object> ml = new List <object>();

            foreach (DataRow dr in dt.Rows)
            {
                MemCards   m = dr.ToModel <MemCards>();
                CardLevels c = dr.ToModel <CardLevels>();
                ml.Add(new { m = m, c = c });
            }
            int pageSize  = int.Parse(Request.Form["rows"] == "NaN" ? "1": Request.Form["rows"]);
            int pageIndex = int.Parse(Request.Form["page"] == "NaN" ? "1" : Request.Form["page"]);

            return(Json(new { total = ml.Count, rows = ml.Skip(--pageIndex * pageSize).Take(pageSize) }, JsonRequestBehavior.AllowGet));
        }
示例#23
0
        //添加礼品记录
        public ActionResult Index(string ExchangLogs)
        {
            ViewBag.err = -1;
            try
            {
                Users u  = Session["UserInfo"] as Users;
                int   id = u.S_ID.Value;
                JavaScriptSerializer jss  = new JavaScriptSerializer();
                List <ExchangLogs>   list = jss.Deserialize <List <ExchangLogs> >(ExchangLogs);
                for (int i = 0; i < list.Count; i++)
                {
                    ExchangLogs el = new Models.ExchangLogs();
                    el.S_ID          = id;
                    el.U_ID          = u.U_ID;
                    el.MC_CardID     = list[i].MC_CardID;
                    el.MC_ID         = list[i].MC_ID;
                    el.MC_Name       = list[i].MC_Name;
                    el.EG_GiftName   = list[i].EG_GiftName;
                    el.EL_CreateTime = DateTime.Now;
                    el.EL_Point      = list[i].EL_Point;
                    el.EG_ID         = list[i].EG_ID;
                    el.EG_GiftCode   = list[i].EG_GiftCode;
                    el.EL_Number     = list[i].EL_Number;
                    ExchangGifts ruslt = (from n in db.ExchangGifts
                                          where n.EG_ID == list[i].EG_ID
                                          select n).First();
                    MemCards m = (from n in db.MemCards
                                  where n.MC_CardID == list[i].MC_CardID
                                  select n).First();
                    m.MC_Point          = m.MC_Point - list[i].EL_Point;
                    ruslt.EG_ExchangNum = (ruslt.EG_ExchangNum + list[i].EL_Number.Value);
                    db.ExchangLogs.InsertOnSubmit(el);
                }

                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                ViewBag.err = "错误消息" + ex.Message;
            }
            return(View());
        }
示例#24
0
        //判断会员是否存在 存在则返回实体
        public ActionResult GetMenInfo()
        {
            //var re = ("/^1[34578][0-9]{9}$/");
            string        MidOrTel = Request.QueryString["mort"].Trim();
            StringBuilder sb       = new StringBuilder("select c.CL_Point,c.CL_LevelName,c.CL_Percent,m.* from MemCards m join CardLevels c on c.CL_ID=m.CL_ID where 1=1");

            sb.Append(string.Format(MidOrTel.ToString().Length == 11 ? " and MC_Mobile='{0}'" : " and MC_CardID='{0}'", Request.QueryString["mort"].Trim()));

            DataTable dt = SqlHelper.GetDataTable(sb.ToString());

            if (dt != null && dt.Rows.Count > 0)
            {
                Session["CriD"] = dt;
                DataRow    dr = dt.Rows[0];
                MemCards   m  = dr.ToModel <MemCards>();
                CardLevels c  = dr.ToModel <CardLevels>();
                return(Json(new { MemCards = m, CardLevels = c }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { msg = "不存在" }, JsonRequestBehavior.AllowGet));
        }
示例#25
0
        public bool FastConsume(ConsumeOrders co, MemCards m)
        {
            string sql = "P_FastConsume";

            SqlParameter[] para =
            {
                new SqlParameter("@S_ID",             co.S_ID),
                new SqlParameter("@U_ID",             co.U_ID),
                new SqlParameter("@CO_OrderCode",     co.CO_OrderCode),
                new SqlParameter("@CO_OrderType",     co.CO_OrderType),
                new SqlParameter("@MC_ID",            co.MC_ID),
                new SqlParameter("@MC_CardID",        co.MC_CardID),
                new SqlParameter("@CO_TotalMoney",    co.CO_TotalMoney),
                new SqlParameter("@CO_DiscountMoney", co.CO_DiscountMoney),
                new SqlParameter("@CO_GavePoint",     co.CO_GavePoint),
                new SqlParameter("@CO_CreateTime",    co.CO_CreateTime),
                new SqlParameter("@MC_Point",         m.MC_Point),
                new SqlParameter("@MC_TotalCount",    m.MC_TotalCount)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
示例#26
0
 public void MemCardReplaceCard()
 {
     try
     {
         MemCards m = (from i in db.MemCards where i.MC_ID == int.Parse(Request.Form["MC_ID"]) select i).First();
         m.MC_CardID   = Request.Form["newMcCard"];
         m.MC_Password = Request.Form["newPWD"];
     }
     catch (Exception ex)
     {
         Response.Write("异常:传值错误。详细:" + ex.Message);
     }
     try
     {
         db.SubmitChanges();
         Response.Write("换卡成功!");
     }
     catch (Exception ex)
     {
         Response.Write("异常:提交错误。详细:" + ex.Message);
     }
 }
示例#27
0
        public void Edit(int id)
        {
            MemCards m = (from i in db.MemCards where i.MC_ID == id select i).First();

            try
            {
                m = GetMByForm(m);
            }
            catch (Exception ex)
            {
                Response.Write("您的输入有误,请检索,错误消息:" + ex.Message);
            }
            try
            {
                db.SubmitChanges();
                Response.Write("编辑会员成功!");
            }
            catch (Exception ex)
            {
                Response.Write("编辑会员有误,请检索,错误消息:" + ex.Message);
            }
        }
示例#28
0
        public bool PointExchange(ExchangLogs el, MemCards m, Model.ExchangGifts eg)
        {
            string sql = "P_PointExchange";

            SqlParameter[] para =
            {
                new SqlParameter("@S_ID",          el.S_ID),
                new SqlParameter("@U_ID",          el.U_ID),
                new SqlParameter("@MC_ID",         el.MC_ID),
                new SqlParameter("@MC_CardID",     el.MC_CardID),
                new SqlParameter("@MC_Name",       el.MC_Name),
                new SqlParameter("@EG_ID",         el.EG_ID),
                new SqlParameter("@EG_GiftCode",   el.EG_GiftCode),
                new SqlParameter("@EG_GiftName",   el.EG_GiftName),
                new SqlParameter("@EL_Number",     el.EL_Number),
                new SqlParameter("@EL_Point",      el.EL_Point),
                new SqlParameter("@EL_CreateTime", el.EL_CreateTime),
                new SqlParameter("@MC_Point",      m.MC_Point),
                new SqlParameter("@EG_Number",     eg.EG_Number),
                new SqlParameter("@EG_ExchangNum", eg.EG_ExchangNum)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
示例#29
0
        public JsonResult GetStatisticInfo(int id)
        {
            StringBuilder sb = new StringBuilder(string.Format("select * from ConsumeOrders, MemCards where ConsumeOrders.MC_ID = MemCards.MC_ID AND ConsumeOrders.S_ID = {0}", (Session["UserInfo"] as Users).S_ID));

            if (!string.IsNullOrEmpty(Request.Form["CO_OrderType"]))
            {
                sb.Append("AND CO_OrderType = " + Request.Form["CO_OrderType"].Trim());
            }
            else
            {
                sb.Append(id == -1 ? "" : "AND CO_OrderType = " + id + "");
            }
            if (!string.IsNullOrEmpty(Request.Form["CO_OrderCode"]))
            {
                sb.AppendFormat(" AND CO_OrderCode like '%{0}%'", Request.Form["CO_OrderCode"].Trim());
            }
            if (!string.IsNullOrEmpty(Request.Form["MC_CardID"]))
            {
                string id1 = Request.Form["MC_CardID"].Trim();
                if (id1.ToString().Trim().Length == 11)//手机号
                {
                    id1 = (from i1 in db.MemCards where i1.MC_Mobile == id1.Trim() select i1).First().MC_CardID.ToString().Trim();
                }
                sb.AppendFormat(" AND MemCards.MC_CardID like '%{0}%'", id1);
            }
            if (!string.IsNullOrEmpty(Request.Form["cID"]))
            {
                sb.AppendFormat(" AND CL_ID = {0}", Request.Form["cID"].Trim());
            }
            if (!string.IsNullOrEmpty(Request.Form["CO_DiscountMoney"]) && !string.IsNullOrEmpty(Request.Form["ysf"]))
            {
                sb.AppendFormat(" AND CO_DiscountMoney {1} '{0}'", Request.Form["CO_DiscountMoney"].Trim(), Request.Form["ysf"].Trim());
            }
            else if (!string.IsNullOrEmpty(Request.Form["CO_GavePoint"]) && !string.IsNullOrEmpty(Request.Form["ysf"]))
            {
                sb.AppendFormat(" AND CO_GavePoint {1} '{0}'", Request.Form["CO_GavePoint"].Trim(), Request.Form["ysf"].Trim());
            }
            else if (!string.IsNullOrEmpty(Request.Form["CO_Recash"]) && !string.IsNullOrEmpty(Request.Form["ysf"]))
            {
                sb.AppendFormat(" AND CO_Recash {1} '{0}'", Request.Form["CO_Recash"].Trim(), Request.Form["ysf"].Trim());
            }
            if (!string.IsNullOrEmpty(Request.Form["BTime"]) && !string.IsNullOrEmpty(Request.Form["ETime"]))
            {
                sb.AppendFormat(" AND CO_CreateTime >= '{0}' AND  CO_CreateTime <= '{1}'", Request.Form["BTime"].Trim(), Request.Form["ETime"].Trim());
            }
            else if (!string.IsNullOrEmpty(Request.Form["BTime"]))
            {
                sb.AppendFormat(" AND CO_CreateTime >= '{0}'", Request.Form["BTime"].Trim());
            }
            else if (!string.IsNullOrEmpty(Request.Form["ETime"]))
            {
                sb.AppendFormat(" AND CO_CreateTime <= '{0}'", Request.Form["ETime"].Trim());
            }
            DataTable     dt = SqlHelper.GetDataTable(sb.ToString());
            List <object> ml = new List <object>();

            foreach (DataRow dr in dt.Rows)
            {
                ConsumeOrders c = dr.ToModel <ConsumeOrders>();
                MemCards      m = dr.ToModel <MemCards>();
                ml.Add(new { m = m, c = c, CI_Name = (from i in db.CategoryItems where i.C_Category == "CO_OrderType" && i.CI_ID == c.CO_OrderType select i).First().CI_Name });
            }
            int pageSize  = int.Parse(Request.Form["rows"] == "NaN" ? "1" : Request.Form["rows"]);
            int pageIndex = int.Parse(Request.Form["page"] == "NaN" ? "1" : Request.Form["page"]);

            return(Json(new { total = ml.Count, rows = ml.Skip(--pageIndex * pageSize).Take(pageSize).ToList() }, JsonRequestBehavior.AllowGet));
        }
示例#30
0
        //消费历史记录
        public ActionResult GetInfoByNumOrders()
        {
            var cardNum = Request.Form["num"];
            var Mobile  = "";
            var CardID  = "";
            //分页
            int pageSize = 2, pageIndex = 0;

            if (Request.Form["rows"] != null)  //每页显示的几条数据
            {
                pageSize = int.Parse(Request.Form["rows"]);
            }
            if (Request.Form["page"].Trim() != null)   //当前页面是第几页
            {
                pageIndex = int.Parse(Request.Form["page"]);
            }
            int skip = (pageIndex - 1) * pageSize;  //需要去除的数据,即当前页面要显示的数据

            if (cardNum == null)
            {
                return(null);
            }
            else
            {
                if (cardNum.Length == 11)
                {
                    var num = (from i in db.MemCards     //判断手机号是否存在
                               where i.MC_Mobile == cardNum
                               select i).Count();
                    if (num > 0)
                    {
                        Mobile = cardNum;
                    }
                    else
                    {
                        Mobile = "";
                        return(null);
                    }
                }
                else
                {
                    var num = (from i in db.MemCards    //判断卡号是否存在
                               where i.MC_CardID == cardNum
                               select i).Count();
                    if (num > 0)
                    {
                        CardID = cardNum;
                    }
                    else
                    {
                        CardID = "";
                        return(null);
                    }
                }
            }

            string    strSql = string.Format(@"select a.CL_LevelName,a.CL_Percent,b.MC_Point,b.MC_ID,b.MC_CardID,b.MC_Name,b.MC_TotalMoney,c.* from CardLevels a,MemCards b,ConsumeOrders c
                                           where b.MC_CardID='{0}' or b.MC_Mobile='{1}'", CardID, Mobile);
            DataTable dt     = SqlHelper.GetDataTable(strSql);

            if (dt != null && dt.Rows.Count > 0)          //表数据不为空
            {
                List <Object> list = new List <Object>(); //申明泛型集合
                foreach (DataRow dr in dt.Rows)           //遍历
                {
                    CardLevels    cl = dr.ToModel <CardLevels>();
                    MemCards      mc = dr.ToModel <MemCards>();
                    ConsumeOrders co = dr.ToModel <ConsumeOrders>();
                    list.Add(new { CardLevels = cl, MemCards = mc, ConsumeOrders = co });
                }
                var result = list.Skip(skip).Take(pageSize).ToList();
                return(Json(new { total = list.Count(), rows = result }, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }