private void btnConfirmerVente_Click(object sender, EventArgs e)
        {
            //  try
            // {

            decimal policeId = (decimal)dgvPolicesEnCours.SelectedCells[0].Value;
            decimal clientId = (decimal)dgvClients.SelectedCells[0].Value;

            // DataSet2.POLICESRow policeRow = dataSet2.POLICES.FindByPOLICE_ID(policeId);
            // dataSet2.POLICES.FindByPOLICE_ID(policeId).BeginEdit();

            Police police = new Police();

            police.PoliceId          = policeId;
            police.Etat              = "vendu";
            police.FrequencePaiement = frequencePaiement[cmbFrequencePmt.SelectedIndex];
            police.MontantPaiement   = decimal.Parse(txtMontantPaiement.Text);
            police.ClientId          = clientId;
            police.DateAchat         = AgentView.SystemDate;
            police.DateDebut         = dtpDateDebut.Value;
            police.DateFin           = dtpDateFin.Value;
            DAO.UpdateTable(police);

            /* dataSet2.POLICES.FindByPOLICE_ID(policeId).ETAT = "vendu";
             * dataSet2.POLICES.FindByPOLICE_ID(policeId).FEQUENCE_PAIEMENT_CLIENT = frequencePaiement[cmbFrequencePmt.SelectedIndex];
             * dataSet2.POLICES.FindByPOLICE_ID(policeId).MONTANT_PAIEMENT_CLIENT = decimal.Parse(txtMontantPaiement.Text);
             * dataSet2.POLICES.FindByPOLICE_ID(policeId).CLIENT_ID = clientId;
             * dataSet2.POLICES.FindByPOLICE_ID(policeId).DATE_ACHAT = AgentView.SystemDate;
             * dataSet2.POLICES.FindByPOLICE_ID(policeId).DATE_DEBUT = dtpDateDebut.Value;
             * dataSet2.POLICES.FindByPOLICE_ID(policeId).DATE_FIN = dtpDateFin.Value;*/
            // dataSet2.POLICES.FindByPOLICE_ID(policeId).EndEdit();



            /*  }
             * catch (Exception)
             * {
             *
             *    MessageBox.Show("Erreur de saisie, tout les champs sont obligatoires");
             * }*/



            // this.pOLICESTableAdapter.Update(dataSet2.POLICES);
            // dataSet2.POLICES.AcceptChanges();


            MessageBox.Show("La vente a était enregistrée avec succès ...");
        }
        private void btnConfirmerVente_Click(object sender, EventArgs e)
        {
            //  try
               // {

               decimal policeId = (decimal)dgvPolicesEnCours.SelectedCells[0].Value;
                decimal clientId = (decimal)dgvClients.SelectedCells[0].Value;

               // DataSet2.POLICESRow policeRow = dataSet2.POLICES.FindByPOLICE_ID(policeId);
               // dataSet2.POLICES.FindByPOLICE_ID(policeId).BeginEdit();

                Police police = new Police();
                police.PoliceId = policeId;
                police.Etat = "vendu";
                police.FrequencePaiement = frequencePaiement[cmbFrequencePmt.SelectedIndex];
                police.MontantPaiement = decimal.Parse(txtMontantPaiement.Text);
                police.ClientId = clientId;
                police.DateAchat = AgentView.SystemDate;
                police.DateDebut = dtpDateDebut.Value;
                police.DateFin = dtpDateFin.Value;
                DAO.UpdateTable(police);
               /* dataSet2.POLICES.FindByPOLICE_ID(policeId).ETAT = "vendu";
                dataSet2.POLICES.FindByPOLICE_ID(policeId).FEQUENCE_PAIEMENT_CLIENT = frequencePaiement[cmbFrequencePmt.SelectedIndex];
                dataSet2.POLICES.FindByPOLICE_ID(policeId).MONTANT_PAIEMENT_CLIENT = decimal.Parse(txtMontantPaiement.Text);
                dataSet2.POLICES.FindByPOLICE_ID(policeId).CLIENT_ID = clientId;
                dataSet2.POLICES.FindByPOLICE_ID(policeId).DATE_ACHAT = AgentView.SystemDate;
                dataSet2.POLICES.FindByPOLICE_ID(policeId).DATE_DEBUT = dtpDateDebut.Value;
                dataSet2.POLICES.FindByPOLICE_ID(policeId).DATE_FIN = dtpDateFin.Value;*/
               // dataSet2.POLICES.FindByPOLICE_ID(policeId).EndEdit();

              /*  }
            catch (Exception)
            {

                MessageBox.Show("Erreur de saisie, tout les champs sont obligatoires");
            }*/

               // this.pOLICESTableAdapter.Update(dataSet2.POLICES);
               // dataSet2.POLICES.AcceptChanges();

            MessageBox.Show("La vente a était enregistrée avec succès ...");
        }
