예제 #1
0
파일: MembersUC.cs 프로젝트: ATGfx/MMSoft
        private void ComboxPostalCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            UInt32 PCID_UL = 0;

            ComboxPostalCode.GetSelectedItemID(out PCID_UL);

            if (PCID_UL > 0)
            {
                ComboxLocality.SelectItemByID(PCID_UL);
            }

            ValueChanged(this, EventArgs.Empty);
        }
예제 #2
0
파일: MembersUC.cs 프로젝트: ATGfx/MMSoft
        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);
            }
        }