Sails.aspx.cs
资源名称:SHOPASP.rar [点击查看]
上传用户:xiecaij
上传日期:2015-02-08
资源大小:2016k
文件大小:3k
源码类别:
百货/超市行业
开发平台:
ASP/ASPX
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace admin
- {
- /// <summary>
- /// Sails 的摘要说明。
- /// </summary>
- public class Sails : General
- {
- protected System.Web.UI.WebControls.DropDownList Year;
- protected System.Web.UI.WebControls.DropDownList Month;
- protected System.Web.UI.WebControls.DropDownList Day;
- protected System.Web.UI.WebControls.Button QueryMonth;
- protected System.Web.UI.WebControls.Button QueryDay;
- protected System.Web.UI.WebControls.DataGrid GridSails;
- protected System.Web.UI.HtmlControls.HtmlForm Form1;
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (!Page.IsPostBack)
- {
- BindDate();
- //绑定当天记录
- BindGrid(DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), DateTime.Now.Day.ToString());
- //显示为当前日期
- Year.SelectedValue = DateTime.Now.Year.ToString();
- Month.SelectedValue = DateTime.Now.Month.ToString();
- Day.SelectedValue = DateTime.Now.Day.ToString();
- //插入日志
- AdminDB.InsertAction("查看当日销售记录", System.DateTime.Now, User.Identity.Name);
- }
- }
- /// <summary>
- /// 绑定某年某月某日的销售记录到DataGrid
- /// </summary>
- /// <param name="year"></param>
- /// <param name="month"></param>
- /// <param name="day"></param>
- void BindGrid(string year, string month, string day)
- {
- GridSails.DataSource = new AdminDB().GetSails(year, month, day);
- GridSails.DataBind();
- }
- /// <summary>
- /// 绑定年月日信息到下拉列表
- /// </summary>
- void BindDate()
- {
- //绑定年
- for (int i=2000; i<2020; i++)
- {
- ListItem item = new ListItem(Convert.ToString(i),Convert.ToString(i));
- Year.Items.Add(item);
- }
- //绑定月
- for (int i = 1 ; i<13 ; i++)
- {
- ListItem item1 = new ListItem(Convert.ToString(i),Convert.ToString(i));
- Month.Items.Add(item1);
- }
- //绑定日
- for (int i=1; i<32; i++)
- {
- ListItem item2 = new ListItem(Convert.ToString(i),Convert.ToString(i));
- Day.Items.Add(item2);
- }
- }
- #region Web 窗体设计器生成的代码
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.QueryMonth.Click += new System.EventHandler(this.QueryMonth_Click);
- this.QueryDay.Click += new System.EventHandler(this.QueryDay_Click);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- //查询所选日期的月销售记录
- private void QueryMonth_Click(object sender, System.EventArgs e)
- {
- BindGrid(Year.SelectedValue, Month.SelectedValue, "0");
- AdminDB.InsertAction("查看"+Year.SelectedValue+"年"+Month.SelectedValue+"月"
- + "的销售记录", System.DateTime.Now, User.Identity.Name);
- }
- //查询所选日期的日销售记录
- private void QueryDay_Click(object sender, System.EventArgs e)
- {
- BindGrid(Year.SelectedValue, Month.SelectedValue, Day.SelectedValue);
- AdminDB.InsertAction("查看"+Year.SelectedValue+"年"+Month.SelectedValue+"月"
- + Day.SelectedValue +"日的销售记录", System.DateTime.Now, User.Identity.Name);
- }
- }
- }