using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Web.UI; using System.Web.UI.WebControls; using SuperMap.RealEstate.CoreFrameWork; using SuperMap.RealEstate.ServiceModel; using SuperMap.RealEstate.Utility; using SuperMap.RealEstate.Web.UI; using SuperMap.RealEstate.Web.UI.WebControls; using SuperMap.RealEstate.Web.Utility; using SuperMap.RealEstate.CoreFrameWork.Dictionary.Business; using Business = SuperMap.RealEstate.HighWay.Storage.Business; using HZQR.Common; namespace SuperMap.RealEstate.HighWay.Modules.SellData { public partial class Default : SuperMap.RealEstate.Web.UI.PageValid { private DataTable _DataTable = null; protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; //初始化并加载列表 GridViewEx1.SelectingWithInit(ObjectDataSource1, GridPageEx1); //设置回车焦点按钮 SetControlClientAction(ButtonSearch); BindDropDownList_SERVERPART(); InitWebControls(); } private void InitWebControls() { BusinessType.Items.Clear(); ListItemEx _ListItemFirst = new ListItemEx(); _ListItemFirst.Text = "全部"; _ListItemFirst.Value = "1=1"; BusinessType.Items.Insert(0, _ListItemFirst); DictionaryHelper.BindingDropDownList("BUSINESSTYPE", BusinessType.Items, this.Transaction); } //查询 protected void ButtonSearch_CallBackClick(object sender, ClientSetEventArgs e) { GridViewEx1.Selecting(ObjectDataSource1, GridPageEx1); //设置UI变化 e.SetValue(GridViewEx1); e.SetValue(GridPageEx1); } //翻页事件 protected void GridPageEx1_CallBackPageChanged(object src, ClientSetEventArgs e) { GridViewEx1.Pagging(ObjectDataSource1, GridPageEx1); //设置UI变化 e.SetValue(GridViewEx1); } //查询SQL设置 protected void GridViewEx1_SelectMethodParameters(object sender, SelectMethodParametersArgs e) { //搜索选项的搜索条件过滤 if (!string.IsNullOrEmpty(TextBox_Search.Text)) e.AddOrParams(GridViewSearch1, TextBox_Search.Text); if (SERVERPART_ID.SelectedIndex != -1) { if (SERVERPART_ID.SelectedValue != "1=1") { e.AddAndParams("SERVERPART_ID", SERVERPART_ID.SelectedValue); } } if (BusinessType.SelectedIndex >0) { e.AddAndParams("BUSINESSTYPE", BusinessType.SelectedValue); } //且搜索条件 //e.AddAndParams(字段名, 值); //或搜索条件 //e.AddOrParams(字段名, 值); //排序 e.AddOrderByParams(GridViewOrderBy1); } #region 方法 -> 加载服务区下拉框【根据用户信息】 public void BindDropDownList_SERVERPART() { SERVERPART_ID.Items.Clear(); ListItemEx _ListItemFirst = new ListItemEx(); _ListItemFirst.Text ="全部"; _ListItemFirst.Value = "1=1"; SERVERPART_ID.Items.Insert(0,_ListItemFirst); string PartString = string.Empty; //获得服务区信息 foreach (string _str in PassportInfo.CityAuthority.Split(',')) { PartString += PartString == string.Empty ? "'" + _str + "'" : ",'" + _str + "'"; } foreach (FieldEnum _FieldEnum in (new FieldEnum()).FillCollection("where FieldEnum_Value in(" + PartString + ")")) { ListItemEx _ListItem = new ListItemEx(); _ListItem.Text = _FieldEnum.FieldEnum_Name; Business.SERVERPART _SERVERPART = new Business.SERVERPART(); _SERVERPART.AddSearchParameter("FIELDENUM_ID", _FieldEnum.FieldEnum_ID); if (_SERVERPART.Search()) { _ListItem.Value = _SERVERPART.SERVERPART_ID.ToString(); SERVERPART_ID.Items.Add(_ListItem); } } } #endregion #region 方法 -> 导出对应的Excel protected void ButtonExport_Click(object sender, EventArgs e) { if (_DataTable == null) { Alert("无数据"); } string StrSql = "SELECT * FROM HIGHWAY_SELLDATA.T_SELLDATA WHERE 1=1"; if (SERVERPART_ID.SelectedIndex != -1) { if (SERVERPART_ID.SelectedValue != "1=1") { StrSql += " AND SERVERPART_ID = " + SERVERPART_ID.SelectedValue; } } if (BusinessType.SelectedIndex >0) { StrSql += " AND BUSINESSTYPE = " + BusinessType.SelectedValue; } _DataTable = (new Storage.Business.COMMODITY()).ExecuteDataTable(StrSql); ExcelHelper _ExcelHelper = new ExcelHelper(); _ExcelHelper.DataTableToExcel("销售数据导出", _DataTable, "销售数据", true); } #endregion } }