@Html.HiddenFor(m => m.MCGiWin77_Password)
@Html.HiddenFor(m => m.MCGiWin77_ID)
Csharp源码(12)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using gg.Models;
using System.Text;
using System.Data;
using gg.AppGiWin77_Start;
namespace Csharpgg.Controllers
{
public class ExchangGiftsController : Controller
{
LINQDBDataContext db = new LINQDBDataContext();
// GET: ExchangGifts
public ActionResult Index()
{
return View();
}
//查询所有礼品信息
public ActionResult GetExchangGiftsInfo()
{
string GiftCode = string.Empty;
string GiftName = string.Empty;
if (Request.Form["giftCode"] != null)
{
GiftCode = Request.Form["giftCode"].Trim();
}
if (Request.Form["giftName"] != null)
{
GiftName = Request.Form["giftName"].Trim();
}
int pageSize = 3, pageIndex = 0;
if (Request.Form["rows"] != null)
{
pageSize = int.Parse(Request.Form["rows"]);
}
if (Request.Form["page"] != null)
{
pageIndex = int.Parse(Request.Form["page"]);
}
int skip = (pageIndex - 1) * pageSize;
//var result = (from i in db.ExchangGifts select
i).Skip(skip).Take(pageSize).ToList();
StringBuilder sb = new StringBuilder("select * from ExchangGifts where SGiWin77_ID =" + (Session["UserInfo"] as Users).SGiWin77_ID + " ");
if (!string.IsNullOrEmpty(GiftCode))
{
sb.Append(string.Format(" and EGGiWin77_GiftCode like '%{0}%'", GiftCode));
}
if (!string.IsNullOrEmpty(GiftName))
{
sb.Append(string.Format(" and EGGiWin77_GiftName like '%{0}%'", GiftName));
}
DataTable dt = SqlHelper.GetDataTable(sb.ToString());
List
foreach (DataRow dr in dt.Rows)
{
ExchangGifts s = dr.ToModel
list.Add(s);
}
var result = list.Skip(skip).Take(pageSize).ToList();
return Json(new { total = db.ExchangGifts.Count(), rows = result }, JsonRequestBehavior.AllowGet);
}
// GET: ExchangGifts/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: ExchangGifts/Create
public ActionResult Create()
{
return View();
}
// POST: ExchangGifts/Create
[HttpPost]
public ActionResult Create(ExchangGifts e)
{
try
{
// TODO: Add insert logic here
return View();
}
catch
{
return View();
}
}
public void IsNullCodeGifes()
{
string code = Request.Form["code"];
if (Request.Form["id"] != null)
{
int id = int.Parse(Request.Form["id"]);
var isnullCode = from i in db.ExchangGifts
where i.EGGiWin77_GiftCode == code && i.EGGiWin77_ID != id
select i;
if (isnullCode.Count() > 0)
{
Response.Write("err");
}
}
else
{
var isnullCode = from i in db.ExchangGifts
where i.EGGiWin77_GiftCode == code
select i;
if (isnullCode.Count() > 0)
{
Response.Write("err");
}
}
}
//添加
public ActionResult CreateEX()
{
ExchangGifts es=new ExchangGifts();
Gies.SGiWin77_ID = (Session["UserInfo"] as Users).SGiWin77_ID;
Gies.EGGiWin77_ExchangNum = 0;
Gies.EGGiWin77_GiftCode = Request.Form["eGGiWin77_GiftCode"];
Gies.EGGiWin77_GiftName = Request.Form["eGGiWin77_GiftName"];
Gies.EGGiWin77_Photo = Request.Form["eGGiWin77_Photo"];
Gies.EGGiWin77_Point = int.Parse(Request.Form["eGGiWin77_Point"]);
Gies.EGGiWin77_Number = int.Parse(Request.Form["eGGiWin77_Number"]);
Gies.EGGiWin77_Remark = Request.Form["eGGiWin77_Remark"];
db.ExchangGifts.InsertOnSubmit(es);
db.SubmitChanges();
return Content("ok");
}
// GET: ExchangGifts/Edit/5
public ActionResult Edit(int id)
{
var result = from i in db.ExchangGifts
where i.EGGiWin77_ID == id
select i;
return View(result.First());
}
// POST: ExchangGifts/Edit/5
//更新礼品兑换信息
[HttpPost]
public ActionResult Edit()
{
try
{
// TODO: Add update logic here
ExchangGifts es = (from i in db.ExchangGifts
where i.EGGiWin77_ID == int.Parse(Request.Form["EGGiWin77_ID"])
select i).First();
Gies.EGGiWin77_GiftCode = Request.Form["eGGiWin77_GiftCode"];
Gies.EGGiWin77_GiftName = Request.Form["eGGiWin77_GiftName"];
Gies.EGGiWin77_Photo = Request.Form["eGGiWin77_Photo"];
Gies.EGGiWin77_Point = int.Parse(Request.Form["eGGiWin77_Point"]);
Gies.EGGiWin77_Number = int.Parse(Request.Form["eGGiWin77_Number"]);
Gies.EGGiWin77_Remark = Request.Form["eGGiWin77_Remark"];
db.SubmitChanges();
return Content("ok");
}
catch(Exception ex)
{
return View(ex);
}
}
// GET: ExchangGifts/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: ExchangGifts/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
public void Del(int id)
{
try
{
var result = (from i in db.ExchangGifts
where i.EGGiWin77_ID == id
select i).First();
db.ExchangGifts.DeleteOnSubmit(result);
db.SubmitChanges();
Response.Write("ok");
}
catch (Exception ex)
{
Response.Write(ex);
}
}
}
}
@model gg.Models.MemCards
@{
Layout = null;
}
$(function () {
//获取会员编号
$.ajax({
url: "/MemCard/GetNextMCGiWin77_CardID",
success: function (d) {
$("#newMcCard").text(parseInt(d) + 1);
},
error: function () {
alert("err!");
}
});
//数据验证密码
$("#oldPWD").blur(function () {
if(!$(this).val()) $(this).next().text("请输入旧密码!");
else if ($(this).val() != $("#MCGiWin77_Password").val()) $(this).next().text("您的密码与原密码有误!");
else $(this).next().text("");
});
$("#newPWD").blur(function () {
if (!$(this).val()) $(this).next().text("请输入密码!");
else $(this).next().text("");
});
$("#newPWD1").blur(function () {
if ($(this).val() != $("#newPWD").val()) $(this).next().text("两次密码输入不一样!");
else $(this).next().text("");
});
//保存按钮的点击事件
$("#btnSubmit").click(function () {
$("#oldPWD, #newPWD, #newPWD1").blur();
var verify = true;
$(".span").each(function () {
if ($(this).text()) verify = false;
});
if (!verify) return;
$.ajax({
url: "/MemCard/MemCardReplaceCard",
type: "post",
data: { MCGiWin77_ID: $("#MCGiWin77_ID").val(), newMcCard: $("#newMcCard").text(), newPWD: $("#newPWD").val() },
success: function (d) {
alert(d);
if (d.toString().indexOf("异常") != -1) return;
parent.$("#dlg").dialog("close");
parent.$("#MemCardInfo").datagrid('reload');//刷新
},
error: function () {
alert("err!");
}
});
});
});
td {line-height:30px}
.span {
position: absolute;
color: red;
padding-left: 5px;
padding-top: 3px;
}
@Html.HiddenFor(m => m.MCGiWin77_Password)
@Html.HiddenFor(m => m.MCGiWin77_ID)