コード例 #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Date,Libelle,Debit,Montant")] Ecriture ecriture)
        {
            if (id != ecriture.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ecriture);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EcritureExists(ecriture.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ecriture));
        }
コード例 #2
0
 private void new_btn_Click(object sender, EventArgs e)
 {
     if (new_btn.Tag == null || !(bool)new_btn.Tag)
     {
         current          = new Ecriture();
         current.Colonnes = new List <ColumnEcriture>();
         foreach (var item in servStructs.GetByEvenement(Convert.ToInt32(events_liste.SelectedValue.ToString())))
         {
             current.Colonnes.Add(new ColumnEcriture {
                 Champs = item
             });
         }
         var liste = new List <Ecriture>();
         liste.Add(current);
         bs.DataSource          = new BindingList <ColumnEcriture>(current.Colonnes);
         columnsGrid.DataSource = bs;
         cle_tb.Clear(); num_tb.Clear(); ligneCondi_tb.Clear();
         num_tb.ReadOnly         = cle_tb.ReadOnly = false;
         ecritures_liste.Enabled = false;
         new_btn.Text            = "A\nn\nn\nu\nl\ne\nr";
         new_btn.Tag             = true;
     }
     else
     {
         columnsGrid.DataSource = null;
         cle_tb.Clear(); num_tb.Clear(); ligneCondi_tb.Clear();
         ecritures_liste.Enabled       = true;
         ecritures_liste.SelectedIndex = -1;
         new_btn.Text = "N\no\nu\nv\ne\na\nu";
         new_btn.Tag  = false;
     }
 }
コード例 #3
0
        //I'm here
        public int Modifier(Ecriture obj, Evenement evenement)
        {
            //try
            //{
            var           cnx = Connector.GetConnection();
            var           cmd = cnx.CreateCommand();
            var           sql = string.Format("update Ecritures_{0} set condition=@condition", evenement.Libelle);
            StringBuilder sb  = new StringBuilder();

            foreach (var item in obj.Colonnes)
            {
                sb.Append(",");
                sb.Append(item.Champs.Champs);
                sb.Append(string.Format("=@{0}", item.Champs.Champs));
            }
            sb.Append(" where cleecrit=@cleecrit and numecrit=@numecrit");
            sql            += sb.ToString();
            cmd.CommandText = sql;
            //remplissage des parametres
            DatasUtility.AddParameterWithValue(cmd, "@cleecrit", obj.Cle);
            DatasUtility.AddParameterWithValue(cmd, "@numecrit", obj.Numero);
            DatasUtility.AddParameterWithValue(cmd, "@condition", obj.Condition);
            foreach (var item in obj.Colonnes)
            {
                DatasUtility.AddParameterWithValue(cmd, "@" + item.Champs.Champs, item.Requette);
            }
            cnx.Open();
            System.Windows.Forms.MessageBox.Show(cmd.CommandText);
            cnx.Close();
            return(0);
            //}
            //catch (Exception)
            //{ return 1; }
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("IdCompte,Date,Libelle,Debit,Montant")] Ecriture ecriture)
        {
            if (ModelState.IsValid)
            {
                ecriture.Id = Guid.NewGuid();
                _context.Add(ecriture);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ecriture));
        }
コード例 #5
0
        private void ecritures_liste_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                current                = (Ecriture)ecritures_liste.SelectedItem;
                bs.DataSource          = new BindingList <ColumnEcriture>(current.Colonnes);
                columnsGrid.DataSource = bs;

                ligneCondi_tb.Text = current.Condition;
                num_tb.Text        = current.Numero.ToString();
                cle_tb.Text        = current.Cle.ToString();

                num_tb.ReadOnly = cle_tb.ReadOnly = true;
            }
            catch (Exception)
            {}
        }
コード例 #6
0
        public bool IsExist(Ecriture ecr, Evenement evenement)
        {
            var cnx = Connector.GetConnection();
            var cmd = cnx.CreateCommand();
            var sql = string.Format("select 1 from Ecritures_{0} where cleecrit=@cle", evenement.Libelle);

            DatasUtility.AddParameterWithValue(cmd, "@cle", ecr.Cle);
            cnx.Open();
            try
            {
                int rslt = (int)cmd.ExecuteScalar();
                cnx.Close(); return(true);
            }
            catch (Exception)
            {
                cnx.Close(); return(false);
            }
        }
コード例 #7
0
        public List <Ecriture> GetByCondition(Evenement evenement, Condition condi)
        {
            servStruct.Connector = this.Connector;
            var                   structures = servStruct.GetByEvenement(evenement.Code);
            List <Ecriture>       liste      = new List <Ecriture>();
            Ecriture              obj;
            List <ColumnEcriture> colsEcr;
            //try
            //{
            var cnx = Connector.GetConnection();
            var cmd = cnx.CreateCommand();

            cmd.CommandText = string.Format("select * from Ecritures_{0} where numecrit={1}",
                                            evenement.Libelle, condi.NumEcriture);
            cnx.Open();
            var dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                obj           = new Ecriture();
                colsEcr       = new List <ColumnEcriture>();
                obj.Cle       = dr.GetInt32(0);
                obj.Numero    = dr.GetInt32(1);
                obj.Condition = dr[2].ToString();
                //Les colonnes
                foreach (var item in structures)
                {
                    colsEcr.Add(new ColumnEcriture {
                        Champs = item, Requette = dr[item.Champs].ToString()
                    });
                }
                obj.Colonnes = colsEcr;
                liste.Add(obj);
            }
            cnx.Close();
            return(liste);
            //}
            //catch (Exception)
            //{ return null; }
        }
コード例 #8
0
        public int Ajouter(Ecriture obj, Evenement evenement)
        {
            //try
            //{
            var           cnx = Connector.GetConnection();
            var           cmd = cnx.CreateCommand();
            var           sql = string.Format("insert into Ecritures_{0}(cleecrit,numecrit,condition", evenement.Libelle);
            StringBuilder sb  = new StringBuilder();

            foreach (var item in obj.Colonnes)
            {
                sb.Append(",");
                sb.Append(item.Champs.Champs);
            }
            sb.Append(") values(@cleecrit,@numecrit,@condition");
            foreach (var item in obj.Colonnes)
            {
                sb.Append(",");
                sb.Append(string.Format("@{0}", item.Champs.Champs));
            }
            sb.Append(")");
            sql            += sb.ToString();
            cmd.CommandText = sql;
            //remplissage des parametres
            DatasUtility.AddParameterWithValue(cmd, "@cleecrit", obj.Cle);
            DatasUtility.AddParameterWithValue(cmd, "@numecrit", obj.Numero);
            DatasUtility.AddParameterWithValue(cmd, "@condition", obj.Condition == null ? (object)DBNull.Value : obj.Condition);
            foreach (var item in obj.Colonnes)
            {
                DatasUtility.AddParameterWithValue(cmd, string.Format("@{0}", item.Champs.Champs), item.Requette);
            }
            cnx.Open();
            cmd.ExecuteNonQuery();
            cnx.Close();
            return(0);
            //}
            //catch (Exception)
            //{ return 1; }
        }