예제 #1
0
 public void TestIfParentIsCorrectlySetAndRetrieved()
 {
     EconomicActivity parent = new EconomicActivity();
     parent.Id = 1;
     doa.Parent = parent;
     Assert.AreEqual(1,doa.Parent.Id);
 }
예제 #2
0
 public EconomicActivity(string name, EconomicActivity pParent, bool deleted)
 {
     _name     = name;
     _parent   = pParent;
     _deleted  = deleted;
     _hasValue = true;
 }
예제 #3
0
        public EconomicActivity(string name, EconomicActivity pParent, bool deleted)
		{
			_name = name;
            _parent = pParent;
			_deleted = deleted;
            _hasValue = true;
		}
예제 #4
0
        public void Get_Set_EconomicActivity()
        {
            ContractAccountingRule rule = new ContractAccountingRule();
            Assert.AreEqual(null, rule.EconomicActivity);

            EconomicActivity economicActivity = new EconomicActivity { Id = 1, Name = "Econimic Acvitity" };
            rule.EconomicActivity = economicActivity;
            Assert.AreEqual(economicActivity, rule.EconomicActivity);
        }
예제 #5
0
 private static void _DisplayAllChildrensNodes(TreeNode pNode, EconomicActivity pApplication)
 {
     foreach (EconomicActivity domainOfApplication in pApplication.Childrens)
     {
         var node = new TreeNode(domainOfApplication.Name) { Tag = domainOfApplication };
         pNode.Nodes.Add(node);
         if (domainOfApplication.HasChildrens)
             _DisplayAllChildrensNodes(node, domainOfApplication);
     }
 }
        public EconomicActivity AddDomainOfApplicationAgri()
        {
            EconomicActivity services = new EconomicActivity();
            services.Name = "Agri";
            services.Parent = null;
            services.Deleted = false;
            services.Id = _domainOfApplicationManagement.AddEconomicActivity(services);

            return services;
        }
 public void AddEconomicActivityWithoutChildren()
 {
     _economicActivityManager = (EconomicActivityManager) container["EconomicActivityManager"];
     EconomicActivity activity = new EconomicActivity
                                     {
                                         Name = "Services",
                                         Parent = null
                                     };
     activity.Id = _economicActivityManager.AddEconomicActivity(activity);
     Assert.AreNotEqual(0,activity.Id);
 }
예제 #8
0
        public int AddEconomicActivity(EconomicActivity pEconomicActivity)
        {
            if (pEconomicActivity.Name == String.Empty)
                throw new OpenCbsDoaSaveException(OpenCbsDOASaveExceptionEnum.NameIsNull);

            if (_doam.ThisActivityAlreadyExist(pEconomicActivity.Name, pEconomicActivity.Parent.Id))
                throw new OpenCbsDoaSaveException(OpenCbsDOASaveExceptionEnum.AlreadyExist);

            if (pEconomicActivity.Parent.Id == 0) pEconomicActivity.Parent = null;

            return _doam.AddEconomicActivity(pEconomicActivity);
        }
예제 #9
0
 public void RemoveChildren(EconomicActivity pChildren)
 {
     for (int i = 0; i < _childrens.Count; i++)
     {
         EconomicActivity domainOfApplication = _childrens[i];
         if (domainOfApplication._id == pChildren.Id)
         {
             _childrens.Remove(pChildren);
             break;
         }
     }
 }
예제 #10
0
        public int AddEconomicActivity(EconomicActivity loanPurpose, bool isLoanPurpose)
        {
            if (loanPurpose.Name == String.Empty)
                throw new OpenCbsDoaSaveException(OpenCbsDOASaveExceptionEnum.NameIsNull);

            if (_doam.ThisActivityAlreadyExist(loanPurpose.Name, loanPurpose.Parent.Id, isLoanPurpose))
                throw new OpenCbsDoaSaveException(OpenCbsDOASaveExceptionEnum.AlreadyExist);

            if (loanPurpose.Parent.Id == 0) loanPurpose.Parent = null;

            return _doam.AddEconomicActivity(loanPurpose, isLoanPurpose);
        }
