Beispiel #1
0
        /*
         *      public void AddFacture( LigneFacture ListF)
         *      {
         *          try
         *          {
         *              SqlCommand MySqlCommand = new SqlCommand("insert into [Facture](Reference,Montant, Date) values(@Facture_ref, @Facture_Montant, @Facture_date)");
         *
         *              MySqlCommand.Parameters.Add("@Facture_ref", SqlDbType.VarChar).Value = Convert.ToString(ListF.RefFProp);
         *              MySqlCommand.Parameters.Add("@Facture_Montant", SqlDbType.Int).Value = ListF.MontantProp ;
         *              MySqlCommand.Parameters.Add("@Facture_Date", SqlDbType.Date).Value = Convert.ToDateTime(ListF.DateProp);
         *              Connexion.FunctionToWrite(MySqlCommand);
         *
         *                  MySqlCommand = new SqlCommand("insert into [LigneFacture](IdFacture, IdArticle, Reference , Pu, Quantite) values(@FactureId, @ArticleId, @articles_ref,  @articles_prix,  @articles_quant)");
         *
         *                  MySqlCommand.Parameters.Add("@articles_ref", SqlDbType.VarChar).Value = Convert.ToString(ListF.RefProp);
         *                  MySqlCommand.Parameters.Add("@articles_prix", SqlDbType.Float).Value = Convert.ToDouble(ListF.PrixUProp);
         *                  MySqlCommand.Parameters.Add("@articles_quant", SqlDbType.Int).Value = Convert.ToInt32(ListF.QuantProp);
         *                  MySqlCommand.Parameters.Add("@ArticleId", SqlDbType.Int).Value = Convert.ToInt32(ListF.IdArtProp);
         *                  MySqlCommand.Parameters.Add("@FactureId", SqlDbType.Int).Value = Convert.ToInt32(GetFactureId(ListF.RefFProp));
         *
         *                  Connexion.FunctionToWrite(MySqlCommand);
         *
         *          }
         *          catch (SqlException es)
         *          {
         *              MessageBox.Show(es.Message);
         *          }
         *
         *      }
         *
         */


        public void AddFacture(LigneFacture ListF)
        {
            try
            {
                SqlCommand MySqlCommand = new SqlCommand("insert into [Facture](Reference,Montant, Date) values(@Facture_ref, @Facture_Montant, @Facture_date)");

                MySqlCommand.Parameters.Add("@Facture_ref", SqlDbType.VarChar).Value = Convert.ToString(ListF.RefFProp);
                MySqlCommand.Parameters.Add("@Facture_Montant", SqlDbType.Int).Value = ListF.MontantProp;
                MySqlCommand.Parameters.Add("@Facture_Date", SqlDbType.Date).Value   = Convert.ToDateTime(ListF.DateProp);
                Connexion.FunctionToWrite(MySqlCommand);

                MySqlCommand = new SqlCommand("insert into [LigneFacture](IdFacture, IdArticle, Reference , Pu, Quantite) values(@FactureId, @ArticleId, @articles_ref,  @articles_prix,  @articles_quant)");

                MySqlCommand.Parameters.Add("@articles_ref", SqlDbType.VarChar).Value = Convert.ToString(ListF.RefProp);
                MySqlCommand.Parameters.Add("@articles_prix", SqlDbType.Float).Value  = Convert.ToDouble(ListF.PrixUProp);
                MySqlCommand.Parameters.Add("@articles_quant", SqlDbType.Int).Value   = Convert.ToInt32(ListF.QuantProp);
                MySqlCommand.Parameters.Add("@ArticleId", SqlDbType.Int).Value        = Convert.ToInt32(ListF.IdArtProp);
                MySqlCommand.Parameters.Add("@FactureId", SqlDbType.Int).Value        = Convert.ToInt32(GetFactureId(ListF.RefFProp));

                Connexion.FunctionToWrite(MySqlCommand);
            }
            catch (SqlException es)
            {
                MessageBox.Show(es.Message);
            }
        }