예제 #3
0
        public static void UpdateTable(Police police)
        {
            OracleCommand    sql        = new OracleCommand();
            OracleConnection connection = GetConnection();

            /*police.Etat = "vendu";
             * police.FrequencePaiement = frequencePaiement[cmbFrequencePmt.SelectedIndex];
             * police.MontantPaiement = decimal.Parse(txtMontantPaiement.Text);
             * police.ClientId = clientId;
             * police.DateAchat = AgentView.SystemDate;
             * police.DateDebut = dtpDateDebut.Value;
             * police.DateFin = dtpDateFin.Value;*/

            string query = "UPDATE polices SET etat = '" + police.Etat + "', fequence_paiement_client = '" +
                           police.FrequencePaiement + "', montant_paiement_client = " + police.MontantPaiement + ", client_id ='" +
                           police.ClientId + "', date_achat = to_date('"
                           + police.DateAchat.ToString(DateFormat) + "','" + DateFormat + "'), date_debut = to_date('"
                           + police.DateDebut.ToString(DateFormat) + "','" + DateFormat + "'), date_fin = to_date('"
                           + police.DateFin.ToString(DateFormat) + "','" + DateFormat + "')" +
                           "WHERE police_id = " + police.PoliceId;

            try
            {
                connection.Open();
                sql.Connection  = connection;
                sql.CommandText = query;
                sql.CommandType = System.Data.CommandType.Text;

                sql.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("DAO - UpdateTable :" + ex.Message);
                throw;
            }
            finally
            {
                connection.Close();
            }
        }
예제 #4
0
        public static void UpdateTable(Police police)
        {
            OracleCommand sql = new OracleCommand();
            OracleConnection connection = GetConnection();
            /*police.Etat = "vendu";
            police.FrequencePaiement = frequencePaiement[cmbFrequencePmt.SelectedIndex];
            police.MontantPaiement = decimal.Parse(txtMontantPaiement.Text);
            police.ClientId = clientId;
            police.DateAchat = AgentView.SystemDate;
            police.DateDebut = dtpDateDebut.Value;
            police.DateFin = dtpDateFin.Value;*/

            string query = "UPDATE polices SET etat = '" + police.Etat + "', fequence_paiement_client = '"+
                police.FrequencePaiement + "', montant_paiement_client = " + police.MontantPaiement + ", client_id ='"+
                police.ClientId + "', date_achat = to_date('"
                    + police.DateAchat.ToString(DateFormat) + "','" + DateFormat + "'), date_debut = to_date('"
                    + police.DateDebut.ToString(DateFormat) + "','" + DateFormat + "'), date_fin = to_date('"
                    + police.DateFin.ToString(DateFormat) + "','" + DateFormat + "')"+
                    "WHERE police_id = "+police.PoliceId;
            try
            {
                connection.Open();
                sql.Connection = connection;
                sql.CommandText = query;
                sql.CommandType = System.Data.CommandType.Text;

                sql.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("DAO - UpdateTable :"+ex.Message);
                throw;
            }
            finally
            {
                connection.Close();
            }
        }