예제 #11
0
 public void RemoveChildren(EconomicActivity pChildren)
 {
     for (int i = 0; i < _childrens.Count; i++)
     {
         EconomicActivity domainOfApplication = _childrens[i];
         if (domainOfApplication._id == pChildren.Id)
         {
             _childrens.Remove(pChildren);
             break;
         }
     }
 }
        public void AddEconomicActivityWhenNameAlreadyExist()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activity = new EconomicActivity { Name = "Services", Parent = new EconomicActivity { Id = 1 } };

            _dynamicMock.ExpectAndReturn("ThisActivityAlreadyExist", true, "Services", 1);
            _dynamicMock.ExpectAndReturn("AddEconomicActivity", 0, activity);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            _economicActivityServices.AddEconomicActivity(activity);
        }
        public void AddEconomicActivity()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activity = new EconomicActivity { Name = "Services",Parent = new EconomicActivity {Id=1}};

            _dynamicMock.ExpectAndReturn("ThisActivityAlreadyExist", false, "Services", 1);
            _dynamicMock.ExpectAndReturn("AddEconomicActivity", 2, activity);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            activity.Id = _economicActivityServices.AddEconomicActivity(activity);
            Assert.AreEqual(2,activity.Id);
        }
예제 #14
0
        private void AddDomain()
        {
            TreeNode selectedNode = tvEconomicActivity.SelectedNode;

            //var doan = new FrmEconomicActivityName { DoaName = String.Empty, Text = "Economic activity" };
            //doan.ShowDialog();
            //if (doan.IsClosed) return;

            var doa = new EconomicActivity { Name = textBoxName.Text };

            try
            {
                EconomicActivity parent;

                // add economic activity (in the root)
                if (selectedNode.Tag == null)
                {
                    parent = new EconomicActivity();
                    doa.Parent = parent;
                }
                // add in the tree
                else
                {
                    parent = (EconomicActivity)selectedNode.Tag;
                    doa.Parent = parent;
                }
                doa.Id = ServicesProvider.GetInstance().GetEconomicActivityServices().AddEconomicActivity(doa);
                TreeNode node = new TreeNode(doa.Name);
                node.Tag = doa;
                selectedNode.Nodes.Add(node);

                if (parent != null)
                {
                    parent.Childrens.Add(doa);
                    selectedNode.Tag = parent;
                }
                selectedNode.Expand();
            }
            catch (Exception up)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(up)).ShowDialog();
            }

            SelectRootNode();

            tvEconomicActivity.Sort();
        }
예제 #15
0
        /// <summary>
        /// Add an economic activity in database
        /// </summary>
        /// <param name="pEconomicActivity">the economic activity object to add</param>
        /// <returns>the id of the economic activity added</returns>
        public int AddEconomicActivity(EconomicActivity pEconomicActivity)
        {
            const string sqlText = @"INSERT INTO EconomicActivities ([name] , [parent_id] , [deleted])
                        VALUES (@name,@parentId,@deleted) SELECT SCOPE_IDENTITY()";

            using (SqlConnection connection = GetConnection())
            using (OpenCbsCommand insert = new OpenCbsCommand(sqlText, connection))
            {
                insert.AddParam("@name", pEconomicActivity.Name);
                insert.AddParam("@deleted", pEconomicActivity.Deleted);
                if (pEconomicActivity.Parent != null)
                    insert.AddParam("@parentId", pEconomicActivity.Parent.Id);
                else
                    insert.AddParam("@parentId", null);
                return int.Parse(insert.ExecuteScalar().ToString());
            }
        }
예제 #16
0
        public int AddEconomicActivity(EconomicActivity loanPurpose, bool isLoanPurpose)
        {
            string sqlText = "";

            if (isLoanPurpose)
            {
                sqlText = @"INSERT INTO LoanPurpose ([name] , [parent_id] , [deleted])
                        VALUES (@name,@parentId,@deleted) SELECT SCOPE_IDENTITY()";
            }
            using (SqlConnection connection = GetConnection())
            using (OpenCbsCommand insert = new OpenCbsCommand(sqlText, connection))
            {
                insert.AddParam("@name", loanPurpose.Name);
                insert.AddParam("@deleted", loanPurpose.Deleted);
                if (loanPurpose.Parent != null)
                    insert.AddParam("@parentId", loanPurpose.Parent.Id);
                else
                    insert.AddParam("@parentId", null);
                return int.Parse(insert.ExecuteScalar().ToString());
            }
        }
