private void BTN_Aperçu_cmd_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (bs.Current != null) { DataRowView drv = (DataRowView)bs.Current; DataTable dt = CLIENT_APP_PARAM.gcws.Imprimer_BL(drv["CODE_B_LIV"].ToString()); decimal montant_ht = 0; decimal montant_remise = 0; decimal montant_TVA = 0; decimal montant_TTC = 0; foreach (DataRow dr in dt.Rows) { montant_ht += (decimal)dr["PRIX_HT_B_LIV"] * (decimal)dr["QTE_LIGNE_B_LIV"]; montant_remise += (decimal)dr["PRIX_HT_B_LIV"] * (decimal)dr["REMISE"] / 100 * (decimal)dr["QTE_LIGNE_B_LIV"]; montant_TVA += ((decimal)dr["PRIX_HT_B_LIV"] - (decimal)dr["PRIX_HT_B_LIV"] * (decimal)dr["REMISE"] / 100) * (decimal)dr["TVA_B_LIV"] / 100 * (decimal)dr["QTE_LIGNE_B_LIV"]; } montant_TTC = montant_ht - montant_remise + montant_TVA; RPT_B_LIV rpt = new RPT_B_LIV(); rpt.SetDataSource(dt); rpt.SetParameterValue("mnt_HT", montant_ht); rpt.SetParameterValue("Total_Remise", montant_remise); rpt.SetParameterValue("Total_TVA", montant_TVA); rpt.SetParameterValue("Montant_TTC", montant_TTC); rpt.SetParameterValue("entete", CLIENT_APP_PARAM.entete); //rpt.PrintOptions.PrinterName = CLIENT_APP_PARAM.ReportPrinter; //rpt.PrintToPrinter(1, true, 1, 1); CHM_ETATS etat = new CHM_ETATS(); etat.CHM_Aperçu_document.ReportSource = rpt; etat.MdiParent = CLIENT_APP_PARAM.Fenetre_principale; etat.WindowState = FormWindowState.Maximized; etat.Show(); } else { MessageBox.Show("Sélectionnez le bon de livraison à imprimer."); } } catch (Exception er) { this.Cursor = Cursors.Default; MessageBox.Show(er.Message, CLIENT_APP_PARAM.Fenetre_principale.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
private void BTN_APERçU_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; DataTable dt = CLIENT_APP_PARAM.gcws.Imprimer_BL(CODE_B_LIV); decimal montant_ht = 0; decimal montant_remise = 0; decimal montant_tva = 0; decimal montant_ttc = 0; for (int i = 0; i < dt_lg_b_liv.Rows.Count; i++) { montant_ht += (decimal)dt_lg_b_liv.Rows[i]["PRIX_TOTAL_HT"]; montant_ttc += (decimal)dt_lg_b_liv.Rows[i]["PRIX_TOTAL_TTC"]; montant_remise += (decimal)dt_lg_b_liv.Rows[i]["QTE_LIGNE_B_LIV"] * (decimal)dt_lg_b_liv.Rows[i]["PRIX_HT_B_LIV"] * (decimal)dt_lg_b_liv.Rows[i]["REMISE"] / 100; montant_tva += (decimal)dt_lg_b_liv.Rows[i]["QTE_LIGNE_B_LIV"] * ((decimal)dt_lg_b_liv.Rows[i]["PRIX_HT_B_LIV"] - (decimal)dt_lg_b_liv.Rows[i]["PRIX_HT_B_LIV"] * (decimal)dt_lg_b_liv.Rows[i]["REMISE"] / 100) * (decimal)dt_lg_b_liv.Rows[i]["TVA_B_LIV"] / 100; } RPT_B_LIV rpt = new RPT_B_LIV(); rpt.SetDataSource(dt); rpt.SetParameterValue("mnt_HT", montant_ht.ToString("#,##0")); rpt.SetParameterValue("Total_Remise", montant_remise.ToString("#,0###")); rpt.SetParameterValue("Total_TVA", montant_tva.ToString("#,0##")); rpt.SetParameterValue("Montant_TTC", montant_ttc.ToString("#,0##")); //rpt.PrintOptions.PrinterName = CLIENT_APP_PARAM.ReportPrinter; //rpt.PrintToPrinter(1, true, 1, 1); CHM_ETATS etat = new CHM_ETATS(); etat.CHM_Aperçu_document.ReportSource = rpt; etat.MdiParent = CLIENT_APP_PARAM.Fenetre_principale; etat.WindowState = FormWindowState.Maximized; etat.Show(); } catch (Exception er) { this.Cursor = Cursors.Default; MessageBox.Show(er.Message, CLIENT_APP_PARAM.Fenetre_principale.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
private void BTN_ENREGISTRER_Click(object sender, EventArgs e) { if (dataSet11.LG_BON_LIVRAISON.Rows.Count > 0) { if (MessageBox.Show("Etes vous sur d'enregistrer le bon de livraison?", "Vaalidation enregistrement", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { this.Cursor = Cursors.WaitCursor; try { Application.DoEvents(); CODE_CMD = ""; foreach (DataRow dr in dataSet11.LG_BON_LIVRAISON.Rows) { if (dr["CODE_COMMANDE"].ToString() != "" && !CODE_CMD.Contains(dr["CODE_COMMANDE"].ToString())) { CODE_CMD += dr["CODE_COMMANDE"].ToString(); } } //CHM_GESTION_COMERCIALE.RESULT_QUERY res = CLIENT_APP_PARAM.GEST.P_BON_LIVRAISON.SAVE(DATE_B_LIV.Value, CODE_CLIENT, CODE_CMD, CLIENT_APP_PARAM.Fenetre_principale.code_user, dt_lg_b_liv_prepare); dt_lg_b_liv_prepare.Clear(); foreach (DataRow dr in dataSet11.LG_BON_LIVRAISON.Rows) { DataRow drDet = dt_lg_b_liv_prepare.NewRow(); drDet.BeginEdit(); drDet["CODE_ARTICLE"] = dr["CODE_ARTICLE"]; drDet["REF_ARTICLE"] = dr["REF_ARTICLE"]; drDet["DESIGNATION_ARTICLE"] = dr["DESIGNATION_ARTICLE"]; drDet["QTE_LIGNE_B_LIV"] = dr["QTE_LIGNE_B_LIV"]; drDet["PRIX_HT_B_LIV"] = dr["PRIX_HT_B_LIV"]; drDet["PRIX_TOTAL_HT"] = dr["PRIX_TOTAL_HT"]; drDet["REMISE"] = dr["REMISE"]; drDet["TVA_B_LIV"] = dr["TVA_B_LIV"]; drDet["PRIX_U_TTC"] = dr["PRIX_U_TTC"]; drDet["PRIX_TOTAL_TTC"] = dr["PRIX_TOTAL_TTC"]; drDet["CODE_COMMANDE"] = dr["CODE_COMMANDE"]; drDet["QTTE_STOCK"] = dr["QTTE_STOCK"]; drDet["MAX_REMISE"] = dr["MAX_REMISE"]; drDet.EndEdit(); dt_lg_b_liv_prepare.Rows.Add(drDet); dt_lg_b_liv_prepare.AcceptChanges(); } CHMGC.RESULT_QUERY res = CLIENT_APP_PARAM.gcws.SAVE(DATE_B_LIV.Value, CODE_CLIENT, CODE_CMD, Convert.ToDecimal(cbx_magasin.SelectedValue), CLIENT_APP_PARAM.Fenetre_principale.code_user, dt_lg_b_liv_prepare, NUM_FI.ToArray()); if (res.OK) { CODE_B_LIV.Text = res.CODE; MessageBox.Show(res.MESSAGE, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); chM_CMP_VALIDATION1.button1.Enabled = false; this.Cursor = Cursors.Default; if (MessageBox.Show("Voulez vous imprimer le bon de livraison?", "Impression", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { this.Cursor = Cursors.WaitCursor; DataTable dt = CLIENT_APP_PARAM.gcws.Imprimer_BL(res.CODE); decimal montant_ht = 0; decimal montant_remise = 0; decimal montant_TVA = 0; decimal montant_TTC = 0; foreach (DataRow dr in dt.Rows) { montant_ht += (decimal)dr["PRIX_HT_B_LIV"] * (decimal)dr["QTE_LIGNE_B_LIV"]; montant_remise += (decimal)dr["PRIX_HT_B_LIV"] * (decimal)dr["REMISE"] / 100 * (decimal)dr["QTE_LIGNE_B_LIV"]; montant_TVA += ((decimal)dr["PRIX_HT_B_LIV"] - (decimal)dr["PRIX_HT_B_LIV"] * (decimal)dr["REMISE"] / 100) * (decimal)dr["TVA_B_LIV"] / 100 * (decimal)dr["QTE_LIGNE_B_LIV"]; } montant_TTC = montant_ht - montant_remise + montant_TVA; RPT_B_LIV rpt = new RPT_B_LIV(); rpt.SetDataSource(dt); rpt.SetParameterValue("mnt_HT", montant_ht); rpt.SetParameterValue("Total_Remise", montant_remise); rpt.SetParameterValue("Total_TVA", montant_TVA); rpt.SetParameterValue("Montant_TTC", montant_TTC); rpt.SetParameterValue("entete", CLIENT_APP_PARAM.entete); rpt.PrintOptions.PrinterName = CLIENT_APP_PARAM.ReportPrinter; rpt.PrintToPrinter(1, true, 0, 0); this.Cursor = Cursors.Default; } Close(); } else { MessageBox.Show(res.MESSAGE, "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception er) { MessageBox.Show(er.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } } } else { MessageBox.Show("Bon de livraison vide, veuillez insérer les articles!"); } }