Esempio n. 1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (radGridView.Rows.Count == 0)
            {
                return;
            }
            try
            {
                this.Cursor = Cursors.WaitCursor;
                Njit.Program.FastReportExtensions.Forms.PrintPreview form = new Njit.Program.FastReportExtensions.Forms.PrintPreview(Setting.Program.ThisProgram.GetReportPath("Report.frx"), Njit.Program.FastReportExtensions.Forms.PrintPreview.PrintSizes.A4, null, 1);
                form.ReportDocument.SetParameterValue("CompanyName", Setting.Archive.ThisProgram.LoadedArchiveSettings.OrganName);
                form.ReportDocument.SetParameterValue("ReportPrintDate", Njit.Common.PersianCalendar.GetDate(DateTime.Now));
                form.ReportDocument.SetParameterValue("ReportPrintTime", Njit.Common.PersianCalendar.GetTime());
                Njit.Program.Forms.GetValue f = new Njit.Program.Forms.GetValue("دریافت عنوان", "عنوان گزارش را وارد کنید:");
                if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    form.ReportDocument.SetParameterValue("Title", f.Value);
                }
                FastReport.ReportPage page     = form.ReportDocument.Pages[0] as FastReport.ReportPage;
                FastReport.DataBand   databand = page.Bands[0] as FastReport.DataBand;
                float width = databand.Width;
                foreach (var item in radGridView.Columns)
                {
                    FastReport.TextObject bandText = new FastReport.TextObject();
                    bandText.CreateUniqueName();
                    bandText.HorzAlign = FastReport.HorzAlign.Center;
                    int currentWidth = item.Width;
                    bandText.Bounds       = new RectangleF(width - currentWidth, 0.0f, currentWidth, databand.Height);
                    bandText.Border.Lines = FastReport.BorderLines.All;
                    //bandText.AutoWidth = true;
                    bandText.RightToLeft = true;
                    bandText.Font        = new System.Drawing.Font("B Nazanin", 9);
                    bandText.Text        = "[ReportData." + item.Name + "]";
                    databand.AddChild(bandText);
                    width -= item.Width;// bandText.CalcWidth();
                }

                //databand.AfterLayout += databand_AfterLayout;
                DataTable dt = (radGridView.DataSource as DataTable).Clone();
                dt.Rows.InsertAt(dt.NewRow(), 0);
                GetColumnsHeaders(dt.Rows[0]);
                foreach (DataRow row in (radGridView.DataSource as DataTable).Rows)
                {
                    dt.Rows.Add(row.ItemArray);
                }
                form.ReportDocument.RegisterData(dt, "ReportData");
                form.ReportDocument.GetDataSource("ReportData").Enabled = true;
                databand.DataSource = form.ReportDocument.GetDataSource("ReportData");
                form.ShowDialog(this);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 2
0
        private Form GetForm(Type type)
        {
            Form form;

            if (formsObject.ContainsKey(type.FullName))
            {
                form = formsObject[type.FullName];
            }
            else
            {
                if (TypeHaveParameterLessConstructor(type))
                {
                    form = (Form)Activator.CreateInstance(type);
                }
                else
                {
                    ConstructorInfo firstConstructor      = type.GetConstructors()[0];
                    ParameterInfo[] constructorParameters = firstConstructor.GetParameters();
                    List <object>   args = new List <object>(constructorParameters.Length);
                    foreach (var parameter in constructorParameters)
                    {
                        Njit.Program.Forms.GetValue getParameterForm = new Njit.Program.Forms.GetValue("مقدار دهی پارامتر " + parameter.Name, "پارامتر " + parameter.Name + " سازنده فرم " + type.Name + " را وارد کنید", GetDefaultValue(parameter.ParameterType));
                        getParameterForm.ShowDialog();
                        if (parametersValues.ContainsKey(parameter))
                        {
                            args.Add(parametersValues[parameter]);
                        }
                        else
                        {
                            object convertedVaue = getParameterForm.Value == "NULL" ? null : getParameterForm.Value;
                            Njit.Common.PublicMethods.ConvertValue(getParameterForm.Value, ref convertedVaue, parameter.ParameterType);
                            args.Add(convertedVaue);
                            parametersValues.Add(parameter, convertedVaue);
                        }
                    }
                    try
                    {
                        form = (Form)Activator.CreateInstance(type, args.ToArray());
                    }
                    catch (Exception ex)
                    {
                        PersianMessageBox.Show(this, "خطا در ایجاد شی از فرم\r\n" + type.Name + "\r\n\r\n" + ex.Message);
                        form = null;
                    }
                }
                formsObject.Add(type.FullName, form);
            }
            return(form);
        }
Esempio n. 3
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            string name;

            using (Njit.Program.Forms.GetValue f = new Njit.Program.Forms.GetValue("نام گزارش", "نام گزارش را وارد کنید"))
            {
                if (savedReportsListBox.SelectedIndex > 0)
                {
                    f.Value = savedReportsListBox.SelectedItem.ToString();
                }
                if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    name = f.Value;
                }
                else
                {
                    return;
                }
            }

            Model.Archive.Report report = null;
            try
            {
                List <SearchField> searchFields = new List <SearchField>();
                AddToSearchFields(searchFields, queryTreeView.Nodes);
                List <Model.Archive.ArchiveField> displayFields = new List <Model.Archive.ArchiveField>();
                AddToDisplayFields(displayFields, dossierFieldsTreeView.Nodes);
                AddToDisplayFields(displayFields, documentsFieldsTreeView.Nodes);
                report = Controller.Archive.ReportController.AddReport(name, searchFields, displayFields);
            }
            catch (Exception ex)
            {
                PersianMessageBox.Show(this, "خطا در ثبت اطلاعات" + "\r\n\r\n" + ex.Message);
                return;
            }
            RefreshReports(report.ID);
        }