I have a dynamic report and i put all of my report's components from c#, now i need a component that is sum of a component in the data band in static report i use " {sum(dt.column)} " for value of this component, now for define and use sum function in dynamic report, how can i do?
Code: Select all
private void BtnExtera_zOnClickPrint(EventArgs e)
{
StiReport report = new StiReport();
filllevel();
treestatusname();
FillDocName();
Peresent();
double p = 0;
double width1 = 0;
double width2 = 0;
double width3 = 0;
double width4 = 0;
double width5 = 0;
double width6 = 0;
double q0 = 0;
double q1 = 0;
double q2 = 0;
double q3 = 0;
double q4 = 0;
double q5 = 0;
double columnWidth = 0;
if (rdadvance.IsChecked)
{
if (Rbtn8.IsChecked)
{
if (ChkEft.Checked)
{
if (File.Exists(Manage.ClGlobal.ReportDirAcc + @"\RptAccTaraz2Tahlili.mrt"))
{
report.Load(Manage.ClGlobal.ReportDirAcc + @"\RptAccTaraz2Tahlili.mrt");
((Stimulsoft.Report.Dictionary.StiSqlDatabase)report.Dictionary.Databases[0]).ConnectionString = Manage.ClGlobal.ConnectionStr;
Stimulsoft.Report.Components.StiPageHeaderBand PHdr = new StiPageHeaderBand();
Stimulsoft.Report.Components.StiPageHeaderBand PTitr = new StiPageHeaderBand();
Stimulsoft.Report.Components.StiHeaderBand HdrHeader = new StiHeaderBand();
Stimulsoft.Report.Components.StiHeaderBand Hdrlbl = new StiHeaderBand();
Stimulsoft.Report.Components.StiDataBand DtTaraz = new StiDataBand();
DtTaraz = (Stimulsoft.Report.Components.StiDataBand)report.Pages["PgAccTarazSade2Column"].Components["DtAccTaraz2"];
Hdrlbl = (Stimulsoft.Report.Components.StiHeaderBand)report.Pages["PgAccTarazSade2Column"].Components["Hdrlbl"];
PTitr = (Stimulsoft.Report.Components.StiPageHeaderBand)report.Pages["PgAccTarazSade2Column"].Components["PTitr"];
PHdr = (Stimulsoft.Report.Components.StiPageHeaderBand)report.Pages["PgAccTarazSade2Column"].Components["PHdr"];
HdrHeader = (Stimulsoft.Report.Components.StiHeaderBand)report.Pages["PgAccTarazSade2Column"].Components["HdrHeader"];
((StiText)PHdr.Components["Status2"]).Text = reportstatus;
((StiText)PHdr.Components["Remain"]).Text = peresentText;
((StiText)PHdr.Components["PresentType"]).Text = Rbtn8.Text;
StiPage Page = report.Pages["PgAccTarazSade2Column"];
HdrHeader.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
Hdrlbl.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
((StiText)PTitr.Components["Date"]).Text = Manage.ClGlobal.GetDateServer();
((StiText)PHdr.Components["Doc"]).Text = reportdoc;
//((StiText)PTitr.Components["Date"]).Text = clGlobal.ConvertToShamsi(DateTime.Now);
((StiText)PHdr.Components["Hacc"]).Text = reportlevel;
report.Pages[0].Orientation = Stimulsoft.Report.Components.StiPageOrientation.Landscape;
//Page.SegmentPerWidth = 2;
Page.Components["RecHdrTop"].ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 8.6, Page.Width, .6);
StiEndPointPrimitive end = report.GetComponentByName("EndPointPrimitive3") as StiEndPointPrimitive;
StiStartPointPrimitive start = report.GetComponentByName("StartPointPrimitive3") as StiStartPointPrimitive;
start.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 0, 0, 0);
end.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(Page.Width, .6, 0, 0);
Page.Components["RecHdr"].ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 10, Page.Width, .6);
StiEndPointPrimitive endhdr = report.GetComponentByName("EndPointPrimitive2") as StiEndPointPrimitive;
StiStartPointPrimitive starthdr = report.GetComponentByName("StartPointPrimitive2") as StiStartPointPrimitive;
starthdr.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 0, 0, 0);
endhdr.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(Page.Width, .6, 0, 0);
Page.Components["RecDt"].ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 11.4, Page.Width, .6);
StiEndPointPrimitive endhdrh = report.GetComponentByName("EndPointPrimitive1") as StiEndPointPrimitive;
StiStartPointPrimitive starthdrh = report.GetComponentByName("StartPointPrimitive1") as StiStartPointPrimitive;
starthdrh.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 0, 0, 0);
endhdrh.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(Page.Width, .6, 0, 0);
Page.Width -= 20;
columnWidth = StiAlignValue.AlignToMaxGrid(Page.Width / GrdBase.Columns.Count, .001, true);
Page.Width += 20;
if (RBtnDate.IsChecked)
{
((StiText)PHdr.Components["AzDate"]).Text = txtAzDate.Text;
((StiText)PHdr.Components["TaDate"]).Text = txtTaDate.Text;
((StiText)PHdr.Components["AzDateTxt"]).Enabled = true;
((StiText)PHdr.Components["AzDate"]).Enabled = true;
((StiText)PHdr.Components["TaDateTxt"]).Enabled = true;
((StiText)PHdr.Components["TaDate"]).Enabled = true;
((StiText)PHdr.Components["AzDocTxt"]).Enabled = false;
((StiText)PHdr.Components["AzDoc"]).Enabled = false;
((StiText)PHdr.Components["TaDocTxt"]).Enabled = false;
((StiText)PHdr.Components["TaDoc"]).Enabled = false;
((StiText)PHdr.Components["AzDate2"]).Text = txtAzDate.Text;
((StiText)PHdr.Components["TaDate2"]).Text = txtTaDate.Text;
((StiText)PHdr.Components["AzDateTxt2"]).Enabled = true;
((StiText)PHdr.Components["AzDate2"]).Enabled = true;
((StiText)PHdr.Components["TaDateTxt2"]).Enabled = true;
((StiText)PHdr.Components["TaDate2"]).Enabled = true;
((StiText)PHdr.Components["AzDocTxt2"]).Enabled = false;
((StiText)PHdr.Components["AzDoc2"]).Enabled = false;
((StiText)PHdr.Components["TaDocTxt2"]).Enabled = false;
((StiText)PHdr.Components["TaDoc2"]).Enabled = false;
}
if (RBtnDoc.IsChecked)
{
((StiText)PHdr.Components["AzDoc"]).Text = txtAzDoc.Text;
((StiText)PHdr.Components["TaDoc"]).Text = txtTaDoc.Text;
((StiText)PHdr.Components["AzDateTxt"]).Enabled = false;
((StiText)PHdr.Components["AzDate"]).Enabled = false;
((StiText)PHdr.Components["TaDateTxt"]).Enabled = false;
((StiText)PHdr.Components["TaDate"]).Enabled = false;
((StiText)PHdr.Components["AzDocTxt"]).Enabled = true;
((StiText)PHdr.Components["AzDoc"]).Enabled = true;
((StiText)PHdr.Components["TaDocTxt"]).Enabled = true;
((StiText)PHdr.Components["TaDoc"]).Enabled = true;
((StiText)PHdr.Components["AzDoc2"]).Text = txtAzDoc.Text;
((StiText)PHdr.Components["TaDoc2"]).Text = txtTaDoc.Text;
((StiText)PHdr.Components["AzDateTxt2"]).Enabled = false;
((StiText)PHdr.Components["AzDate2"]).Enabled = false;
((StiText)PHdr.Components["TaDateTxt2"]).Enabled = false;
((StiText)PHdr.Components["TaDate2"]).Enabled = false;
((StiText)PHdr.Components["AzDocTxt2"]).Enabled = true;
((StiText)PHdr.Components["AzDoc2"]).Enabled = true;
((StiText)PHdr.Components["TaDocTxt2"]).Enabled = true;
((StiText)PHdr.Components["TaDoc2"]).Enabled = true;
}
for (int i = 0; i < GrdBase.Columns.Count; i++)
{
//if (GrdBase.Columns[i].Name != "l")
//{
report.Dictionary.DataSources["Taraz"].Columns.Add(GrdBase.Columns[i].Name, typeof(string));
}
double h = 0;
double w = 0;
double x = 0;
double y = 0;
h = Hdrlbl.Height;
y = DtTaraz.Height;
for (int i = 0; i < GrdBase.Columns.Count; i++)
{
string s = GrdBase.Columns[i].Name;
StiText f = new StiText(new RectangleD(0, 0, columnWidth, y));
StiText t = new StiText(new RectangleD(0, 0, columnWidth, h));
if (GrdBase.Columns[i].IsVisible)
{
if ((s == "l1" || s == "l2"))
{
//w = f.Width - 2;
f.Width = 1;
t.Width = 1;
w += f.Width;
}
if (s == "AccName")
{
t.Width = 10;
f.Width = 10;
t.HorAlignment = Stimulsoft.Base.Drawing.StiTextHorAlignment.Center;
f.HorAlignment = StiTextHorAlignment.Left;
}
if (s == "l3" || s == "l4" || s == "l5" || s == "l6")
{
f.Width = 2;
t.Width = 2;
x += f.Width;
}
//if (s == "l1" || s == "l2" || s == "l3" || s == "l4" || s == "l5" || s == "l6")
//{
// q0++;
//}
if (s == "Debit" || s == "Credit" || s == "RemainDebit" || s == "RemainCredit" || s == "BeforDebit" || s == "BeforCredit" || s == "EfDebit" || s == "EfCredit")
{
f.Width = columnWidth + 2;
t.Width = columnWidth + 2;
}
if (s == "AccCode" || s == "AccName")
{
q1 += f.Width;
}
if (s == "Debit" || s == "Credit")
{
q2 += f.Width;
}
if (s == "RemainDebit" || s == "RemainCredit")
{
q3 += f.Width;
}
if (s == "BeforDebit" || s == "BeforCredit")
{
q4 += f.Width;
}
if (s == "EfDebit" || s == "EfCredit")
{
q5 += f.Width;
}
}
t.Enabled = f.Enabled = GrdBase.Columns[i].IsVisible;
t.Text = GrdBase.Columns[i].HeaderText;
t.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
f.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White);
f.Text = "{Taraz." + DtGrid.Columns[i].Caption + "}";
t.VertAlignment = StiVertAlignment.Center;
f.VertAlignment = StiVertAlignment.Center;
if (s != "AccCode" && s != "AccName")
{
t.HorAlignment = StiTextHorAlignment.Left;
f.HorAlignment = StiTextHorAlignment.Left;
}
t.DockStyle = StiDockStyle.Right;
f.DockStyle = StiDockStyle.Right;
if (i == 0)
{
t.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Left, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
f.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Left, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
}
if (i == GrdBase.Columns.Count - 1)
{
t.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Right, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
f.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Right, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
}
if (i != 0 && i != GrdBase.Columns.Count - 1)
{
t.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.All, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
f.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.All, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
}
t.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
f.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
t.Font = clGlobal.FontObj;
f.Font = clGlobal.FontObj;
t.Alias = GrdBase.Columns[i].Name;
f.Alias = GrdBase.Columns[i].Name;
t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");
f.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");
Hdrlbl.Components.Add(t);
DtTaraz.Components.Add(f);
}
for (int i = 0; i < GrdBase.Columns.Count; i++)
{
string s = GrdBase.Columns[i].Name;
}
width1 = w + x;
width2 = q1;
width3 = q2;
width4 = q3;
width5 = q4;
width6 = q5;
h = HdrHeader.Height;
StiText m = new StiText(new RectangleD(0, 0, width1, h));
m.Text = "سطح";
//m.Width=BestFitColumnMode.
m.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
m.VertAlignment = StiVertAlignment.Center;
m.HorAlignment = StiTextHorAlignment.Center;
m.DockStyle = StiDockStyle.Right;
m.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Left, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
m.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
m.Font = clGlobal.FontObj;
m.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");
HdrHeader.Components.Add(m);
StiText n = new StiText(new RectangleD(0, 0, width2, h));
n.Text = "عنوان حساب";
n.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
n.VertAlignment = StiVertAlignment.Center;
n.HorAlignment = StiTextHorAlignment.Center;
n.DockStyle = StiDockStyle.Right;
n.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.All, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
n.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
n.Font = clGlobal.FontObj;
n.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");
HdrHeader.Components.Add(n);
StiText mm = new StiText(new RectangleD(0, 0, width5, h));
mm.Text = "ابتدای دوره";
mm.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
mm.VertAlignment = StiVertAlignment.Center;
mm.HorAlignment = StiTextHorAlignment.Center;
mm.DockStyle = StiDockStyle.Right;
mm.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.All, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
mm.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
mm.Font = clGlobal.FontObj;
mm.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");
HdrHeader.Components.Add(mm);
StiText l = new StiText(new RectangleD(0, 0, width3, h));
l.Text = "گردش";
l.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
l.VertAlignment = StiVertAlignment.Center;
l.HorAlignment = StiTextHorAlignment.Center;
l.DockStyle = StiDockStyle.Right;
l.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.All, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
l.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
l.Font = clGlobal.FontObj;
l.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");
HdrHeader.Components.Add(l);
StiText k = new StiText(new RectangleD(0, 0, width6, h));
k.Text = "مانده از قبل";
k.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
k.VertAlignment = StiVertAlignment.Center;
k.HorAlignment = StiTextHorAlignment.Center;
k.DockStyle = StiDockStyle.Right;
k.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.All, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
k.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
k.Font = clGlobal.FontObj;
k.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");
HdrHeader.Components.Add(k);
StiText q = new StiText(new RectangleD(0, 0, width4, h));
q.Text = "مانده";
q.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
q.VertAlignment = StiVertAlignment.Center;
q.HorAlignment = StiTextHorAlignment.Center;
q.DockStyle = StiDockStyle.Right;
q.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Right, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
q.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
q.Font = clGlobal.FontObj;
q.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");
HdrHeader.Components.Add(q);
}
}
}
}
DataSet ds = new DataSet();
DataTable dtcompanyinfo = new DataTable();
dtcompanyinfo = Manage.ClGlobal.dtCompanyInfo;
dtcompanyinfo.TableName = "DtComanyInfo";
ds.Tables.Add(dtcompanyinfo.Copy());
DtGrid.TableName = "Taraz";
ds.Tables.Add(DtGrid.Copy());
report.Dictionary.Clear();
report.RegData(ds);
report.Dictionary.Synchronize();
if (DtGrid.Rows.Count > 0)
{
report.Show();
}
q0 = 0;
q1 = 0;
q2 = 0;
q3 = 0;
q4 = 0;
q5 = 0;
}