Exemplo n.º 1
0
        private void BtnSaveChanges_Click(object sender, EventArgs e)
        {
            if (mEditState_b)
            {
                UInt32 ClientID_UL = DBListViewClient.GetSelectedItemID();

                //Build update request
                if (mDBManager_O != null && mDBManager_O.mConnected_b)
                {
                    UInt32 TypeSocID_UL;
                    UInt32 CPFactID_UL, CPLivrID_UL;
                    UInt32 ClientNumber_UL;

                    if (UInt32.TryParse(TxtClientNumber.Text, out ClientNumber_UL))
                    {
                        // Check if client number already exists
                        String ClientWithSameNumber_ST   = mDBManager_O.GetTableField("Client", "ClientNom", "NumClientInterne='" + ClientNumber_UL + "'");
                        String ClientIDWithSameNumber_ST = mDBManager_O.GetTableField("Client", "ClientID", "NumClientInterne='" + ClientNumber_UL + "'");
                        UInt32 ClientIDWithSameNumber_UL = 0;
                        UInt32.TryParse(ClientIDWithSameNumber_ST, out ClientIDWithSameNumber_UL);
                        DialogResult DlgRes_O = DialogResult.Yes;

                        if (!String.IsNullOrEmpty(TxtClientNumber.Text) && !String.IsNullOrEmpty(ClientWithSameNumber_ST) && ClientID_UL != ClientIDWithSameNumber_UL)
                        {
                            DlgRes_O = MessageBox.Show("Le client " + ClientWithSameNumber_ST + " existe déjà sous le numéro " + ClientNumber_UL + ". Poursuivre quand même l'enregistrement ?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        }

                        if (DlgRes_O == DialogResult.Yes)
                        {
                            DBComboxTypeSoc.GetSelectedItemID(out TypeSocID_UL);
                            DBComboxCPFact.GetSelectedItemID(out CPFactID_UL);
                            DBComboxCPLivr.GetSelectedItemID(out CPLivrID_UL);

                            List <String> Param_O  = new List <String>();
                            List <Object> Values_O = new List <Object>();

                            String SqlCommand_O = @"UPDATE Client SET ClientNom=@ClientNom, NumClientInterne=@NumClientInterne, TypeSocID=@TypeSocID, NrTVA=@NrTVA, Contact=@Contact, ContactTel=@ContactTel,
                                                           ContactEmail=@ContactEmail, AdresseFact=@AdresseFact, CodePostalFactID=@CodePostalFactID, AdresseLivraison=@AdresseLivraison, CodePostalLivraisonID=@CodePostalLivraisonID,
                                                            ClientTel=@ClientTel, ClientFax=@ClientFax, ClientMail=@ClientMail, ClientRem=@ClientRem, NoteEnvoi=@NoteEnvoi, Certif=@Certif, RappConf=@RappConf
                                                       WHERE ClientID=@ClientID";

                            Param_O.Add("@ClientNom"); Values_O.Add(TxtClientName.Text);
                            Param_O.Add("@NumClientInterne"); Values_O.Add((int)ClientNumber_UL);
                            Param_O.Add("@TypeSocID"); Values_O.Add((int)TypeSocID_UL);
                            Param_O.Add("@NrTVA"); Values_O.Add(TxtTVA.Text);
                            Param_O.Add("@Contact"); Values_O.Add(TxtContactName.Text);
                            Param_O.Add("@ContactTel"); Values_O.Add(TxtContactTel.Text);
                            Param_O.Add("@ContactEmail"); Values_O.Add(TxtContactMail.Text);
                            Param_O.Add("@AdresseFact"); Values_O.Add(TxtAdressFact.Text);
                            Param_O.Add("@CodePostalFactID"); Values_O.Add((int)CPFactID_UL);
                            Param_O.Add("@AdresseLivraison"); Values_O.Add(TxtAdressLivr.Text);
                            Param_O.Add("@CodePostalLivraisonID"); Values_O.Add((int)CPLivrID_UL);
                            Param_O.Add("@ClientTel"); Values_O.Add(TxtTel.Text);
                            Param_O.Add("@ClientFax"); Values_O.Add(TxtFax.Text);
                            Param_O.Add("@ClientMail"); Values_O.Add(TxtMail.Text);
                            Param_O.Add("@ClientRem"); Values_O.Add(TxtRem.Text);
                            Param_O.Add("@ClientID"); Values_O.Add((int)ClientID_UL);
                            Param_O.Add("@NoteEnvoi"); Values_O.Add(CheckBoxNE.Checked);
                            Param_O.Add("@Certif"); Values_O.Add(CheckBoxCertif.Checked);
                            Param_O.Add("@RappConf"); Values_O.Add(CheckBoxRappConf.Checked);

                            mDBManager_O.ExecuteRequest(SqlCommand_O, Param_O, Values_O);

                            SetEditState(false);
                            DBListViewClient.SetLockState(false);
                            DBListViewClient.Refresh();
                            DBListViewClient.SelectItemByID(ClientID_UL);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Impossible d'enregistrer les modifications : le numéro de client entré n'est pas un nombre valide.", "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void BtnSaveChanges_Click(object sender, EventArgs e)
        {
            if (mEditState_b)
            {
                UInt32 ProviderID_UL = DBListViewProvider.GetSelectedItemID();

                //Build update request
                if (mDBManager_O != null && mDBManager_O.mConnected_b)
                {
                    UInt32 TypeSocID_UL;
                    UInt32 CPFactID_UL;

                    // Check if provider number already exists
                    String ProviderWithSameNumber_ST   = mDBManager_O.GetTableField("Fourn", "FournNom", "NumFournInterne='" + TxtProviderNumber.Text + "'");
                    String ProviderIDWithSameNumber_ST = mDBManager_O.GetTableField("Fourn", "FournID", "NumFournInterne='" + TxtProviderNumber.Text + "'");
                    UInt32 ProviderIDWithSameNumber_UL = 0;
                    UInt32.TryParse(ProviderIDWithSameNumber_ST, out ProviderIDWithSameNumber_UL);
                    DialogResult DlgRes_O = DialogResult.Yes;

                    if (!String.IsNullOrEmpty(TxtProviderNumber.Text) && !String.IsNullOrEmpty(ProviderWithSameNumber_ST) && ProviderID_UL != ProviderIDWithSameNumber_UL)
                    {
                        DlgRes_O = MessageBox.Show("Le fournisseur " + ProviderWithSameNumber_ST + " existe déjà sous le numéro " + TxtProviderNumber.Text + ". Poursuivre quand même l'enregistrement ?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    }

                    if (DlgRes_O == DialogResult.Yes)
                    {
                        DBComboxTypeSoc.GetSelectedItemID(out TypeSocID_UL);
                        DBComboxCPFact.GetSelectedItemID(out CPFactID_UL);

                        List <String> Param_O  = new List <String>();
                        List <Object> Values_O = new List <Object>();

                        String SqlCommand_O = @"UPDATE Fourn SET FournNom=@FournNom, NumFournInterne=@NumFournInterne, TypeSocID=@TypeSocID, NrTVA=@NrTVA, Contact=@Contact, ContactTel=@ContactTel,
                                                           ContactEmail=@ContactEmail, Adresse=@Adresse, CodePostalID=@CodePostalID, FournTel=@FournTel, FournFax=@FournFax, FournMail=@FournMail,
                                                           FournRem=@FournRem
                                                       WHERE FournID=@FournID";

                        Param_O.Add("@FournNom");        Values_O.Add(TxtProviderName.Text);
                        Param_O.Add("@NumFournInterne"); Values_O.Add(TxtProviderNumber.Text);
                        Param_O.Add("@TypeSocID");       Values_O.Add((int)TypeSocID_UL);
                        Param_O.Add("@NrTVA");           Values_O.Add(TxtTVA.Text);
                        Param_O.Add("@Contact");         Values_O.Add(TxtContactName.Text);
                        Param_O.Add("@ContactTel");      Values_O.Add(TxtContactTel.Text);
                        Param_O.Add("@ContactEmail");    Values_O.Add(TxtContactMail.Text);
                        Param_O.Add("@Adresse");         Values_O.Add(TxtAdressFact.Text);
                        Param_O.Add("@CodePostalID");    Values_O.Add((int)CPFactID_UL);
                        Param_O.Add("@FournTel");        Values_O.Add(TxtTel.Text);
                        Param_O.Add("@FournFax");        Values_O.Add(TxtFax.Text);
                        Param_O.Add("@FournMail");       Values_O.Add(TxtMail.Text);
                        Param_O.Add("@FournRem");        Values_O.Add(TxtRem.Text);
                        Param_O.Add("@FournID");         Values_O.Add((int)ProviderID_UL);

                        mDBManager_O.ExecuteRequest(SqlCommand_O, Param_O, Values_O);

                        SetEditState(false);
                        DBListViewProvider.SetLockState(false);
                        DBListViewProvider.Refresh();
                        DBListViewProvider.SelectItemByID(ProviderID_UL);
                    }
                }
            }
        }