Пример #1
0
    public static GroupTree GetGroupsTree(String OrgID)
    {
        GroupTree groupTree = new GroupTree();
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int orgId = Convert.ToInt32(OrgID);
            dataBlock.OpenConnection();
            String name = dataBlock.organizationTable.GetOrganizationName(orgId);

            groupTree.OrgName = name;

            TreeGroup gr = new TreeGroup();
            gr.GroupName = "Водители";
            List<int> groupIds = dataBlock.cardsTable.GetAllGroupIds(orgId, dataBlock.cardsTable.driversCardTypeId);
            foreach (int grId in groupIds)
            {
                if (dataBlock.cardsTable.GetGroupCardTypeById(grId) != 0)
                {
                    String name1 = dataBlock.cardsTable.GetGroupNameById(grId);
                    gr.addValue(grId.ToString(), name1);
                }
            }
            gr.GroupId = 1;
            groupTree.addGroup(gr);

            gr = new TreeGroup();
            gr.GroupName = "Транспортные средства";
            gr.GroupId = 2;
            groupIds = dataBlock.cardsTable.GetAllGroupIds(orgId, dataBlock.cardsTable.vehicleCardTypeId);
            foreach (int grId in groupIds)
            {
                if (dataBlock.cardsTable.GetGroupCardTypeById(grId) != 0)
                {
                    String name1 = dataBlock.cardsTable.GetGroupNameById(grId);
                    gr.addValue(grId.ToString(), name1);
                }
            }
            groupTree.addGroup(gr);

            dataBlock.CloseConnection();
            return groupTree;
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
    }
Пример #2
0
    public static GroupTree GetOverlookVehiclesTree(String OrgID)
    {
        GroupTree vehTree = new GroupTree();
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int orgId = Convert.ToInt32(OrgID);
            dataBlock.OpenConnection();
            String name = dataBlock.organizationTable.GetOrganizationName(orgId);

            vehTree.OrgName = name;

            List<int> groupIds = dataBlock.cardsTable.GetAllGroupIds(orgId, dataBlock.cardsTable.vehicleCardTypeId);
            for (int i = 0; i < groupIds.Count; i++)
            {
                TreeGroup gr = new TreeGroup();
                string grName = dataBlock.cardsTable.GetGroupNameById(groupIds[i]);
                gr.GroupName = grName;
                gr.GroupId = groupIds[i];
                List<int> values = dataBlock.cardsTable.GetAllCardIdsByGroupId(orgId, dataBlock.cardsTable.vehicleCardTypeId, groupIds[i]);

                for (int j = 0; j < values.Count; j++)
                {
                    String veh_name = dataBlock.cardsTable.GetCardHolderNameByCardId(values[j]);
                    gr.addValue(values[j].ToString(), veh_name);
                }
                vehTree.addGroup(gr);
            }
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
        return vehTree;
    }