示例#1
0
 public ActionResult CardState(MemCards mc)
 {
     try
     {
         MemCardsBLL bll = new MemCardsBLL();
         bll.Edit(mc, "MC_State");
         bll.SaveChanges();
         return Json(new { result = "ok" });
     }
     catch
     {
         return Json(new { result = "error" });
     }
 }
示例#2
0
 /// <summary>
 /// 创建新的 MemCards 对象。
 /// </summary>
 /// <param name="mC_ID">MC_ID 属性的初始值。</param>
 /// <param name="mC_CardID">MC_CardID 属性的初始值。</param>
 public static MemCards CreateMemCards(global::System.Int32 mC_ID, global::System.String mC_CardID)
 {
     MemCards memCards = new MemCards();
     memCards.MC_ID = mC_ID;
     memCards.MC_CardID = mC_CardID;
     return memCards;
 }
示例#3
0
        public ActionResult Create(MemCards mc)
        {
            try
            {
                MemCardsBLL bll = new MemCardsBLL();
                MemCards refererMc = new MemCards();
                Users user = Session["user"] as Users;

                mc.S_ID = user.S_ID;
                mc.MC_Password = mc.MC_Password ?? "123456";
                mc.MC_IsPast = Request.Form["MC_IsPast"] == "on" ? true : false;
                mc.MC_IsPointAuto = Request.Form["MC_IsPointAuto"] == "on" ? true : false;
                //积分兑换等级
                if (mc.MC_IsPointAuto == true)
                {
                    var level = bll.MenCardLevel(mc);
                    mc.CL_ID = level.CL_ID;
                }
                if (mc.MC_RefererName != null)
                {
                    mc.MC_RefererID = bll.GetExchange(mc.MC_RefererCard).MC_ID;
                    //被推荐人增加积分
                    mc.MC_Point = mc.MC_Point + 100;
                    //推荐人增加积分
                    refererMc.MC_Point = bll.GetExchange(mc.MC_RefererCard).MC_Point + 100;
                    refererMc.MC_ID = bll.GetExchange(mc.MC_RefererCard).MC_ID;
                    bll.Edit(refererMc, "MC_Point");
                }
                mc.MC_TotalCount = 0;
                mc.MC_TotalMoney = 0;
                mc.MC_CreateTime = DateTime.Now;

                bll.Add(mc);
                bll.SaveChanges();
                return Json(new { result = "ok" });
            }
            catch
            {
                return Json(new { result = "error" });
            }
        }
示例#4
0
 public ActionResult UpExcel()
 {
     HttpPostedFileBase upfile = Request.Files[0];
     if (upfile.ContentLength > 0)
     {
         string fileName = Path.GetFileName(upfile.FileName);
         string fileExt = Path.GetExtension(fileName);
         if (fileExt.Equals(".xls") || fileExt.Equals(".xlsx"))
         {
             string path = Request.MapPath("/Filters/" + fileName);
             upfile.SaveAs(path);
             using (FileStream file = System.IO.File.OpenRead(path))
             {
                 try
                 {
                     // 根据文件名后缀加载IWorkbook
                     IWorkbook workbook = fileExt == ".xls" ? new HSSFWorkbook(file)
                         : workbook = new XSSFWorkbook(file);
                     ISheet sheet = workbook.GetSheetAt(0);
                     List<MemCards> mcList = new List<MemCards>();
                     for (int i = sheet.FirstRowNum + 1; i <= sheet.LastRowNum; i++)
                     {
                         IRow row = sheet.GetRow(i);
                         MemCards mc = new MemCards();
                         mc.MC_CardID = row.Cells[0].ToString();
                         mc.MC_Name = row.Cells[1].ToString();
                         mc.MC_Sex = row.Cells[2].ToString() == "男" ? 1 : 0;
                         mc.MC_Mobile = row.Cells[3].ToString();
                         mc.MC_Point = (int)row.Cells[4].NumericCellValue;
                         mc.MC_TotalMoney = (float)row.Cells[5].NumericCellValue;
                         mc.MC_TotalCount = (int)row.Cells[6].NumericCellValue;
                         int state = 1;
                         if (row.Cells[7].ToString() == "挂失") state = 2;
                         else if (row.Cells[7].ToString() == "锁定") state = 3;
                         mc.MC_State = state;
                         mc.CL_ID = (int)row.Cells[8].NumericCellValue;
                         mc.MC_CreateTime = Convert.ToDateTime(row.Cells[9].ToString());
                         mc.S_ID = (Session["user"] as Users).S_ID;
                         mc.MC_Password = "******";
                         mcList.Add(mc);
                     }
                     MemCardsBLL bll = new MemCardsBLL();
                     foreach (MemCards mc in mcList)
                     {
                         bll.Add(mc);
                     }
                     bll.SaveChanges();
                     return Content("ok");
                 }
                 catch
                 {
                     return Content("error");
                 }
             }
         } return Content("no");
     }
     return Content("none");
 }
