1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| private void EditRptBtn_Click(object sender, RoutedEventArgs e)
{
EditRptBtn.Cursor = Cursors.Wait;
EditRptBtn.Opacity = 0.5;
DateTime pikerDate = Convert.ToDateTime(DecDatePiker.Text);
string d = pikerDate.ToString("MM/dd/yyyy");
string d1 = pikerDate.ToString("dd.MM.yyyy");
string decVpfPath = ($"{ApplicationDirectories.dossierDoc}\\{ApplicationDirectories.appName}\\Dossiers {ApplicationDirectories.appName}\\Dec_VPF");
string decVPFFile = ($"{decVpfPath}\\Dec_VPF_{d1}.pdf");
string query = ($"SELECT Last(R_PORCS.ID) AS DernierDeID, R_PLANNING_APPRO.PL_DATE, R_LOTS.GROUP, R_LOTS.IDLOT, R_PORCS.FRAPPE," +
$" R_LOTS.NBPORC, R_PORCS.NUM_TUER, R_LOTS.DATE_DERREP, R_LOTS.H_DERREP, R_LOTS.DATE_CHARG, R_LOTS.H_CHARG, R_LOTS.DATE_DECHARG," +
$" R_LOTS.H_DECHARG, R_PORCS.H_PESEE, R_PORCS.ABC, R_PORCS.OBS1, R_PORCS.OBS2, R_PORCS.OBS3, R_PLANNING_APPRO.PL_SIGNEQ, R_PORCS.PORC," +
$" R_PORCS.MFS, R_PLANNING_APPRO.Quant, R_PORCS.P1CHconv FROM R_PLANNING_APPRO INNER JOIN(R_PORCS INNER JOIN R_LOTS ON R_PORCS.FRAPPE = R_LOTS.IDLOT)" +
$" ON R_PLANNING_APPRO.PL_FRAPPE = R_LOTS.FRAPPE GROUP BY R_PLANNING_APPRO.PL_DATE, R_LOTS.GROUP, R_LOTS.IDLOT, R_PORCS.FRAPPE," +
$" R_LOTS.NBPORC, R_PORCS.NUM_TUER, R_LOTS.DATE_DERREP, R_LOTS.H_DERREP, R_LOTS.DATE_CHARG, R_LOTS.H_CHARG, R_LOTS.DATE_DECHARG," +
$" R_LOTS.H_DECHARG, R_PORCS.H_PESEE, R_PORCS.ABC, R_PORCS.OBS1, R_PORCS.OBS2, R_PORCS.OBS3, R_PLANNING_APPRO.PL_SIGNEQ, R_PORCS.PORC," +
$" R_PORCS.MFS, R_PLANNING_APPRO.Quant, R_PORCS.P1CHconv HAVING(((R_PLANNING_APPRO.PL_DATE) =#{d}#) AND ((R_PORCS.ABC)<>'A')" +
$" AND ((R_PLANNING_APPRO.PL_SIGNEQ)='VPF')) OR (((R_PLANNING_APPRO.PL_DATE)=#{d}#) AND ((R_PORCS.OBS1)<>0) AND ((R_PLANNING_APPRO.PL_SIGNEQ)='VPF'))");
comm = new OleDbCommand(query, conn)
{
CommandType = CommandType.Text
};
conn.Open();
OleDbDataAdapter dap = new OleDbDataAdapter(comm);
DataTable dt = new DataTable("DEC_VPF");
dap.Fill(dt);
dt.WriteXmlSchema("DecVPF.xml");
conn.Close();
conn.Open();
comm = new OleDbCommand("SELECT * FROM [R_Pds_Frappe_VPF]", conn)
{
CommandType = CommandType.Text
};
OleDbDataAdapter dap1 = new OleDbDataAdapter(comm);
DataTable dt1 = new DataTable("PdsFrappeVpf");
dap1.Fill(dt1);
dt1.WriteXmlSchema("Pds_FrappeVpf.xml");
conn.Close();
try
{
DecVPF_CR cr = new DecVPF_CR();
cr.Database.Tables["0"].SetDataSource(dt);
cr.Database.Tables["1"].SetDataSource(dt1);
cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, decVPFFile);
var mess = MessageBox.Show("Souhaitez-vous imprimer le rapport ?", ApplicationDirectories.appName, MessageBoxButton.YesNo,
MessageBoxImage.Question);
switch (mess)
{
case MessageBoxResult.No:
EditRptBtn.Opacity = 1;
EditRptBtn.Cursor = Cursors.Arrow;
return;
case MessageBoxResult.Yes:
cr.PrintToPrinter(1, true, 0, 0);
EditRptBtn.Opacity = 1;
EditRptBtn.Cursor = Cursors.Arrow;
break;
}
}
catch (Exception ex)
{
Messages.ErrorMessages(ex.Message);
}
EditRptBtn.Opacity = 1;
EditRptBtn.Cursor = Cursors.Arrow;
} |
Partager