نظرات مطالب
ویدیوهای آموزشی QT
پسورد نداره. یا ناقص دریافت کردید یا از برنامه 7-zip برای باز کردن استفاده نکردید. مورد اول بیشتر محتمل است.
نظرات مطالب
چک لیست نصب SQL Server
سلام

خیلی مطلب خوب و مفیدی بود آقای نصیری، خصوصا موارد 2 و 6 و 7 جالب و آموزنده بودند.
بازخوردهای پروژه‌ها
مشکل عمل نکردن فونت فارسی
سلام
باتشکر از شما
آقای نصیری بنده برای راحتی استفاده در برنامه یک کلاس استاتیک بصورت زیر تعریف کرده ام :
  public static class ReportMethod
    {
        static FontSelector fontSelector = new FontSelector();
        const char RightToLeftEmbedding = (char)PersianDate.RightToLeftEmbedding;
        const char PopDirectionalFormatting = (char)PersianDate.PopDirectionalFormatting;
        public static Dictionary<string, string> fontDicBody = new Dictionary<string, string> { { "BMitra", "B Mitra" }, { "tahoma", "tahoma" } };
        public static Dictionary<string, string> fontDicHeader1 = new Dictionary<string, string> { { "BMitraBd", "B Mitra Bold" }, { "tahoma", "tahoma" } };
        public static Dictionary<string, string> fontDicHeader2 = new Dictionary<string, string> { { "BTitrBd", "B Titr Bold" }, { "tahoma", "tahoma" } };
        public static Dictionary<string, string> fontDicFooter = new Dictionary<string, string> { { "BMitra", "B Mitra" }, { "tahoma", "tahoma" } };

        public static string FixWeakCharacters(string data)
        {
            if (string.IsNullOrWhiteSpace(data))
                return string.Empty;
            var weakCharacters = new[] { @"\", "/", "+", "-", "=", ";", "$" };
            foreach (var weakCharacter in weakCharacters)
            {
                data = data.Replace(weakCharacter, RightToLeftEmbedding + weakCharacter + PopDirectionalFormatting);
            }
            return data;
        }

        public static Phrase SetFont(string data, int fontType)
        {
            Dictionary<string, string> fontDic;
            float fontSize = 11;
            switch (fontType)
            {
                case 0:
                    fontDic = fontDicBody;
                    fontSize = 11;
                    break;
                case 1:
                    fontDic = fontDicHeader1;
                    fontSize = 14;
                    break;
                case 2:
                    fontDic = fontDicFooter;
                    fontSize = 12;
                    break;
                case 11:
                    fontDic = fontDicHeader2;
                    fontSize = 18;
                    break;
                default:
                    fontDic = fontDicBody;
                    fontSize = 11;
                    break;
            }
            foreach (var item in fontDic)
            {
                FontFactory.Register("c:\\windows\\fonts\\" + item.Key + ".ttf");
                Font newfont = FontFactory.GetFont(item.Value, BaseFont.IDENTITY_H, fontSize);
                if (newfont.Familyname != "unknown")
                    fontSelector.AddFont(newfont);
            }
            return fontSelector.Process(FixWeakCharacters(data));
        }

        public static PdfPCell SetCell(string text, int border, int colspan, int Horizontal, int Vertical, bool DirectionRTL, int fontType = 0)
        {
            if (DirectionRTL)
            {
                var cell = new PdfPCell { RunDirection = PdfWriter.RUN_DIRECTION_RTL };
                cell.Border = border;
                cell.Colspan = colspan;
                cell.HorizontalAlignment = Horizontal;
                cell.VerticalAlignment = Vertical;
                cell.Phrase = new Phrase(ReportMethod.SetFont(text, fontType));
                return cell;
            }
            else
            {
                var cell = new PdfPCell();
                cell.Border = border;
                cell.Colspan = colspan;
                cell.HorizontalAlignment = Horizontal;
                cell.VerticalAlignment = Vertical;
                cell.Phrase = new Phrase(ReportMethod.SetFont(text, fontType));
                return cell;
            }
        }
    }
که این کلاس برای ایجاد سلول با فونت مورد نظر من معرفی شده است
و کد گزارش من به صورت زیر تعریف شده است :
    public IPdfReportData CreatePdfReport_SRptTeach(int MemberID, List<sp_Teach_Communicate_Select_ReportTeachResult> Teach_Result, string st, List<sp_Institute_Center_Info_Select_Name_MasterResult> Info)
        {
            string fileName = string.Format("SRptTeach-{0}.pdf", Guid.NewGuid().ToString("N"));            
            return new PdfReport()
                                  .DocumentPreferences(doc =>
                                  {
                                      doc.RunDirection(PdfRunDirection.RightToLeft);
                                      doc.Orientation(PageOrientation.Landscape);
                                      doc.PageSize(PdfPageSize.A4);
                                      doc.DocumentMetadata(new DocumentMetadata { Author = Info[0].InstName, Application = "PdfRpt", Keywords = "گزارش", Subject = "گزارش ویژه", Title = "گزارش کارکرد مدرسید" });
                                      doc.Compression(new CompressionSettings
                                      {
                                          EnableCompression = true,
                                          EnableFullCompression = true
                                      });
                                      doc.PrintingPreferences(new PrintingPreferences
                                      {
                                          ShowPrintDialogAutomatically = false
                                      });
                                  })
                                  .DefaultFonts(fonts =>
                                  {
                                      fonts.Path(System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\" + ReportMethod.fontDicBody.ElementAt(0).Key + ".ttf"),
                                          System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\" + ReportMethod.fontDicBody.ElementAt(1).Key + ".ttf"));
                                      fonts.Size(11);
                                      fonts.Color(System.Drawing.Color.Black);
                                  })
                                  .PagesFooter(footer =>
                                  {
                                      footer.CustomFooter(new CustomFooter(footer.PdfFont, PdfRunDirection.RightToLeft));
                                  })
                                  .PagesHeader(header =>
                                  {
                                      header.CustomHeader(new CustomHeader_SRptTeach(MemberID, st, Info));
                                  })
                                  .MainTableTemplate(template =>
                                  {
                                      //template.BasicTemplate(BasicTemplate.SimpleTemplate);
                                      template.CustomTemplate(new TransparentTemplate());
                                  })
                                  .MainTablePreferences(table =>
                                  {
                                      table.ColumnsWidthsType(TableColumnWidthType.Relative);
                                      table.GroupsPreferences(new GroupsPreferences
                                      {
                                          GroupType = GroupType.IncludeGroupingColumns,
                                          RepeatHeaderRowPerGroup = true,
                                          ShowOneGroupPerPage = false,
                                          SpacingBeforeAllGroupsSummary = 5f,
                                          ShowGroupingPropertiesInAllRows = true
                                      });
                                  })
                                  .MainTableDataSource(dataSource =>
                                  {
                                      dataSource.StronglyTypedList<sp_Teach_Communicate_Select_ReportTeachResult>(Teach_Result);
                                  })
                                  .MainTableSummarySettings(summarySettings =>
                                  {
                                      summarySettings.OverallSummarySettings("جمع مبالغ");
                                      summarySettings.AllGroupsSummarySettings("جمع کل مبالغ");
                                  })
                                  .MainTableColumns(columns =>
                                  {
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.RowNo);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(0);
                                          column.Width(4);
                                          column.HeaderCell("ردیف");
                                      });

                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.ParentName);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(1);
                                          column.Width(5);
                                          column.HeaderCell("مرکز");
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.FullName);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(2);
                                          column.Width(12);
                                          column.HeaderCell("نام و نام خانوادگی");
                                          column.Group(true,
                                              (val1, val2) =>
                                              {
                                                  return val1.ToString() == val2.ToString();
                                              });
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.TermInfoName);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(3);
                                          column.Width(8);
                                          column.HeaderCell("ترم");
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.Contract_NO);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(4);
                                          column.Width(7);
                                          column.HeaderCell("شماره قرارداد");
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.LessonFullCode);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(5);
                                          column.Width(4);
                                          column.HeaderCell("کد درس");
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.LessonName);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(6);
                                          column.Width(10);
                                          column.HeaderCell("نام درس");
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.Start_Date_Lesson);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(7);
                                          column.Width(6);
                                          column.HeaderCell("تاریخ شروع");
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.End_Date_Lesson);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(8);
                                          column.Width(6);
                                          column.HeaderCell("تاریخ پایان");
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.TeachAmount);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(9);
                                          column.Width(6);
                                          column.HeaderCell("مبلغ حق التدریس(ریال)");
                                          column.ColumnItemsTemplate(template =>
                                          {
                                              template.TextBlock();
                                              template.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                                          });
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.DoTeacherTime);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(10);
                                          column.Width(3);
                                          column.HeaderCell("ساعت کارکرد");
                                          column.ColumnItemsTemplate(template =>
                                          {
                                              template.TextBlock();
                                              template.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                                          });
                                          column.AggregateFunction(aggregateFunction =>
                                          {
                                              aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                                              aggregateFunction.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                                          });
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName("CanPay");
                                          column.CalculatedField(true,
                                              list =>
                                              {
                                                  if (list == null)
                                                      return string.Empty;
                                                  var amount = list.GetSafeStringValueOf<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.TeachAmount);
                                                  var doTime = list.GetSafeStringValueOf<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.DoTeacherTime);
                                                  var result = float.Parse(amount) * float.Parse(doTime);
                                                  return Convert.ToDecimal(result);
                                              });
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(11);
                                          column.Width(7);
                                          column.HeaderCell("قابل پرداخت(ریال)");
                                          column.ColumnItemsTemplate(template =>
                                          {
                                              template.TextBlock();
                                              template.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                                          });
                                          column.AggregateFunction(aggregateFunction =>
                                          {
                                              aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                                              aggregateFunction.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                                          });
                                      });
                                      columns.AddColumn(column =>
                                      {
                                          column.PropertyName<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.Personal_Education);
                                          column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                          column.IsVisible(true);
                                          column.Order(12);
                                          column.Width(6);
                                          column.HeaderCell("مدرک تحصیلی");
                                      });
                                      //columns.AddColumn(column =>
                                      //{
                                      //    column.PropertyName("Descriptions");
                                      //    column.CalculatedField(true,
                                      //        list =>
                                      //        {
                                      //            if (list == null)
                                      //                return string.Empty;
                                      //            var Row = list.GetSafeStringValueOf<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.RowNoPerson);
                                      //            return "";
                                      //        });
                                      //    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                                      //    column.IsVisible(true);
                                      //    column.Order(13);
                                      //    column.Width(3);
                                      //    column.HeaderCell("توضیحات");
                                      //});
                                  })
                                  .MainTableEvents(events =>
                                  {
                                      events.DataSourceIsEmpty(message: "اطلاعاتی برای نمایش وجود ندارد.");
                                      events.DocumentClosing(docClose =>
                                      {
                                          string[] msgField = { "مدیر گروه", Info.Where(sp => sp.ID == MemberID).FirstOrDefault().InstKindName, Info.Where(sp => sp.ID == 0).FirstOrDefault().InstKindName, "امور مالی", "معاون پشتیبانی" };
                                          string[] dataField = { "", Info.Where(sp => sp.ID == MemberID).FirstOrDefault().MasterName, Info.Where(sp => sp.ID == 0).FirstOrDefault().MasterName, "", Info.Where(sp => sp.ID == 1).FirstOrDefault().MasterName };
                                          var infoTable = new PdfGrid(msgField.Length) { RunDirection = PdfWriter.RUN_DIRECTION_RTL, WidthPercentage = 100 };
                                          foreach (var item in msgField)
                                          {
                                              infoTable.AddCell(ReportMethod.SetCell(item, PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_MIDDLE, true));
                                          }
                                          foreach (var item in dataField)
                                          {
                                              infoTable.AddCell(ReportMethod.SetCell(item, PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_MIDDLE, true));
                                          }
                                          docClose.PdfDoc.Add(infoTable);
                                      });
                                  })
                                  .Export(export =>
                                  {
                                      export.ToExcel();
                                      export.ToCsv();
                                      export.ToXml();
                                      export.ToString();
                                  })
                                  .Generate(data =>
                                  {
                                      fileName = HttpUtility.UrlEncode(fileName, Encoding.UTF8);
                                      data.FlushInBrowser(fileName, FlushType.Inline);
                                  });
            //.Generate(data => data.AsPdfFile(string.Format("{0}\\PlansPage\\RptIListSample-{1}.pdf", AppPath.ApplicationPath, Guid.NewGuid().ToString("N"))));
        }