示例#5
0
        public ActionResult Transfer(string TL_FromMC_CardID, string TL_ToMC_CardID, int TL_TransferMoney, string TL_Remark)
        {
            MemCardsBLL mcBll = new MemCardsBLL();
            TransferLogsBLL tfBll = new TransferLogsBLL();
            TransferLogs tf = new TransferLogs();
            MemCards mcTo = new MemCards();
            MemCards mcFrom = new MemCards();
            try
            {
                MemCards uTo = mcBll.GetExchange(TL_ToMC_CardID);
                MemCards uFrom = mcBll.GetExchange(TL_FromMC_CardID);
                Users user = Session["user"] as Users;

                using (TransactionScope ts = new TransactionScope())
                {
                    //修改转出卡号信息
                    mcTo.MC_ID = uFrom.MC_ID;
                    mcTo.MC_Point = uFrom.MC_Point - TL_TransferMoney;

                    //修改转入卡号信息
                    mcFrom.MC_ID = uTo.MC_ID;
                    mcFrom.MC_Point = uTo.MC_Point + TL_TransferMoney;

                    mcBll.Edit(mcFrom, "MC_Point");
                    mcBll.Edit(mcTo, "MC_Point");
                    mcBll.SaveChanges();

                    //转账信息表添加数据
                    tf.S_ID = user.S_ID;
                    tf.U_ID = user.U_ID;
                    tf.TL_FromMC_ID = mcBll.SelectWhere(m => m.MC_CardID == TL_FromMC_CardID).Select(m => m.MC_ID).FirstOrDefault();
                    tf.TL_FromMC_CardID = TL_FromMC_CardID;
                    tf.TL_ToMC_ID = mcBll.SelectWhere(m => m.MC_CardID == TL_ToMC_CardID).Select(m => m.MC_ID).FirstOrDefault();
                    tf.TL_ToMC_CardID = TL_ToMC_CardID;
                    tf.TL_TransferMoney = TL_TransferMoney;
                    tf.TL_Remark = TL_Remark;
                    tf.TL_CreateTime = DateTime.Now;
                    tfBll.Add(tf);
                    tfBll.SaveChanges();
                    ts.Complete();
                }
                return Json(new { result = "ok" });
            }
            catch
            {
                return Json(new { result = "error" });
            }
        }
示例#6
0
 public ActionResult ExchangeCard(int MC_ID, string MC_Password, string MC_CardID)
 {
     MemCardsBLL fromMc = new MemCardsBLL();
     //判断卡号和密码是否正确
     if (fromMc.IsTruePwd(MC_ID, MC_Password))
     {
         try
         {
             MemCardsBLL bll = new MemCardsBLL();
             MemCards toMc = new MemCards();
             toMc.MC_ID = MC_ID;
             toMc.MC_Password = toMc.MC_Password ?? "1";
             toMc.MC_CardID = MC_CardID;
             bll.Edit(toMc, "MC_CardID", "MC_Password");
             bll.SaveChanges();
             return Json(new { result = "ok" });
         }
         catch
         {
             return Json(new { result = "error" });
         }
     }
     return Json(new { result = "no" });
 }
示例#7
0
 public ActionResult Edit(MemCards mc)
 {
     try
     {
         MemCardsBLL bll = new MemCardsBLL();
         mc.MC_Password = mc.MC_Password ?? Request.Form["PWD"];
         mc.MC_IsPast = Request.Form["MC_IsPast"] == "on" ? true : false;
         bll.Edit(mc, "CL_ID", "MC_Password", "MC_Name", "MC_Sex", "MC_Mobile", "MC_Photo", "MC_Birthday_Month", "MC_Birthday_Day", "MC_BirthdayType", "MC_IsPast", "MC_PastTime", "MC_Money", "MC_State");
         bll.SaveChanges();
         return Json(new { result = "ok" });
     }
     catch
     {
         return Json(new { result = "error" });
     }
 }
示例#8
0
 /// <summary>
 /// 删除会员信息
 /// </summary>
 public ActionResult Delete(int id)
 {
     try
     {
         MemCardsBLL bll = new MemCardsBLL();
         MemCards mc = new MemCards();
         mc.MC_ID = id;
         mc.MC_State = 4;
         bll.Edit(mc, "MC_State");
         bll.SaveChanges();
         return Json(new { result = "ok" }, JsonRequestBehavior.AllowGet);
     }
     catch
     {
         return Json(new { result = "error" }, JsonRequestBehavior.AllowGet);
     }
 }