Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _files.Clear();
     Localize();
     WebChartControl.ProcessImageRequest(this.Page);
     if ((!this.Page.IsPostBack) && (!this.Page.IsCallback))
     {
         deStartDate.Date     = DateTime.Now.AddDays(-7);
         deFinishDate.Date    = DateTime.Now;
         deStartDate.MaxDate  = DateTime.Now;
         deFinishDate.MaxDate = DateTime.Now;
     }
     panelPics.Controls.Clear();
     Bind();
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            q = new SqlQuery();


            // Y Axis value

            // We watch Obrat
            if (ddlYValueType.SelectedValue.Equals("Obrat"))
            {
                //q.Start(QueryType.Select, SelectList.Expression, "");
            }

            // We watch Prodanych kusu
            if (ddlYValueType.SelectedValue.Equals("ProdanychKusu"))
            {
                //q.Start(QueryType.Select, SelectList.Count, "");
            }

            if (ddlYFilterType.SelectedIndex > 0)
            {
                //q.WhereEquals(ddlYFilterType.SelectedValue, lbYFilter);
            }

            //q.GroupBy(ddlYGroupBy.SelectedValue);
            //q.OrderByCount();


            // jak budeme resit kresleni po dnech???
            //foreach ()
            //{
            //}

            WebChartControl.ProcessImageRequest(this.Page);
            pnlGraph.Controls.Clear();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Page_Load(object sender, EventArgs e)
        {
            //AjaxContentID = reportForm.ID;
            if (!string.IsNullOrEmpty(Request["ajax"]))
            {
                if (Request["ajax"].Equals("yes"))
                {
                    IsAjax = true;
                }
            }

            // AJAX - please extract this
            #region Dynamic form fields & JS settings

            if (!IsAjax)
            {
                lbFormAction.Attributes.Add("onclick", string.Format("return SendForm('{0}', 'ValidateFormAndSend', this);", reportForm.ClientID));
                lbFormAction.Attributes.Add("style", "display: none!important;");
                ddlYFilterType.Attributes.Add("onchange", "document.getElementById('" + lbFormAction.ClientID + "').click();");
                ddlXValueType.Attributes.Add("onchange", "document.getElementById('" + lbFormAction.ClientID + "').click();");
                ddlYGroupBy.Attributes.Add("onchange", "Lines(0, '" + lbYHaving.ClientID + "');document.getElementById('" + lbFormAction.ClientID + "').click();");
                //ddlYGroupBy.Attributes.Add("onchange", string.Format("document.getElementById('{0}').style.visibility='hidden';", lbYHaving.ClientID));

                StringBuilder js = new StringBuilder();
                js.AppendLine("<script language=\"javascript\">");
                js.AppendLine(string.Format("ajax_url = '{0}';", Request.Url));
                js.AppendLine("XBrowserAddHandler(window, 'load', function() {");
                js.AppendLine(string.Format("ddlLines='{2}'; InitGraphSize('{0}', '{1}');", txtScreenWidth.ClientID, txtScreenHeight.ClientID, lbYHaving.ClientID));
                js.AppendLine(" });");
                js.AppendLine("XBrowserAddHandler(window, 'resize', function() {");
                js.AppendLine(string.Format("InitGraphSize('{0}', '{1}');", txtScreenWidth.ClientID, txtScreenHeight.ClientID));
                js.AppendLine(" });");
                js.AppendLine("</script>");

                ((Literal)Master.FindControl("ltrJS")).Text = js.ToString();
            }

            #endregion

            if (!IsPostBack)
            {
                //ccDateFrom.Date = DateTime.Now.AddMonths(-1);
                //ccDateTo.Date = DateTime.Now;
                //ccDateFrom.Date = new DateTime(2010, 1, 1);
                //ccDateTo.Date = new DateTime(2010, 1, 1).AddYears(1).AddDays(-1);

                ccDateFrom.Date = new DateTime(2011, 1, 1);
                ccDateTo.Date   = new DateTime(2011, 1, 1).AddYears(1).AddDays(-1);

                Panel();
                DrawChart(null, ccDateFrom.Date, ccDateTo.Date, (IntervalType)Convert.ToInt32(ddlXGroupByTime.SelectedValue), ValueRepresentation.AbsoluteValues, true);
            }
            else
            {
                if (!string.IsNullOrEmpty(Request["ctl00$Content$ccDateFrom$deMainDate$I"]))
                {
                    ccDateFrom.Date = Convert.ToDateTime(Request["ctl00$Content$ccDateFrom$deMainDate$I"]);
                    ccDateTo.Date   = Convert.ToDateTime(Request["ctl00$Content$ccDateTo$deMainDate$I"]);
                }
            }

            List <SearchBox> sbs = new List <SearchBox>();

            #region Y Filter

            if (Session["Controls"] == null)
            {
                // Omezeni na distributora
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString))
                {
                    conn.Open();

                    List <string> seriesNames = new List <string>();

                    int k = 0;
                    // Create series
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection = conn;

                        foreach (ListItem li in ddlYFilterType.Items)
                        {
                            if (k > 0 && li.Enabled)
                            {
                                SearchBox sb = (SearchBox)LoadControl("Controls/SearchBox.ascx");

                                sb.ID      = "lb" + li.Value;
                                sb.Display = false;
                                sb.Class   = "filter";
                                pnlYFilter.Controls.Add(sb);

                                // DataBind
                                if (!IsPostBack)
                                {
                                    if (ddlYGroupBy.SelectedValue == "ReselerGroupJoined")
                                    {
                                        cmd.CommandText = string.Format("SELECT DISTINCT IsNull(" + li.Value + ", 'NO-NAME') AS Text, " + li.Value + " AS Value FROM PivotTable ORDER BY " + li.Value, ddlYGroupBy.SelectedValue);
                                    }
                                    else
                                    {
                                        cmd.CommandText = string.Format("SELECT DISTINCT IsNull(" + li.Value + ", '(neuvedeno)') AS Text, " + li.Value + " AS Value FROM PivotTable ORDER BY " + li.Value, ddlYGroupBy.SelectedValue);
                                    }


                                    SqlDataAdapter sda = new SqlDataAdapter();
                                    sda.SelectCommand = cmd;
                                    DataTable dt = new DataTable();
                                    sda.Fill(dt);
                                    sb.AddResults(dt);
                                }

                                sbs.Add(sb);
                            }
                            k++;
                        }
                    }
                    conn.Close();
                    Session["Controls"] = sbs;
                }
            }

            else
            {
                List <SearchBox> sbs_session = (List <SearchBox>)Session["Controls"];
                foreach (SearchBox sb in sbs_session)
                {
                    pnlYFilter.Controls.Add(sb);
                }
            }

            #endregion


            if (!IsPostBack)
            {
                WebChartControl.ProcessImageRequest(this.Page);
                pnlGraph.Controls.Clear();
            }


            // Y
            foreach (Control c in pnlYFilter.Controls)
            {
                if (c is SearchBox)
                {
                    ((SearchBox)c).Display = false;
                }
            }
            if (ddlYFilterType.SelectedValue != "-")
            {
                Control c = pnlYFilter.FindControl("lb" + ddlYFilterType.SelectedValue);
                ((SearchBox)c).Display = true;
            }

            if (ddlXValueType.SelectedValue == "Time")
            {
                ddlXGroupByTime.Style.Add("display", "block");
                ddlXGroupByData.Style.Add("display", "none");
            }
            else
            {
                ddlXGroupByTime.Style.Add("display", "none");
                ddlXGroupByData.Style.Add("display", "block");
            }

            base.Page_Load(sender, e);
        }