예제 #17
0
 private void treeViewActivities_DoubleClick(object sender, EventArgs e)
 {
     TreeNode selectedNode = treeViewActivities.SelectedNode;
     try
     {
         if (selectedNode.Nodes.Count == 0)
         {
             if (ServicesProvider.GetInstance().GetEconomicActivityServices().NodeEditable(selectedNode.Tag))
             {
                 _domain = (EconomicActivity) selectedNode.Tag;
                 Close();
             }
         } else
         {
             MessageBox.Show(MultiLanguageStrings.GetString(Ressource.FrmActivity, "selectSubitem.Text"),
                 "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         _domain = null;
         new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
     }
 }
예제 #18
0
 private static EconomicActivity GetEconomicActivity(OpenCbsReader pReader)
 {
     EconomicActivity doa = new EconomicActivity();
     if (pReader != null)
     {
         if (!pReader.Empty)
         {
             pReader.Read();
             doa.Id = pReader.GetInt("id");
             doa.Name = pReader.GetString("name");
             doa.Deleted = pReader.GetBool("deleted");
         }
     }
     return doa;
 }
예제 #19
0
        private List<EconomicActivity> SelectChildren(int pParentId)
        {
            List<EconomicActivity> doaList = new List<EconomicActivity>();

            const string sqlText = "SELECT id, name, deleted FROM EconomicActivities WHERE parent_id = @id AND deleted = 0";

            using (SqlConnection connection = GetConnection())
            using (OpenCbsCommand sqlCommand = new OpenCbsCommand(sqlText, connection))
            {
                sqlCommand.AddParam("@id", pParentId);
                using (OpenCbsReader reader = sqlCommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        EconomicActivity domain = new EconomicActivity
                                                      {
                                                          Id = reader.GetInt("id"),
                                                          Name = reader.GetString("name"),
                                                          Deleted = reader.GetBool("deleted")
                                                      };
                        doaList.Add(domain);
                    }
                }
            }
            for (int i = 0; i < doaList.Count; i++)
                doaList[i].Childrens = SelectChildren(doaList[i].Id);

            return doaList;
        }
예제 #20
0
        /// <summary>
        /// This methods allows us to find all domains of application
        /// </summary>
        /// <returns>hierarchic collection of DomainOfApplication
        /// </returns>
        public List<EconomicActivity> SelectAllEconomicActivities()
        {
            List<EconomicActivity> doaList = new List<EconomicActivity>();

            const string sqlText = "SELECT id FROM EconomicActivities WHERE parent_id IS NULL AND deleted = 0";

            using (SqlConnection connection = GetConnection())
            using (OpenCbsCommand selectAll = new OpenCbsCommand(sqlText, connection))
            {
                using (OpenCbsReader reader = selectAll.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        EconomicActivity domain = new EconomicActivity
                                                      {Id = reader.GetInt("id")};
                        doaList.Add(domain);
                    }
                }
            }

            for (int i = 0; i < doaList.Count; i++)
                doaList[i] = SelectEconomicActivity(doaList[i].Id);

            return doaList;
        }
예제 #21
0
        /// <summary>
        /// Update economic activity name and delete
        /// </summary>
        /// <param name="pEconomicActivity">EconomicActivity object</param>
        public void UpdateEconomicActivity(EconomicActivity pEconomicActivity)
        {
            const string sqlText = "UPDATE EconomicActivities SET name = @name,deleted = @wasDeleted WHERE id = @id";

            using (SqlConnection connection = GetConnection())
            using (OpenCbsCommand update = new OpenCbsCommand(sqlText, connection))
            {
                update.AddParam("@id", pEconomicActivity.Id);
                update.AddParam("@name",  pEconomicActivity.Name);
                update.AddParam("@wasDeleted", pEconomicActivity.Deleted);
                update.ExecuteNonQuery();
            }
        }
예제 #22
0
        public void TestFixtureSetUp()
        {
            TechnicalSettings.UseOnlineMode = false;

            _DeleteDatas();
            _cltManagement = new ClientManager(DataUtil.TESTDB);
            _locations = new LocationsManager(DataUtil.TESTDB);
            _agriculture = _addDataForTesting.AddDomainOfApplicationAgriculture();
            _district = _addDataForTesting.AddDistrictIntoDatabase();
            _projectManager = new ProjectManager(DataUtil.TESTDB);
            ApplicationSettings settings = ApplicationSettings.GetInstance("");
        }
        public EconomicActivity AddDomainOfApplicationAgriculture()
        {
            EconomicActivity agriculture = new EconomicActivity();
            agriculture.Name = "Agriculture";
            agriculture.Parent = null;
            agriculture.Deleted = false;
            agriculture.Id = _domainOfApplicationManagement.AddEconomicActivity(agriculture);

            return agriculture;
        }
