Ejemplo n.º 1
0
        protected void Bind()
        {
            if ((!this.IsCallback) && (!this.IsPostBack))
            {
                //Restore filter from cookies
                this.LoadFilterFromCookies();
                this.InitialFilterBind();
                SessionManager.CurrentCategories = this.GetListOfCategories();
            }
            //Get main results
            try
            {
                List<int> channelIds = (SessionManager.CurrentChannels.Count==0)?this.GetListOfChannels()
                                                                                :SessionManager.CurrentChannels;
                List<int> categoryIds = (SessionManager.CurrentCategories.Count==0)?this.GetListOfCategories()
                                                                                :SessionManager.CurrentCategories;
                SessionManager.CurrentChannels = channelIds;
                SessionManager.CurrentCategories = categoryIds;

                CanonMainMonitor monitor = new CanonMainMonitor(Cdb.ConnectionString);
                monitor.Date = deDate.Date;
                monitor.ChannelIds = channelIds;
                monitor.PriceCondition = this.GetPriceCondition();
                if (categoryIds != null)
                    monitor.CategoryIds = categoryIds;
                if (!string.IsNullOrEmpty(txtProduct.Text.Trim()))
                    monitor.ProductName = Memos.Framework.Utilities.TruncateString(txtProduct.Text.Trim(), 300);
                mappingRules = monitor.GetMappingRules();
                DataSet ds = monitor.GetMainMonitorValues();
                //get sorting settings before columns clearing
                DevExpress.Data.ColumnSortOrder sortOrder = DevExpress.Data.ColumnSortOrder.None;
                string sortColumn = string.Empty;
                foreach (GridViewColumn gvc in gridMainMonitor.Columns)
                {
                    GridViewDataColumn gvdc = gvc as GridViewDataColumn;
                    if (gvdc != null)
                        if (gvdc.SortOrder != DevExpress.Data.ColumnSortOrder.None)
                        {
                            sortColumn = gvdc.FieldName;
                            sortOrder = gvdc.SortOrder;
                        }
                }
                gridMainMonitor.Columns.Clear();
                GridViewCommandColumn col0 = new GridViewCommandColumn();
                col0.ShowSelectCheckbox = true;
                col0.VisibleIndex = 0;
                col0.HeaderTemplate = new CommandColumnHeaderTemplate(gridMainMonitor, "selCheckbox", "gridMainMonitorSelectionBox");
                col0.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                col0.HeaderStyle.VerticalAlign = VerticalAlign.Middle;
                gridMainMonitor.Columns.Add(col0);
                int visIndex = 1;
                foreach (DataColumn dc in ds.Tables[0].Columns)
                {
                    GridViewDataTextColumn col1 = new GridViewDataTextColumn();
                    col1.Caption = this.LocalizeColumnName(dc.ColumnName);
                    col1.FieldName = dc.ColumnName;
                    col1.VisibleIndex = visIndex++;
                    if (dc.ColumnName == "ProductId")
                        col1.Visible = false;
                    if ((!string.IsNullOrEmpty(sortColumn)) && (col1.FieldName == sortColumn))
                        col1.SortOrder = sortOrder;
                    col1.Settings.SortMode = DevExpress.XtraGrid.ColumnSortMode.Custom;
                    gridMainMonitor.Columns.Add(col1);
                }
                gridMainMonitor.SettingsPager.PageSize = int.Parse(cbPageSize.SelectedItem.Value.ToString());
                gridMainMonitor.DataSource = ds.Tables[0];
                gridMainMonitor.DataBind();
                gridMainMonitor.JSProperties["cpRowsCount"] = gridMainMonitor.VisibleRowCount;
            }
            catch (Exception ex)
            {
                Logger.Log(string.Format("exception {0}", ex.ToString()), LogLevel.Error);
                gridMainMonitor.Columns.Clear();
                gridMainMonitor.DataSource = null;
                gridMainMonitor.DataBind();
            }
        }
Ejemplo n.º 2
0
 protected DataTable GenerateExcelData(List<int> channels, List<int> products, DateTime date)
 {
     CanonMainMonitor monitor = new CanonMainMonitor(Cdb.ConnectionString);
     monitor.Date = date;
     monitor.ChannelIds = channels;
     monitor.ProductIds = products;
     monitor.PriceCondition = this.GetPriceCondition();
     DataSet ds = monitor.GetMainMonitorValues();
     if (ds.Tables.Count > 0)
         return ds.Tables[0];
     return null;
 }