Beispiel #2
0
 private void Btn_Ajouter_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(Txt_RefFac.Text) || string.IsNullOrEmpty(Txt_Quant.Text) || string.IsNullOrEmpty(Cbx_Ref.SelectedItem.ToString()))
         {
             MessageBox.Show("Une ou plusieurs entrées invalides", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else if (Int32.Parse(Txt_Quant.Text.ToString()) > QuantiteInit)
         {
             MessageBox.Show("Quantité disponible est " + QuantiteInit + " !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             LigneFacture Lg = new LigneFacture(Cbx_Ref.SelectedItem.ToString(), float.Parse(Txt_Prix.Text), Int32.Parse(Txt_Quant.Text));
             CurrentLg         = Lg;
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
     }
     catch (Exception Ex)
     {
         MessageBox.Show(Ex.Message);
     }
 }
Beispiel #3
0
        private void Btn_AjouterLgFacture_Click(object sender, EventArgs e)
        {
            AjouterLineFacture AjoutLF = new AjouterLineFacture(Fac);

            var result = AjoutLF.ShowDialog();

            if (result == DialogResult.OK)
            {
                LigneFacture NewLg = AjoutLF.CurrentLg;
                int          qte   = 0;
                foreach (DataRow row in CurrentDataTableLigneFactures.Rows)
                {
                    if (row["Référence"].ToString() == AjoutLF.CurrentLg.RefProp)
                    {
                        NewLg.QuantProp = Int32.Parse(row["Quantité"].ToString()) + NewLg.QuantProp;
                        qte             = Int32.Parse(row["Quantité"].ToString());
                        CurrentDataTableLigneFactures.Rows.Remove(row);
                        foreach (LigneFacture lf in Fac.ListLgFacture)
                        {
                            if (lf.RefProp == NewLg.RefProp)
                            {
                                Fac.ListLgFacture.Remove(lf);
                                break;
                            }
                        }
                        break;
                    }
                }

                Fac.ListLgFacture.Add(NewLg);

                if (Lb_Mont.Text == "Pas de Montant")
                {
                    Lb_Mont.Text = (NewLg.PrixUProp * NewLg.QuantProp).ToString();
                }
                else

                {
                    Lb_Mont.Text = (Int32.Parse(Lb_Mont.Text) + NewLg.PrixUProp * NewLg.QuantProp - qte * NewLg.PrixUProp).ToString();
                }
                CurrentDataTableLigneFactures.Rows.Add(
                    NewLg.RefProp,
                    NewLg.PrixUProp,
                    NewLg.QuantProp

                    );


                DtgListeLigneFacture.DataSource = CurrentDataTableLigneFactures;
                Btn_Modifier.Enabled            = true;
                Btn_SupprimerLF.Enabled         = true;
                Btn_Enregistrer.Enabled         = true;
            }
        }
Beispiel #4
0
        public void UpdateV2(LigneFacture NewLine)
        {
            MySqlCommand = new SqlCommand(" UPDATE [LigneFacture] SET  Reference= @articles_ref ,   Pu= @articles_prix ,  Quantite = @articles_quant where Reference=@Ref");

            MySqlCommand.Parameters.Add("@articles_ref", SqlDbType.VarChar).Value = Convert.ToString(NewLine.RefProp);
            MySqlCommand.Parameters.Add("@articles_prix", SqlDbType.Float).Value  = Convert.ToDouble(NewLine.PrixUProp);
            MySqlCommand.Parameters.Add("@articles_quant", SqlDbType.Int).Value   = Convert.ToInt32(NewLine.QuantProp);
            MySqlCommand.Parameters.Add("@Ref", SqlDbType.VarChar).Value          = Convert.ToString(NewLine.RefProp);


            Connexion.FunctionToWrite(MySqlCommand);
        }
Beispiel #5
0
        static LigneFacture ConvertRowToLgFacture(DataRow row)
        {
            LigneFacture CurrentFacture = new LigneFacture();


            string Reff = (row["Reference"].ToString().Length != 0) ? row["Reference"].ToString() : "pas de reference";

            CurrentFacture.RefProp = Reff;

            float Mnt = float.Parse(row["Pu"].ToString());

            CurrentFacture.PrixUProp = Mnt;

            int qte = Int32.Parse(row["Quantite"].ToString());

            CurrentFacture.QuantProp = qte;


            return(CurrentFacture);
        }
Beispiel #6
0
        private void Btn_Modifier_Click(object sender, EventArgs e)
        {
            DataRowView          currentDataRowView = (DataRowView)DtgListeLigneFacture.CurrentRow.DataBoundItem;
            ModifierLingeFacture MF = new ModifierLingeFacture(currentDataRowView);

            var result = MF.ShowDialog();

            if (result == DialogResult.OK)
            {
                LigneFacture NewLg = MF.CurrentLg;
                int          qte   = 0;
                foreach (DataRow row in CurrentDataTableLigneFactures.Rows)
                {
                    if (row["Référence"].ToString() == MF.CurrentLg.RefProp)
                    {
                        NewLg.QuantProp = Int32.Parse(row["Quantité"].ToString()) + NewLg.QuantProp;
                        qte             = Int32.Parse(row["Quantité"].ToString());
                        CurrentDataTableLigneFactures.Rows.Remove(row);
                        foreach (LigneFacture lf in Fac.ListLgFacture)
                        {
                            if (lf.RefProp == NewLg.RefProp)
                            {
                                Fac.ListLgFacture.Remove(lf);
                                break;
                            }
                        }
                        break;
                    }
                }
                Fac.ListLgFacture.Add(NewLg);

                Lb_Mont.Text = (Int32.Parse(Lb_Mont.Text) + NewLg.PrixUProp * NewLg.QuantProp - qte * NewLg.PrixUProp).ToString();

                CurrentDataTableLigneFactures.Rows.Add(
                    NewLg.RefProp,
                    NewLg.PrixUProp,
                    NewLg.QuantProp

                    );
            }
        }