using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ResMangSys.DAL.RepRegistTableAdapters;
// 下载于www.51aspx.com
namespace ResMangSys
{
    public partial class RepRecordQuery : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["id"] == null)
                {
                    Response.Redirect("Default.aspx");
                    return;
                }
                if (Session["role"].ToString() == "user")
                {
                    Response.Redirect("Default.aspx");
                    return;
                }
                ddlAttrLocal.DataSource = GetList.GetDataList("select distinct AttrLocal from T_RepRegist", "AttrLocal");
                ddlAttrLocal.DataBind();
                ddlBaStaId.DataSource = GetList.GetDataList("select distinct BaStaId from T_RepRegist", "BaStaId");
                ddlBaStaId.DataBind();
            }
            else
            {
                if (Session["id"] == null)
                {
                    Response.Redirect("Default.aspx");
                    return;
                }
                if (ddlAttrLocal.SelectedItem.Text != "--归属地--")
                {
                    T_RepRegistTableAdapter adapter = new T_RepRegistTableAdapter();
                    LVRepRegist.DataSourceID = "ODSRepRegistByTimeLocal";
                    LVRepRegist.DataBind();
                    ltCount.Text = adapter.CountQueryByTimeLocal(txtStarTime.Text, txtEndTime.Text, ddlAttrLocal.SelectedItem.Text).Value.ToString();
                    try
                    {
                        ltMoney.Text = adapter.SumQueryByTimeLocal(txtStarTime.Text, txtEndTime.Text, ddlAttrLocal.SelectedItem.Text).Value.ToString();
                    }
                    catch
                    {
                        ltMoney.Text = "0";
                    }
                }
                if (ddlBaStaId.SelectedItem.Text != "--基站编号--")
                {
                    T_RepRegistTableAdapter adapter = new T_RepRegistTableAdapter();
                    LVRepRegist.DataSourceID = "ODSRepRegistByTimeBaStaId";
                    LVRepRegist.DataBind();
                    ltCount.Text = adapter.CountQueryByTimeBaStaId(txtStarTime.Text, txtEndTime.Text, ddlBaStaId.SelectedItem.Text).Value.ToString();
                    try
                    {
                        ltMoney.Text = adapter.SumQueryByTimeBaStaId(txtStarTime.Text, txtEndTime.Text, ddlBaStaId.SelectedItem.Text).Value.ToString();
                    }
                    catch
                    {
                        ltMoney.Text = "0";
                    }
                }
            }
        }
    }
}