コード例 #1
0
        /// <summary>
        /// Shows the print preview dialog with a C1PrintDocument
        /// representing the grid.
        /// </summary>
        public void PrintPreview()
        {
            C1PrintPreviewDialog pview = new C1PrintPreviewDialog();

            pview.PreviewPane.ZoomMode = ZoomModeEnum.PageWidth;
            pview.Document             = MakeDocument();
            pview.ShowDialog();
        }
コード例 #2
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            LoadADO();

            // show the report
            C1PrintPreviewDialog dlg = new C1PrintPreviewDialog();

            dlg.Document = _c1r;
            dlg.ShowDialog();
        }
コード例 #3
0
ファイル: FRCTR.cs プロジェクト: nguyenhoanghai/NurseCall
        private void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                this.conn   = new SqlConnection((this.strConnString == "") ? this.strConnStringDefault : this.strConnString);
                if (this.conn.State == ConnectionState.Closed)
                {
                    this.conn.Open();
                }
                SqlCommand sqlCommand = new SqlCommand("sp_call_detail_view", this.conn);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.Add("@dTimeFrom", SqlDbType.DateTime).Value = this.dateTimePicker1.Value;
                sqlCommand.Parameters.Add("@dTimeTo", SqlDbType.DateTime).Value   = this.dateTimePicker2.Value;
                sqlCommand.Parameters.Add("@iRegionID", SqlDbType.Int).Value      = int.Parse(this.c1Combo1.SelectedValue.ToString());
                sqlCommand.ExecuteNonQuery();
                string fileName = Application.StartupPath + "\\Reports\\ErrorsbyRegion.xml";
                this.c1Report1.Load(fileName, "ErrorsbyRegion");
                this.c1Report1.DataSource.ConnectionString = this.GetStringConnectFull();
                this.c1Report1.DataSource.RecordSource     = "v_call_detail_view";
                this.c1Report1.Fields["Field6"].Subreport.DataSource.ConnectionString = this.GetStringConnectFull();
                this.c1Report1.Fields["Field6"].Subreport.DataSource.RecordSource     = "v_call_detail_view";
                if (this.dateTimePicker1.Value.ToString("dd/MM/yyyy") != this.dateTimePicker2.Value.ToString("dd/MM/yyyy"))
                {
                    this.c1Report1.Fields["DateFromTo"].Text = "Từ ngày: " + this.dateTimePicker1.Value.ToString("dd/MM/yyyy") + " đến ngày: " + this.dateTimePicker2.Value.ToString("dd/MM/yyyy");
                }
                else
                {
                    this.c1Report1.Fields["DateFromTo"].Text = "Ngày: " + this.dateTimePicker1.Value.ToString("dd/MM/yyyy");
                }

                using (C1PrintPreviewDialog c1PrintPreviewDialog = new C1PrintPreviewDialog())
                {
                    c1PrintPreviewDialog.Document = this.c1Report1;
                    c1PrintPreviewDialog.PrintPreviewControl.PreviewNavigationPanel.Visible = false;
                    c1PrintPreviewDialog.PrintPreviewControl.ToolBars.File.Open.Visible     = false;
                    c1PrintPreviewDialog.PrintPreviewControl.ToolBars.File.Save.Visible     = true;
                    c1PrintPreviewDialog.Text = Properties.Resources.CallbyTime;
                    c1PrintPreviewDialog.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "okButton_Click");
            }
            finally
            {
                this.Cursor = Cursors.Default;
                if (this.conn.State == ConnectionState.Open)
                {
                    this.conn.Close();
                }
                base.Close();
            }
        }
コード例 #4
0
        private void _btnC1Show_Click(object sender, System.EventArgs e)
        {
            Sort();

            // show report
            C1PrintPreviewDialog p = new C1PrintPreviewDialog();

            ((Form)p).Text = "Report sorted by " + _list.Text;
            p.Document     = _c1r;
            p.ShowDialog();
        }
