Exemple #1
0
        /// <summary>
        /// This method checks if all data entered by user is correct before recording modifications. If this is not the case, wrong elements in GUI are highlighted.
        /// </summary>
        /// <returns></returns>
        private bool CheckData(out float Nbrh_f, out float NbrhMach1_f, out float NbrhMach2_f, out float NbrhMach3_f, out float NbrhMach4_f)
        {
            bool   Rts_b = true;
            UInt32 Mach1SelectedItemID_UL, Mach2SelectedItemID_UL, Mach3SelectedItemID_UL, Mach4SelectedItemID_UL, TaskID_UL;

            NbrhMach1_f = 0.0f;
            NbrhMach2_f = 0.0f;
            NbrhMach3_f = 0.0f;
            NbrhMach4_f = 0.0f;

            Rts_b &= DBComboxTask.GetSelectedItemID(out TaskID_UL);
            Rts_b &= float.TryParse(TxtNbrH.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out Nbrh_f);

            if (DBComboxMachine1.GetSelectedItemID(out Mach1SelectedItemID_UL))
            {
                Rts_b &= float.TryParse(TxtNbrhMach1.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out NbrhMach1_f);
            }

            if (DBComboxMachine2.GetSelectedItemID(out Mach2SelectedItemID_UL))
            {
                Rts_b &= float.TryParse(TxtNbrhMach2.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out NbrhMach2_f);
            }

            if (DBComboxMachine3.GetSelectedItemID(out Mach3SelectedItemID_UL))
            {
                Rts_b &= float.TryParse(TxtNbrhMach3.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out NbrhMach3_f);
            }

            if (DBComboxMachine4.GetSelectedItemID(out Mach4SelectedItemID_UL))
            {
                Rts_b &= float.TryParse(TxtNbrhMach4.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out NbrhMach4_f);
            }

            return(Rts_b);
        }
Exemple #2
0
        /// <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);
        }