private void AjaxAction(string action) { string[] strArray; OneyuanTaoInfo oneyuanTaoInfoById; string s = "{\"state\":false,\"msg\":\"未定义操作\"}"; NameValueCollection form = base.Request.Form; string str2 = ""; switch (action) { case "Del": s = "{\"state\":false,\"msg\":\"活动信息未找到失败\"}"; str2 = form["Aid"]; if (!string.IsNullOrEmpty(str2) && (OneyuanTaoHelp.GetOneyuanTaoInfoById(str2) != null)) { if (!OneyuanTaoHelp.DeleteOneyuanTao(str2)) { s = "{\"state\":false,\"msg\":\"该活动已有人参与,不能删除!\"}"; break; } s = "{\"state\":true,\"msg\":\"删除成功\"}"; OneyuanTaoHelp.DelParticipantMember(str2, true); } break; case "BatchDel": s = "{\"state\":false,\"msg\":\"批量删除失败\"}"; str2 = form["Aids"]; if (!string.IsNullOrEmpty(str2)) { strArray = str2.Split(new char[] { ',' }); int num = OneyuanTaoHelp.BatchDeleteOneyuanTao(strArray); if (num <= 0) { s = "{\"state\":false,\"msg\":\"没有找到可删除的数据!\"}"; break; } string[] strArray2 = new string[] { "{\"state\":true,\"msg\":\"成功删除", num.ToString(), "条数据,失败", (strArray.Length - num).ToString(), "条!\"}" }; s = string.Concat(strArray2); foreach (string str3 in strArray) { OneyuanTaoHelp.DelParticipantMember(str3, true); } } break; case "EndII": { s = "{\"state\":false,\"msg\":\"结束失败\"}"; str2 = form["Aid"]; string str4 = form["CanDraw"]; if (!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str4)) { if (str4.Trim() == "1") { s = "{\"state\":false,\"msg\":\"开奖错误\"}"; string str5 = OneyuanTaoHelp.CalculateWinner(str2); if (str5 == "success") { s = "{\"state\":true,\"msg\":\"手动开奖成功!\"}"; } else { s = "{\"state\":false,\"msg\":\"" + str5 + "\"}"; } } else { s = "{\"state\":false,\"msg\":\"退款错误\"}"; if (OneyuanTaoHelp.SetOneyuanTaoIsOn(str2, false)) { s = "{\"state\":true,\"msg\":\"提前终止活动成功!!\"}"; OneyuanTaoHelp.DelParticipantMember(str2, true); } else { s = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; } } break; } s = "{\"state\":false,\"msg\":\"参数错误\"}"; break; } case "End": s = "{\"state\":false,\"msg\":\"结束失败\"}"; str2 = form["Aid"]; if (!string.IsNullOrEmpty(str2)) { oneyuanTaoInfoById = OneyuanTaoHelp.GetOneyuanTaoInfoById(str2); if (oneyuanTaoInfoById != null) { if (this.getOneTaoState(oneyuanTaoInfoById) != OneTaoState.进行中) { s = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; break; } if (!OneyuanTaoHelp.SetOneyuanTaoIsOn(str2, false)) { s = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; break; } s = "{\"state\":true,\"msg\":\"提前终止活动成功!!\"}"; OneyuanTaoHelp.DelParticipantMember(str2, true); } } break; case "Start": s = "{\"state\":false,\"msg\":\"操作开始失败\"}"; str2 = form["Aid"]; if (!string.IsNullOrEmpty(str2)) { oneyuanTaoInfoById = OneyuanTaoHelp.GetOneyuanTaoInfoById(str2); if (oneyuanTaoInfoById != null) { if (this.getOneTaoState(oneyuanTaoInfoById) != OneTaoState.未开始) { s = "{\"state\":false,\"msg\":\"当前状态开启活动!\"}"; break; } if (!OneyuanTaoHelp.SetOneyuanTaoIsOn(str2, true)) { s = "{\"state\":false,\"msg\":\"当前状态不能结束!\"}"; break; } s = "{\"state\":true,\"msg\":\"提前开启活动成功!!\"}"; } } break; case "BatchStart": s = "{\"state\":false,\"msg\":\"批量操作开始失败\"}"; str2 = form["Aids"]; if (!string.IsNullOrEmpty(str2)) { strArray = str2.Split(new char[] { ',' }); int num2 = OneyuanTaoHelp.BatchSetOneyuanTaoIsOn(strArray, true); if (num2 <= 0) { s = "{\"state\":false,\"msg\":\"没有找到可开启的活动数据!\"}"; break; } string[] strArray4 = new string[] { "{\"state\":true,\"msg\":\"成功开启", num2.ToString(), "条活动,失败", (strArray.Length - num2).ToString(), "条!\"}" }; s = string.Concat(strArray4); } break; } base.Response.ClearContent(); base.Response.ContentType = "application/json"; base.Response.Write(s); base.Response.End(); }
void AjaxAction(string action) { string rs = "{\"state\":false,\"msg\":\"未定义操作\"}"; NameValueCollection Form = Request.Form; string Aid = ""; string[] Aids; OneyuanTaoInfo selitem; OneTaoState rowState; switch (action) { case "Del": rs = "{\"state\":false,\"msg\":\"活动信息未找到失败\"}"; Aid = Form["Aid"]; if (!string.IsNullOrEmpty(Aid)) { selitem = OneyuanTaoHelp.GetOneyuanTaoInfoById(Aid); if (selitem != null) { if (OneyuanTaoHelp.DeleteOneyuanTao(Aid)) { rs = "{\"state\":true,\"msg\":\"删除成功\"}"; OneyuanTaoHelp.DelParticipantMember(Aid); //清除未支付的用户信息 } else { rs = "{\"state\":false,\"msg\":\"该活动已有人参与,不能删除!\"}"; } } } break; case "BatchDel": rs = "{\"state\":false,\"msg\":\"批量删除失败\"}"; Aid = Form["Aids"]; if (!string.IsNullOrEmpty(Aid)) { Aids = Aid.Split(','); int delnum = OneyuanTaoHelp.BatchDeleteOneyuanTao(Aids); if (delnum > 0) { rs = "{\"state\":true,\"msg\":\"成功删除" + delnum.ToString() + "条数据,失败" + (Aids.Length - delnum).ToString() + "条!\"}"; foreach (string tAid in Aids) { OneyuanTaoHelp.DelParticipantMember(tAid); //清除未支付的用户信息 } } else { rs = "{\"state\":false,\"msg\":\"没有找到可删除的数据!\"}"; } } break; case "EndII": //有参与人数的情况下,提前终结活动 rs = "{\"state\":false,\"msg\":\"结束失败\"}"; Aid = Form["Aid"]; string CanDraw = Form["CanDraw"]; if (string.IsNullOrEmpty(Aid) || string.IsNullOrEmpty(CanDraw)) { rs = "{\"state\":false,\"msg\":\"参数错误\"}"; } else { if (CanDraw.Trim() == "1") { rs = "{\"state\":false,\"msg\":\"开奖错误\"}"; string DrawRs = OneyuanTaoHelp.CalculateWinner(Aid); if (DrawRs == "success") { rs = "{\"state\":true,\"msg\":\"手动开奖成功!\"}"; } else { rs = "{\"state\":false,\"msg\":\"" + DrawRs + "\"}"; } } else { rs = "{\"state\":false,\"msg\":\"退款错误\"}"; if (OneyuanTaoHelp.SetOneyuanTaoIsOn(Aid, false)) { rs = "{\"state\":true,\"msg\":\"提前终止活动成功!!\"}"; //提前终止,表示活动失败 OneyuanTaoHelp.DelParticipantMember(Aid); //清除未支付的用户信息 //没有人参与时 } else { rs = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; } } } break; case "End": //无参与人员的情况下,结束活动 rs = "{\"state\":false,\"msg\":\"结束失败\"}"; Aid = Form["Aid"]; if (!string.IsNullOrEmpty(Aid)) { selitem = OneyuanTaoHelp.GetOneyuanTaoInfoById(Aid); if (selitem != null) { rowState = getOneTaoState(selitem); if (rowState == OneTaoState.进行中) { //关闭活动,自动结束 if (OneyuanTaoHelp.SetOneyuanTaoIsOn(Aid, false)) { rs = "{\"state\":true,\"msg\":\"提前终止活动成功!!\"}"; //提前终止,表示活动失败 OneyuanTaoHelp.DelParticipantMember(Aid); //清除未支付的用户信息 //没有人参与时 } else { rs = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; } } else { rs = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; } } } break; case "Start": rs = "{\"state\":false,\"msg\":\"操作开始失败\"}"; Aid = Form["Aid"]; if (!string.IsNullOrEmpty(Aid)) { selitem = OneyuanTaoHelp.GetOneyuanTaoInfoById(Aid); if (selitem != null) { rowState = getOneTaoState(selitem); if (rowState == OneTaoState.未开始) { //开启活动,如果时间没到,重设活动开始时间为当前时间 if (OneyuanTaoHelp.SetOneyuanTaoIsOn(Aid, true)) { rs = "{\"state\":true,\"msg\":\"提前开启活动成功!!\"}"; //提前终止,表示活动失败 //进行活动终止的相关处理 } else { rs = "{\"state\":false,\"msg\":\"当前状态不能结束!\"}"; } } else { rs = "{\"state\":false,\"msg\":\"当前状态开启活动!\"}"; } } } break; case "BatchStart": rs = "{\"state\":false,\"msg\":\"批量操作开始失败\"}"; Aid = Form["Aids"]; if (!string.IsNullOrEmpty(Aid)) { Aids = Aid.Split(','); int Startnum = OneyuanTaoHelp.BatchSetOneyuanTaoIsOn(Aids, true); if (Startnum > 0) { rs = "{\"state\":true,\"msg\":\"成功开启" + Startnum.ToString() + "条活动,失败" + (Aids.Length - Startnum).ToString() + "条!\"}"; } else { rs = "{\"state\":false,\"msg\":\"没有找到可开启的活动数据!\"}"; } } break; default: break; } Response.ClearContent(); Response.ContentType = "application/json"; Response.Write(rs); Response.End(); }
private void AjaxAction(string action) { string s = "{\"state\":false,\"msg\":\"未定义操作\"}"; System.Collections.Specialized.NameValueCollection form = base.Request.Form; switch (action) { case "Del": { s = "{\"state\":false,\"msg\":\"活动信息未找到失败\"}"; string text = form["Aid"]; if (!string.IsNullOrEmpty(text)) { OneyuanTaoInfo oneyuanTaoInfoById = OneyuanTaoHelp.GetOneyuanTaoInfoById(text); if (oneyuanTaoInfoById != null) { if (OneyuanTaoHelp.DeleteOneyuanTao(text)) { s = "{\"state\":true,\"msg\":\"删除成功\"}"; OneyuanTaoHelp.DelParticipantMember(text, true); } else { s = "{\"state\":false,\"msg\":\"该活动已有人参与,不能删除!\"}"; } } } break; } case "BatchDel": { s = "{\"state\":false,\"msg\":\"批量删除失败\"}"; string text = form["Aids"]; if (!string.IsNullOrEmpty(text)) { string[] array = text.Split(new char[] { ',' }); int num2 = OneyuanTaoHelp.BatchDeleteOneyuanTao(array); if (num2 > 0) { s = string.Concat(new string[] { "{\"state\":true,\"msg\":\"成功删除", num2.ToString(), "条数据,失败", (array.Length - num2).ToString(), "条!\"}" }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string activityId = array2[i]; OneyuanTaoHelp.DelParticipantMember(activityId, true); } } else { s = "{\"state\":false,\"msg\":\"没有找到可删除的数据!\"}"; } } break; } case "EndII": { string text = form["Aid"]; string text2 = form["CanDraw"]; if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2)) { s = "{\"state\":false,\"msg\":\"参数错误\"}"; } else if (text2.Trim() == "1") { string text3 = OneyuanTaoHelp.CalculateWinner(text); if (text3 == "success") { s = "{\"state\":true,\"msg\":\"手动开奖成功!\"}"; } else { s = "{\"state\":false,\"msg\":\"" + text3 + "\"}"; } } else if (OneyuanTaoHelp.SetOneyuanTaoIsOn(text, false)) { s = "{\"state\":true,\"msg\":\"提前终止活动成功!!\"}"; OneyuanTaoHelp.DelParticipantMember(text, true); } else { s = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; } break; } case "End": { s = "{\"state\":false,\"msg\":\"结束失败\"}"; string text = form["Aid"]; if (!string.IsNullOrEmpty(text)) { OneyuanTaoInfo oneyuanTaoInfoById = OneyuanTaoHelp.GetOneyuanTaoInfoById(text); if (oneyuanTaoInfoById != null) { OneTaoState oneTaoState = this.getOneTaoState(oneyuanTaoInfoById); if (oneTaoState == OneTaoState.进行中) { if (OneyuanTaoHelp.SetOneyuanTaoIsOn(text, false)) { s = "{\"state\":true,\"msg\":\"提前终止活动成功!!\"}"; OneyuanTaoHelp.DelParticipantMember(text, true); } else { s = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; } } else { s = "{\"state\":false,\"msg\":\"提前终止活动失败!\"}"; } } } break; } case "Start": { s = "{\"state\":false,\"msg\":\"操作开始失败\"}"; string text = form["Aid"]; if (!string.IsNullOrEmpty(text)) { OneyuanTaoInfo oneyuanTaoInfoById = OneyuanTaoHelp.GetOneyuanTaoInfoById(text); if (oneyuanTaoInfoById != null) { if (this.getOneTaoState(oneyuanTaoInfoById) == OneTaoState.未开始) { if (OneyuanTaoHelp.SetOneyuanTaoIsOn(text, true)) { s = "{\"state\":true,\"msg\":\"提前开启活动成功!!\"}"; } else { s = "{\"state\":false,\"msg\":\"当前状态不能结束!\"}"; } } else { s = "{\"state\":false,\"msg\":\"当前状态开启活动!\"}"; } } } break; } case "BatchStart": { s = "{\"state\":false,\"msg\":\"批量操作开始失败\"}"; string text = form["Aids"]; if (!string.IsNullOrEmpty(text)) { string[] array = text.Split(new char[] { ',' }); int num3 = OneyuanTaoHelp.BatchSetOneyuanTaoIsOn(array, true); if (num3 > 0) { s = string.Concat(new string[] { "{\"state\":true,\"msg\":\"成功开启", num3.ToString(), "条活动,失败", (array.Length - num3).ToString(), "条!\"}" }); } else { s = "{\"state\":false,\"msg\":\"没有找到可开启的活动数据!\"}"; } } break; } } base.Response.ClearContent(); base.Response.ContentType = "application/json"; base.Response.Write(s); base.Response.End(); }