コード例 #5
0
ファイル: FRCTO.cs プロジェクト: nguyenhoanghai/NurseCall
 private void okButton_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         this.conn   = new SqlConnection((this.strConnString == "") ? this.strConnStringDefault : this.strConnString);
         if (this.conn.State == ConnectionState.Closed)
         {
             this.conn.Open();
         }
         SqlCommand sqlCommand = new SqlCommand("sp_call_wait_over", this.conn);
         sqlCommand.CommandType = CommandType.StoredProcedure;
         sqlCommand.Parameters.Add("@dTimeFrom", SqlDbType.DateTime).Value = this.dateTimePicker1.Value;
         sqlCommand.Parameters.Add("@dTimeTo", SqlDbType.DateTime).Value   = this.dateTimePicker2.Value;
         sqlCommand.Parameters.Add("@TimeInterval", SqlDbType.Int).Value   = int.Parse(this.txtMinus.Text) * 60;
         sqlCommand.ExecuteNonQuery();
         string fileName = Application.StartupPath + "\\Reports\\CallTimeOver.xml";
         this.c1Report1.Load(fileName, "CallTimeOver");
         this.c1Report1.DataSource.ConnectionString = this.GetStringConnectFull();
         this.c1Report1.DataSource.RecordSource     = "v_call_wait_over";
         this.c1Report1.Fields["titleLbl"].Text     = "Danh sách các sự kiện >= " + this.txtMinus.Text + " phút";
         if (this.dateTimePicker1.Value.ToString("dd/MM/yyyy") != this.dateTimePicker2.Value.ToString("dd/MM/yyyy"))
         {
             this.c1Report1.Fields["DateFromTo"].Text = "Từ ngày: " + this.dateTimePicker1.Value.ToString("dd/MM/yyyy") + " đến ngày: " + this.dateTimePicker2.Value.ToString("dd/MM/yyyy");
         }
         else
         {
             this.c1Report1.Fields["DateFromTo"].Text = "Ngày: " + this.dateTimePicker1.Value.ToString("dd/MM/yyyy");
         }
         using (C1PrintPreviewDialog c1PrintPreviewDialog = new C1PrintPreviewDialog())
         {
             c1PrintPreviewDialog.Document = this.c1Report1;
             c1PrintPreviewDialog.PrintPreviewControl.PreviewNavigationPanel.Visible = false;
             c1PrintPreviewDialog.PrintPreviewControl.ToolBars.File.Open.Visible     = false;
             c1PrintPreviewDialog.PrintPreviewControl.ToolBars.File.Save.Visible     = true;
             c1PrintPreviewDialog.Text = Resources.CallWaitOver;
             c1PrintPreviewDialog.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "okButton_Click");
     }
     finally
     {
         this.Cursor = Cursors.Default;
         if (this.conn.State == ConnectionState.Open)
         {
             this.conn.Close();
         }
         base.Close();
     }
 }
コード例 #6
0
        private void c1Button1_Click(object sender, EventArgs e)
        {
            //print preview gauge
            C1PrintPreviewDialog dlg = new C1PrintPreviewDialog();

            dlg.Text = "C1PrintPreview";
            C1PrintDocument doc = new C1PrintDocument();

            doc.StartDoc();
            doc.AllowNonReflowableDocs            = true;
            doc.PageLayout.PageSettings.Landscape = true;
            string date = (weatherData1.Current as DataRowView)["year"].ToString();

            doc.RenderBlockText("Weather Statistics on " + date);
            doc.RenderBlockImage(c1Gauge1.GetImage());
            doc.EndDoc();
            dlg.Document = doc;
            dlg.Show(this.ParentForm);
        }
