📄 openshop.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.Text;
namespace YXShop.Web.Membercenter.Shop
{
public partial class OpenShop : System.Web.UI.Page
{
BLL.YXShop_Shop B_Shop = new YXShop.BLL.YXShop_Shop();
BLL.MemberInfo B_MemberInfo = new YXShop.BLL.MemberInfo();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
void BindData()
{
List<Model.YXShop_Shop> listShop = B_Shop.GetListByColumn("UID", Convert.ToInt32(Session["MemberID"]));
int ShopRank = 0;
string strState = string.Empty;
if (listShop.Count > 0)
{
//ltlState.Text = "";
if (listShop[0].State != 1)
{
YXShop.Common.alert.showAndGo("你还没有通过审核", "DefaultLinkman.aspx"); Response.End();
}
ShopRank = (int)listShop[0].ShopRank;
BindRadionList(rblShopType, (int)listShop[0].ShopRank);
if (DateTime.Now > listShop[0].StartDate && DateTime.Now < listShop[0].EndDate)
{
strState = "未过期";
btnSubmit.Text = " 续 费 ";
rblShopType.Enabled = false;
dpStart.Enabled = false;
}
else
{
strState = "以过期";
}
strState += "(" + listShop[0].StartDate.ToString() + "--" + listShop[0].EndDate.ToString() + ")";
}
else { YXShop.Common.alert.showAndGo("出错了", Request.UrlReferrer.ToString()); Response.End(); }
YXShop.BLL.YXShop_ShopType stBll = new YXShop.BLL.YXShop_ShopType();
List<Model.YXShop_ShopType> listShopType = stBll.GetListByColumn("STID", ShopRank);
if (listShopType.Count > 0)
{
strState = listShopType[0].STName + strState;
}
ltlState.Text = strState;
}
private void BindRadionList(RadioButtonList rBtnList, int shopRank)
{
//用户不能修改为比已使用天数更少的规模方案
rBtnList.Items.Clear();
YXShop.BLL.YXShop_ShopType stBll = new YXShop.BLL.YXShop_ShopType();
List<YXShop.Model.YXShop_ShopType> stList = stBll.GetListByColumn();
ListItem lItem = null;
StringBuilder sb = new StringBuilder();
string showCss = "showCss";
string noShowCss = "noShowCss";
foreach (YXShop.Model.YXShop_ShopType stModel in stList)
{
lItem = new ListItem();
lItem.Value = String.Format("{0}", stModel.STID);
lItem.Text = String.Format("<font style='color:red;'>{0}</font> 租金:{1}元,经营商品数量为{2}个,空间大小{3}kb,可使用[{4}]天数", stModel.STName, stModel.STPrice, stModel.ProCount, stModel.ShopSpace, stModel.ExpendDays);
if (shopRank == stModel.STID)
{
lItem.Selected = true;
sb.Append(string.Format("<div class=\"{2}\" id=\"ShopTypeInfo_{0}\"><div class=\"Title\">{3}</div>{1}", stModel.STID, stModel.Content, showCss,stModel.STName));
sb.Append("</div>");
}
else
{
sb.Append(string.Format("<div class=\"{2}\" id=\"ShopTypeInfo_{0}\"><div class=\"Title\">{3}</div>{1}", stModel.STID, stModel.Content, noShowCss, stModel.STName));
sb.Append("</div>");
}
rBtnList.Items.Add(lItem);
lItem = null;
}
ltlShopTypeContent.Text = sb.ToString();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
List<Model.MemberInfo> M_MemberInfo = B_MemberInfo.GetListByColumn("UID", Convert.ToInt32(Session["MemberID"]));
decimal SurplusCapital = 0;//余额
decimal CostFund = 0;//消费金额
decimal Price = 0;//支付金额
double ExpendDays = 0;//天数
#region 用户信息
if (M_MemberInfo.Count > 0)
{
SurplusCapital = (decimal)M_MemberInfo[0].fSurplusCapital;
CostFund = (decimal)M_MemberInfo[0].fCostFund;
}
#endregion
#region 取出类型的价格 天数
YXShop.BLL.YXShop_ShopType stBll = new YXShop.BLL.YXShop_ShopType();
List<Model.YXShop_ShopType> listShopType = stBll.GetListByColumn("STID", Convert.ToInt32(rblShopType.Text));
if (listShopType.Count > 0)
{
Price = (decimal)listShopType[0].STPrice;
ExpendDays = (double)listShopType[0].ExpendDays;
}
#endregion
#region 金额判断
if (SurplusCapital < Price)
{
Common.alert.showAndGo("你的帐户余额不足,请充值","页面");
return;
}
#endregion
B_MemberInfo.Amend(Convert.ToInt32(Session["MemberID"]), "fSurplusCapital", SurplusCapital - Price);//减去余额
B_MemberInfo.Amend(Convert.ToInt32(Session["MemberID"]), "fSurplusCapital", CostFund + Price);//添加消费金额
List<Model.YXShop_Shop> listShop = B_Shop.GetListByColumn("UID", Convert.ToInt32(Session["MemberID"]));
if (listShop.Count > 0)
{
if (DateTime.Now > listShop[0].StartDate && DateTime.Now < listShop[0].EndDate)
{
B_Shop.Amend(Convert.ToInt32(Session["MemberID"]), "EndDate", ((DateTime)listShop[0].EndDate).AddDays(ExpendDays), 0);
}
else
{
B_Shop.Amend(Convert.ToInt32(Session["MemberID"]), "StartDate", dpStart.Date, 0);
B_Shop.Amend(Convert.ToInt32(Session["MemberID"]), "EndDate", dpStart.Date.AddDays(ExpendDays), 0);
B_Shop.Amend(Convert.ToInt32(Session["MemberID"]), "ShopRank", rblShopType.Text, 0);//修改用户等级
}
}
Common.alert.showOnly("申请成功");
}
catch
{
Common.alert.showOnly("申请失败");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -