protected void Button1_Click(object sender, EventArgs e) { string MyChangeValue = ChangeValue.Text; string MyMoneyType = MoneyType.SelectedValue; string MyMoneyType1 = MoneyType1.SelectedValue; string MyPassWord = PassWord.Text; // Muser = Buser.GetCookie(); M_User Muser_1 = new M_User(); int UserId=Muser.UserID; Muser_1 = Buser.GetUser(UserId); string MyUserIntegral=UserIntegral.Text; string MyUserYellowBoy=UserYellowBoy.Text; string MyUserExpireDay=UserExpireDay.Text; string SuLabel = ""; string SucLabel = ""; string SucLabelValue = ""; #region 验证判断 if (!Function.CheckNumberNotZero(MyChangeValue)) { Function.ShowMsg(0, "<li>请输入一个大于0的整数</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } if (MyMoneyType == "0" || MyMoneyType1 == "0") { Function.ShowMsg(0, "<li>请选择转换栏目</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } if (MyPassWord == "" || MyPassWord == null) { Function.ShowMsg(0, "<li>请输入登陆密码</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } if (Muser_1.UserPwd != Function.MD5Encrypt(MyPassWord)) { Function.ShowMsg(0, "<li>登陆密码输入错误</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } #endregion B_Money BMoney = new B_Money(); #region 数值判断 #region 金币判断 if (MyMoneyType == "1") //如果是金币 { SuLabel = "" + GUnitName.Text + "金币"; if (Muser_1.YellowBoy < int.Parse(MyChangeValue)) { Function.ShowMsg(0, "<li>金币不足,请重新输入</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } else { //金币 if (MyMoneyType1=="1") { Function.ShowMsg(0, "<li>金币无需再次换成金币</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } //积分 if (MyMoneyType1 == "2") { BMoney.YellowBoy(-decimal.Parse(MyChangeValue), UserId); //更新金币(减少) BMoney.Integral(int.Parse(MyChangeValue) * int.Parse(MyUserIntegral) / int.Parse(MyUserYellowBoy), UserId); //积分 SucLabel = "点积分"; SucLabelValue = (int.Parse(MyChangeValue) * int.Parse(MyUserIntegral) / int.Parse(MyUserYellowBoy)).ToString(); } //有效期 if (MyMoneyType1 == "3") { BMoney.YellowBoy(-decimal.Parse(MyChangeValue), UserId); //更新金币(减少) BMoney.ExpireTime(int.Parse(MyChangeValue) * int.Parse(MyUserExpireDay) / int.Parse(MyUserYellowBoy), UserId); //有效期 SucLabel = "天有效期"; SucLabelValue = (int.Parse(MyChangeValue) * int.Parse(MyUserExpireDay) / int.Parse(MyUserYellowBoy)).ToString(); } } } #endregion #region 积分判断 if (MyMoneyType == "2") //如果是积分 { SuLabel = "点积分"; if (Muser_1.Integral < int.Parse(MyChangeValue)) { Function.ShowMsg(0, "<li>积分不足,请重新输入</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } else { //积分 if (MyMoneyType1 == "2") { Function.ShowMsg(0, "<li>积分无需再次换成积分</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } //金币 if (MyMoneyType1 == "1") { BMoney.Integral(-int.Parse(MyChangeValue), UserId); //更新积分(减少) BMoney.YellowBoy(decimal.Parse(MyChangeValue) * decimal.Parse(MyUserYellowBoy) / decimal.Parse(MyUserIntegral), UserId); //金币 SucLabel = "" + GUnitName.Text + "金币"; SucLabelValue = (int.Parse(MyChangeValue) * decimal.Parse(MyUserYellowBoy) / int.Parse(MyUserIntegral)).ToString(); } //有效期 if (MyMoneyType1 == "3") { BMoney.Integral(-int.Parse(MyChangeValue), UserId); //更新积分(减少) BMoney.ExpireTime(int.Parse(MyChangeValue) * int.Parse(MyUserExpireDay) / int.Parse(MyUserIntegral), UserId); //有效期. SucLabel = "天有效期"; SucLabelValue = (int.Parse(MyChangeValue) * int.Parse(MyUserExpireDay) / int.Parse(MyUserIntegral)).ToString(); } } } #endregion #region 有效期判断 if (MyMoneyType == "3") //如果是有效期 { SuLabel = "天有效期"; TimeSpan ts1 = new TimeSpan(Muser_1.ExpireTime.Ticks); TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks); if (ts1.Subtract(ts2).Days < int.Parse(MyChangeValue)) { Function.ShowMsg(0, "<li>有效期天数不足,请重新输入</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } else { //有效期 if (MyMoneyType1 == "3") { Function.ShowMsg(0, "<li>有效期无需再次换成有效期</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>"); } //金币 if (MyMoneyType1 == "1") { BMoney.ExpireTime(-int.Parse(MyChangeValue), UserId); //更新有效期(减少) BMoney.YellowBoy(decimal.Parse(MyChangeValue) * decimal.Parse(MyUserYellowBoy) / decimal.Parse(MyUserExpireDay), UserId); //金币 SucLabel = "" + GUnitName.Text + "金币"; SucLabelValue = (decimal.Parse(MyChangeValue) * decimal.Parse(MyUserYellowBoy) / int.Parse(MyUserExpireDay)).ToString(); } //积分 if (MyMoneyType1 == "2") { BMoney.ExpireTime(-int.Parse(MyChangeValue), UserId); //更新积分(减少) BMoney.Integral(int.Parse(MyChangeValue) * int.Parse(MyUserIntegral) / int.Parse(MyUserExpireDay), UserId); //积分 SucLabel = "点积分"; SucLabelValue = (int.Parse(MyChangeValue) * int.Parse(MyUserIntegral) / int.Parse(MyUserExpireDay)).ToString(); } } } #endregion #endregion //记录日志 B_UserLog logBll = new B_UserLog(); M_UserLog logModel = new M_UserLog(); logModel.AddTime = DateTime.Now; logModel.Description = "成功将" + MyChangeValue + "" + SuLabel + "兑换成" + SucLabelValue + "" + SucLabel; logModel.InfoId = 0; logModel.ModelType = 0; logModel.Point = 0; logModel.UserId = Muser_1.UserID; logModel.UserName = Muser_1.LogName; logBll.Add(logModel); Function.ShowMsg(1, "<li>成功将" + MyChangeValue + "" + SuLabel + "兑换成" + SucLabelValue + "" + SucLabel + "</li><li><a href='Money/MoneyChange.aspx'>返回财富兑换</a></li>"); }
protected void Button1_Click(object sender, EventArgs e) { string MyChangeValue = ChangeValue.Text; string MyMoneyType = MoneyType.SelectedValue; string MySendUser = SendUser.Text; string MyMoneyType_1 = MoneyType.SelectedItem.Text; string MyGUnitName = ""; //汇率 Msite = Bsiteinfo.GetSiteModel(); if (MyMoneyType == "1") { MyGUnitName = Msite.GUnitName.ToString(); } if (MyMoneyType == "2") { MyGUnitName = "点"; } if (MyMoneyType == "3") { MyGUnitName = "天"; } string MyPassWord = PassWord.Text; // Muser = Buser.GetCookie(); M_User Muser_1 = new M_User(); int UserId = Muser.UserID; Muser_1 = Buser.GetUser(UserId); #region 验证判断 if (!Function.CheckNumberNotZero(MyChangeValue)) { Function.ShowMsg(0, "<li>请输入一个大于0的整数</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>"); } if (MyMoneyType == "0") { Function.ShowMsg(0, "<li>请选择转换栏目</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>"); } if (MySendUser == "0") { Function.ShowMsg(0, "<li>请输入赠送用户名称</li><li><a href='Money/MoneySend.aspx>返回上一步</a></li>"); } if (MyPassWord == "" || MyPassWord == null) { Function.ShowMsg(0, "<li>请输入登陆密码</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>"); } if (Muser_1.UserPwd != Function.MD5Encrypt(MyPassWord)) { Function.ShowMsg(0, "<li>登陆密码输入错误</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>"); } #endregion #region 判断用户输入赠送用户的合法性 B_Money BMoney = new B_Money(); if (Buser.GetUser(MySendUser) == null) { Function.ShowMsg(0, "<li>赠送的用户不存在</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>"); } else { int SendUserId=Buser.GetUser(MySendUser).UserID; if (MyMoneyType == "1") { if (Muser_1.YellowBoy < int.Parse(MyChangeValue)) { Function.ShowMsg(0, "<li>金币不足,请重新输入</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>"); } else { BMoney.YellowBoy(decimal.Parse(MyChangeValue), SendUserId); BMoney.YellowBoy(-decimal.Parse(MyChangeValue), UserId); } } if (MyMoneyType == "2") { if (Muser_1.Integral < int.Parse(MyChangeValue)) { Function.ShowMsg(0, "<li>积分不足,请重新输入</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>"); } else { BMoney.Integral(int.Parse(MyChangeValue), SendUserId); BMoney.Integral(-int.Parse(MyChangeValue), UserId); } } if (MyMoneyType == "3") { TimeSpan ts1 = new TimeSpan(Muser_1.ExpireTime.Ticks); TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks); if (ts1.Subtract(ts2).Days < int.Parse(MyChangeValue)) { Function.ShowMsg(0, "<li>有效期天数不足,请重新输入</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>"); } else { BMoney.ExpireTime(int.Parse(MyChangeValue), SendUserId); BMoney.ExpireTime(-int.Parse(MyChangeValue), UserId); } } } #endregion //记录日志 B_UserLog logBll = new B_UserLog(); M_UserLog logModel = new M_UserLog(); logModel.AddTime = DateTime.Now; logModel.Description = "成功赠送给[" + MySendUser + "]" + MyChangeValue + "" + MyGUnitName + "" + MyMoneyType_1; logModel.InfoId = 0; logModel.ModelType = 0; logModel.Point = 0; logModel.UserId = Muser_1.UserID; logModel.UserName = Muser_1.LogName; logBll.Add(logModel); Function.ShowMsg(1, "<li>成功赠送给[" + MySendUser + "]" + MyChangeValue + "" + MyGUnitName + "" + MyMoneyType_1 + "</li><li><a href='Money/MoneySend.aspx'>返回财富赠送</a></li>"); }