protected void BindGrid() { DataTable dt = CardAccess.GetCardList(userId); this.CardList.DataSource = dt; this.CardList.DataBind(); foreach (DataRow dr in dt.Rows) { totalMoney += Double.Parse(dr["CardMoney"].ToString()); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int userId = Int32.Parse(Session["UserID"].ToString()); DataTable catTypeList = UserCategoryAccess.GetCategoryTypeList(userId); this.CatTypeList.DataSource = catTypeList; this.CatTypeList.DataBind(); this.CategoryTypeDown.DataSource = catTypeList; this.CategoryTypeDown.DataTextField = "CategoryTypeName"; this.CategoryTypeDown.DataValueField = "CategoryTypeID"; this.CategoryTypeDown.DataBind(); this.CategoryTypeDown.Items.Insert(0, new ListItem("请选择", "0")); this.ZhuanTiDown.DataSource = ZhuanTiAccess.GetZhuanTiList(userId); this.ZhuanTiDown.DataTextField = "ZhuanTiName"; this.ZhuanTiDown.DataValueField = "ZTID"; this.ZhuanTiDown.DataBind(); this.ZhuanTiDown.Items.Insert(0, new ListItem("请选择", "0")); this.ItemType.Attributes.Add("readonly", "readonly"); this.CategoryTypeDown.Attributes.Add("readonly", "readonly"); this.ItemBuyDate.Attributes.Add("readonly", "readonly"); //this.ItemBuyDate1.Attributes.Add("readonly", "readonly"); //this.ItemBuyDate2.Attributes.Add("readonly", "readonly"); if (Session["TodayDate"] != null) { string today = Session["TodayDate"].ToString(); string today2 = DateTime.Parse(today).AddMonths(11).ToString("yyyy-MM-dd"); this.ItemBuyDate.Text = today + " " + ItemHelper.GetWeekString(today, 0); this.ItemBuyDateHid.Value = today; this.ItemBuyDate1.Text = today; this.ItemBuyDate2.Text = today2; } //钱包 this.CardDown.DataSource = CardAccess.GetCardList(userId); this.CardDown.DataTextField = "CardName"; this.CardDown.DataValueField = "CardID"; this.CardDown.DataBind(); if (Request.Cookies["CardID"] != null) { string cardId = Request.Cookies["CardID"].Value; this.CardDown.SelectedValue = cardId; } } }
protected void Page_Load(object sender, EventArgs e) { userId = Int32.Parse(Session["UserID"].ToString()); catTypeList = UserCategoryAccess.GetCategoryTypeList(userId); itemTypeList = ItemAccess.GetItemListType(); cardList = CardAccess.GetCardList(userId); if (Request.QueryString["date"] != null && Request.QueryString["date"] != "") { if (!ValidHelper.CheckDate(Request.QueryString["date"])) { Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd"); } else { Session["TodayDate"] = Request.QueryString["date"]; } } today = Session["TodayDate"].ToString(); if (!IsPostBack) { BindGrid(); this.CatTypeEmpIns.DataSource = catTypeList; this.CatTypeEmpIns.DataTextField = "CategoryTypeName"; this.CatTypeEmpIns.DataValueField = "CategoryTypeID"; this.CatTypeEmpIns.DataBind(); if (Request.Cookies["CatTypeID"] != null) { this.CatTypeEmpIns.SelectedValue = Request.Cookies["CatTypeID"].Value; } this.ItemTypeEmpIns.DataSource = itemTypeList; this.ItemTypeEmpIns.DataTextField = "ItemTypeName"; this.ItemTypeEmpIns.DataValueField = "ItemTypeValue"; this.ItemTypeEmpIns.DataBind(); //钱包 this.CardEmpIns.DataSource = cardList; this.CardEmpIns.DataTextField = "CardName"; this.CardEmpIns.DataValueField = "CardID"; this.CardEmpIns.DataBind(); if (Request.Cookies["CardID"] != null) { this.CardEmpIns.SelectedValue = Request.Cookies["CardID"].Value; } } }
//导出数据到App// protected void Button1_Click(object sender, EventArgs e) { int userId = Int32.Parse(Session["UserID"].ToString()); fileName = "aalife2.bak"; StringBuilder sb = new StringBuilder(); DataTable itemListTab = BackupAccess.BackupItemTableById(userId); if (itemListTab.Rows.Count > 0) { sb.AppendLine("DELETE FROM ItemTable;"); foreach (DataRow dr in itemListTab.Rows) { sb.AppendLine("INSERT INTO ItemTable (ItemType, ItemName, ItemPrice, ItemBuyDate, CategoryID, Recommend, Synchronize, RegionID, RegionType, ZhuanTiID, CardID) VALUES ('" + dr["ItemType"].ToString() + "', '" + dr["ItemName"].ToString() + "', '" + dr["ItemPrice"].ToString() + "', '" + String.Format("{0:yyyy-MM-dd}", dr["ItemBuyDate"]) + "', '" + dr["CategoryTypeID"].ToString() + "', '" + dr["Recommend"].ToString() + "', '0', '" + dr["RegionID"].ToString() + "', '" + dr["RegionType"].ToString() + "', '" + dr["ZhuanTiID"].ToString() + "', '" + dr["CardID"].ToString() + "');"); } sb.AppendLine(""); } DataTable catListTab = UserCategoryAccess.GetCategoryTypeList(userId); if (catListTab.Rows.Count > 0) { sb.AppendLine("DELETE FROM CategoryTable;"); foreach (DataRow dr in catListTab.Rows) { sb.AppendLine("INSERT INTO CategoryTable (CategoryID, CategoryName, CategoryPrice, CategoryRank, CategoryDisplay, CategoryLive) VALUES ('" + dr["CategoryTypeID"].ToString() + "', '" + dr["CategoryTypeName"].ToString() + "', '" + dr["CategoryTypePrice"].ToString() + "', '" + dr["CategoryTypeID"].ToString() + "', '1', '1');"); } sb.AppendLine(""); } DataTable zhuanTiTab = ZhuanTiAccess.GetZhuanTiList(userId); if (zhuanTiTab.Rows.Count > 0) { sb.AppendLine("DELETE FROM ZhuanTiTable;"); foreach (DataRow dr in zhuanTiTab.Rows) { sb.AppendLine("INSERT INTO ZhuanTiTable (ZTID, ZhuanTiName, ZhuanTiImage, ZhuanTiLive, Synchronize) VALUES ('" + dr["ZTID"].ToString() + "', '" + dr["ZhuanTiName"].ToString() + "', '" + dr["ZhuanTiImage"].ToString() + "', '" + dr["ZhuanTiLive"].ToString() + "', '0');"); } sb.AppendLine(""); } DataTable cardTab = CardAccess.GetCardList(userId); if (cardTab.Rows.Count > 0) { sb.AppendLine("DELETE FROM CardTable;"); foreach (DataRow dr in cardTab.Rows) { if (dr["CardID"].ToString() == "0") { continue; } sb.AppendLine("INSERT INTO CardTable (CDID, CardName, CardMoney, CardLive, Synchronize) VALUES ('" + dr["CardID"].ToString() + "', '" + dr["CardName"].ToString() + "', '" + dr["CardMoney"].ToString() + "', '" + dr["CardLive"].ToString() + "', '0');"); } } BackupAccess.WriteBackupFile(filePath + fileName, sb.ToString()); //Utility.Alert(this, "导出成功。"); DownBackFile(); }
protected void BindGrid() { if (Request.QueryString["date"] != null && Request.QueryString["date"] != "") { if (!ValidHelper.CheckDate(Request.QueryString["date"])) { Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd"); } else { Session["TodayDate"] = Request.QueryString["date"]; } } string today = Session["TodayDate"].ToString(); int userId = Int32.Parse(Session["UserID"].ToString()); //图表点击事件 double priceMax = 0; DataTable dd = ItemAccess.GetItemDateTopList(today, userId, "chart", out priceMax); this.hidChartData.Value = ItemHelper.GetChartData(dd, "ItemBuyDate"); #region 每日消费代码 double shouruPrice = 0; double zhichuPrice = 0; double shouruPriceMonth = 0; double zhichuPriceMonth = 0; double shouruPriceYear = 0; double zhichuPriceYear = 0; DataTable total = ItemAccess.GetItemListShouZhi(today, userId, out shouruPrice, out zhichuPrice, out shouruPriceMonth, out zhichuPriceMonth, out shouruPriceYear, out zhichuPriceYear); this.Label2.Text = shouruPrice.ToString("0.0##"); this.Label4.Text = zhichuPrice.ToString("0.0##"); this.Label1.Text = shouruPriceMonth.ToString("0.0##"); this.Label3.Text = zhichuPriceMonth.ToString("0.0##"); this.Label11.Text = shouruPriceYear.ToString("0.0##"); this.Label12.Text = zhichuPriceYear.ToString("0.0##"); double jiechuPrice = 0; double huanruPrice = 0; double jieruPrice = 0; double huanchuPrice = 0; DataTable jiehuan = ItemAccess.GetItemListJieHuanYear(today, userId, out jiechuPrice, out huanruPrice, out jieruPrice, out huanchuPrice); this.Label5.Text = jiechuPrice.ToString("0.##"); this.Label6.Text = huanruPrice.ToString("0.##"); this.Label7.Text = jieruPrice.ToString("0.##"); this.Label8.Text = huanchuPrice.ToString("0.##"); this.Label9.Text = (jiechuPrice - huanruPrice).ToString("0.##"); this.Label10.Text = (jieruPrice - huanchuPrice).ToString("0.##"); #endregion //首页功能链接 string userFunction = ""; if (Session["UserFunction"] != null) { userFunction = Session["UserFunction"].ToString(); } this.Label13.Text = UserAccess.GetUserFunctionText(userFunction); //钱包列表 this.CardList.DataSource = CardAccess.GetCardList(userId); this.CardList.DataTextField = "CardName"; this.CardList.DataValueField = "CardID"; this.CardList.DataBind(); if (Request.Cookies["CardID"] != null) { string cardId = Request.Cookies["CardID"].Value; this.CardList.SelectedValue = cardId; } CardList_SelectionChanged(this.CardList, null); }