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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
private void btnNouv_Click(object sender, EventArgs e)
{
#region Entete
string title = Param.SoftName;
if (ChampNonVide())
{
if (MessageBox.Show(
"Cette opération est irrévestible. Etes-vous de l'authenticité de vos entrées?",
title, MessageBoxButtons.YesNo,
MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1)
== DialogResult.Yes)
{
if (mttlist < TotalVend)
{
decimal x;
if (MessageBox.Show(
"L'encaissement est inférieur au solde. Voulez-vous vraiment l'encaisser ?",
title, MessageBoxButtons.YesNo,
MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1)
== DialogResult.No)
{
return;
}
}
if (_CurrentReglement == null)
_CurrentReglement = new REGLEMENT();
_CurrentReglement.DTEOP = DateTime.Now;
_CurrentReglement.ID_SIM = IdSIM2;
_CurrentReglement.ID_Caissier = Param_Base.iduservENTE;
//_CurrentReglement.N_BORDEREAU = txtNBordereau.Text.Trim();
_CurrentReglement.REF_REGLEMENT = txtRefBR.Text.Trim();
//_CurrentReglement.MODEPAIEMENT = CboMPaie.Text.Trim();
_CurrentReglement.MTTREGLEMENT = MttPayer;
_CurrentReglement.IS_VALIDER = true;
_CurrentReglement.IS_COMPTABILISER = false;
}
else
{
return;
}
#endregion
SqlTransaction transAchat = null;
try
{
if (DbConnectionInfo.DbConnection.State == ConnectionState.Closed)
{
DbConnectionInfo.DbConnection.Open();
}
transAchat = DbConnectionInfo.DbConnection.BeginTransaction();
//transAchat.Save();
_CurrentReglement.Save(transAchat);
idRef = _CurrentReglement.ID_AUTO;
#region Insertion dans la table Mouvement Caisse
//Ajouter detail Achat
_CurrentMvtCaisse = new MVT_CAISSE();
_CurrentMvtCaisse.DATEOP = DateTime.Now;
_CurrentMvtCaisse.LBLOPERATION = "Règlement de " + CboVM.Text.Trim();
_CurrentMvtCaisse.MTT_REPORT = oldSoldCaisse;
_CurrentMvtCaisse.MTT_CREDITE = 0;
_CurrentMvtCaisse.MTT_DEBITE = MttPayer;
_CurrentMvtCaisse.ID_CAISSE = Param_Base.iduservENTE;
_CurrentMvtCaisse.REF_MVEMENT = txtRefBR.Text.Trim();
_CurrentMvtCaisse.Save(transAchat);
#endregion
#region Entree Mouvement TransfertM2
_currentMTransfert = new MVT_TRANSFERT();
_currentMTransfert.REF_MVT = txtRefBR.Text.Trim();
_currentMTransfert.DATEOP = DateTime.Now;
_currentMTransfert.ID_SIM = IdSIM2;
_currentMTransfert.IS_ANNULER = false;
_currentMTransfert.LOGINPAS = Param_Base._loginpastor;
_currentMTransfert.OBSERVATION = "Inventaire N°" + txtRefBR.Text.Trim();
_currentMTransfert.STK_ANCIEN = initial;
_currentMTransfert.STK_ENTREE = 0;
_currentMTransfert.STK_SORTIE = MttCharger;
_currentMTransfert.STK_FINAL = CreditFinal;
_currentMTransfert.LOGINPAS = Param_Base._loginpastor;
_currentMTransfert.TypeSIM = TSIME;
_currentMTransfert.Save(transAchat);
#endregion
#region Détails Approvisionnement
//Ajouter detail Achat
int compteur = 0;
for (compteur = 0; compteur < _DetailReglementList.Count; compteur++)
{
_currentpayé = new DETAIL_REGLEMENT();
_currentpayé.ID_REGLEMENT = idRef;
_currentpayé.MONTANTPAYE = _DetailReglementList[compteur].MONTANTPAYE;
_currentpayé.NBORDEREAU = _DetailReglementList[compteur].NBORDEREAU;
_currentpayé.MODEPAIEMENT = _DetailReglementList[compteur].MODEPAIEMENT;
_currentpayé.AGENRT_PAYEUR = _DetailReglementList[compteur].AGENRT_PAYEUR;
_currentpayé.ID_BANK = idbank;
_currentpayé.Save(transAchat);
}
#endregion
#region Mouvements du dépôt
// MOuvement de sortie sur le dépôt de Vente
_currentRelevéVM = new RELEVECPTE_VM();
//_currentRelevéVM.Id_Famille = _RelevéList[0].
//_currentRelevéVM.ID_SIM
_currentRelevéVM.ID_SIM = IdSIM2;
_currentRelevéVM.LBLMVT = "Règlement " + CboVM.Text.Trim();
_currentRelevéVM.SOLDE_REPORT = _RelevéList[0].SOLDECPTE;
_currentRelevéVM.MTT_CREDIT = MttPayer;
_currentRelevéVM.MTT_DEBIT = 0;
_currentRelevéVM.N_BORDEREAU = txtRefBR.Text.Trim();
_currentRelevéVM.SOLDECPTE = FinSoldVM;
_currentRelevéVM.DATEOP = DateTime.Now;
_currentRelevéVM.Save(transAchat);
#endregion
transAchat.Commit();
//string title = Param.SoftName;
string message = string.Format("Règlement effectué avec succès.");
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
//EmptyFields();
}
catch (SqlException ex)
{
transAchat.Rollback();
//string title = Param.SoftName;
string message = string.Format("Une erreur est survenue. Raison: {0}", ex.Message);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
//_Currentvente = null;
}
}
} |
Partager