و قسمت هدر گزارش به صورت سفارشی به صورت زیر معرفی شده است :
namespace Academy.Control.Reports
{
    public class CustomHeader_SRptTeach : IPageHeader
    {
        public IPdfFont PdfRptFont { set; get; }
        string st;
        List<sp_Institute_Center_Info_Select_Name_MasterResult> Info;
        int MemberID;

        public CustomHeader_SRptTeach(int MemberID, string st, List<sp_Institute_Center_Info_Select_Name_MasterResult> Info)
        {
            this.st = st;
            this.Info = Info;
            this.MemberID = MemberID;
        }

        public PdfGrid RenderingGroupHeader(Document pdfDoc, PdfWriter pdfWriter, IList<CellData> rowdata, IList<SummaryCellData> summaryData)
        {
            // return null;
            var groupFullName = rowdata.GetSafeStringValueOf<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.FullName);
            var groupPersonalEducation = rowdata.GetSafeStringValueOf<sp_Teach_Communicate_Select_ReportTeachResult>(x => x.Personal_Education);

            var table = new PdfGrid(2) { WidthPercentage = 100 };
            table.AddSimpleRow(
                (cellData, cellProperties) =>
                {
                    cellData.Value = "نام و نام خانوادگی:";
                    cellProperties.PdfFont = PdfRptFont;
                    cellProperties.PdfFontStyle = DocumentFontStyle.Bold;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                },
                (cellData, cellProperties) =>
                {
                    cellData.Value = groupFullName;
                    cellProperties.PdfFont = PdfRptFont;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
                {
                    cellData.Value = "مدرک تحصیلی :";
                    cellProperties.PdfFont = PdfRptFont;
                    cellProperties.PdfFontStyle = DocumentFontStyle.Bold;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                },
                (cellData, cellProperties) =>
                {
                    cellData.Value = groupPersonalEducation;
                    cellProperties.PdfFont = PdfRptFont;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                });
            return table.AddBorderToTable(borderColor: BaseColor.LIGHT_GRAY, spacingBefore: 10f);

        }    

