void trip_diesel_balance_keydown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab | e.Key == Key.Enter) { if (trip_diesel_balance.Text.Length >= 13 && trip_diesel_balance.Text.Length <= 16) { string l = trip_diesel_balance.Text; if (Regex.IsMatch(l, "^[0-9]{6}[A-Za-z]{2}[0-9]{2}")) { try { Connection CON = new Connection(); CON.open_connection(); OdbcCommand cmd = new OdbcCommand("select CARD_ID,ORIGIN,DESTINATION,PLACE,DATE_FORMAT(fill_date,'%d/%m/%Y') as FILL_DATE,LITTERS,PRICE_PER,TOTAL_COST from diesel_balance_sheet where trip_number='" + trip_diesel_balance.Text + "'", CON.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { Report_Viewer.Reset(); Report_Viewer.Clear(); MainWindow m = new MainWindow(); Report_Viewer.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("Trip_Diesel_DataSet", dt); Report_Viewer.LocalReport.DataSources.Add(ds); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Trip_Diesel_Report.rdlc"; ReportParameter[] param = new ReportParameter[4]; param[0] = new ReportParameter("Title", m.Title_Name.Content.ToString()); param[1] = new ReportParameter("TripNumber", trip_diesel_balance.Text); param[2] = new ReportParameter("Origin", dt.Rows[0]["origin"].ToString()); param[3] = new ReportParameter("Destination", dt.Rows[0]["destination"].ToString()); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); trip_diesel_balance.Text = ""; } else { MessageBox.Show("TRIP NUMBER Not Exist"); trip_diesel_balance.Text = ""; } } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Invalid Trip Number Format"); } } else { MessageBox.Show("INCORRECT TRIP NUMBER"); trip_diesel_balance.Text = ""; } } }
void load_keydown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab | e.Key == Key.Enter) { string user = Properties.Settings.Default.User; if (user == "ADMIN" || user == "MANAGER" || user == "USER") { try { if (load.Text.Equals("ALL")) { // Connection con = new Connection(); con.open_connection(); OdbcCommand cmd = new OdbcCommand("select VEHICLE_NUMBER,TRANSPORT_NAME,DATE_FORMAT(insurance_expiry,'%d/%m/%Y')AS INSURANCE_EXPIRY,DATE_FORMAT(national_expiry,'%d/%m/%Y')AS NATIONAL_EXPIRY,DATE_FORMAT(permit_expiry,'%d/%m/%Y')AS PERMIT_EXPIRY,DATE_FORMAT(tax_expiry,'%d/%m/%Y')AS TAX_EXPIRY from vechicle_details where CORPORATION='LOAD'", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { Report_Viewer1.Clear(); sp1.Visibility = Visibility.Hidden; sp2.Visibility = Visibility.Visible; Report_Viewer1.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("Load_DataSet", dt); Report_Viewer1.LocalReport.DataSources.Add(ds); Report_Viewer1.LocalReport.ReportEmbeddedResource = "Project_Transport.Load_Report.rdlc"; Report_Viewer1.RefreshReport(); e.Handled = true; } else { MessageBox.Show("Details Not Exist"); e.Handled = true; } con.close_connection(); } else if (load.Text != null) { string l = load.Text; if (Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{1}[0-9]{5}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{7}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{8}")) { MessageBox.Show("Incorrect Number Format"); e.Handled = true; load.Text = ""; } else if (Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{2}[0-9]{4}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{2}[0-9]{3}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{1}[0-9]{4}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{1}[0-9]{3}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{6}")) { con.open_connection(); OdbcCommand cmd = new OdbcCommand("select VEHICLE_NUMBER,TRANSPORT_NAME,DATE_FORMAT(insurance_expiry,'%d/%m/%Y')AS INSURANCE_EXPIRY,DATE_FORMAT(national_expiry,'%d/%m/%Y')AS NATIONAL_EXPIRY,DATE_FORMAT(permit_expiry,'%d/%m/%Y')AS PERMIT_EXPIRY,DATE_FORMAT(tax_expiry,'%d/%m/%Y')AS TAX_EXPIRY from vechicle_details where vehicle_number='" + load.Text + "'", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); con.close_connection(); Report_Viewer.Clear(); sp2.Visibility = Visibility.Hidden; sp1.Visibility = Visibility.Visible; if (dt.Rows.Count > 0) { Report_Viewer.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("Load_DataSet", dt); Report_Viewer.LocalReport.DataSources.Add(ds); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Load_Report.rdlc"; Report_Viewer.RefreshReport(); e.Handled = true; } else { MessageBox.Show("Details Not Exist"); e.Handled = true; } //con.close_connection(); } else { MessageBox.Show("Invalid Vehicle Number Format"); e.Handled = true; } // Connection con = new Connection(); } else { MessageBox.Show("please select number from dropdown list"); e.Handled = true; } } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Access Denied"); } } }
void ioc_keydown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab | e.Key == Key.Enter) { string user = Properties.Settings.Default.User; if (user == "ADMIN" || user == "MANAGER" || user == "USER") { try { if (ioc.Text.Equals("ALL")) { //onnection con = new Connection(); con.open_connection(); OdbcCommand cmd = new OdbcCommand("select VEHICLE_NUMBER,TRANSPORT_NAME,VENDOR_CODE,DRIVER_NAME,CARD_ID,DATE_FORMAT(fc_expiry,'%d/%m/%Y') AS FC_EXPIRY,DATE_FORMAT(insurance_expiry,'%d/%m/%Y') AS INSURANCE_EXPIRY,DATE_FORMAT(national_expiry,'%d/%m/%Y') AS NATIONAL_EXPIRY,DATE_FORMAT(permit_expiry,'%d/%m/%Y') AS PERMIT_EXPIRY,DATE_FORMAT(explosive_expiry,'%d/%m/%Y') AS EXPLOSIVE_EXPIRY,DATE_FORMAT(yearly_expiry,'%d/%m/%Y') AS YEARLY_EXPIRY,DATE_FORMAT(half_yearly_expiry,'%d/%m/%Y') AS HALF_YEARLY_EXPIRY,DATE_FORMAT(hydro_expiry,'%d/%m/%Y') AS HYDRO_EXPIRY,DATE_FORMAT(cll_policy,'%d/%m/%Y') AS CLL_POLICY,DATE_FORMAT(pli,'%d/%m/%Y') AS PLI,DATE_FORMAT(tax_expiry,'%d/%m/%Y') AS TAX_EXPIRY from vechicle_details where corporation='IOC'", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { sp1.Visibility = Visibility.Hidden; sp2.Visibility = Visibility.Visible; Report_Viewer1.Clear(); Report_Viewer1.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("Lpg_DataSet", dt); Report_Viewer1.LocalReport.DataSources.Add(ds); Report_Viewer1.LocalReport.ReportEmbeddedResource = "Project_Transport.Lpg_Report.rdlc"; Report_Viewer1.RefreshReport(); e.Handled = true; } else { MessageBox.Show("Details Not Exist"); e.Handled = true; } con.close_connection(); } else if (ioc.Text != null) { string l = ioc.Text; if (Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{1}[0-9]{5}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{7}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{8}")) { MessageBox.Show("Incorrect Number Format"); e.Handled = true; ioc.Text = ""; } else if (Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{2}[0-9]{4}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{2}[0-9]{3}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{1}[0-9]{4}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{2}[A-Za-z]{1}[0-9]{3}") || Regex.IsMatch(l, "^[A-Za-z]{2}[0-9]{6}")) { con.open_connection(); OdbcCommand cmd = new OdbcCommand("select VEHICLE_NUMBER,TRANSPORT_NAME,VENDOR_CODE,DRIVER_NAME,CARD_ID,DATE_FORMAT(fc_expiry,'%d/%m/%Y') AS FC_EXPIRY,DATE_FORMAT(insurance_expiry,'%d/%m/%Y') AS INSURANCE_EXPIRY,DATE_FORMAT(national_expiry,'%d/%m/%Y') AS NATIONAL_EXPIRY,DATE_FORMAT(permit_expiry,'%d/%m/%Y') AS PERMIT_EXPIRY,DATE_FORMAT(explosive_expiry,'%d/%m/%Y') AS EXPLOSIVE_EXPIRY,DATE_FORMAT(yearly_expiry,'%d/%m/%Y') AS YEARLY_EXPIRY,DATE_FORMAT(half_yearly_expiry,'%d/%m/%Y') AS HALF_YEARLY_EXPIRY,DATE_FORMAT(hydro_expiry,'%d/%m/%Y') AS HYDRO_EXPIRY,DATE_FORMAT(cll_policy,'%d/%m/%Y') AS CLL_POLICY,DATE_FORMAT(pli,'%d/%m/%Y') AS PLI,DATE_FORMAT(tax_expiry,'%d/%m/%Y') AS TAX_EXPIRY from vechicle_details where vehicle_number='" + ioc.Text + "'", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); con.close_connection(); if (dt.Rows.Count > 0) { MainWindow m = new MainWindow(); sp2.Visibility = Visibility.Hidden; sp1.Visibility = Visibility.Visible; Report_Viewer.Clear(); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Single_Vehicle_Report.rdlc"; ReportParameter[] param = new ReportParameter[14]; param[0] = new ReportParameter("Title", m.Title_Name.Content.ToString()); param[1] = new ReportParameter("Vehicle", dt.Rows[0]["vehicle_number"].ToString()); param[2] = new ReportParameter("Transport", dt.Rows[0]["transport_name"].ToString()); param[3] = new ReportParameter("FC", dt.Rows[0]["fc_expiry"].ToString()); param[4] = new ReportParameter("Insurance", dt.Rows[0]["insurance_expiry"].ToString()); param[5] = new ReportParameter("National", dt.Rows[0]["national_expiry"].ToString()); param[6] = new ReportParameter("Permit", dt.Rows[0]["permit_expiry"].ToString()); param[7] = new ReportParameter("Explosive", dt.Rows[0]["explosive_expiry"].ToString()); param[8] = new ReportParameter("Yearly", dt.Rows[0]["yearly_expiry"].ToString()); param[9] = new ReportParameter("HalfYearly", dt.Rows[0]["half_yearly_expiry"].ToString()); param[10] = new ReportParameter("Hydro", dt.Rows[0]["hydro_expiry"].ToString()); param[11] = new ReportParameter("CllPolicy", dt.Rows[0]["cll_policy"].ToString()); param[12] = new ReportParameter("Pli", dt.Rows[0]["pli"].ToString()); param[13] = new ReportParameter("Tax", dt.Rows[0]["tax_expiry"].ToString()); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); e.Handled = true; } else { MessageBox.Show("Details Not Exist"); e.Handled = true; } } else { MessageBox.Show("Invalid Vehicle Number Format"); e.Handled = true; } // Connection con = new Connection(); } else { MessageBox.Show("please select number from dropdown list"); e.Handled = true; } } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Access Denied"); } } }
void deposit_diesel_entry_view_Click(object sender, RoutedEventArgs e) { string user = Properties.Settings.Default.User; if (user == "ADMIN" || user == "MANAGER" || user == "USER") { try { Connection con = new Connection(); con.open_connection(); if (!string.IsNullOrWhiteSpace(card_view.Text) && !string.IsNullOrWhiteSpace(From.Text) && !string.IsNullOrWhiteSpace(To.Text)) { if (card_view.Text.Length <= 17) { try { string d1 = Convert.ToDateTime(From.Text).ToString("yyyy/MM/dd"); string d2 = Convert.ToDateTime(To.Text).ToString("yyyy/MM/dd"); string d3 = Convert.ToDateTime(From.Text).ToString("dd/MM/yyyy"); string d4 = Convert.ToDateTime(To.Text).ToString("dd/MM/yyyy"); OdbcCommand cmd1 = new OdbcCommand("select card_id,credit_amount,DATE_FORMAT(credit_date,'%d/%m/%Y')as credit_date from credit_details where card_id='" + card_view.Text + "' and credit_date BETWEEN '" + d1 + "' AND '" + d2 + "' and bool=0", con.conn); OdbcDataAdapter da1 = new OdbcDataAdapter(cmd1); DataSet dt1 = new DataSet(); da1.Fill(dt1); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Deposit_Diesel_Report.rdlc"; OdbcCommand cmd = new OdbcCommand("select ORIGIN,DESTINATION,PLACE,DATE_FORMAT(fill_date,'%d/%m/%Y') as FILL_DATE,LITTERS,PRICE_PER,TOTAL_COST from diesel_balance_sheet where card_id='" + card_view.Text + "' and fill_date BETWEEN '" + d1 + "' AND '" + d2 + "'", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd); DataSet dt = new DataSet(); da.Fill(dt); Report_Viewer.Reset(); Report_Viewer.Clear(); Report_Viewer.LocalReport.DataSources.Clear(); ReportDataSource ds1 = new ReportDataSource("Diesel_Deposit_DataSet", dt1.Tables[0]); ReportDataSource ds2 = new ReportDataSource("Diesel_DataSet", dt.Tables[0]); Report_Viewer.LocalReport.DataSources.Add(ds1); Report_Viewer.LocalReport.DataSources.Add(ds2); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Diesel_Deposit_Report.rdlc"; ReportParameter[] param = new ReportParameter[3]; param[0] = new ReportParameter("Title", Properties.Settings.Default.Title); param[1] = new ReportParameter("Id", card_view.Text); param[2] = new ReportParameter("Date", "Deposit & Withdraw " + d3 + " To " + d4); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); To.Text = DateTime.Now.ToShortDateString(); From.Text = "Select Date"; } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Allow Combination of 17 Characters and Numbers"); card_view.Text = ""; } } else if (!string.IsNullOrWhiteSpace(card_view.Text)) { if (card_view.Text.Length <= 17) { try { OdbcCommand cmd1 = new OdbcCommand("select credit_amount,DATE_FORMAT(credit_date,'%d/%m/%Y')as credit_date from credit_details where card_id='" + card_view.Text + "' and bool=0", con.conn); OdbcDataAdapter da1 = new OdbcDataAdapter(cmd1); DataSet dt1 = new DataSet(); da1.Fill(dt1); //int i = dt1.Rows.Count; //Report_Viewer.Reset(); OdbcCommand cmd = new OdbcCommand("select ORIGIN,DESTINATION,PLACE,DATE_FORMAT(fill_date,'%d/%m/%Y') as FILL_DATE,LITTERS,PRICE_PER,TOTAL_COST from diesel_balance_sheet where card_id='" + card_view.Text + "'", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd); DataSet dt = new DataSet(); da.Fill(dt); Report_Viewer.Reset(); Report_Viewer.Clear(); Report_Viewer.LocalReport.DataSources.Clear(); ReportDataSource ds1 = new ReportDataSource("Diesel_Deposit_DataSet", dt1.Tables[0]); //Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Diesel_Deposit_Report.rdlc"; ReportDataSource ds2 = new ReportDataSource("Diesel_DataSet", dt.Tables[0]); Report_Viewer.LocalReport.DataSources.Add(ds1); Report_Viewer.LocalReport.DataSources.Add(ds2); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Diesel_Deposit_Report.rdlc"; ReportParameter[] param = new ReportParameter[3]; param[0] = new ReportParameter("Title", Properties.Settings.Default.Title); param[1] = new ReportParameter("Id", card_view.Text); param[2] = new ReportParameter("Date", "Card Deposit & Withdraw Details"); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Allow Combination of 17 Characters and Numbers"); card_view.Text = ""; } } else { MessageBox.Show("Invalid Date Or Card Id"); } con.close_connection(); } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Access Denied"); } }
void deposit_view_Click(object sender, RoutedEventArgs e) { string user = Properties.Settings.Default.User; if (user == "ADMIN" || user == "MANAGER" || user == "USER") { Connection con = new Connection(); con.open_connection(); if (!string.IsNullOrWhiteSpace(card_view.Text) && !string.IsNullOrWhiteSpace(From.Text) && !string.IsNullOrWhiteSpace(To.Text)) { if (card_view.Text.Length <= 17) { try { string d1 = Convert.ToDateTime(From.Text).ToString("yyyy/MM/dd"); string d2 = Convert.ToDateTime(To.Text).ToString("yyyy/MM/dd"); string d3 = Convert.ToDateTime(From.Text).ToString("dd/MM/yyyy"); string d4 = Convert.ToDateTime(To.Text).ToString("dd/MM/yyyy"); OdbcCommand cmd1 = new OdbcCommand("select corporation,customer_id,card_id,credit_amount,DATE_FORMAT(credit_date,'%d/%m/%Y')as credit_date from credit_details where card_id='" + card_view.Text + "' and credit_date BETWEEN '" + d1 + "' AND '" + d2 + "' and bool=0", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd1); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { Report_Viewer.Reset(); Report_Viewer.Clear(); Report_Viewer.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("Card_Deposit_DataSet", dt); Report_Viewer.LocalReport.DataSources.Add(ds); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Deposit_Report.rdlc"; ReportParameter[] param = new ReportParameter[3]; param[0] = new ReportParameter("Title", Properties.Settings.Default.Title); param[1] = new ReportParameter("Card", card_view.Text); param[2] = new ReportParameter("Details", "Deposit Details " + d3 + " To " + d4); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); To.Text = DateTime.Now.ToShortDateString(); From.Text = "Select Date"; } else { MessageBox.Show("Record Doesnot Exist"); } } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Allow Combination of 17 Characters and Numbers"); card_view.Text = ""; } // diesel_details_view.ItemsSource = dt.DefaultView; } else if (!string.IsNullOrWhiteSpace(card_view.Text)) { if (card_view.Text.Length <= 17) { try { OdbcCommand cmd1 = new OdbcCommand("select corporation,customer_id,card_id,credit_amount,DATE_FORMAT(credit_date,'%d/%m/%Y')as credit_date from credit_details where card_id='" + card_view.Text + "' and bool=0 ", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd1); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { Report_Viewer.Reset(); Report_Viewer.Clear(); Report_Viewer.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("Card_Deposit_DataSet", dt); Report_Viewer.LocalReport.DataSources.Add(ds); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Deposit_Report.rdlc"; ReportParameter[] param = new ReportParameter[3]; param[0] = new ReportParameter("Title", Properties.Settings.Default.Title); param[1] = new ReportParameter("Card", card_view.Text); param[2] = new ReportParameter("Details", "Deposit Details"); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); } else { MessageBox.Show("Record Doesnot Exist"); } } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Allow Combination of 17 Characters and Numbers"); card_view.Text = ""; } } else { MessageBox.Show("Invalid Date Or Card Id"); } con.close_connection(); } else { MessageBox.Show("Access Denied"); } }
void card_details_view_Click(object sender, RoutedEventArgs e) { string user = Properties.Settings.Default.User; if (user == "ADMIN" || user == "MANAGER" || user == "USER") { Connection con = new Connection(); con.open_connection(); if (!string.IsNullOrWhiteSpace(card_view.Text)) { if (card_view.Text.Length <= 17) { try { OdbcCommand cmd1 = new OdbcCommand("select corporation,customer_id,card_id,vehicle_number from diesel_card_details where card_id='" + card_view.Text + "'", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd1); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { Report_Viewer.Reset(); Report_Viewer.Clear(); Report_Viewer.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("Card_Details_DataSet", dt); Report_Viewer.LocalReport.DataSources.Add(ds); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Card_Report.rdlc"; ReportParameter[] param = new ReportParameter[1]; param[0] = new ReportParameter("Title", Properties.Settings.Default.Title); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); } else { MessageBox.Show("Record Doesnot Exist"); } // diesel_details_view.ItemsSource = dt.DefaultView; } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } else { MessageBox.Show("Allow Combination of 17 Characters and Numbers"); card_view.Text = ""; } } else if (string.IsNullOrWhiteSpace(card_view.Text) || card_view.Text.Equals("ALL")) { try { OdbcCommand cmd1 = new OdbcCommand("select corporation,customer_id,card_id,vehicle_number from diesel_card_details", con.conn); OdbcDataAdapter da = new OdbcDataAdapter(cmd1); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { Report_Viewer.Reset(); Report_Viewer.Clear(); Report_Viewer.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("Card_Details_DataSet", dt); Report_Viewer.LocalReport.DataSources.Add(ds); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Diesel.Card_Report.rdlc"; ReportParameter[] param = new ReportParameter[1]; param[0] = new ReportParameter("Title", Properties.Settings.Default.Title); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); } else { MessageBox.Show("Record Doesnot Exist"); } // diesel_details_view.ItemsSource = dt.DefaultView; } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } } con.close_connection(); } else { MessageBox.Show("Access Denied"); } }
void print_data() { ReportParameter[] param = new ReportParameter[111]; try { List <string> date = new List <string>(); Connection con = new Connection(); con.connection_string(); OdbcCommand cmd1 = new OdbcCommand("select fl_date,fr_date,cfol_date,cfil_date,cfor_date,cfir_date,ccol_date,ccil_date,ccor_date,ccir_date,cbol_date,cbil_date,cbor_date,cbir_date,afol_date,afil_date,afor_date,afir_date,acol_date,acil_date,acor_date,acir_date,abol_date,abil_date,abor_date,abir_date,adt_date from trailer where vehicle_no='" + tyre_vehicle_numbers.Text + "'", con.str); OdbcDataReader dr1 = cmd1.ExecuteReader(); while (dr1.Read()) { for (int j = 0; j < 27; j++) { date.Add(dr1[j].ToString()); } } OdbcCommand cmd = new OdbcCommand("SELECT fl_id,fr_id,cfol_id,cfil_id,cfor_id,cfir_id,ccol_id,ccil_id,ccor_id,ccir_id,cbol_id,cbil_id,cbor_id,cbir_id,afol_id,afil_id,afor_id,afir_id,acol_id,acil_id,acor_id,acir_id,abol_id,abil_id,abor_id,abir_id,adt_id from trailer where vehicle_no='" + tyre_vehicle_numbers.Text + "'", con.str); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { int p = 0, q = 1, r = 2, s = 3; for (int i = 0; i < 27; i++) { int A = p + 1, B = q + 1, C = r + 1, D = s + 1; string id = dr[i].ToString(); if (!string.IsNullOrWhiteSpace(id)) { OdbcCommand cmd2 = new OdbcCommand("select no,starting_km,company from trailer_tyre_details where id=" + id + "", con.str); OdbcDataReader dr2 = cmd2.ExecuteReader(); while (dr2.Read()) { param[p] = new ReportParameter("Param" + A + "", dr2[0].ToString()); param[q] = new ReportParameter("Param" + B + "", dr2[1].ToString()); param[r] = new ReportParameter("Param" + C + "", dr2[2].ToString()); param[s] = new ReportParameter("Param" + D + "", Convert.ToDateTime(date[i]).ToString("dd/MM/yyyy")); } } else { param[p] = new ReportParameter("Param" + A + "", " "); param[q] = new ReportParameter("Param" + B + "", " "); param[r] = new ReportParameter("Param" + C + "", " "); param[s] = new ReportParameter("Param" + D + "", " "); } p += 4; q += 4; r += 4; s += 4; } } Report_Viewer.Clear(); Report_Viewer.LocalReport.ReportEmbeddedResource = "Project_Transport.Trailer_Tyre_Report.rdlc"; param[108] = new ReportParameter("Param109", Properties.Settings.Default.Title.ToString()); param[109] = new ReportParameter("Param110", (tyre_vehicle_numbers.Text).ToString()); param[110] = new ReportParameter("Param111", Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy")); Report_Viewer.LocalReport.SetParameters(param); Report_Viewer.RefreshReport(); } catch (OdbcException ex) { MessageBox.Show("Error :" + ex); } }
void Tyre_Report_Back_Click(object sender, RoutedEventArgs e) { tyre_print_panel.Visibility = Visibility.Hidden; Report_Viewer.Clear(); }