Exemple #1
0
        private void validChanges_Click(object sender, EventArgs e)
        {
            Dictionary <string, string> Import_Values = new Dictionary <string, string>
            {
                { "NumDossier", TB_numDoss.Text },
                { "NumFactureFournisseurEtrange", TB_NFactFournEtrange.Text },
                { "NumBonComndEtrnge", TB_numBCmdEtrange.Text },
                { "NomFournisseurEtrange", TB_NomFournEtrange.Text },
                { "RefFactureFournisseurLocal1", TB_refFactFournLocal1.Text },
                { "NumBonComndFournisseurLocal1", TB_numBonCmdFournLocal1.Text },
                { "RefFactureFournisseurLocal2", TB_refFactFournLocal2.Text },
                { "NumBonComndFournisseurLocal2", TB_numBonCmdFournLocal2.Text },
                { "NumEngagementImport", TB_numEngagImport.Text },
                { "NumBoite", TB_numBoite.Text },
            };

            // Verifier les erreurs
            bool allgood = true;
            var  errmsg  = "Veillez remplir le champs";

            foreach (var item in Import_Values)
            {
                if (item.Value == "")
                {
                    switch (item.Key)
                    {
                    case "NumDossier":
                        errorProvider1.SetError(TB_numDoss, errmsg);
                        allgood = false;
                        break;

                    case "NumFactureFournisseurEtrange":
                        errorProvider1.SetError(TB_NFactFournEtrange, errmsg);
                        allgood = false;
                        break;

                    case "NumBonComndEtrnge":
                        errorProvider1.SetError(TB_numBCmdEtrange, errmsg);
                        allgood = false;
                        break;

                    case "NomFournisseurEtrange":
                        errorProvider1.SetError(TB_NomFournEtrange, errmsg);
                        allgood = false;
                        break;

                    case "RefFactureFournisseurLocal1":
                        errorProvider1.SetError(TB_refFactFournLocal1, errmsg);
                        allgood = false;
                        break;

                    case "NumBonComndFournisseurLocal1":
                        errorProvider1.SetError(TB_numBonCmdFournLocal1, errmsg);
                        allgood = false;
                        break;

                    case "RefFactureFournisseurLocal2":
                        errorProvider1.SetError(TB_refFactFournLocal2, errmsg);
                        allgood = false;
                        break;

                    case "NumBonComndFournisseurLocal2":
                        errorProvider1.SetError(TB_numBonCmdFournLocal2, errmsg);
                        allgood = false;
                        break;

                    case "NumEngagementImport":
                        errorProvider1.SetError(TB_numEngagImport, errmsg);
                        allgood = false;
                        break;

                    case "NumBoite":
                        errorProvider1.SetError(TB_numBoite, errmsg);
                        allgood = false;
                        break;
                    }
                }
            }

            if (!allgood)
            {
                MessageBox.Show("Veillez remplir tous les champs nécessaire!!");
                return;
            }


            //verifier les chagements des colonnes
            Helper.VerifyChanges(Import_Values, this);

            Import_Values["NumBoite"] = string.IsNullOrWhiteSpace(TB_numBoite.Text) ? "0" : TB_numBoite.Text;

            Helper.CheckForQuote(ref Import_Values);

            var constr = ConfigurationManager.ConnectionStrings["StrCon"].ConnectionString;

            using (SqlConnection cnn = new SqlConnection(constr))
            {
                cnn.Open();

                // update vente set [Client]= ,[DateFacture]= ,[Numfacture]= ,[NumProjet]= ,[BU]= ,[Numboite]= where [NomDossier]=
                var req = $"UPDATE import SET [NumDossier]='{Import_Values["NumDossier"]}' ,[NumFactureFournisseurEtrange]='{Import_Values["NumFactureFournisseurEtrange"]}' ,[NumBonComndEtrnge]='{Import_Values["NumBonComndEtrnge"]}' ,[NomFournisseurEtrange]='{Import_Values["NomFournisseurEtrange"]}', [RefFactureFournisseurLocal1]='{Import_Values["RefFactureFournisseurLocal1"]}',[NumBonComndFournisseurLocal1]='{Import_Values["NumBonComndFournisseurLocal1"]}' ,[RefFactureFournisseurLocal2]='{Import_Values["RefFactureFournisseurLocal2"]}' ,[NumBonComndFournisseurLocal2]='{Import_Values["NumBonComndFournisseurLocal2"]}', [NumEngagementImport]='{Import_Values["NumEngagementImport"]}' , [NumBoite]={Import_Values["NumBoite"]} ,[id_status]=6 ,[id_user_control]={id_user_control},date_control=GETDATE() WHERE [NomDossier]='{NomDoc}' ";

                var cmd = new SqlCommand(req, cnn);
                cmd.ExecuteNonQuery();
                //MessageBox.Show("Opération effectué!!");
            }
            // supprimer le document dans le treeView
            controle.UpdateTreeView();
            controle.CalculeProdControl();
        }
        private void ValidChanges_Click(object sender, EventArgs e)
        {
            Dictionary <string, string> Fourn_Values = new Dictionary <string, string>
            {
                { "Fournisseur", TBFournisseur.Text },
                { "DateFacture", TBDateFacture.Text },
                { "NumProjet", TBNumProjet.Text },
                { "NumBonCommande", string.IsNullOrWhiteSpace(TBNumBonCom.Text) ? "" : TBNumBonCom.Text },
                { "NumBoite", TBNumBoite.Text },
                { "Reference", TBReference.Text },
                { "BU", TBbu.Text }
            };
            // Verifier la saisie
            bool allgood = true;
            var  errmsg  = "Veillez remplir le champs";

            foreach (var item in Fourn_Values)
            {
                if (item.Value == "")
                {
                    switch (item.Key)
                    {
                    case "Fournisseur":
                        errorProvider1.SetError(TBFournisseur, errmsg);
                        allgood = false;
                        break;

                    case "DateFacture":
                        errorProvider1.SetError(TBDateFacture, errmsg);
                        allgood = false;
                        break;

                    case "NumBoite":
                        errorProvider1.SetError(TBNumBoite, errmsg);
                        allgood = false;
                        break;

                    case "Reference":
                        errorProvider1.SetError(TBReference, errmsg);
                        allgood = false;
                        break;
                    }
                }
            }

            if (!allgood)
            {
                MessageBox.Show("Veillez remplir tous les champs nécessaire!!");
                return;
            }


            //verifier les chagements des colonnes
            Helper.VerifyChanges(Fourn_Values, this);

            Fourn_Values["NumBoite"] = string.IsNullOrWhiteSpace(TBNumBoite.Text) ? "0" : TBNumBoite.Text;

            Helper.CheckForQuote(ref Fourn_Values);
            var constr = ConfigurationManager.ConnectionStrings["StrCon"].ConnectionString;

            using (SqlConnection cnn = new SqlConnection(constr))
            {
                cnn.Open();

                // update vente set [Client]= ,[DateFacture]= ,[Numfacture]= ,[NumProjet]= ,[BU]= ,[Numboite]= where [NomDossier]=
                var req = $"UPDATE achat SET [Fournisseur]='{Fourn_Values["Fournisseur"]}' ,[DateFacture]='{Fourn_Values["DateFacture"]}' ,[Reference]='{Fourn_Values["Reference"]}' ,[NumBonCommande]='{Fourn_Values["NumBonCommande"]}', [NumProjet]='{Fourn_Values["NumProjet"]}',[BU]='{Fourn_Values["BU"]}' ,[NumBoite]={Fourn_Values["NumBoite"]} ,[id_status]=6 ,[id_user_control]={id_user_control},date_control=GETDATE() WHERE [NomDossier]='{NomDoc}' ";

                var cmd = new SqlCommand(req, cnn);
                cmd.ExecuteNonQuery();
                //MessageBox.Show("Opération effectué!!");
            }
            // supprimer le document dans le treeView
            controle.UpdateTreeView();
            controle.CalculeProdControl();
        }