        public PdfGrid RenderingReportHeader(Document pdfDoc, PdfWriter pdfWriter, IList<SummaryCellData> summaryData)
        {
            var tableMain = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_RTL, WidthPercentage = 100 };
            tableMain.DefaultCell.Border = PdfPCell.NO_BORDER;
            PdfGrid table = new PdfGrid(3);
            table.DefaultCell.Border = PdfPCell.NO_BORDER;

            table.AddCell(ReportMethod.SetCell("", PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_MIDDLE, false));
            table.AddCell(ReportMethod.SetCell("گزارش کارکرد مدرسین ", PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_MIDDLE, true,11));
            PdfPTable tbRight = new PdfPTable(1) { RunDirection = PdfWriter.RUN_DIRECTION_RTL };
            tbRight.DefaultCell.Border = PdfPCell.NO_BORDER;

            Image _image = Image.GetInstance(System.IO.Path.Combine(AppPath.ApplicationPath, "Content\\Images\\p_jahad2.jpg"));
            var cellImg = new PdfPCell(_image, false) { Border = PdfPCell.NO_BORDER };
            cellImg.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            tbRight.AddCell(cellImg);
            tbRight.AddCell(ReportMethod.SetCell(Info[0].InstName, PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_MIDDLE, false,1));
            tbRight.AddCell(ReportMethod.SetCell(Info.Where(sp => sp.ID == MemberID).FirstOrDefault().SecondName, PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_MIDDLE, false,1));
            table.AddCell(tbRight);

