示例#1
0
        /// <summary>
        /// 获取待充值人员工号,姓名
        /// </summary>
        /// <returns></returns>
        public static List <recharge> GetStaffNo(int ID)
        {
            List <recharge>       rechargeList = new List <recharge>();
            List <MySqlParameter> parameter    = new List <MySqlParameter>();
            StringBuilder         sql          = new StringBuilder("select StaffNo,StaffName from staffs where State = 0 and ID = @id ");

            parameter.Add(new MySqlParameter
            {
                ParameterName = "@id",
                MySqlDbType   = MySqlDbType.Int32,
                Value         = ID
            });

            MySqlDataReader dr = MySQLHelper.ExecuteReader(CommandType.Text, sql.ToString(), parameter.ToArray());

            while (dr.Read())
            {
                recharge newrecharge = new recharge();
                newrecharge.StaffNo   = Convert.ToString(dr["StaffNo"]);
                newrecharge.StaffName = Convert.ToString(dr["StaffName"]);

                rechargeList.Add(newrecharge);
            }
            dr.Close();
            return(rechargeList);
        }
示例#2
0
 public ActionResult Recharge(recharge card)
 {
     //充值代码
     using (LazyfitnessEntities db = new LazyfitnessEntities())
     {
         recharge searchCard = db.recharge.Where(c => c.rechargeId == card.rechargeId).FirstOrDefault();
         if (searchCard == null)
         {
             Tools.AlertAndRedirect("卡号或卡密错误", Url.Action("Recharge", "Home"));
             return(View());
         }
         if (searchCard.rechargePwd != card.rechargePwd)
         {
             Tools.AlertAndRedirect("卡号或卡密错误", Url.Action("Recharge", "Home"));
             return(View());
         }
         if (searchCard.isAvailable == 0)
         {
             Tools.AlertAndRedirect("该卡已被使用", Url.Action("Recharge", "Home"));
             return(View());
         }
         int      userId = Int32.Parse(ViewBag.UserId);
         userInfo user   = db.userInfo.Where(u => u.userId == userId).FirstOrDefault();
         user.userAccount      += searchCard.amount;
         searchCard.isAvailable = 0;
         ViewBag.UserInfo       = user;
         db.SaveChanges();
     }
     Tools.AlertAndRedirect("充值成功", Url.Action("Recharge", "Home"));
     return(View());
 }
示例#3
0
 /// <summary>
 /// 充值卡表增加数据
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public static Boolean insertRecharge(recharge info)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             db.recharge.Add(info);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
示例#4
0
 /// <summary>
 /// 查询充值卡表
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <returns></returns>
 public static recharge[] selectRecharge(Expression <Func <recharge, bool> > whereLambda)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <recharge> dataObject = db.recharge.Where(whereLambda) as DbQuery <recharge>;
             recharge[]         infoList   = dataObject.ToArray();
             return(infoList);
         }
     }
     catch
     {
         recharge[] nullInfo = new recharge[0];
         return(nullInfo);
     }
 }
 /// <summary>
 /// 往充值卡表修改数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static Boolean updateRecharge(Expression <Func <recharge, bool> > whereLambda, recharge info)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <recharge> dataObject = db.recharge.Where(whereLambda) as DbQuery <recharge>;
             recharge           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.rechargePwd = info.rechargePwd;
             oldInfo.amount      = info.amount;
             oldInfo.isAvailable = info.isAvailable;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public ActionResult addCard(recharge recharge)
 {
     try
     {
         if (toolsHelpers.selectToolsController.selectRecharge(u => u.rechargeId == recharge.rechargeId).Length != 0)
         {
             return(Content("已存在此序列号充值卡!"));
         }
         if (toolsHelpers.insertToolsController.insertRecharge(recharge) == true)
         {
             Response.Redirect("/backStage/payManagement/Index");
             return(Content("success"));
         }
         return(Content("增加失败"));
     }
     catch
     {
         return(Content("增加出错"));
     }
 }
 public ActionResult changeCardInfo(recharge recharge)
 {
     try
     {
         //获取对应充值卡信息
         recharge[] info = toolsHelpers.selectToolsController.selectRecharge(u => u.rechargeId == recharge.rechargeId);
         if (info == null || info.Length == 0)
         {
             return(Content("没有此充值卡!"));
         }
         if (toolsHelpers.updateToolsController.updateRecharge(u => u.rechargeId == recharge.rechargeId, recharge) == true)
         {
             Response.Redirect("/backStage/payManagement/Index");
             return(Content("success"));
         }
         return(Content("修改失败!"));
     }
     catch
     {
         return(Content("修改充值卡信息出错!"));
     }
 }
