public void LoadPhysicalFuelStock() { PhysicalStockReport fuelReport = new PhysicalStockReport(); try { PhysicalStockDS ds = db.GetPhysicalStock(_fromDate, _toDate); fuelReport.SetDataSource(ds); this.crystalReportViewer1.ReportSource = fuelReport; TextObject yr = (TextObject)fuelReport.ReportDefinition.Sections["Section5"].ReportObjects["TxtObjLogUser"]; yr.Text = "[ Copyright \u00A9 " + DateTime.Now.Year.ToString() + " Delmo IT " + " PD : " + DateTime.Now.ToString("dd/MM/yyyy") + " PT : " + DateTime.Now.ToString("hh:mm:ss tt") + " Com : " + System.Environment.MachineName.ToString() + " UN : " + Properties.Settings.Default.LastUser + " ]"; //TextObject fromD = (TextObject)fuelReport.ReportDefinition.Sections["Section1"].ReportObjects["CrFromDatTxt"]; //yr.Text = _fromDate.ToString(); } catch { MessageBox.Show("Error loading with the report...", "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { DataTable table = db.FillReportHeader(); DataRow row = table.Rows[0]; TextObject heder = (TextObject)fuelReport.ReportDefinition.Sections["Section1"].ReportObjects["TxtCRName"]; heder.Text = row[0].ToString(); TextObject heder2 = (TextObject)fuelReport.ReportDefinition.Sections["Section1"].ReportObjects["TxtCrAddr"]; heder2.Text = row[1].ToString(); TextObject heder3 = (TextObject)fuelReport.ReportDefinition.Sections["Section1"].ReportObjects["TxtCRTPNo"]; heder3.Text = "Tel : " + row[2].ToString() + " / Fax : " + row[3].ToString(); TextObject heder4 = (TextObject)fuelReport.ReportDefinition.Sections["Section1"].ReportObjects["TxtCREmailWeb"]; heder4.Text = "E-Mail : " + row[4].ToString() + " / Web Address : " + row[5].ToString(); TextObject heder5 = (TextObject)fuelReport.ReportDefinition.Sections["Section1"].ReportObjects["TxtHoLine"]; heder5.Text = "Hot Line : 0774410500 / " + row[2].ToString(); TextObject fromD = (TextObject)fuelReport.ReportDefinition.Sections["Section1"].ReportObjects["CrFromDatTxt"]; fromD.Text = _fromDate; TextObject toDay = (TextObject)fuelReport.ReportDefinition.Sections["Section1"].ReportObjects["CrToDatTxt"]; toDay.Text = _toDate; } catch (Exception ex) { MessageBox.Show("Error loading with the report header... " + ex.Message.ToString(), "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.crystalReportViewer1.RefreshReport(); }
}//Populate DataSet FuelStockDataSet(Stock Movement) public PhysicalStockDS GetPhysicalStock(string fromDate, string toDate) { PhysicalStockDS physicalDS = new PhysicalStockDS(); try { SqlCommand scmd = conn.CreateCommand(); scmd.Connection = conn; scmd.CommandType = CommandType.Text; scmd.CommandText = @"SELECT [FWS_ID] , convert(VARCHAR, CAST(FWS_DATE AS DATETIME),106) as FWS_DATE , [FWS_TIME],[FWS_BALANCE],FWS_SYS_BALANCE ,FWS_BALANCE-FWS_SYS_BALANCE as Stock_Gap,FWS_METER_READ,s.SEC_HDR_USR_NAME as FWS_USER ,[FWS_TERMINAL_NAME] FROM FUEL_TMP_WEEKLY_STOCK as main inner Join SECURITY_HEADER as s on main.[FWS_USER]=s.SEC_HDR_CODE where Cast(FWS_DATE as datetime) >= '" + Convert.ToDateTime(fromDate).ToString("MM/dd/yyyy") + "' and Cast(FWS_DATE as datetime) <= '" + Convert.ToDateTime(toDate).ToString("MM/dd/yyyy") + "' " + "order by FWS_ID desc"; SqlDataAdapter sdas = new SqlDataAdapter(scmd); sdas.Fill(physicalDS, "PhysicalStockDT"); } catch (Exception ex) { MessageBox.Show("ReportAccess class \n" + ex.Message.ToString(), "GetPhysicalStock()", MessageBoxButtons.OK, MessageBoxIcon.Hand); } return(physicalDS); }//Populate PhysicalStockDS(Physical Stock)