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 BindGrid() { DataTable dt = ItemAccess.GetItemList(today, userId); List.DataSource = dt; List.DataBind(); 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")); 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.GetItemListJieHuan(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.##"); }
//导出数据到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() { this.List.DataSource = ZhuanTiAccess.GetZhuanTiList(userId); this.List.DataBind(); }