예제 #24
0
        private void EditDomain()
        {
            try
            {
                if (buttonEdit.Text.Equals(GetString("buttonEdit")))
                {
                    _selectedNode = tvEconomicActivity.SelectedNode;
                    _economicActivity = (EconomicActivity)_selectedNode.Tag;

                    if (_economicActivity != null)
                    {
                        _economicActivity.Parent = (EconomicActivity)_selectedNode.Parent.Tag;
                        textBoxName.Text = _economicActivity.Name;
                        _isSame = textBoxName.Text;
                        buttonExit.Enabled = false;
                        buttonAdd.Enabled = false;
                        buttonDelete.Enabled = false;
                        tvEconomicActivity.Enabled = false;

                        buttonEdit.Text = GetString("buttonSave");
                    }
                }
                else
                {
                    if (ServicesProvider.GetInstance().GetEconomicActivityServices().NodeEditable(_selectedNode.Tag))
                    {
                        if (_selectedNode.Level == 1)
                            _economicActivity.Parent = new EconomicActivity(); // no parent

                        if (_isSame != textBoxName.Text)
                            if (ServicesProvider.GetInstance().GetEconomicActivityServices().ChangeDomainOfApplicationName(_economicActivity, textBoxName.Text))
                            {
                                tvEconomicActivity.BeginUpdate();
                                _selectedNode.Tag = _economicActivity;
                                _selectedNode.Text = textBoxName.Text;
                                tvEconomicActivity.EndUpdate();
                            }
                    }

                    buttonExit.Enabled = true;
                    buttonAdd.Enabled = true;
                    buttonDelete.Enabled = true;
                    tvEconomicActivity.Enabled = true;
                    textBoxName.Text = string.Empty;

                    buttonEdit.Text = GetString("buttonEdit");
                }
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }

            SelectRootNode();

            tvEconomicActivity.Sort();
        }
예제 #25
0
 private Person AddPerson(bool active, EconomicActivity dOA, int loanCycle, string city, District district, string firstName, string lastname,
     char sex, string identificationData)
 {
     Person person = new Person();
     person.Active = active;
     person.Activity = dOA;
     person.City = city;
     person.District = district;
     person.FirstName = firstName;
     person.LastName = lastname;
     person.Sex = sex;
     person.LoanCycle = loanCycle;
     person.IdentificationData = identificationData;
     person.DateOfBirth = new DateTime(1980, 12, 12);
     return person;
 }
예제 #26
0
        public void DeleteEconomicActivity(EconomicActivity pEconomicActivity)
        {
            if (pEconomicActivity.HasChildrens)
                throw new OpenCbsDoaDeleteException(OpenCbsDOADeleteExceptionEnum.HasChildrens);

            pEconomicActivity.Deleted = true;
            _doam.UpdateEconomicActivity(pEconomicActivity);
        }
예제 #27
0
        private void DeleteEconomicActivity(EconomicActivity economicActivity)
        {
            _economicActivity = economicActivity;
            ServicesProvider.GetInstance().GetEconomicActivityServices().DeleteEconomicActivity(_economicActivity);

            var parent = (EconomicActivity)_selectedNode.Parent.Tag;
            if (parent != null) parent.RemoveChildren(_economicActivity);

            tvEconomicActivity.BeginUpdate();
            _selectedNode.Remove();
            tvEconomicActivity.EndUpdate();

            SelectRootNode();

            tvEconomicActivity.Sort();
        }
예제 #28
0
        public bool ChangeDomainOfApplicationName(EconomicActivity pEconomicActivity, string newName)
        {
            if (newName == String.Empty)
                throw new OpenCbsDoaUpdateException(OpenCbsDOAUpdateExceptionEnum.NewNameIsNull);

            if (_doam.ThisActivityAlreadyExist(newName, pEconomicActivity.Parent.Id))
                throw new OpenCbsDoaSaveException(OpenCbsDOASaveExceptionEnum.AlreadyExist);

            EconomicActivity activity = pEconomicActivity;
            activity.Name = newName;

            _doam.UpdateEconomicActivity(activity);

            return true;
        }
예제 #29
0
        private void BtnSelectClick(object sender, EventArgs e)
        {
            frmActivity frmActivity = new frmActivity();
            frmActivity.ShowDialog();

            txbActivity.Clear();
            Activity = frmActivity.EconomicActivity;
            OnActivityChange();
        }
예제 #30
0
 public void Reset()
 {
     Activity = null;
 }
예제 #31
0
 public EconomicActivtyEventArgs(EconomicActivity economicActivity)
 {
     _economicActivity = economicActivity;
 }
예제 #32
0
 public void TestIfDomainOfApplicationIsCorrectlySetAndRetrieved()
 {
     EconomicActivity agriculture = new EconomicActivity(1,"Agriculture",new EconomicActivity(),false);
     person.Activity = agriculture;
     Assert.AreEqual(1,person.Activity.Id);
     Assert.AreEqual("Agriculture",person.Activity.Name);
     Assert.IsNotNull(person.Activity.Parent);
     Assert.IsFalse(person.Activity.Deleted);
 }