\n";
str += mbbs.B_Body + "\n";
str += "
\n";
}
mbbs.B_Layer = 1;
mbbs.B_FatherId = ID;
mbbs.B_MemberId = MemberId;
mbbs.B_IP = Mtxfw.Utility.Common.GetIP;
mbbs.B_LastMemberId = MemberId;
mbbs.B_TPDA_LinkID = 0;
mbbs.B_TP_StarDate = DateTime.Now;
mbbs.B_TP_EndDate = DateTime.Now;
mbbs.B_Url = "";
mbbs.B_Pic = "";
mbbs.B_Body = strBody;
mbbs.B_seef = 1;
mbbs.B_IFReBack = 0;
mbbs.B_IFLogin = 0;
mbbs.B_IFShow = 0;
daobbs.Add(mbbs);
daobbs.Update0(MemberId, ID);
daoUser.UpdateuLevel0("ReArticleNum", 1, mbbs.B_MemberId);
daoUser.UpdateuLevel0("ArticleJF", 2, mbbs.B_MemberId);
daoUser.UpdateuLevel0("ArticleMoney", 1, mbbs.B_MemberId);
if (context.Session["UploadFileIng"] != null)
{
string[] stra = context.Session["UploadFileIng"].ToString().Split(',');
foreach (string str in stra)
{
if (str.Trim() != "")
{
if (mbbs.B_Body.IndexOf(str.Trim()) == -1)
{
if (System.IO.File.Exists(context.Server.MapPath(str.Trim())))
{
System.IO.File.Delete(context.Server.MapPath(str.Trim()));
}
}
}
}
}
context.Session.Remove("UploadFileIng");
System.Collections.IDictionaryEnumerator CacheEnum = context.Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
context.Cache.Remove(CacheEnum.Key.ToString());
}
context.Response.Write("回复成功");
}
}
else
{
context.Response.Write("参数错误2");
}
}
else
{
context.Response.Write("新注册用户注册时间在24小时内不允许发贴");
}
}
}
}
else
{
context.Response.Write("您未登录,不能回复");
}
}
else
{
context.Response.Write("参数错误");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //设置贴子-----------------------------------------------------------------------------------------
//设置贴子
protected void SetBBS(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["t"]) && !String.IsNullOrEmpty(context.Request.Form["v"]) && !String.IsNullOrEmpty(context.Request.Form["ID"]))
{
if (context.Session["MemberId"] != null)
{
if (context.Session["MemberId"].ToString() != "")
{
int MemberId = Convert.ToInt32(context.Session["MemberId"].ToString());
Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info();
Mtxfw.DAL.bbs daobbs = new Mtxfw.DAL.bbs();
Mtxfw.DAL.forum daoforum = new Mtxfw.DAL.forum();
Mtxfw.Model.user_info umodel = daoUser.GetModel(MemberId);
if (umodel != null)
{
if (Mtxfw.Utility.Common.DateDiff(DateTime.Now, umodel.RegTime) > 0)
{
Int32 t = Convert.ToInt32(context.Request.Form["t"].ToString());
Int32 v = Convert.ToInt32(context.Request.Form["v"].ToString());
Int64 ID = Convert.ToInt64(context.Request.Form["ID"].ToString());
Mtxfw.Model.bbs mbbs = daobbs.GetModel(ID);
if (mbbs != null)
{
bool b = true;
if (mbbs.B_seef == 0)
{
b = false;
context.Response.Write("此贴未审核");
}
if (t != 3 && mbbs.B_Lock == 1)
{
b = false;
context.Response.Write("此贴已被锁定");
}
if (mbbs.B_IFDelete == 1)
{
b = false;
context.Response.Write("此贴已被删除");
}
if (!daoforum.IsForumManager(mbbs.B_MemberId, umodel.UserName))
{
b = false;
context.Response.Write("您的权限不足");
}
if (t < 0 || t > 4)
{
b = false;
context.Response.Write("参数错误3");
}
if (v < 0 || v > 1)
{
b = false;
context.Response.Write("参数错误4");
}
if (mbbs.B_Layer == 1 && t != 3 && t != 4)
{
b = false;
context.Response.Write("此贴不允许设置");
}
if (b)
{
string Sel = "";
int SelValue = 0;
if (v == 0)
{
SelValue = 1;
}
else
{
SelValue = 0;
}
if (t == 0)
{
Sel = "B_SetTop";
}
if (t == 1)
{
Sel = "B_IFTJ";
}
if (t == 2)
{
Sel = "B_IFHot";
}
if (t == 3)
{
Sel = "B_Lock";
}
if (t == 4)
{
Sel = "B_IFDelete";
}
daobbs.Update(Sel, SelValue, ID);
System.Collections.IDictionaryEnumerator CacheEnum = context.Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
context.Cache.Remove(CacheEnum.Key.ToString());
}
if (t == 4)
{
context.Response.Write("删除成功");
}
else
{
context.Response.Write("设置成功");
}
}
}
else
{
context.Response.Write("参数错误2");
}
}
else
{
context.Response.Write("新注册用户注册时间在24小时内不允许发贴");
}
}
}
}
else
{
context.Response.Write("您未登录,不能回复");
}
}
else
{
context.Response.Write("参数错误");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //发送验证码-----------------------------------------------------------------------------------------
protected void SendYZM(HttpContext context)
{
if (context.Session["MemberId"] != null)
{
int MemberId = Convert.ToInt32(context.Session["MemberId"]);
Mtxfw.Model.user_info model = new DAL.user_info().GetModel(MemberId);
if (System.Text.RegularExpressions.Regex.IsMatch(model.Phone, @"^[1]+[3,4,5,8]+\d{9}"))
{
DateTime dt1 = DateTime.Now;
DateTime dt2 = model.PhoneTime.AddMinutes(2);
if (DateTime.Compare(dt2, dt1) <= 0)
{
bool bt = false;
if (model.PhoneTime.ToString() != "")
{
dt2 = model.PhoneTime.AddDays(1);
if (DateTime.Compare(dt2, dt1) > 0)
{
bt = true;
}
}
if (model.PhoneCount < 5 || (model.PhoneCount >= 5 && !bt))
{
string strYZM = RandNum(4);
new DAL.user_info().UpdatePhoneTime(strYZM, DateTime.Now, MemberId);
string strconent = "您好!您的手机验证码为" + strYZM + ",此验证码24小时内有效,请及时验证!";
strconent += "【一心科技网】";
try
{
Mtxfw.Utility.Common.sendsms(model.Phone, strconent);
context.Response.Write("0");
}
catch
{
context.Response.Write("发送验证码出现错误!");
}
}
else context.Response.Write("您已经发送超过5次了,请明天再试吧!");
}
else context.Response.Write("请您在2分钟后再操作!");
}
else
{
context.Response.Write("手机号码格式填写不正确!");
}
}
else
{
context.Response.Write("您未登录!");
}
}
protected void SendYZM2(HttpContext context)
{
if (context.Session["MemberId"] != null)
{
int MemberId = Convert.ToInt32(context.Session["MemberId"]);
Mtxfw.Model.user_info model = new DAL.user_info().GetModel(MemberId);
if (model.IFPhone == 1)
{
if (System.Text.RegularExpressions.Regex.IsMatch(model.EditPhone, @"^[1]+[3,4,5,8]+\d{9}"))
{
DateTime dt1 = DateTime.Now;
DateTime dt2 = model.PhoneTime.AddMinutes(2);
if (DateTime.Compare(dt2, dt1) <= 0)
{
bool bt = false;
if (model.PhoneTime.ToString() != "")
{
dt2 = model.PhoneTime.AddDays(1);
if (DateTime.Compare(dt2, dt1) > 0)
{
bt = true;
}
}
if (model.PhoneCount < 5 || (model.PhoneCount >= 5 && !bt))
{
string strYZM = RandNum(4);
new DAL.user_info().UpdatePhoneTime0(strYZM, DateTime.Now, MemberId);
string strconent = "您好!您的手机验证码为" + strYZM + ",此验证码24小时内有效,请及时验证!";
strconent += "【一心科技网】";
try
{
Mtxfw.Utility.Common.sendsms(model.EditPhone, strconent);
context.Response.Write("0");
}
catch
{
context.Response.Write("发送验证码出现错误!");
}
}
else context.Response.Write("您已经发送超过5次了,请明天再试吧!");
}
else context.Response.Write("请您在2分钟后再操作!");
}
else
{
context.Response.Write("手机号码格式填写不正确!");
}
}
else
{
context.Response.Write("请先验证您的旧手机号码!");
}
}
else
{
context.Response.Write("您未登录!");
}
}
protected void SendYZM3(HttpContext context)
{
if (!String.IsNullOrEmpty(context.Request.Form["UserName"]) && !String.IsNullOrEmpty(context.Request.Form["Phone"]))
{
string UserName = HttpUtility.UrlDecode(context.Request.Form["UserName"]).ToString();
string Phone = HttpUtility.UrlDecode(context.Request.Form["Phone"]).ToString();
Mtxfw.Model.user_info model = new DAL.user_info().GetModel(UserName, Phone);
if (model != null)
{
if (System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[1]+[3,4,5,8]+\d{9}"))
{
DateTime dt1 = DateTime.Now;
DateTime dt2 = model.PhoneTime.AddMinutes(2);
if (DateTime.Compare(dt2, dt1) <= 0)
{
bool bt = false;
if (model.PhoneTime.ToString() != "")
{
dt2 = model.PhoneTime.AddDays(1);
if (DateTime.Compare(dt2, dt1) > 0)
{
bt = true;
}
}
if (model.PhoneCount < 5 || (model.PhoneCount >= 5 && !bt))
{
string strYZM = RandNum(4);
new DAL.user_info().UpdatePhoneTime0(strYZM, DateTime.Now, model.Id);
string strconent = "您好!您的手机验证码为" + strYZM + ",此验证码24小时内有效,请及时验证!";
strconent += "【一心科技网】";
try
{
Mtxfw.Utility.Common.sendsms(model.Phone, strconent);
context.Response.Write("0");
}
catch
{
context.Response.Write("发送验证码出现错误!");
}
}
else context.Response.Write("您已经发送超过5次了,请明天再试吧!");
}
else context.Response.Write("请您在2分钟后再操作!");
}
else
{
context.Response.Write("手机号码格式填写不正确!");
}
}
else
{
context.Response.Write("参数错误2!");
}
}
else
{
context.Response.Write("参数错误!");
}
}
///
/// 生成指定位数的随机数
///
///
参数是随机数的位数
///
返回一个随机数字符串
private string RandNum(int VcodeNum)
{
string Vchar = "2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
string[] VcArray = Vchar.Split(','); //拆分成数组
string VNum = "";
int temp = -1; //记录上次随机数值,尽量避避免生产几个一样的随机数
Random rand = new Random();
//采用一个简单的算法以保证生成随机数的不同
for (int i = 0; i < VcodeNum; i++)
{
if (temp != -1)
{
rand = new Random(i * temp * unchecked((int)DateTime.Now.Ticks));
}
int t = rand.Next(VcArray.Length - 1);
if (temp != -1 && temp == t)
{
return RandNum(VcodeNum);
}
temp = t;
VNum += VcArray[t];
}
return VNum;
}
#endregion
#region //删除图片-----------------------------------------------------------------------------------------
//删除图片
protected void DeletePic(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["pic"]))
{
if (context.Session["MemberIdMemberId"] != null || context.Session["MemberId"] != null)
{
if (context.Session["jiaoyouPhoto"] != null)
{
string pic = HttpUtility.UrlDecode(context.Request.Form["pic"].ToString());
context.Session["jiaoyouPhoto"] = context.Session["jiaoyouPhoto"].ToString().Replace(pic + "|", "");
if (File.Exists(context.Server.MapPath("/image/" + pic.Split(',')[0])))
{
File.Delete(context.Server.MapPath("/image/" + pic.Split(',')[0]));
}
context.Response.Write("删除成功");
}
else
{
context.Response.Write("超时退出,不能删除");
}
}
else
{
context.Response.Write("您未登录,不能删除");
}
}
else
{
context.Response.Write("参数错误");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //设置图片为封面-----------------------------------------------------------------------------------------
//设置图片为封面
protected void SetPic(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["pic"]))
{
if (context.Session["MemberIdMemberId"] != null || context.Session["MemberId"] != null)
{
if (context.Session["jiaoyouPhoto"] != null)
{
string pic = HttpUtility.UrlDecode(context.Request.Form["pic"].ToString());
context.Session["jiaoyouPhoto"] = pic + "|" + context.Session["jiaoyouPhoto"].ToString().Replace(pic + "|", "");
string imgurl = "";
string[] strjiaoyouPhotoA = context.Session["jiaoyouPhoto"].ToString().Split('|');
string stryanseoption = "";
if (context.Request.Form["yanse"] != "")
{
string stryanse = HttpUtility.UrlDecode(context.Request.Form["yanse"].ToString());
string[] Ayanse = stryanse.Split('|');
for (int i = 0; i < Ayanse.Length; i++)
{
if (Ayanse[i] != "")
{
string[] stra = Ayanse[i].Split('#');
stryanseoption += "
";
}
}
}
for (int i = 0; i < strjiaoyouPhotoA.Length; i++)
{
if (strjiaoyouPhotoA[i] != "")
{
string[] strPhoto = strjiaoyouPhotoA[i].Split(',');
imgurl += "
删除";
if (i == 0)
{
imgurl += " 已设为封面";
}
else
{
imgurl += " 设为封面";
}
if (stryanseoption != "")
{
string stryanseoption2 = stryanseoption;
if (strPhoto.Length == 2)
{
if (strPhoto[1] != "")
{
stryanseoption2 = stryanseoption.Replace("value='" + strPhoto[1] + "'", "value='" + strPhoto[1] + "' selected");
}
}
imgurl += "
";
}
imgurl += "";
}
}
context.Response.Write(imgurl);
}
else
{
context.Response.Write("发生错误1");
}
}
else
{
context.Response.Write("您未登录");
}
}
else
{
context.Response.Write("参数错误");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //保存图片-----------------------------------------------------------------------------------------
//保存图片
protected void SavePic(HttpContext context)
{
try
{
if (context.Request.Form["sels"] !=null && !String.IsNullOrEmpty(context.Request.Form["ID"]))
{
if (context.Session["MemberIdMemberId"] != null || context.Session["MemberId"] != null)
{
if (context.Session["jiaoyouPhoto"] != null)
{
string sels = HttpUtility.UrlDecode(context.Request.Form["sels"].ToString());
string[] asels = sels.Split('|');
string[] strjiaoyouPhotoA = context.Session["jiaoyouPhoto"].ToString().Split('|');
int UpdateID = Convert.ToInt32(context.Request.Form["ID"].ToString());
Mtxfw.Model.P_Product model = new Mtxfw.DAL.P_Product().GetModel(UpdateID);
if (model != null)
{
string strPhotos = "";
for (int i = 0; i < strjiaoyouPhotoA.Length; i++)
{
if (strjiaoyouPhotoA[i] != "")
{
string[] strPhoto = strjiaoyouPhotoA[i].Split(',');
if (sels != "")
{
try
{
strPhotos += strPhoto[0] + "," + asels[i] + "|";
}
catch
{
strPhotos += strPhoto[0] + "|";
}
}
else
{
strPhotos += strPhoto[0] + "|";
}
}
model.P_images = strPhotos;
new Mtxfw.DAL.P_Product().Update(model);
}
context.Response.Write("保存成功");
}
else
{
context.Response.Write("发生错误2");
}
}
else
{
context.Response.Write("发生错误1");
}
}
else
{
context.Response.Write("您未登录");
}
}
else
{
context.Response.Write("参数错误");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //保存配送地址-----------------------------------------------------------------------------------------
//保存配送地址
protected void saveaddress(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["name"]))
{
if (!String.IsNullOrEmpty(context.Request.Form["phone"]))
{
if (!String.IsNullOrEmpty(context.Request.Form["province"]))
{
if (!String.IsNullOrEmpty(context.Request.Form["city"]))
{
if (!String.IsNullOrEmpty(context.Request.Form["address"]))
{
string strname = HttpUtility.UrlDecode(context.Request.Form["name"].ToString()).Trim();
string strphone = HttpUtility.UrlDecode(context.Request.Form["phone"].ToString()).Trim();
string strprovince = HttpUtility.UrlDecode(context.Request.Form["province"].ToString()).Trim();
string strcity = HttpUtility.UrlDecode(context.Request.Form["city"].ToString()).Trim();
string straddress = HttpUtility.UrlDecode(context.Request.Form["address"].ToString());
string strcounty = "";
if (context.Request.Form["county"] != null)
{
strcounty = HttpUtility.UrlDecode(context.Request.Form["county"].ToString()).Trim();
}
string strpostalcode = "";
if (context.Request.Form["postalcode"] != null)
{
strpostalcode = HttpUtility.UrlDecode(context.Request.Form["postalcode"].ToString()).Trim();
}
int addressid = 0;
if (!String.IsNullOrEmpty(context.Request.Form["addressid"]))
{
addressid = int.Parse(HttpUtility.UrlDecode(context.Request.Form["addressid"].ToString()).Trim());
}
bool b = true;
if (!String.IsNullOrEmpty(strname))
{
if (!System.Text.RegularExpressions.Regex.IsMatch(strname, @"[\u4e00-\u9fa5]"))
{
b = false;
context.Response.Write("联系人姓名填写不正确,只能输入中文!");
}
}
if (b)
{
if (context.Session["MemberId"] != null && context.Session["MemberName"] != null)
{
int MemberId = int.Parse(context.Session["MemberId"].ToString());
if (MemberId > 0)
{
if (addressid > 0)
{
Model.user_address model = new DAL.user_address().GetModel(addressid);
if (model != null)
{
model.Contactname = strname;
model.Contacttel = strphone;
model.Province = strprovince;
model.City = strcity;
model.County = strcounty;
model.Address = straddress;
model.Zipcode = strpostalcode;
new DAL.user_address().Update(model);
context.Response.Write("true");
}
}
else
{
if (new DAL.user_address().GetCount("UserID=" + MemberId) < 5)
{
Model.user_address model = new Model.user_address();
model.Contactname = strname;
model.Contacttel = strphone;
model.Province = strprovince;
model.City = strcity;
model.County = strcounty;
model.Address = straddress;
model.Zipcode = strpostalcode;
model.Guests = "";
model.IFIndex = 0;
model.UserID = MemberId;
new DAL.user_address().Add(model);
Mtxfw.Model.user_info ModelUser = new Mtxfw.DAL.user_info().GetModel(MemberId);
if (ModelUser != null)
{
if (ModelUser.RealName == "")
{
ModelUser.RealName = strname;
}
if (ModelUser.Phone == "")
{
ModelUser.Phone = strphone;
}
if (ModelUser.Province == "")
{
ModelUser.Province = strprovince;
}
if (ModelUser.City == "")
{
ModelUser.City = strcity;
}
if (ModelUser.County == "")
{
ModelUser.County = strcounty;
}
if (ModelUser.MailingAddress == "")
{
ModelUser.MailingAddress = straddress;
}
if (ModelUser.PostalCode == "")
{
ModelUser.PostalCode = strpostalcode;
}
if (ModelUser.RealName == "")
{
new Mtxfw.DAL.user_info().Update(ModelUser);
}
}
context.Response.Write("true");
}
else
{
context.Response.Write("最多只能添加5个地址");
}
}
}
}
else
{
context.Response.Write("您未登录");
}
}
}
else
{
context.Response.Write("参数错误");
}
}
else
{
context.Response.Write("城市必须选择");
}
}
else
{
context.Response.Write("省份必须选择");
}
}
else
{
context.Response.Write("联系电话不能为空");
}
}
else
{
context.Response.Write("联系人不能为空");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //删除配送地址-----------------------------------------------------------------------------------------
//删除配送地址
protected void deladdress(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["addressid"]))
{
int addressid = int.Parse(HttpUtility.UrlDecode(context.Request.Form["addressid"].ToString()).Trim());
if (context.Session["MemberId"] != null && context.Session["MemberName"] != null)
{
int MemberId = int.Parse(context.Session["MemberId"].ToString());
if (MemberId > 0)
{
if (addressid > 0)
{
Model.user_address model = new DAL.user_address().GetModel(addressid);
if (model != null)
{
if (model.UserID == MemberId)
{
new DAL.user_address().Delete(addressid);
context.Response.Write("true");
}
else
{
context.Response.Write("参数有误2");
}
}
else
{
context.Response.Write("参数有误");
}
}
}
}
else
{
context.Response.Write("您未登录");
}
}
else
{
context.Response.Write("联系人不能为空");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //设置配送地址-----------------------------------------------------------------------------------------
//设置配送地址
protected void setaddress(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["addressid"]))
{
int addressid = int.Parse(HttpUtility.UrlDecode(context.Request.Form["addressid"].ToString()).Trim());
if (context.Session["MemberId"] != null && context.Session["MemberName"] != null)
{
int MemberId = int.Parse(context.Session["MemberId"].ToString());
if (MemberId > 0)
{
if (addressid > 0)
{
Model.user_address model = new DAL.user_address().GetModel(addressid);
if (model != null)
{
if (model.UserID == MemberId)
{
new DAL.user_address().UpdateIFIndex(model.Id,model.UserID);
context.Response.Write("true");
}
else
{
context.Response.Write("参数有误2");
}
}
else
{
context.Response.Write("参数有误");
}
}
}
}
else
{
context.Response.Write("您未登录");
}
}
else
{
context.Response.Write("联系人不能为空");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //增加抽奖池金额-----------------------------------------------------------------------------------------
//增加抽奖池金额
protected void addqjje(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["t"]) && !String.IsNullOrEmpty(context.Request.Form["qjje"]))
{
int t = int.Parse(HttpUtility.UrlDecode(context.Request.Form["t"].ToString()));
Double qjje = int.Parse(HttpUtility.UrlDecode(context.Request.Form["qjje"].ToString()));
if (context.Session["MemberIdMemberId"] != null)
{
if (t == 0)
{
new Mtxfw.DAL.user_jjfp().Updatecount("count1", qjje, 5);
}
else
{
new Mtxfw.DAL.user_jjfp().Updatecount("count1", qjje, 6);
}
context.Response.Write("true");
}
else
{
context.Response.Write("您未登录");
}
}
else
{
context.Response.Write("参数不能为空");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //保存中奖金额-----------------------------------------------------------------------------------------
//保存中奖金额
protected void savezjje(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["zjje1"]) && !String.IsNullOrEmpty(context.Request.Form["zjje2"]) && !String.IsNullOrEmpty(context.Request.Form["zjje3"]) && !String.IsNullOrEmpty(context.Request.Form["zjje4"]) && !String.IsNullOrEmpty(context.Request.Form["zjje5"]) && !String.IsNullOrEmpty(context.Request.Form["zjje21"]) && !String.IsNullOrEmpty(context.Request.Form["zjje22"]) && !String.IsNullOrEmpty(context.Request.Form["zjje23"]) && !String.IsNullOrEmpty(context.Request.Form["zjje24"]) && !String.IsNullOrEmpty(context.Request.Form["zjje25"]))
{
Double zjje1 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje1"].ToString()));
Double zjje2 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje2"].ToString()));
Double zjje3 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje3"].ToString()));
Double zjje4 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje4"].ToString()));
Double zjje5 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje5"].ToString()));
Double zjje21 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje21"].ToString()));
Double zjje22 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje22"].ToString()));
Double zjje23 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje23"].ToString()));
Double zjje24 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje24"].ToString()));
Double zjje25 = int.Parse(HttpUtility.UrlDecode(context.Request.Form["zjje25"].ToString()));
if (context.Session["MemberIdMemberId"] != null)
{
new Mtxfw.DAL.user_jjfp().Updatecount0("count2", zjje1, 5);
new Mtxfw.DAL.user_jjfp().Updatecount0("count3", zjje2, 5);
new Mtxfw.DAL.user_jjfp().Updatecount0("count4", zjje3, 5);
new Mtxfw.DAL.user_jjfp().Updatecount0("count5", zjje4, 5);
new Mtxfw.DAL.user_jjfp().Updatecount0("count6", zjje5, 5);
new Mtxfw.DAL.user_jjfp().Updatecount0("count2", zjje21, 6);
new Mtxfw.DAL.user_jjfp().Updatecount0("count3", zjje22, 6);
new Mtxfw.DAL.user_jjfp().Updatecount0("count4", zjje23, 6);
new Mtxfw.DAL.user_jjfp().Updatecount0("count5", zjje24, 6);
new Mtxfw.DAL.user_jjfp().Updatecount0("count6", zjje25, 6);
context.Response.Write("true");
}
else
{
context.Response.Write("您未登录");
}
}
else
{
context.Response.Write("参数不能为空");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //保存抽奖设置-----------------------------------------------------------------------------------------
//保存抽奖设置
protected void savecj(HttpContext context)
{
try
{
if (!String.IsNullOrEmpty(context.Request.Form["vals"]))
{
string[] vals = HttpUtility.UrlDecode(context.Request.Form["vals"].ToString()).Trim().Split('|');
if (context.Session["MemberIdMemberId"] != null)
{
bool b = true;
int t1 = 0;
int t2 = 0;
foreach (string val in vals)
{
if (val != "")
{
string[] ava = val.Split(',');
Model.choujiang model = new DAL.choujiang().GetModel(int.Parse(ava[0]));
if (model != null)
{
if (model.utype == 0)
{
if (Convert.ToInt32(ava[2]) > 10 || Convert.ToInt32(ava[3]) > 10 || Convert.ToInt32(ava[4]) > 10 || Convert.ToInt32(ava[5]) > 10 || Convert.ToInt32(ava[6]) > 10)
{
b = false;
t1 += 1;
}
}
else
{
if (Convert.ToInt32(ava[2]) > 1 || Convert.ToInt32(ava[3]) > 1 || Convert.ToInt32(ava[4]) > 1 || Convert.ToInt32(ava[5]) > 1 || Convert.ToInt32(ava[6]) > 1)
{
b = false;
t2 += 1;
}
}
}
}
}
if (b)
{
foreach (string val in vals)
{
if (val != "")
{
string[] ava = val.Split(',');
Model.choujiang model = new DAL.choujiang().GetModel(int.Parse(ava[0]));
if (model != null)
{
model.xfje = Convert.ToDouble(ava[1]);
model.kzjzs1 = Convert.ToInt32(ava[2]);
model.kzjzs2 = Convert.ToInt32(ava[3]);
model.kzjzs3 = Convert.ToInt32(ava[4]);
model.kzjzs4 = Convert.ToInt32(ava[5]);
model.kzjzs5 = Convert.ToInt32(ava[6]);
new DAL.choujiang().Update(model);
}
}
}
context.Response.Write("true");
}
else
{
if (t1 > 0)
{
context.Response.Write("次数填写错误,不能大于10次");
}
else
{
context.Response.Write("次数填写错误,不能大于1次");
}
}
}
else
{
context.Response.Write("您未登录");
}
}
else
{
context.Response.Write("联系人不能为空");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
#endregion
#region //抽奖-----------------------------------------------------------------------------------------
//抽奖
protected void qoujiang(HttpContext context)
{
try
{
Mtxfw.DAL.user_address daoaddress = new Mtxfw.DAL.user_address();
Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info();
if (context.Session["MemberId"] != null && context.Session["MemberName"] != null)
{
bool bb = false;
DateTime dt = DateTime.Now;
if (dt.Hour >= 23 && dt.Minute >= 30)
{
bb = true;
}
if (bb)
{
context.Response.Write("系统正在结算中,请过了晚上12点再来抽奖^-^");
}
else
{
Mtxfw.DAL.choujiang daocj = new Mtxfw.DAL.choujiang();
Mtxfw.DAL.User_xjcjq daocjq = new Mtxfw.DAL.User_xjcjq();
Mtxfw.DAL.User_zhongjiang daozj = new Mtxfw.DAL.User_zhongjiang();
int MemberId = int.Parse(context.Session["MemberId"].ToString());
Mtxfw.Model.user_info umodel = new DAL.user_info().GetModel(MemberId);
if (umodel != null)
{
int utype = 0;
if (context.Request.Form["t"] != null)
{
utype = int.Parse(context.Request.Form["t"].ToString());
}
if (utype == 0)
{
DataSet ds = daocjq.GetList("top 1 ", "utype=" + utype + " And MemberId=" + MemberId + " And (kqjcs-yqjcs)>0 And Seef=1 And (Select Count(Id) From User_zhongjiang b where b.utype=a.utype and b.MemberId=a.MemberId And b.cjqId=a.id And DateDiff(day,addtime,getdate())=0)=0");
if (ds.Tables[0].Rows.Count > 0)
{
int cjqid = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
int cjId = int.Parse(ds.Tables[0].Rows[0]["cjId"].ToString());
int _cjqcount1 = daozj.GetCount("utype=" + utype + " And MemberId=" + MemberId + " And cjqId=" + cjqid + " And zjdj=1");
int _cjqcount2 = daozj.GetCount("utype=" + utype + " And MemberId=" + MemberId + " And cjqId=" + cjqid + " And zjdj=2");
int _cjqcount3 = daozj.GetCount("utype=" + utype + " And MemberId=" + MemberId + " And cjqId=" + cjqid + " And zjdj=3");
int _cjqcount4 = daozj.GetCount("utype=" + utype + " And MemberId=" + MemberId + " And cjqId=" + cjqid + " And zjdj=4");
int _cjqcount5 = daozj.GetCount("utype=" + utype + " And MemberId=" + MemberId + " And cjqId=" + cjqid + " And zjdj=5");
Model.choujiang cjm = daocj.GetModel(cjId);
if (cjm != null)
{
int cjqcount1 = cjm.kzjzs1 - _cjqcount1;
int cjqcount2 = cjm.kzjzs2 - _cjqcount2;
int cjqcount3 = cjm.kzjzs3 - _cjqcount3;
int cjqcount4 = cjm.kzjzs4 - _cjqcount4;
int cjqcount5 = cjm.kzjzs5 - _cjqcount5;
string Vchar = "";
if (cjqcount1 > 0)
{
if (Vchar == "")
{
Vchar += "1";
}
else
{
Vchar += ",1";
}
}
if (cjqcount2 > 0)
{
if (Vchar == "")
{
Vchar += "2";
}
else
{
Vchar += ",2";
}
}
if (cjqcount3 > 0)
{
if (Vchar == "")
{
Vchar += "3";
}
else
{
Vchar += ",3";
}
}
if (cjqcount4 > 0)
{
if (Vchar == "")
{
Vchar += "4";
}
else
{
Vchar += ",4";
}
}
if (cjqcount5 > 0)
{
if (Vchar == "")
{
Vchar += "5";
}
else
{
Vchar += ",5";
}
}
string strzjhm = RandNum_CJ(1, Vchar);
if (strzjhm == "")
{
strzjhm = "1";
}
int zjhm = int.Parse(strzjhm);
Double zjje = 0, jcje = 0, zjje1 = 0, zjje2 = 0, zjje3 = 0, zjje4 = 0, zjje5 = 0;
System.Data.DataSet Ds = new Mtxfw.DAL.user_jjfp().GetList("", "TType=5");
if (Ds.Tables[0].Rows.Count > 0)
{
jcje = Convert.ToDouble(Ds.Tables[0].Rows[0]["count1"]);
zjje1 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count2"]);
zjje2 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count3"]);
zjje3 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count4"]);
zjje4 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count5"]);
zjje5 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count6"]);
}
Ds.Clear();
if (zjhm == 1)
{
zjje = zjje1;
}
else if (zjhm == 2)
{
zjje = zjje2;
}
else if (zjhm == 3)
{
zjje = zjje3;
}
else if (zjhm == 4)
{
zjje = zjje4;
}
else if (zjhm == 5)
{
zjje = zjje5;
}
if (Convert.ToDouble(jcje.ToString("f2")) > Convert.ToDouble(zjje.ToString("f2")))
{
Model.User_zhongjiang mzj = new Model.User_zhongjiang();
mzj.cjqId = cjqid;
mzj.zjdj = zjhm;
mzj.zjje = zjje;
mzj.addtime = DateTime.Now;
mzj.MemberId = MemberId;
mzj.utype = utype;
daozj.Add(mzj);
Double money = zjje;
Double umoney12 = (umodel.umoney12 - umodel.umoney22);
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = MemberId;
mjl2.MemberId2 = 0;
mjl2.Addmoney = money;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney12 + money;
mjl2.addtime = DateTime.Now;
mjl2.BZContent = "现金抽奖中奖金额";
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 2;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
new DAL.user_Results_jl2().Add(mjl2);
new DAL.user_info().UpdateMoney("umoney12", money, MemberId);
daocjq.Updateyqjcs(1, MemberId, utype, cjqid);
new Mtxfw.DAL.user_jjfp().Updatecount("count1", -zjje, 5);
context.Response.Write("恭喜您抽中" + Mtxfw.Utility.Common.czjhm(zjhm.ToString()) + "等奖,获得了" + zjje + "元|" + zjhm);
}
else
{
context.Response.Write("奖池里的钱已经被抽完了,明天早点来吧,^-^" + zjje);
}
}
else
{
context.Response.Write("抽奖权错误" + cjId);
}
}
else
{
context.Response.Write("您今日的抽奖权已经用完了,明天再来吧,^-^");
}
ds.Clear();
}
else
{
int CJQCount = 0;
string strCJQCount = new DAL.user_info().Getzd("(umoney30-umoney31) as umoney30", "UserState='正常' And ID=" + MemberId).ToString();
if (strCJQCount != "")
{
CJQCount = Convert.ToInt32(strCJQCount.Split('.')[0]);
}
string strxfje = new DAL.choujiang().Getzd("xfje", "utype=" + utype).ToString();
Double xfje = 0;
if (strxfje != "")
{
xfje = Convert.ToDouble(strxfje);
}
int KYCJQCount = int.Parse((CJQCount / xfje).ToString().Split('.')[0].Replace(",", ""));
if (KYCJQCount > 0)
{
if (daozj.GetCount("utype=" + utype + " And MemberId=" + MemberId + " And DateDiff(day,addtime,getdate())=0") == 0)
{
Model.choujiang cjm = daocj.GetModel(5);
if (cjm != null)
{
int cjqcount1 = cjm.kzjzs1;
int cjqcount2 = cjm.kzjzs2;
int cjqcount3 = cjm.kzjzs3;
int cjqcount4 = cjm.kzjzs4;
int cjqcount5 = cjm.kzjzs5;
string Vchar = "";
if (cjqcount1 > 0)
{
if (Vchar == "")
{
Vchar += "1";
}
else
{
Vchar += ",1";
}
}
if (cjqcount2 > 0)
{
if (Vchar == "")
{
Vchar += "2";
}
else
{
Vchar += ",2";
}
}
if (cjqcount3 > 0)
{
if (Vchar == "")
{
Vchar += "3";
}
else
{
Vchar += ",3";
}
}
if (cjqcount4 > 0)
{
if (Vchar == "")
{
Vchar += "4";
}
else
{
Vchar += ",4";
}
}
if (cjqcount5 > 0)
{
if (Vchar == "")
{
Vchar += "5";
}
else
{
Vchar += ",5";
}
}
string strzjhm = RandNum_CJ(1, Vchar);
if (strzjhm == "")
{
strzjhm = "1";
}
int zjhm = int.Parse(strzjhm);
Double zjje = 0, jcje = 0, zjje1 = 0, zjje2 = 0, zjje3 = 0, zjje4 = 0, zjje5 = 0;
System.Data.DataSet Ds = new Mtxfw.DAL.user_jjfp().GetList("", "TType=6");
if (Ds.Tables[0].Rows.Count > 0)
{
jcje = Convert.ToDouble(Ds.Tables[0].Rows[0]["count1"]);
zjje1 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count2"]);
zjje2 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count3"]);
zjje3 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count4"]);
zjje4 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count5"]);
zjje5 = Convert.ToDouble(Ds.Tables[0].Rows[0]["count6"]);
}
Ds.Clear();
if (zjhm == 1)
{
zjje = zjje1;
}
else if (zjhm == 2)
{
zjje = zjje2;
}
else if (zjhm == 3)
{
zjje = zjje3;
}
else if (zjhm == 4)
{
zjje = zjje4;
}
else if (zjhm == 5)
{
zjje = zjje5;
}
if (Convert.ToDouble(jcje.ToString("f2")) > Convert.ToDouble(zjje.ToString("f2")))
{
Model.User_zhongjiang mzj = new Model.User_zhongjiang();
mzj.cjqId = 0;
mzj.zjdj = zjhm;
mzj.zjje = zjje;
mzj.addtime = DateTime.Now;
mzj.MemberId = MemberId;
mzj.utype = utype;
daozj.Add(mzj);
Double money = 10;
Double umoney30 = (umodel.umoney30 - umodel.umoney31);
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = MemberId;
mjl2.MemberId2 = 0;
mjl2.Addmoney = 0;
mjl2.Cutmoney = -money;
mjl2.Totalmoney = umoney30 - money;
mjl2.addtime = DateTime.Now;
mjl2.BZContent = "积分抽奖扣除积分";
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 1;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
new DAL.user_Results_jl2().Add(mjl2);
new DAL.user_info().UpdateMoney("umoney31", 10, MemberId);
umoney30 -= money;
money = zjje;
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = MemberId;
mjl2.MemberId2 = 0;
mjl2.Addmoney = money;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney30 + money;
mjl2.addtime = DateTime.Now;
mjl2.BZContent = "积分抽奖中奖积分";
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 1;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
new DAL.user_Results_jl2().Add(mjl2);
new DAL.user_info().UpdateMoney("umoney30", money, MemberId);
new Mtxfw.DAL.user_jjfp().Updatecount("count2", -zjje, 5);
context.Response.Write("恭喜您抽中" + Mtxfw.Utility.Common.czjhm(zjhm.ToString()) + "等奖,获得了" + zjje + "积分|" + zjhm);
}
else
{
context.Response.Write("积分奖池里的积分已经被抽完了,明天早点来吧,^-^");
}
}
}
else
{
context.Response.Write("您今日已经抽奖过了,明天再来试吧,^-^");
}
}
else
{
context.Response.Write("您的积分不足了,赶紧消费吧,^-^");
}
}
}
}
}
else
{
context.Response.Write("您未登录");
}
}
catch (Exception ex)
{
Mtxfw.Utility.Common.WriteHtml("/weixin/weixin0.txt", ex.ToString());
}
}
///
/// 生成指定位数的随机数
///
///
参数是随机数的位数
///
返回一个随机数字符串
private string RandNum_CJ(int VcodeNum, string Vchar)
{
string[] VcArray = Vchar.Split(','); //拆分成数组
string VNum = "";
Random random = new Random();
for (int i = 0; i < VcArray.Length; i++)
{
VNum = VcArray[random.Next(VcArray.Length)];
}
return VNum;
}
#endregion
public bool IsReusable { get { return false; } }
}
}