            PdfGrid tbLeft = new PdfGrid(2) { RunDirection = PdfWriter.RUN_DIRECTION_RTL };
            tbLeft.DefaultCell.Border = PdfPCell.NO_BORDER;
            tbLeft.AddCell(ReportMethod.SetCell("تاریخ گزارش : " + System.DateTime.Now.ToPersianDateTime("/", false), PdfPCell.NO_BORDER, 2, PdfPCell.ALIGN_LEFT, PdfPCell.ALIGN_MIDDLE, false));
            tbLeft.AddCell(ReportMethod.SetCell("از تاریخ " + st.Split(';')[0], PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_LEFT, PdfPCell.ALIGN_MIDDLE, false));
            tbLeft.AddCell(ReportMethod.SetCell("تا تاریخ " + st.Split(';')[1], PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_LEFT, PdfPCell.ALIGN_MIDDLE, false));

            table.AddCell(tbLeft);
            table.AddCell(ReportMethod.SetCell("", PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_MIDDLE, false));
            table.AddCell(ReportMethod.SetCell("", PdfPCell.NO_BORDER, 1, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_MIDDLE, false));
            tableMain.AddCell(table);
            return tableMain;
        }
    }
}
حالا من دو مشکل دارم که هرچی سعی کردم نتونستم این موارد را رفع کنم و درخواست راهنمایی دارم از شما :
1. فونت هایی که من معرفی کردم برای هدر اصلا اعمال نمی‌شود و همینطور فونت در متن اصلی هم که تغییر میدم باز تغییر ایجاد نمیشه و به نظر میاد اصلا اعمال نمیشه به کل و هدر و متن با یک فونت نمایش داده میشه در صورتی که من فونت‌ها و سایز‌های متفاوتی برای متن‌ها انتخاب میکنم و اعمال میکنم
2. قسمت گروه هدری که من معرفی کردم اصلا کار نمیکنه و نمایش داده نمیشه
ممنون میشم شما من رو راهنمایی کنید 
مثال‌های قبلی رو هم دیدم در مورد فونت و گروه هدر و سعی کردم مثل همون موارد اعمال کنم اما باز اعمال نشد
متشکرم از وقتی که می‌گذارید
اشتراک‌ها
اضافه شدن SHA1 به SQLite 3.17.0

The new sha1(X) function computes the SHA1 hash of the input X, or NULL if X is NULL, while the sha1_query(Y) function evalutes all queries in the SQL statements of Y and returns a hash of their results. 

اضافه شدن SHA1 به SQLite 3.17.0