private void btnRptView_Click(object sender, EventArgs e) { //try //{ // //string strRecSelect = null; // ReportDocument objRptDoc = new ReportDocument(); // ConnectionInfo objConInfo = new ConnectionInfo(); // TableLogOnInfo objTableLogOnInfo = new TableLogOnInfo(); // Tables objCrTables; // objRptDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "\\Reports\\rptRetDCDetail.rpt"); // objConInfo.ServerName = GeneralBLL.GetSqlServerPCName(); // objConInfo.DatabaseName = GeneralBLL.GetDatabaseName(); // objConInfo.UserID = GeneralBLL.GetDBUserName(); // objConInfo.Password = GeneralBLL.GetDBPwd(); // objConInfo.IntegratedSecurity = false; // objCrTables = objRptDoc.Database.Tables; // foreach (Table objCrTable in objCrTables) // { // objTableLogOnInfo = objCrTable.LogOnInfo; // objTableLogOnInfo.ConnectionInfo = objConInfo; // objCrTable.ApplyLogOnInfo(objTableLogOnInfo); // } // DateTime mFromDate = Convert.ToDateTime(dtpFromDate.Text); // DateTime mToDate = Convert.ToDateTime(dtpToDate.Text); // //strRecSelect = " Date({RETURNABLEDC.ENTRYDATE})>= #" + mFromDate.ToString("yyyy-MM-dd") + "# And Date({RETURNABLEDC.ENTRYDATE})<= #" + mToDate.ToString("yyyy-MM-dd") + "#"; // //strRecSelect = " Date({RETURNABLEDC.ENTRYDATE})>= @mFromDate And Date({RETURNABLEDC.ENTRYDATE})<= @mToDate "; // //if (cboParty.Text.Trim() != "ALL") // //{ // // //objRptDoc.RecordSelectionFormula = " Date({RETURNABLEDC.ENTRYDATE})>= #" + dtpFromDate.Text + "# And Date({RETURNABLEDC.ENTRYDATE})<= #" + dtpToDate.Text + "# And ({RETURNABLEDC.PARTYNAME}) = '" + cboParty.Text + "'"; // // strRecSelect += " And ({RETURNABLEDC.PARTYNAME}) = '" + cboParty.Text + "'"; // //} // //objRptDoc.RecordSelectionFormula = strRecSelect; // // Start // objRptDoc.ParameterFields.Add("mFromDate"); // objRptDoc.ParameterFields.Add("mToDate"); // objRptDoc.SetParameterValue("mFromDate", mFromDate.ToShortDateString()); // objRptDoc.SetParameterValue("mToDate", mToDate.ToShortDateString()); // if (cboParty.Text.Trim() != "ALL") // { // objRptDoc.ParameterFields.Add("mParty"); // objRptDoc.SetParameterValue("mParty", cboParty.Text); // } // // End // frmReportViewer objFrmRpt = new frmReportViewer(); // objFrmRpt.crystalReportViewer1.ReportSource = objRptDoc; // objFrmRpt.MdiParent = this.MdiParent; // objFrmRpt.WindowState = FormWindowState.Maximized; // objFrmRpt.crystalReportViewer1.Refresh(); // objFrmRpt.Show(); // //objRpt.crystalReportViewer1.ReportSource = objRptDoc; // //objRpt.MdiParent = this.MdiParent; // //objRpt.WindowState = FormWindowState.Maximized; // //objRpt.crystalReportViewer1.Refresh(); // //objRpt.Show(); //} //catch (Exception ex) //{ // MessageBox.Show(ex.InnerException.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //} try { DateTime mFromDate, mToDate; ConnectionInfo objConInfo = new ConnectionInfo(); TableLogOnInfo objTableLogOnInfo = new TableLogOnInfo(); Tables objCrTables; rptRetDCReport objRptDoc = new rptRetDCReport(); frmReportViewer objFrmRpt = new frmReportViewer(); mFromDate = dtpFromDate.Value.Date; mToDate = dtpToDate.Value.Date; objRptDoc.SetParameterValue("@EntryType", cboEntryType.Text); objRptDoc.SetParameterValue("@FromDate", mFromDate); objRptDoc.SetParameterValue("@ToDate", mToDate); objConInfo.ServerName = GeneralBLL.GetSqlServerPCName(); objConInfo.DatabaseName = GeneralBLL.GetDatabaseName(); objConInfo.UserID = GeneralBLL.GetDBUserName(); objConInfo.Password = GeneralBLL.GetDBPwd(); objConInfo.IntegratedSecurity = false; objCrTables = objRptDoc.Database.Tables; foreach (Table objCrTable in objCrTables) { objTableLogOnInfo = objCrTable.LogOnInfo; objTableLogOnInfo.ConnectionInfo = objConInfo; objCrTable.ApplyLogOnInfo(objTableLogOnInfo); } objFrmRpt.crystalReportViewer1.ReportSource = null; objFrmRpt.crystalReportViewer1.ReportSource = objRptDoc; objFrmRpt.MdiParent = this.MdiParent; objFrmRpt.WindowState = FormWindowState.Maximized; objFrmRpt.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnRptView_Click(object sender, EventArgs e) { // try // { // frmReportViewer objRpt = new frmReportViewer(); // ReportDocument objRptDoc = new ReportDocument(); // ConnectionInfo objConInfo = new ConnectionInfo(); // TableLogOnInfo objTableLogOnInfo = new TableLogOnInfo(); // Tables objCrTables; // objRptDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "\\Reports\\rptVehInOutDet.rpt"); // objConInfo.ServerName = GeneralBLL.GetSqlServerPCName(); // objConInfo.DatabaseName = GeneralBLL.GetDatabaseName(); // objConInfo.UserID = GeneralBLL.GetDBUserName(); // objConInfo.Password = GeneralBLL.GetDBPwd(); // objConInfo.IntegratedSecurity = false; // objCrTables = objRptDoc.Database.Tables; // foreach (CrystalDecisions.CrystalReports.Engine.Table objCrTable in objCrTables) // { // objTableLogOnInfo = objCrTable.LogOnInfo; // objTableLogOnInfo.ConnectionInfo = objConInfo; // objCrTable.ApplyLogOnInfo(objTableLogOnInfo); // } // DateTime mFromDate = Convert.ToDateTime(dtpFromDate.Text); // DateTime mToDate = Convert.ToDateTime(dtpToDate.Text); // int tempValue; // string strSelect; // strSelect = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + mFromDate.ToString("yyyy-MM-dd") + "# And Date({VEHINOUTDETAIL.ENTRYDATE}) <= #" + mToDate.ToString("yyyy-MM-dd") + "# "; //// CONVERT(varchar, mFromDate, 23) // //if (cboType.Text == "ALL") // //{ // // //objRptDoc.RecordSelectionFormula = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + dtpFromDate.Text + "# And Date({VEHINOUTDETAIL.ENTRYDATE})<= #" + dtpToDate.Text + "# "; // // strSelect = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + dtpFromDate.Text + "# And Date({VEHINOUTDETAIL.ENTRYDATE})<= #" + dtpToDate.Text + "# "; // //} // if (cboType.Text == "COMPANY") // { // tempValue = 1; // //objRptDoc.RecordSelectionFormula = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + dtpFromDate.Text + // // "# And Date({VEHINOUTDETAIL.ENTRYDATE})<= #" + dtpToDate.Text + // // "# And ({VEHINOUTDETAIL.TYPE}) = " + tempValue; // strSelect += " And ({VEHINOUTDETAIL.TYPE}) = " + tempValue; // } // else if (cboType.Text == "IN/OUT OTHER") // { // tempValue = 4; // //objRptDoc.RecordSelectionFormula = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + dtpFromDate.Text + // // "# And Date({VEHINOUTDETAIL.ENTRYDATE})<= #" + dtpToDate.Text + // // "# And ({VEHINOUTDETAIL.TYPE}) = " + tempValue; // strSelect += " And ({VEHINOUTDETAIL.TYPE}) = " + tempValue; // } // objRptDoc.RecordSelectionFormula = strSelect; // objRpt.crystalReportViewer1.ReportSource = objRptDoc; // objRpt.MdiParent = this.MdiParent; // objRpt.WindowState = FormWindowState.Maximized; // objRpt.crystalReportViewer1.Refresh(); // objRpt.Show(); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // } try { frmReportViewer objRpt = new frmReportViewer(); rptVehInOutDet objRptDoc = new rptVehInOutDet(); ConnectionInfo objConInfo = new ConnectionInfo(); TableLogOnInfo objTableLogOnInfo = new TableLogOnInfo(); Tables objCrTables; if (cboType.Text == "COMPANY") { objRptDoc.SetParameterValue("@Type", 4); } else if (cboType.Text == "IN/OUT OTHER") { objRptDoc.SetParameterValue("@Type", 1); } objRptDoc.SetParameterValue("@FromDate", dtpFromDate.Value.Date); objRptDoc.SetParameterValue("@ToDate", dtpToDate.Value.Date); //objRptDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "\\Reports\\rptVehInOutDet.rpt"); objConInfo.ServerName = GeneralBLL.GetSqlServerPCName(); objConInfo.DatabaseName = GeneralBLL.GetDatabaseName(); objConInfo.UserID = GeneralBLL.GetDBUserName(); objConInfo.Password = GeneralBLL.GetDBPwd(); objConInfo.IntegratedSecurity = false; objCrTables = objRptDoc.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table objCrTable in objCrTables) { objTableLogOnInfo = objCrTable.LogOnInfo; objTableLogOnInfo.ConnectionInfo = objConInfo; objCrTable.ApplyLogOnInfo(objTableLogOnInfo); } //DateTime mFromDate = Convert.ToDateTime(dtpFromDate.Text); //DateTime mToDate = Convert.ToDateTime(dtpToDate.Text); //int tempValue; //string strSelect; //strSelect = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + mFromDate.ToString("yyyy-MM-dd") + "# And Date({VEHINOUTDETAIL.ENTRYDATE}) <= #" + mToDate.ToString("yyyy-MM-dd") + "# "; //// CONVERT(varchar, mFromDate, 23) ////if (cboType.Text == "ALL") ////{ //// //objRptDoc.RecordSelectionFormula = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + dtpFromDate.Text + "# And Date({VEHINOUTDETAIL.ENTRYDATE})<= #" + dtpToDate.Text + "# "; //// strSelect = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + dtpFromDate.Text + "# And Date({VEHINOUTDETAIL.ENTRYDATE})<= #" + dtpToDate.Text + "# "; ////} //if (cboType.Text == "COMPANY") //{ // tempValue = 1; // //objRptDoc.RecordSelectionFormula = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + dtpFromDate.Text + // // "# And Date({VEHINOUTDETAIL.ENTRYDATE})<= #" + dtpToDate.Text + // // "# And ({VEHINOUTDETAIL.TYPE}) = " + tempValue; // strSelect += " And ({VEHINOUTDETAIL.TYPE}) = " + tempValue; //} //else if (cboType.Text == "IN/OUT OTHER") //{ // tempValue = 4; // //objRptDoc.RecordSelectionFormula = " Date({VEHINOUTDETAIL.ENTRYDATE})>= #" + dtpFromDate.Text + // // "# And Date({VEHINOUTDETAIL.ENTRYDATE})<= #" + dtpToDate.Text + // // "# And ({VEHINOUTDETAIL.TYPE}) = " + tempValue; // strSelect += " And ({VEHINOUTDETAIL.TYPE}) = " + tempValue; //} //objRptDoc.RecordSelectionFormula = strSelect; objRpt.crystalReportViewer1.ReportSource = objRptDoc; objRpt.MdiParent = this.MdiParent; objRpt.WindowState = FormWindowState.Maximized; objRpt.crystalReportViewer1.Refresh(); objRpt.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }