예제 #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            ItemsReport rpt = new ItemsReport();

            rpt.Site = this.Site;
            return(rpt);
        }
        private void dataGridView_displayitems_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                var            dt        = new DataTable();
                var            UsedClass = new BasicClass();
                var            crp       = new Reports.ItemsReport();
                var            form      = new PrintForm();
                string         itemName  = dataGridView_displayitems.Rows[e.RowIndex].Cells["ColumnItemName"].Value.ToString();
                SqlParameter[] param     = new SqlParameter[3];
                param[0] = new SqlParameter("@ItemName", SqlDbType.NVarChar, 250);
                param[1] = new SqlParameter("@InvoiceType", SqlDbType.NVarChar, 250);
                param[2] = new SqlParameter("@InvoiceSatus", SqlDbType.NVarChar, 250);
                TextObject invoiceType    = (TextObject)crp.ReportDefinition.Sections["Section1"].ReportObjects["Text11"];
                TextObject itemNameHeader = (TextObject)crp.ReportDefinition.Sections["Section1"].ReportObjects["Text17"];
                switch (e.ColumnIndex)
                {
                case 0:      //Purshace Invoices
                    param[0].Value = itemName;
                    param[1].Value = "شراء";
                    param[2].Value = "Run";
                    dt             = UsedClass.selectdata("Report_Select_items_using_itemName_and_InvoiceType", param);
                    if (dt.Rows.Count > 0)
                    {
                        invoiceType.Text    = "قائمة مشتريات";
                        itemNameHeader.Text = itemName;
                        crp.SetDataSource(dt);
                        form.crystalReportViewer1.ReportSource = crp;
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("لا توجد بيانات لعرضها", "MESSAGE");
                    }
                    break;

                case 1:     //Sale Invoices
                    param[0].Value = itemName;
                    param[1].Value = "بيع";
                    param[2].Value = "Run";
                    dt             = UsedClass.selectdata("Report_Select_items_using_itemName_and_InvoiceType", param);
                    if (dt.Rows.Count > 0)
                    {
                        invoiceType.Text    = "قائمة مبيعات";
                        itemNameHeader.Text = itemName;
                        crp.SetDataSource(dt);
                        form.crystalReportViewer1.ReportSource = crp;
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("لا توجد بيانات لعرضها", "MESSAGE");
                    }
                    break;

                case 2:     //Save Invoices
                    param[0].Value = itemName;
                    param[1].Value = "بيع";
                    param[2].Value = "SAVE";
                    dt             = UsedClass.selectdata("Report_Select_items_using_itemName_and_InvoiceType", param);
                    if (dt.Rows.Count > 0)
                    {
                        invoiceType.Text    = "قائمة مبيعات";
                        itemNameHeader.Text = itemName;
                        crp.SetDataSource(dt);
                        form.crystalReportViewer1.ReportSource = crp;
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("لا توجد بيانات لعرضها", "MESSAGE");
                    }
                    break;

                case 3:
                    param[0].Value = itemName;
                    param[1].Value = "شراء";
                    param[2].Value = "SAVE";
                    dt             = UsedClass.selectdata("Report_Select_items_using_itemName_and_InvoiceType", param);
                    if (dt.Rows.Count > 0)
                    {
                        invoiceType.Text    = "قائمة مبيعات";
                        itemNameHeader.Text = itemName;
                        crp.SetDataSource(dt);
                        form.crystalReportViewer1.ReportSource = crp;
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("لا توجد بيانات لعرضها", "MESSAGE");
                    }
                    break;

                default:
                    break;
                }
            }
        }