Exemple #3
0
        private void ValidChanges_Click(object sender, EventArgs e)
        {
            Dictionary <string, string> cs_Values = new Dictionary <string, string>()
            {
                { "DatePiece", TBDatePiece.Text },
                { "NumProjet", TBNProjet.Text },
                { "BU", TBBU.Text },
                { "Reference", TBReference.Text },
                { "NumDImatricul", TBNumImm.Text },
                { "Salarie", TBSalarie.Text },
                { "NumBoite", TBNumBoite.Text },
            };

            // Verifier la saisie

            bool allgood = true;
            var  errmsg  = "Veillez remplir le champs";

            foreach (var item in cs_Values)
            {
                if (string.IsNullOrWhiteSpace(item.Value))
                {
                    switch (item.Key)
                    {
                    case "DatePiece":
                        errorProvider1.SetError(TBDatePiece, errmsg);
                        allgood = false;
                        break;

                    case "NumProjet":
                        errorProvider1.SetError(TBNProjet, errmsg);
                        allgood = false;
                        break;

                    case "NumDImatricul":
                        errorProvider1.SetError(TBNumImm, errmsg);
                        allgood = false;
                        break;

                    case "Salarie":
                        errorProvider1.SetError(TBSalarie, errmsg);
                        allgood = false;
                        break;

                    case "NumBoite":
                        errorProvider1.SetError(TBNumBoite, errmsg);
                        allgood = false;
                        break;
                    }
                }
            }

            if (!allgood)
            {
                MessageBox.Show("Veillez remplir tous les champs nécessaire!!");
                return;
            }

            //verifier les chagements des colonnes
            Helper.VerifyChanges(cs_Values, this);

            cs_Values["NumBoite"] = string.IsNullOrWhiteSpace(TBNumBoite.Text) ? "0" : TBNumBoite.Text;
            Helper.CheckForQuote(ref cs_Values);
            // Enregistrer les modifications
            var req    = $"update Caisse set [DatePiece]='{cs_Values["DatePiece"]}' ,[NumProjet]='{cs_Values["NumProjet"]}' ,[BU]='{cs_Values["BU"]}' ,[NumBoite]={cs_Values["NumBoite"]},Reference='{cs_Values["Reference"]}',NumDImatricul='{cs_Values["NumDImatricul"]}',Salarie='{cs_Values["Salarie"]}',id_status=6,id_user_control={id_user_control},date_control=GETDATE() WHERE [NomDossier]='{NomDoc}' ";
            var constr = ConfigurationManager.ConnectionStrings["StrCon"].ConnectionString;

            using (SqlConnection cnn = new SqlConnection(constr))
            {
                cnn.Open();
                var cmd = new SqlCommand(req, cnn);
                cmd.ExecuteNonQuery();
                //MessageBox.Show("Opération effectué!!");
            }
            // supprimer le document dans le treeView
            controle.UpdateTreeView();
            controle.CalculeProdControl();
        }