private void Print_EM26() { string strRptPath = ""; string strU_RptNo = ""; string strRptNo = ""; string strRType = lookRType.Text.Trim(); int strBranch_ID = -1; if (lookBranch_ID.Text != "") { strBranch_ID = Convert.ToInt32(lookBranch_ID.EditValue); } RptViewer frmRptViewer = new RptViewer(); ParameterField rptParamField = new ParameterField(); ParameterFields rptParamFields = new ParameterFields(); ParameterDiscreteValue rptParamDiscreteValue = new ParameterDiscreteValue(); ReportDocument rptDocument = new ReportDocument(); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@nComp_ID"; rptParamDiscreteValue.Value = mSys_System.pComp_ID; rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@nBranch_ID"; rptParamDiscreteValue.Value = strBranch_ID.ToString(); rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@dBegDate"; rptParamDiscreteValue.Value = dtpBegDate.EditValue; rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@dEndDate"; rptParamDiscreteValue.Value = dtpEndDate.EditValue; rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@dFYSDate"; rptParamDiscreteValue.Value = mSys_System.pFYSDate.ToShortDateString(); rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@sMainCode"; rptParamDiscreteValue.Value = lookUpEdit1.GetColumnValue("Code"); rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@nU_S"; rptParamDiscreteValue.Value = mSys_System.pUser_ID; rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@sU_Name"; rptParamDiscreteValue.Value = mSys_System.pUserName; rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@sU_RptName"; rptParamDiscreteValue.Value = strRType; rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@sU_Event"; rptParamDiscreteValue.Value = ""; rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); if (strRType == "Complete Account Balance") { rptParamField = new ParameterField(); rptParamDiscreteValue = new ParameterDiscreteValue(); rptParamField.Name = "@sU_RptNo"; rptParamDiscreteValue.Value = "EM26.01"; rptParamField.CurrentValues.Add(rptParamDiscreteValue); rptParamFields.Add(rptParamField); frmRptViewer.Text = lookRType.Text + "..........."; try { strRptPath = Application.StartupPath; strRptPath = strRptPath.Substring(0, strRptPath.Length - 3) + "Reports\\rptAC0101.rpt"; rptDocument.Load(strRptPath); frmRptViewer.Set_ReportConnection(rptDocument); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //---Passing Report Formula's FormulaFieldDefinitions formulaList; formulaList = rptDocument.DataDefinition.FormulaFields; formulaList["CN"].Text = "'" + mSys_System.pCN.ToString().ToUpper() + "'"; formulaList["BranchSName"].Text = "'" + lookBranch_ID.Text + "'"; formulaList["Criteria1"].Text = "'" + strRType + "'"; formulaList["Criteria2"].Text = "'Reporting From " + dtpBegDate.EditValue + " to " + dtpEndDate.EditValue + "'"; formulaList["RPT"].Text = "'EM26.01'"; formulaList["UserName"].Text = "'" + mSys_System.pUserName + "'"; //---Passing Selection formula rptDocument.DataDefinition.RecordSelectionFormula = ""; //---Setting Report to view frmRptViewer.crv.ParameterFieldInfo = rptParamFields; frmRptViewer.crv.ReportSource = rptDocument; frmRptViewer.Show(); return; } }