コード例 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            C1PrintDocument doc = new C1PrintDocument();

            // Add a document header:
            RenderText rtxt = new RenderText("This is a data-bound C1PrintDocument.");

            rtxt.Text                += "\rThe RenderTable below is a crosstab, it has product categories in the column headers, years in the row headers, and total amounts of sales for that category and year in the table cells.";
            rtxt.Text                += "\rJust to spice things up, sales amounts of $75,000 and above are highlighted.";
            rtxt.Style.FontSize      += 2;
            rtxt.Style.FontItalic     = true;
            rtxt.Style.Spacing.Bottom = "1cm";
            doc.Body.Children.Add(rtxt);

            // Create data source for data binding the document:
            DataSource ds = new DataSource();

            ds.ConnectionProperties.DataProvider  = DataProviderEnum.OLEDB;
            ds.ConnectionProperties.ConnectString = GetConnectionString();
            doc.DataSchema.DataSources.Add(ds);

            // Create Categories data set - this will be used for column headers:
            C1.C1Preview.DataBinding.DataSet dCategories = new C1.C1Preview.DataBinding.DataSet();
            dCategories.Name              = "Categories";
            dCategories.Query.DataSource  = ds;
            dCategories.Query.CommandText =
                @"SELECT DISTINCTROW Categories.CategoryID, Categories.CategoryName " +
                "  FROM Categories INNER JOIN (Products INNER JOIN (Orders INNER JOIN [Order Details Extended] ON Orders.OrderID = [Order Details Extended].OrderID) ON Products.ProductID = [Order Details Extended].ProductID) ON Categories.CategoryID = Products.CategoryID " +
                " ORDER BY Categories.CategoryName";
            doc.DataSchema.DataSets.Add(dCategories);

            // Create Years data set - this will be used for row headers:
            C1.C1Preview.DataBinding.DataSet dYears = new C1.C1Preview.DataBinding.DataSet();
            dYears.Query.DataSource  = ds;
            dYears.Name              = "Years";
            dYears.Query.CommandText =
                @"SELECT DISTINCT Year(OrderDate) as Y " +
                " FROM Categories INNER JOIN (Products INNER JOIN (Orders INNER JOIN [Order Details Extended] ON Orders.OrderID = [Order Details Extended].OrderID) ON Products.ProductID = [Order Details Extended].ProductID) ON Categories.CategoryID = Products.CategoryID " +
                " ORDER BY 1";
            doc.DataSchema.DataSets.Add(dYears);

            // Create a RenderTable that will have categories in column headers,
            // years in row headers, and total order amounts (sums) in cells:
            RenderTable rt = new RenderTable();

            rt.Style.GridLines.All = LineDef.Default;
            // Bind row 0 to dYears data source - this will create a row for each year:
            rt.RowGroups[1, 1].DataBinding.DataSource = dYears;
            // Bind column 0 to dCategories data source - this will create a column for each category:
            rt.ColGroups[1, 1].DataBinding.DataSource = dCategories;
            // Set up cells in row 0 and column 0 (data-bound) to show category and year:
            rt.Cells[0, 1].Text = "[Fields!CategoryName.Value]";
            rt.Cells[1, 0].Text = "[Fields!Y.Value]";
            // To show just plain text:
            // rt.Cells[1, 1].Text = "[Document.UserData.CalcSum(ColFields!CategoryID.Value, RowFields!Y.Value)]";
            // ...but we really want it formatted as currency:
            rt.Cells[1, 1].Text = "[string.Format(\"{0:C}\",Document.UserData.CalcSum(ColFields!CategoryID.Value, RowFields!Y.Value))]";
            // Highlight cells with totals above $75,000:
            rt.Cells[1, 1].Style.BackColorExpr = "iif(Document.UserData.CalcSum(ColFields!CategoryID.Value, RowFields!Y.Value)>75000, Color.Yellow, Color.Transparent)";
            // Add the table to the document:
            doc.Body.Children.Add(rt);

            // Create the "summary calculator" and assign it to UserData on the document -
            // this will be available to scripting and used by rt.Cells[1,1].Text expression above:
            doc.UserData = new AggCalc();

            //*** Functionaly, we're done, code below just adds some visual niceties ***

            // Adjust visual properties of the table:
            // auto-size columns, allow table to split horizontally:
            rt.SplitHorzBehavior = SplitBehaviorEnum.SplitIfNeeded;
            rt.Width             = "auto";
            rt.ColumnSizingMode  = TableSizingModeEnum.Auto;
            // Set up repeating row and column headers:
            rt.RowGroups[0, 1].Header          = TableHeaderEnum.All;
            rt.ColGroups[0, 1].Header          = TableHeaderEnum.All;
            rt.RowGroups[0, 1].Style.BackColor = Color.Cornsilk;
            rt.ColGroups[0, 1].Style.BackColor = Color.Cornsilk;
            // Right-align sums:
            rt.Cells[1, 1].Style.TextAlignHorz = AlignHorzEnum.Right;
            // Add some padding:
            rt.CellStyle.Padding.All = "1mm";

            // Done, show the document:
            using (C1PrintPreviewDialog d = new C1PrintPreviewDialog())
            {
                d.Document = doc;
                d.ShowDialog();
            }
        }