示例#8
0
        /// <summary>
        /// 获取充值信息记录
        /// </summary>
        /// <returns></returns>
        public static List <recharge> GetRecharge(string StaffNo, string startRechargeMoney, string endRechargeMoney, string startRechargeDatetime, string endRechargeDatetime)
        {
            List <recharge> rechargeList = new List <recharge>();
            StringBuilder   sql          = new StringBuilder("select rechargetable.ID,rechargetable.StaffNo,staffs.StaffName,rechargetable.RechargeMoney,rechargetable.RechargeDatetime,rechargetable.Remark,rechargetable.CreateStaffNo ");

            sql.Append("from rechargetable inner join staffs on rechargetable.StaffNo = staffs.StaffNo ");
            sql.Append("where rechargetable.State = 0 and staffs.State=0;");
            List <MySqlParameter> parameter = new List <MySqlParameter>();

            if (!string.IsNullOrEmpty(StaffNo))
            {
                sql.Append(" and StaffNo = @staffno ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@staffno",
                    MySqlDbType   = MySqlDbType.VarChar,
                    Value         = string.Format("{0}", StaffNo.Trim())
                });
            }
            if (!string.IsNullOrEmpty(startRechargeMoney))
            {
                decimal dt = Convert.ToDecimal(startRechargeMoney);
                sql.Append(" and RechargeMoney >= @startrechargemoney ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@startrechargemoney",
                    MySqlDbType   = MySqlDbType.Decimal,
                    Value         = dt
                });
            }
            if (!string.IsNullOrEmpty(endRechargeMoney))
            {
                decimal dt = Convert.ToDecimal(endRechargeMoney);
                sql.Append(" and RechargeMoney <= @endrechargemoney ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@endrechargemoney",
                    MySqlDbType   = MySqlDbType.Decimal,
                    Value         = dt
                });
            }
            if (!string.IsNullOrEmpty(startRechargeDatetime))
            {
                DateTime dt = Convert.ToDateTime(startRechargeDatetime);
                sql.Append(" and RechargeDatetime >= @startrechargedatetime ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@startrechargedatetime",
                    MySqlDbType   = MySqlDbType.DateTime,
                    Value         = dt
                });
            }
            if (!string.IsNullOrEmpty(endRechargeDatetime))
            {
                DateTime dt = Convert.ToDateTime(endRechargeDatetime);
                sql.Append(" and RechargeDatetime <= @endrechargedatetime ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@endrechargedatetime",
                    MySqlDbType   = MySqlDbType.DateTime,
                    Value         = dt
                });
            }
            MySqlDataReader dr = MySQLHelper.ExecuteReader(CommandType.Text, sql.ToString(), parameter.ToArray());


            while (dr.Read())
            {
                recharge newrecharge = new recharge();
                newrecharge.ID               = Convert.ToInt32(dr["ID"]);
                newrecharge.StaffNo          = Convert.ToString(dr["StaffNo"]);
                newrecharge.StaffName        = Convert.ToString(dr["StaffName"]);
                newrecharge.RechargeMoney    = Convert.ToDecimal(dr["RechargeMoney"]);
                newrecharge.RechargeDatetime = Convert.ToDateTime(dr["RechargeDatetime"]);
                newrecharge.Remark           = Convert.ToString(dr["Remark"]);
                newrecharge.CreateStaffNo    = Convert.ToString(dr["CreateStaffNo"]);

                rechargeList.Add(newrecharge);
            }
            dr.Close();
            return(rechargeList);
        }