using System.Data;
private BCE.AutoCount.Report.BaseReport __report;
private void Report_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
__report = Report as BCE.AutoCount.Report.BaseReport;
DataSet ds = (DataSet) Report.DataSource;
DataTable optionTable = ds.Tables["Report Option"];
if (optionTable.Rows[0]["ShowCriteria"].ToString() == "No")
{
PanelCriteria.Visible = false;
}
if (optionTable.Rows[0]["GroupBy"].ToString() == "None")
{
GroupHeader3.Visible = false;
}
new BCE.AutoCount.Report.ReportDrillDown(__report.DBSetting, Report, "DocType", "DocKey", new string[] {"xrLabel24", "xrLabel25", "xrLabel26", "xrLabel27", "xrInOutQty", "xrBalQty", "xrLabel4", "xrLabel31", "xrLabel32", "xrLabel37"});
}
private void Detail1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
decimal inQty = __report.DecimalSetting.RoundQuantity(DetailReport.GetCurrentColumnValue("InQty"));
if (inQty > 0)
xrInOutQty.Text = __report.DecimalSetting.FormatQuantity(inQty);
else
{
decimal outQty = __report.DecimalSetting.RoundQuantity(DetailReport.GetCurrentColumnValue("OutQty"));
xrInOutQty.Text = __report.DecimalSetting.FormatQuantity(outQty);
}
decimal balQty = __report.DecimalSetting.RoundQuantity(DetailReport.GetCurrentColumnValue("Balance"));
if (balQty < 0)
xrBalQty.ForeColor = Color.Red;
else
xrBalQty.ForeColor = Color.Black;
string AAA = DetailReport.GetCurrentColumnValue("DtlKey").ToString();
string ee = DetailReport.GetCurrentColumnValue("DocKey").ToString();
string type= DetailReport.GetCurrentColumnValue("DocType").ToString();
if (type =="IV")
{
xrLabel10.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Pltno from IVDTL WHERE DtlKey=?", AAA).ToString();
xrLabel41.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Rmk1 from IVDTL WHERE DtlKey=?", AAA).ToString();
xrLabel1.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Desc2 from IV WHERE DocKey=?", ee).ToString();
}
else if (type == "PI")
{ xrLabel10.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Pltno from PIDTL WHERE DtlKey=?", AAA).ToString();
xrLabel41.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Rmk1 from PIDTL WHERE DtlKey=?", AAA).ToString();
xrLabel1.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Desc2 from PI WHERE DocKey=?", ee).ToString();
}
else if (type == "DO")
{ xrLabel10.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Pltno from DODTL WHERE DtlKey=?", AAA).ToString();
xrLabel41.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Rmk1 from DODTL WHERE DtlKey=?", AAA).ToString();
xrLabel1.Text = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT UDF_Desc2 from DO WHERE DocKey=?", ee).ToString();
}
else
{ xrLabel10.Text ="";
xrLabel41.Text ="";
xrLabel1.Text ="";
}
}
private void xrLabel3_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
string docType = DetailReport.GetCurrentColumnValue("DocType").ToString();
string dtlKey = DetailReport.GetCurrentColumnValue("DtlKey").ToString();
string fromDocNo = GetTransferFromDocNo(docType, dtlKey);
string toDocNo = GetTransferToDocNo(docType, dtlKey);
(sender as XRLabel).Text = (fromDocNo == "" && toDocNo == "") ? "" :
(fromDocNo == "") ? string.Format("Trf.To: {0}", toDocNo) :
(toDocNo == "") ? string.Format("Trf.From: {0}", fromDocNo) :
string.Format("Trf.From: {0} Trf.To: {1}", fromDocNo, toDocNo);
}
private string GetTransferFromDocNo(string DocType, string DtlKey)
{
string docDtl = "";
string fromDocNo = "";
object oFromDocNo = null;
if (DocType == "DO")
docDtl = "DODTL";
else if (DocType == "IV")
docDtl = "IVDTL";
else if (DocType == "CS")
docDtl = "CSDTL";
else if (DocType == "CN")
docDtl = "CNDTL";
else if (DocType == "DR")
docDtl = "DRDTL";
else if (DocType == "GR")
docDtl = "GRDTL";
else if (DocType == "PI")
docDtl = "PIDTl";
else if (DocType == "PR")
docDtl = "PRDTL";
else if (DocType == "GT")
docDtl = "GTDTL";
else
docDtl = "";
if (docDtl != "")
oFromDocNo = BCE.AutoCount.Application.DBSetting.ExecuteScalar("SELECT FromDocNo FROM " + docDtl + " WHERE DtlKey=?", DtlKey);
if (oFromDocNo != null)
fromDocNo = oFromDocNo.ToString();
return fromDocNo;
}
private string GetTransferToDocNo(string DocType, string DtlKey)
{
string list = "";
if (DocType == "DO")
{
list = GetToDocNoList(list, "IV", DtlKey);
list = GetToDocNoList(list, "DR", DtlKey);
}
else if (DocType == "IV")
{
list = GetToDocNoList(list, "CN", DtlKey);
}
else if (DocType == "CS")
{
list = GetToDocNoList(list, "CN", DtlKey);
}
else if (DocType == "GR")
{
list = GetToDocNoList(list, "PI", DtlKey);
list = GetToDocNoList(list, "GT", DtlKey);
}
else if (DocType == "PI")
{
list = GetToDocNoList(list, "PR", DtlKey);
}
return list;
}
private string GetToDocNoList(string List, string Doc, string DtlKey)
{
string sqlTemp = "select distinct(a.DocNo) from {0} a join {0}dtl b on A.DocKey=B.DocKey where b.fromdocdtlkey=?";
DataTable dtDoc = BCE.AutoCount.Application.DBSetting.GetDataTable(string.Format(sqlTemp, Doc), false, DtlKey);
if (dtDoc == null) return List;
for (int i=0; i