private void ToolStripBtnDelete_Click(object sender, EventArgs e) { if (mDBManager_O != null && mDBManager_O.mConnected_b) { if (mDBManager_O.ExecuteRequest("DELETE FROM NoteEnvoi WHERE NoteEnvoiID=" + mSendNoteID_UL)) { // execute delete of rapp conf but can fail because rapp conf do not necessary exists mDBManager_O.ExecuteRequest("DELETE FROM RappConf WHERE NoteEnvoiID=" + mSendNoteID_UL); this.Parent.Controls.Remove(this); } } }
private void JobClicked(UInt32 JobID_UL, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { FormAskJobHourCorrection Form_O = new FormAskJobHourCorrection(); Form_O.StartPosition = FormStartPosition.Manual; Point EndPoint_O = DBListViewJobs.mListView_O.PointToScreen(new Point(e.X, e.Y)); if (EndPoint_O.X + Form_O.Width > Screen.PrimaryScreen.Bounds.Width) { EndPoint_O.X -= Form_O.Width; } if (EndPoint_O.Y + Form_O.Height > Screen.PrimaryScreen.Bounds.Height) { EndPoint_O.Y -= Form_O.Height; } Form_O.Location = new Point(EndPoint_O.X, EndPoint_O.Y); DialogResult DlgRes_O = Form_O.ShowDialog(); if (DlgRes_O == DialogResult.OK) { String SqlRequest_st = "UPDATE ComJob SET SommeHeureCorrect='" + Form_O.mEnteredNumber_f.ToString().Replace(",", ".") + "', ChkHoursCorrected=1 WHERE ComJobID=" + DBListViewJobs.GetSelectedItemID(); if (mDBManager_O != null && mDBManager_O.mConnected_b) { mDBManager_O.ExecuteRequest(SqlRequest_st); RefreshJobsList(); RefreshSum(); } } } }
private void ToolStripBtnGoto_Click(object sender, EventArgs e) { bool EncodingError_b = false; if (mDBManager_O != null && mDBManager_O.mConnected_b && sender.GetType() == typeof(ToolStripButton)) { UInt32 StatusID_UL = 0, DestinationStatusID_UL = Convert.ToUInt32(((ToolStripButton)sender).Tag) + 1; if (UInt32.TryParse(mDBManager_O.GetTableField("ComJob", "ComStatusID", "ComJobID=" + mComJobID_UL), out StatusID_UL)) { for (UInt32 i = StatusID_UL; i < DestinationStatusID_UL && !EncodingError_b; i++) { // Do not do anything before this because status change are done at other place in software if (i == 3) { mDBManager_O.mStoredProcedureManager_O.STPROC_ExpedierJob(mComJobID_UL); } else if (i == 4) { float QteFact_f, PUFact_f; if (Single.TryParse(ToolStripTxtboxQteFact.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out QteFact_f) && Single.TryParse(ToolStripTxtboxPUFact.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out PUFact_f)) { mDBManager_O.mStoredProcedureManager_O.STPROC_FacturerJob(mComJobID_UL); String UpdateString_st = "Update ComJob SET QteFact='" + QteFact_f.ToString(System.Globalization.CultureInfo.InvariantCulture) + "', PVFact='" + PUFact_f.ToString(System.Globalization.CultureInfo.InvariantCulture) + "' WHERE ComJobID=" + mComJobID_UL; mDBManager_O.ExecuteRequest(UpdateString_st); } else { MessageBox.Show("Impossible d'archiver le job car les valeurs de quantité et prix unitaire facturés ne sont pas correctes.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); EncodingError_b = true; } } else if (i == 5) { mDBManager_O.mStoredProcedureManager_O.STPROC_ArchiverJob(mComJobID_UL); } } UpdateJobStatus(); } } }
private void ToolStripBtnCloseJob_Click(object sender, EventArgs e) { FormAskString FormAskString_O = new FormAskString("Quantité produite :"); DialogResult DlgRes_O = FormAskString_O.ShowDialog(); float Qte_f; if (DlgRes_O == DialogResult.OK && mDBManager_O != null && mDBManager_O.mConnected_b) { if (DbListViewComJobs.GetSelectedItemID() > 0) { if (float.TryParse(FormAskString_O.mEnteredString_ST, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out Qte_f)) { DialogResult DlgConfirm_O = MessageBox.Show("Etes-vous sûr de vouloir clôturer le job " + DbListViewComJobs.GetSelectedItemField("JobLib") + " avec une quantité produite de " + Qte_f + " ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (DlgConfirm_O == DialogResult.Yes) { if (mDBManager_O.ExecuteRequest("UPDATE ComJob SET QteProd='" + Qte_f.ToString().Replace(",", ".") + "' WHERE ComJobID=" + DbListViewComJobs.GetSelectedItemID())) { mDBManager_O.mStoredProcedureManager_O.STPROC_CloseJob(DbListViewComJobs.GetSelectedItemID()); // Send message to tell manager that job is finished String Msg_ST = "[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + "] "; Msg_ST += "Job " + DbListViewComJobs.GetSelectedItemField("JobLib") + " clôturé"; mDBManager_O.mStoredProcedureManager_O.STPROC_SendMsg(Msg_ST, mUserID_UL); // Open return document if (mDocManager_O != null && DbListViewComJobs.GetSelectedItemID() > 0) { mDocManager_O.ShowReturnDocument(DbListViewComJobs.GetSelectedItemID()); } DbListViewComJobs.Refresh(); } else { MessageBox.Show("Impossible d'enregistrer la valeur " + FormAskString_O.mEnteredString_ST + " comme quantité produite.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("La quantité entrée n'est pas valide.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Veuillez sélectionner un job à clôturer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void BtnSaveComChanges_Click(object sender, EventArgs e) { if (mJobEditState_b) { MessageBox.Show("Des modifications sont en cours sur un job associé à la commande. Enregistez d'abord les modifications sur le job, ensuite celles sur la commande.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (mComEditState_b) { UInt32 ComID_UL = ComJobSelector.GetComListView().GetSelectedItemID(); //Build update request if (mDBManager_O != null && mDBManager_O.mConnected_b) { List <String> Param_O = new List <String>(); List <Object> Values_O = new List <Object>(); String SqlCommand_st = @"UPDATE Com SET NumRefInterne=@NumRefInterne, NumCmdClient=@NumCmdClient, LibelleCmd=@LibelleCmd, Info=@Info, NoteEnvoi=@NoteEnvoi, Certif=@Certif, RappConf=@RappConf WHERE ComID=@ComID"; Param_O.Add("@NumRefInterne"); Param_O.Add("@NumCmdClient"); Param_O.Add("@LibelleCmd"); Param_O.Add("@Info"); Param_O.Add("@NoteEnvoi"); Param_O.Add("@Certif"); Param_O.Add("@RappConf"); Param_O.Add("@ComID"); Values_O.Add(TxtComNumber.Text); Values_O.Add(TxtNumComClient.Text); Values_O.Add(TxtComLib.Text); Values_O.Add(TxtComInfos.Text); Values_O.Add(CheckBoxNE.Checked); Values_O.Add(CheckBoxCertif.Checked); Values_O.Add(CheckBoxRappConf.Checked); Values_O.Add((int)ComID_UL); mDBManager_O.ExecuteRequest(SqlCommand_st, Param_O, Values_O); } SetComEditState(false); ComJobSelector.GetComListView().SetLockState(false); ComJobSelector.GetComListView().Refresh(); ComJobSelector.GetComListView().SelectItemByID(ComID_UL); } }
/// <summary> /// This method record checking edition. /// </summary> public bool RecordModifications() { float NbrH_f, NbrhMach1_f, NbrhMach2_f, NbrhMach3_f, NbrhMach4_f; bool Rts_b = false; UInt32 TaskCount_UL, ComJobEtapeID_UL, SelectedItemID_UL, NewCheckingID_UL; if (mMode_e == CheckingEditionMode.Add) { if (CheckData(out NbrH_f, out NbrhMach1_f, out NbrhMach2_f, out NbrhMach3_f, out NbrhMach4_f) && mDataBaseManager_O.mConnected_b) { // Create job step TaskCount_UL = mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CountTask(mComJobID_UL); if (DBComboxTask.GetSelectedItemID(out SelectedItemID_UL)) { ComJobEtapeID_UL = mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreateComJobEtape(mComJobID_UL, SelectedItemID_UL, TaskCount_UL); if (ComJobEtapeID_UL > 0) { // Create pointage on this step NewCheckingID_UL = mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointage(mComJobID_UL, ComJobEtapeID_UL, mPersID_UL, NbrH_f, TxtRem.Text, mDate_O); // Create pointage machine if (DBComboxMachine1.GetSelectedItemID(out SelectedItemID_UL)) { mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointageMachine(ComJobEtapeID_UL, SelectedItemID_UL, NbrhMach1_f); } if (DBComboxMachine2.GetSelectedItemID(out SelectedItemID_UL)) { mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointageMachine(ComJobEtapeID_UL, SelectedItemID_UL, NbrhMach2_f); } if (DBComboxMachine3.GetSelectedItemID(out SelectedItemID_UL)) { mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointageMachine(ComJobEtapeID_UL, SelectedItemID_UL, NbrhMach3_f); } if (DBComboxMachine4.GetSelectedItemID(out SelectedItemID_UL)) { mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointageMachine(ComJobEtapeID_UL, SelectedItemID_UL, NbrhMach4_f); } // If first checking on job, set status to "in progress" if (TaskCount_UL == 0) { mDataBaseManager_O.mStoredProcedureManager_O.STPROC_StartJob(mComJobID_UL); } } else { MessageBox.Show("Erreur lors de l'enregistrement du pointage : l'étape associée n'a pu être créée.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Rts_b = true; } } else if (mMode_e == CheckingEditionMode.Edit) { UInt32 SelectedTaskID_UL; UInt32 MachineID_UL; List <String> Param_O = new List <String>(); List <Object> Values_O = new List <Object>(); if (mDataBaseManager_O.mConnected_b) { DBComboxTask.GetSelectedItemID(out SelectedTaskID_UL); // Update task Param_O.Add("@TypeTacheID"); Values_O.Add((int)SelectedTaskID_UL); Param_O.Add("@ComJobEtapeID"); Values_O.Add((int)mComJobEtapeID_UL); mDataBaseManager_O.ExecuteRequest("UPDATE ComJobEtape SET TypeTacheID=@TypeTacheID WHERE ComJobEtapeID=@ComJobEtapeID", Param_O, Values_O); // Update pointage Param_O.Clear(); Values_O.Clear(); float Nbrh_f; float.TryParse(TxtNbrH.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out Nbrh_f); Param_O.Add("@NbrH"); Values_O.Add(Nbrh_f); Param_O.Add("@Rem"); Values_O.Add(TxtRem.Text); Param_O.Add("@ComJobEtapeID"); Values_O.Add((int)mComJobEtapeID_UL); mDataBaseManager_O.ExecuteRequest("UPDATE Pointage SET NbrH=@NbrH, Rem=@Rem WHERE ComJobEtapeID=@ComJobEtapeID", Param_O, Values_O); // Update pointage machine (create it if not yet created) if (CheckData(out NbrH_f, out NbrhMach1_f, out NbrhMach2_f, out NbrhMach3_f, out NbrhMach4_f)) { DBComboxMachine1.GetSelectedItemID(out MachineID_UL); if (MachineID_UL > 0) { if (mPointageMachineID_O[0] == 0 && DBComboxTask.GetSelectedItemID(out SelectedItemID_UL)) { mPointageMachineID_O[0] = mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointageMachine(mComJobEtapeID_UL, SelectedItemID_UL, NbrhMach1_f); } Param_O.Clear(); Values_O.Clear(); Param_O.Add("@MachineID"); Values_O.Add((int)MachineID_UL); float.TryParse(TxtNbrhMach1.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out Nbrh_f); Param_O.Add("@NbrHMachine"); Values_O.Add(Nbrh_f); Param_O.Add("@PointageMachinelID"); Values_O.Add((int)mPointageMachineID_O[0]); mDataBaseManager_O.ExecuteRequest("UPDATE PointageMachine SET MachineID=@MachineID, NbrHMachine=@NbrHMachine WHERE PointageMachinelID=@PointageMachinelID", Param_O, Values_O); } DBComboxMachine2.GetSelectedItemID(out MachineID_UL); if (MachineID_UL > 0) { if (mPointageMachineID_O[1] == 0 && DBComboxTask.GetSelectedItemID(out SelectedItemID_UL)) { mPointageMachineID_O[1] = mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointageMachine(mComJobEtapeID_UL, SelectedItemID_UL, NbrhMach2_f); } Param_O.Clear(); Values_O.Clear(); Param_O.Add("@MachineID"); Values_O.Add((int)MachineID_UL); Param_O.Add("@NbrHMachine"); Values_O.Add(TxtNbrhMach2.Text); Param_O.Add("@PointageMachinelID"); Values_O.Add((int)mPointageMachineID_O[1]); mDataBaseManager_O.ExecuteRequest("UPDATE PointageMachine SET MachineID=@MachineID, NbrHMachine=@NbrHMachine WHERE PointageMachinelID=@PointageMachinelID", Param_O, Values_O); } DBComboxMachine3.GetSelectedItemID(out MachineID_UL); if (MachineID_UL > 0) { if (mPointageMachineID_O[2] == 0 && DBComboxTask.GetSelectedItemID(out SelectedItemID_UL)) { mPointageMachineID_O[2] = mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointageMachine(mComJobEtapeID_UL, SelectedItemID_UL, NbrhMach3_f); } Param_O.Clear(); Values_O.Clear(); Param_O.Add("@MachineID"); Values_O.Add((int)MachineID_UL); Param_O.Add("@NbrHMachine"); Values_O.Add(TxtNbrhMach3.Text); Param_O.Add("@PointageMachinelID"); Values_O.Add((int)mPointageMachineID_O[2]); mDataBaseManager_O.ExecuteRequest("UPDATE PointageMachine SET MachineID=@MachineID, NbrHMachine=@NbrHMachine WHERE PointageMachinelID=@PointageMachinelID", Param_O, Values_O); } DBComboxMachine4.GetSelectedItemID(out MachineID_UL); if (MachineID_UL > 0) { if (mPointageMachineID_O[3] == 0 && DBComboxTask.GetSelectedItemID(out SelectedItemID_UL)) { mPointageMachineID_O[3] = mDataBaseManager_O.mStoredProcedureManager_O.STPROC_CreatePointageMachine(mComJobEtapeID_UL, SelectedItemID_UL, NbrhMach4_f); } Param_O.Clear(); Values_O.Clear(); Param_O.Add("@MachineID"); Values_O.Add((int)MachineID_UL); Param_O.Add("@NbrHMachine"); Values_O.Add(TxtNbrhMach4.Text); Param_O.Add("@PointageMachinelID"); Values_O.Add((int)mPointageMachineID_O[3]); mDataBaseManager_O.ExecuteRequest("UPDATE PointageMachine SET MachineID=@MachineID, NbrHMachine=@NbrHMachine WHERE PointageMachinelID=@PointageMachinelID", Param_O, Values_O); } } Rts_b = true; } // Don't forget to update hours tot and corrected on job if (Rts_b) { mDataBaseManager_O.mStoredProcedureManager_O.STPROC_UpdateJobSumHours(mComJobID_UL); } } return(Rts_b); }
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); } } } }
private void ToolStripBtnValidate_Click(object sender, EventArgs e) { bool LoginOK_b = false; bool PwdOK_b = false; bool PrefHallOK_b = false; bool PrefDepOK_b = false; UInt32 PrefHallID_UL, PrefDepID_UL; if (mDBManager_O.mConnected_b) { // Check user login LoginOK_b = !String.IsNullOrEmpty(TxtLogin.Text); if (!LoginOK_b) { MessageBox.Show("Votre login ne peut être vide.", "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Check password PwdOK_b = !String.IsNullOrEmpty(TxtPwd.Text) && !String.IsNullOrEmpty(TxtConfirmPwd.Text); if (!PwdOK_b) { MessageBox.Show("Votre mot de passe ne peut être vide.", "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { PwdOK_b = TxtConfirmPwd.Text.Equals(TxtPwd.Text); if (!PwdOK_b) { MessageBox.Show("Votre mot de passe et sa confirmation ne sont pas identiques.", "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Error); } } // Check pref hall DBComboxPrefHall.GetSelectedItemID(out PrefHallID_UL); PrefHallOK_b = (PrefHallID_UL > 0); if (!PrefHallOK_b) { MessageBox.Show("Le hall préféré sélectionné n'est pas valide.", "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Check pref dep DBComboxPrefDep.GetSelectedItemID(out PrefDepID_UL); PrefDepOK_b = (PrefDepID_UL > 0); if (!PrefDepOK_b) { MessageBox.Show("Le département préféré sélectionné n'est pas valide.", "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (LoginOK_b && PwdOK_b && PrefHallOK_b && PrefDepOK_b) { List <String> Param_O = new List <String>(); List <Object> Values_O = new List <Object>(); String SQLCommand_st = @"UPDATE Pers SET UserLogin=@UserLogin, Pwd=@Pwd, PrefHallID=@PrefHallID, PrefDepID=@PrefDepID WHERE PersID=@PersID"; Param_O.Add("@UserLogin"); Param_O.Add("@Pwd"); Param_O.Add("@PrefHallID"); Param_O.Add("@PrefDepID"); Param_O.Add("@PersID"); Values_O.Add(TxtLogin.Text); Values_O.Add(TxtPwd.Text); Values_O.Add((int)PrefHallID_UL); Values_O.Add((int)PrefDepID_UL); Values_O.Add((int)mPersID_UL); mDBManager_O.ExecuteRequest(SQLCommand_st, Param_O, Values_O); this.Dispose(); } } }
private void BtnSaveChanges_Click(object sender, EventArgs e) { String SqlCommand_st; List <String> Param_O = new List <String>(); List <Object> Values_O = new List <Object>(); if (mEditState_b) { UInt32 MemberID_UL = DBListViewMembers.GetSelectedItemID(); //Build update request if (mDBManager_O != null && mDBManager_O.mConnected_b) { // Update member field SqlCommand_st = @"UPDATE Pers SET PersStatutID = @PersStatutID, DateNaissance = @DateNaissance, NumRegNat = @NumRegNat, NumTel = @NumTel, Adresse = @Adresse, SitFam = @SitFam, CodePostalID = @CodePostalID, NbrEnfCharge = @NbrEnfCharge, ConjActif = @ConjActif, DateEntreeService = @DateEntreeService, CompteBanq = @CompteBanq, CoutHeure = @CoutHeure, UserLogin = @UserLogin WHERE PersID=@PersID"; UInt32 PersStatusID_UL = 0, CPID_UL = 0; String CoutHeure_ST; float CoutHeure_f = 0.0f; DBComboxStatus.GetSelectedItemID(out PersStatusID_UL); ComboxPostalCode.GetSelectedItemID(out CPID_UL); CoutHeure_ST = TxtCost.Text.Trim('\u20AC'); CoutHeure_ST = CoutHeure_ST.Trim(); float.TryParse(CoutHeure_ST, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out CoutHeure_f); Param_O.Add("@PersID"); Values_O.Add((int)DBListViewMembers.GetSelectedItemID()); Param_O.Add("@PersStatutID"); Values_O.Add((int)PersStatusID_UL); Param_O.Add("@DateNaissance"); Values_O.Add(DTPBirthdate.Value); Param_O.Add("@NumRegNat"); Values_O.Add(TxtRegNumber.Text); Param_O.Add("@NumTel"); Values_O.Add(TxtTel.Text); Param_O.Add("@Adresse"); Values_O.Add(TxtAdress.Text); Param_O.Add("@SitFam"); Values_O.Add(ComBoxFamilyState.Text); Param_O.Add("@CodePostalID"); Values_O.Add((int)CPID_UL); Param_O.Add("@NbrEnfCharge"); Values_O.Add(TxtChilds.Text); Param_O.Add("@ConjActif"); Values_O.Add(CheckBoxActivePartner.Checked); Param_O.Add("@DateEntreeService"); Values_O.Add(DTPEntryDate.Value); Param_O.Add("@CompteBanq"); Values_O.Add(TxtBankAccount.Text); Param_O.Add("@CoutHeure"); Values_O.Add(CoutHeure_f); Param_O.Add("@UserLogin"); Values_O.Add(TxtLogin.Text); mDBManager_O.ExecuteRequest(SqlCommand_st, Param_O, Values_O); Param_O.Clear(); Values_O.Clear(); // Update member's department associations if (mUpdateDepartmentAssociation_b) { // Remove all association SqlCommand_st = @"DELETE FROM RelDepPers WHERE PersID=@PersID"; Param_O.Add("@PersID"); Values_O.Add((int)DBListViewMembers.GetSelectedItemID()); mDBManager_O.ExecuteRequest(SqlCommand_st, Param_O, Values_O); Param_O.Clear(); Values_O.Clear(); // Add them back plus new ones List <UInt32> IdList_UL = DepartmentSelector.GetSelectedDepartmentsID(); for (int i = 0; i < IdList_UL.Count; i++) { SqlCommand_st = @"INSERT INTO RelDepPers(DepID, PersID) VALUES (@DepID, @PersID)"; Param_O.Add("@DepID"); Values_O.Add((int)IdList_UL[i]); Param_O.Add("@PersID"); Values_O.Add((int)DBListViewMembers.GetSelectedItemID()); mDBManager_O.ExecuteRequest(SqlCommand_st, Param_O, Values_O); Param_O.Clear(); Values_O.Clear(); } mUpdateDepartmentAssociation_b = false; } } SetEditState(false); DBListViewMembers.SetLockState(false); DBListViewMembers.Refresh(); DBListViewMembers.SelectItemByID(MemberID_UL); } }
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); } } } }