public void LoadUsersTable()
    {
        string currentLanguage = ConfigurationManager.AppSettings["language"];
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, currentLanguage);
        HistoryTable historyTable = new HistoryTable(connectionString, currentLanguage, dataBlock.sqlDb);
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        List<int> usersIds = new List<int>();
        List<UserFromTable> userFromTableList = new List<UserFromTable>();

        dataBlock.OpenConnection();//выборка по типам пользователей
        usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.DriverUserTypeId));
        usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.AdministratorUserTypeId));
        usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.ManagerUserTypeId));
        DataTable data = historyTable.GetAllHistorysForUsers(usersIds);
        LogDataGrid.DataSource = data;
        LogDataGrid.DataBind();

        List<KeyValuePair<string, int>> actions = historyTable.GetAllActions();
        LogFilterTable_EventDropDown.Items.Clear();

        LogFilterTable_EventDropDown.Items.Add(new ListItem("Все", "-1", true));
        foreach (KeyValuePair<string, int> action in actions)
            LogFilterTable_EventDropDown.Items.Add(new ListItem(action.Key, action.Value.ToString()));

        dataBlock.CloseConnection();
    }
Beispiel #2
0
 public static string GetCardStartDate(String CardID)
 {
     string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
     DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
     dataBlock.OpenConnection();
     int cardId = Convert.ToInt32(CardID);
     string result = dataBlock.cardsTable.GetMinimumDataForCard(cardId);
     dataBlock.CloseConnection();
     return result;
 }
    public void LoadReportsTable()
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        List<int> reportsIds = new List<int>();

        dataBlock.OpenConnection();

        reportsIds = dataBlock.reportsTable.GetAllReportsIds();
        Session["ReportsTab_UserControl_ReportsIds"] = reportsIds;

        DataTable dt = new DataTable();
        DataRow dr;
        dt.Columns.Add(new DataColumn("CODE", typeof(string)));
        dt.Columns.Add(new DataColumn("TYPE", typeof(string)));
        dt.Columns.Add(new DataColumn("NAME", typeof(string)));
        dt.Columns.Add(new DataColumn("PRICE", typeof(string)));
        dt.Columns.Add(new DataColumn("UPDATE_DATE", typeof(string)));
        dt.Columns.Add(new DataColumn("BEGIN_DATE", typeof(string)));
        dt.Columns.Add(new DataColumn("END_DATE", typeof(string)));

        DateTime date = new DateTime();
        string dateStringToShow = "";
        foreach (int reportId in reportsIds)
        {
            dr = dt.NewRow();
            dr["CODE"] = reportId.ToString();
            dr["TYPE"] = dataBlock.reportsTable.GetReportTypeName(reportId, 0);
            dr["NAME"] = dataBlock.reportsTable.GetReportName(reportId);
            dr["PRICE"] = dataBlock.reportsTable.GetReportPrice(reportId);
            dr["UPDATE_DATE"] = dataBlock.reportsTable.GetReportDateUpdate(reportId).ToShortDateString();
            //Дата добавления в организацию.
            if (DateTime.TryParse(dataBlock.reportsTable.GetReportUserOrg_BDATE(reportId, orgId), out date))
                dateStringToShow = date.ToShortDateString();
            else
                dateStringToShow = "Не добавлен";
            dr["BEGIN_DATE"] = dateStringToShow;
            //Дата окончания в организации.
            if (DateTime.TryParse(dataBlock.reportsTable.GetReportUserOrg_EDATE(reportId, orgId), out date))
                dateStringToShow ="До " + date.ToShortDateString();
            else
                dateStringToShow = "-";
            dr["END_DATE"] = dateStringToShow;
            dt.Rows.Add(dr);
        }

        ReportsDataGrid.DataSource = dt;
        ReportsDataGrid.DataBind();
        dataBlock.CloseConnection();
    }
Beispiel #4
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;
        }
    }
    public void LoadClientsTable()
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        List<int> clientsIds = new List<int>();

        dataBlock.OpenConnection();
        int orgTypeId = dataBlock.organizationTable.GetOrgTypeId(orgId);
        clientsIds = dataBlock.organizationTable.Get_AllOrganizationsId(orgId);

        Session["ClientsTab_UserControl_ClientsIds"] = clientsIds;

        DataTable dt = new DataTable();
        DataRow dr;
        dt.Columns.Add(new DataColumn("CLIENTNAME", typeof(string)));
        dt.Columns.Add(new DataColumn("REG_DATE", typeof(string)));
        dt.Columns.Add(new DataColumn("ENDREG_DATE", typeof(string)));
        dt.Columns.Add(new DataColumn("COUNTRY", typeof(string)));
        dt.Columns.Add(new DataColumn("CITY", typeof(string)));

        int clientInfoId = 0;
        DateTime date = new DateTime();
        int userId = 1;
        foreach (int id in clientsIds)
        {
            userId = 0;

            dr = dt.NewRow();
            dr["CLIENTNAME"] = dataBlock.organizationTable.GetOrganizationName(id);
            //REG_DATE
            if (DateTime.TryParse(dataBlock.organizationTable.GetAdditionalOrgInfo(id, DataBaseReference.OrgInfo_RegistrationDate), out date))
                dr["REG_DATE"] = date.ToLongDateString() + " " + date.ToShortTimeString();
            //END_REG_DATE
            if (DateTime.TryParse(dataBlock.organizationTable.GetAdditionalOrgInfo(id, DataBaseReference.OrgInfo_EndOfRegistrationDate), out date))
                dr["ENDREG_DATE"] = date.ToLongDateString();
            //COUNTRY
            dr["COUNTRY"] = dataBlock.organizationTable.GetOrgCountryName(id);
            //CITY
            dr["CITY"] = dataBlock.organizationTable.GetAdditionalOrgInfo(id, DataBaseReference.OrgInfo_City);
            //
            dt.Rows.Add(dr);
        }
        ClientsDataGrid.DataSource = dt;
        ClientsDataGrid.DataBind();
        dataBlock.CloseConnection();
    }
    public void LoadInvoicesTable()
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        List<int> invoicesIds = new List<int>();

        // dataBlock.invoiceTable.OpenConnection();
        dataBlock.OpenConnection();

        invoicesIds = dataBlock.invoiceTable.GetAllInvoices(orgId);
        Session["InvoicesTab_UserControl_UsersIds"] = invoicesIds;

        DataTable dt = new DataTable();
        DataRow dr;
        dt.Columns.Add(new DataColumn("NAME", typeof(string)));
        dt.Columns.Add(new DataColumn("INVOICEDATE", typeof(string)));
        dt.Columns.Add(new DataColumn("PAYTERMDATE", typeof(string)));
        dt.Columns.Add(new DataColumn("STATUS", typeof(string)));
        dt.Columns.Add(new DataColumn("PAYDATE", typeof(string)));

        DateTime date = new DateTime();
        string dateStringToShow = "";
        foreach (int invoiceId in invoicesIds)
        {
            dr = dt.NewRow();
            dr["NAME"] = dataBlock.invoiceTable.GetInvoiceName(invoiceId);
            date = dataBlock.invoiceTable.GetDateInvoice(invoiceId);
            dr["INVOICEDATE"] = date.ToShortDateString();
            date = dataBlock.invoiceTable.GetDatePaymentTerm(invoiceId);
            dr["PAYTERMDATE"] = date.ToShortDateString();
            dr["STATUS"] = dataBlock.invoiceTable.GetInvoiceStatus(invoiceId);
              //PAYTERMDATE - Дата оплаты
            if (DateTime.TryParse(dataBlock.invoiceTable.GetDatePayment(invoiceId), out date))
                dateStringToShow = date.ToShortDateString();
            else
                dateStringToShow = "-";
            dr["PAYDATE"] = dateStringToShow;
            dt.Rows.Add(dr);
        }

        InvoicesDataGrid.DataSource = dt;
        InvoicesDataGrid.DataBind();
        //dataBlock.invoiceTable.CloseConnection();
        dataBlock.CloseConnection();
    }
    private void LoadTabContainer()
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        dataBlock.OpenConnection();
        int userId = dataBlock.usersTable.Get_UserID_byName(Page.User.Identity.Name);
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        DateTime date = new DateTime();
        //GeneralInfo
        date = dataBlock.usersTable.Get_TimeConnect(userId);
        GeneralDataTab_Table_CurConnectDateValue.Text = date.ToLongDateString() + " " + date.ToShortTimeString();
        if (DateTime.TryParse(dataBlock.organizationTable.GetAdditionalOrgInfo(orgId, DataBaseReference.OrgInfo_RegistrationDate), out date))
            GeneralDataTab_Table_RegDateValue.Text = date.ToLongDateString() + " " + date.ToShortTimeString();
        if (DateTime.TryParse(dataBlock.organizationTable.GetAdditionalOrgInfo(orgId, DataBaseReference.OrgInfo_EndOfRegistrationDate), out date))
            GeneralDataTab_Table_EndRegDateValue.Text = date.ToLongDateString();
        GeneralDataTab_Table_LicenseTypeValue.Text = "Flat";
        //Registration data
        RegistrationDataTab_RegCodeValue.Text = orgId.ToString();

        RegistrationDataTab_CityDropDown.Items.Clear();
        RegistrationDataTab_TownDropDown.Items.Clear();
        List<KeyValuePair<string, int>> orgCountries = dataBlock.organizationTable.GetAllCountry();
        string orgCountryName = dataBlock.organizationTable.GetOrgCountryName(orgId);
        int countryId = 1;
        foreach (KeyValuePair<string, int> country in orgCountries)
        {
            RegistrationDataTab_CityDropDown.Items.Add(new ListItem(country.Key, country.Value.ToString()));
            if (country.Key == orgCountryName)
            {
                RegistrationDataTab_CityDropDown.Items[RegistrationDataTab_CityDropDown.Items.Count - 1].Selected = true;
                countryId = country.Value;
            }
        }

        List<KeyValuePair<string, int>> orgRegions = dataBlock.organizationTable.GetAllRegions(countryId);

        string orgCRegionName = dataBlock.organizationTable.GetOrgRegionName(orgId);
        foreach (KeyValuePair<string, int> region in orgRegions)
        {
            RegistrationDataTab_TownDropDown.Items.Add(new ListItem(region.Key, region.Value.ToString()));
            if (region.Key == orgCRegionName)
            {
                RegistrationDataTab_TownDropDown.Items[RegistrationDataTab_TownDropDown.Items.Count - 1].Selected = true;
            }
        }

        RegistrationDataTab_AddressTextBox.Text = dataBlock.organizationTable.GetAdditionalOrgInfo(orgId, DataBaseReference.OrgInfo_Address);

        //Language
        string CurrentLanguage = dataBlock.organizationTable.GetAdditionalOrgInfo(orgId, DataBaseReference.OrgInfo_SiteLang);
        string Russian = ConfigurationManager.AppSettings["language"];
        string English = ConfigurationManager.AppSettings["language"];
        RegistrationDataTab_LanguageDropDown.Items.Clear();
        RegistrationDataTab_LanguageDropDown.Items.Add(new ListItem("Русский", Russian));
        RegistrationDataTab_LanguageDropDown.Items.Add(new ListItem("English", English));
        if (CurrentLanguage == Russian)
            RegistrationDataTab_LanguageDropDown.Items[0].Selected = true;
        if (CurrentLanguage == English)
            RegistrationDataTab_LanguageDropDown.Items[1].Selected = true;

        RegistrationDataTab_SaveDataPeriodTextBox.Text = dataBlock.organizationTable.GetAdditionalOrgInfo(orgId, DataBaseReference.OrgInfo_StorageDataPeriod); ;
        dataBlock.CloseConnection();
    }
    protected void InvoicesDataGrid_RadioButton_Checked(object sender, EventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
          /*  foreach (DataGridItem oldrow in InvoicesDataGrid.Items)
            {
                ((RadioButton)oldrow.FindControl("InvoicesDataGrid_RadioButton")).Checked = false;
            }*/
            //Set the new selected row
            RadioButton rb = (RadioButton)sender;
            DataGridItem row = (DataGridItem)rb.NamingContainer;
            ((RadioButton)row.FindControl("InvoicesDataGrid_RadioButton")).Checked = true;
            int invoiceId = ((List<int>)Session["InvoicesTab_UserControl_UsersIds"])[row.DataSetIndex];
            Selected_InvoicesDataGrid_Index.Value = invoiceId.ToString();
            //LoadUserAdditionalInfo(userId); dataBlock.reportsTable.OpenConnection();

            //dataBlock.invoiceTable.OpenConnection();
            dataBlock.OpenConnection();
            //делает кнопку Оплатить неактивной, если счет уже оплачен и наоборот
            DateTime outdatetime = new DateTime();
            if (DateTime.TryParse(dataBlock.invoiceTable.GetDatePayment(invoiceId), out outdatetime))
            {
                InvoicesTab_PayInvoiceButton.Enabled = false;
            }
            else
            {
                InvoicesTab_PayInvoiceButton.Enabled = true;
            }
            ///////////////////////
            InvoicesDataGridUpdatePanel.Update();
            InvoicesTab_ButtonsUpdateTable.Update();
            //////////////////////
            //dataBlock.invoiceTable.CloseConnection();
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.CloseConnection();
        //            dataBlock.invoiceTable.CloseConnection();
            RaiseException(ex);
        }
    }
Beispiel #9
0
    public static List<YearData> GetOverlookDriverNodeData(String CardID, String OrgID, String StartDate, String EndDate)
    {
        List<YearData> result = new List<YearData>();
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int orgId = Convert.ToInt32(OrgID);
            int cardId = Convert.ToInt32(CardID);
            dataBlock.OpenConnection();

            DateTime startDate = DateTime.Parse(StartDate);
            DateTime endDate = DateTime.Parse(EndDate);

            if (startDate.CompareTo(endDate) >= 0)
            {
                return null;
            }

            List<int> years = getYearsList(startDate, endDate);

            List<int> blocks = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);

            int count = 0;
            foreach (int year in years)
            {
                double py = 0;
                foreach (int block in blocks)
                {
                    py += dataBlock.plfUnitInfo.Statistics_GetYearStatistics(new DateTime(year, 1, 1), block);
                }
                YearData datay = new YearData();
                datay.YearName = year.ToString();
                datay.Percent = py.ToString();
                datay.key = count;
                result.Add(datay);
                count++;
                if (py == 0)
                    continue;
                List<int> months = getMonthsList(year, startDate, endDate);
                foreach (int month in months)
                {
                    double pm = 0;
                    foreach (int block in blocks)
                    {
                        pm += dataBlock.plfUnitInfo.Statistics_GetMonthStatistics(new DateTime(year, month, 1), block);
                    }
                    YearData datam = new YearData();
                    datam.MonthName = getMonthName(month);
                    datam.Percent = pm.ToString();
                    datam.key = count;
                    result.Add(datam);
                    count++;
                    if (pm == 0)
                        continue;
                    List<int> days = getDaysList(year, month, startDate, endDate);
                    foreach (int day in days)
                    {
                        double p = 0;
                        foreach (int block in blocks)
                        {
                            p += dataBlock.plfUnitInfo.Statistics_GetDayStatistics(new DateTime(year, month, day), block);
                        }
                        if (p == 0)
                            continue;
                        YearData data = new YearData();
                        data.DayName = day.ToString();
                        data.Percent = p.ToString();
                        data.key = count;
                        result.Add(data);
                        count++;
                    }
                }
            }

            dataBlock.CloseConnection();
            if (result.Count == 0)
                return null;
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
        return result;
    }
Beispiel #10
0
    public static bool RemoveItemUnparsedDataBlocks(String DataBlockID)
    {
        try
        {
            int dataBlockID = int.Parse(DataBlockID);
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, dataBlockID, ConfigurationManager.AppSettings["language"]);
            dataBlock.DeleteDataBlockAndRecords();

            dataBlock.CloseConnection();

            return true;
        }
        catch (Exception ex)
        {
            throw ex;
            //return false;
        }
    }
Beispiel #11
0
    public static bool ParseDataBlocks(String OrgID, String UserName)
    {
        string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        PLFUnit.PLFUnitClass plfForXml = new PLFUnit.PLFUnitClass();
        List<int> dataBlockIDs = new List<int>();
        int filesCounter = 0;
        object parsedObject;

        try
        {
            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);
            int orgId = int.Parse(OrgID);
            dataBlockIDs = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
            if (dataBlockIDs.Count == 0)
            {
                return true;
            }
            string output = "";
            foreach (int blockId in dataBlockIDs)
            {
                dataBlock.SetDataBlockIdForParse(blockId);
                dataBlock.SetOrgIdForParse(orgId);
                string state = dataBlock.GetDataBlockState(blockId);
                if (state.Equals("Not parsed"))
                {
                    output = HttpContext.Current.Server.MapPath("~/XML_PLF") + "\\";
                    parsedObject = dataBlock.ParseRecords(true, output, userId);
                    filesCounter++;
                }
            }
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();

            return true;
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            throw ex;
            //return false;
        }
    }
Beispiel #12
0
    public static List<MapItem> GetRecoverUserTransportTree(String OrgID)
    {
        List<MapItem> data;
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            int orgID = Convert.ToInt32(OrgID);
            List<int> vehicles = dataBlock.cardsTable.GetAllCardIds(orgID, dataBlock.cardsTable.vehicleCardTypeId);
            data = new List<MapItem>();
            for (int i = 0; i < vehicles.Count; i++)
            {
                string value = dataBlock.cardsTable.GetCardName(vehicles[i]);
                string key = vehicles[i].ToString();
                data.Add(new MapItem(key, value));
            }
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
        return data;
    }
Beispiel #13
0
    protected void Vehicles_InsertedCardType(object sender, EventArgs e)
    {
        EnableAllVehiclesPreviewButtons();
        VehicleInsertedCardType.Enabled = false;
        FilesPreviewPanel.Visible = true;

        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int dataBlockId = Convert.ToInt32(onlyForInternal.Value);

            dataBlock.OpenConnection();

            DDDClass.CardSlotsStatus slotsStatus = new DDDClass.CardSlotsStatus();
            slotsStatus = dataBlock.vehicleUnitInfo.Get_VehicleOverview_CardSlotsStatus(dataBlockId);

            FilesPreviewDataGrid.DataSource = VehiclePreviewDataTable.VehiclePreview_InsertedCardType(slotsStatus);
            FilesPreviewDataGrid.DataBind();
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
            TextBoxTest.Text = "";
            TextBoxTest.Visible = false;
            StatusUpdatePanel.Update();
        }
        finally
        {
            dataBlock.CloseConnection();
            ModalPopupExtender1.Hide();
        }
    }
Beispiel #14
0
    protected void Vehicles_Identification(object sender, EventArgs e)
    {
        EnableAllVehiclesPreviewButtons();
        VehicleIdentification_btn.Enabled = false;
        FilesPreviewPanel.Visible = true;

        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int dataBlockId = Convert.ToInt32(onlyForInternal.Value);

            dataBlock.OpenConnection();
            VehichleUnit.Vehicle_Overview vehicleCard = new VehichleUnit.Vehicle_Overview();

            vehicleCard.vehicleIdentificationNumber.vehicleIdentificationNumber = dataBlock.vehicleUnitInfo.Get_VehicleOverview_IdentificationNumber(dataBlockId);
            vehicleCard.vehicleRegistrationIdentification = dataBlock.vehicleUnitInfo.Get_VehicleOverview_RegistrationIdentification(dataBlockId);

            FilesPreviewDataGrid.DataSource = VehiclePreviewDataTable.VehiclePreview_Identification(vehicleCard);
            FilesPreviewDataGrid.DataBind();
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
            TextBoxTest.Text = "";
            TextBoxTest.Visible = false;
            StatusUpdatePanel.Update();
        }
        finally
        {
            dataBlock.CloseConnection();
            ModalPopupExtender1.Hide();
        }
    }
Beispiel #15
0
    protected void Vehicles_TimeAdjustmentData(object sender, EventArgs e)
    {
        EnableAllVehiclesPreviewButtons();
        VehicleTimeAdjustmentData_btn.Enabled = false;
        FilesPreviewPanel.Visible = true;

        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int dataBlockId = Convert.ToInt32(onlyForInternal.Value);
            dataBlock.OpenConnection();
            List<DDDClass.VuTimeAdjustmentRecord> records = dataBlock.vehicleUnitInfo.Get_VehicleEventsAndFaults_VuTimeAdjustmentData(dataBlockId);

            FilesPreviewDataGrid.DataSource = VehiclePreviewDataTable.VehiclePreview_TimeAdjustmentData(records);
            FilesPreviewDataGrid.DataBind();
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
            TextBoxTest.Text = "";
            TextBoxTest.Visible = false;
            StatusUpdatePanel.Update();
        }
        finally
        {
            dataBlock.CloseConnection();
            ModalPopupExtender1.Hide();
        }
    }
Beispiel #16
0
    public static List<MapItem> GetRecoverUserDriversTree(String OrgID)
    {
        List<MapItem> data;
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int orgId = Convert.ToInt32(OrgID);
            List<int> namesIds = new List<int>();
            List<string> cardNames = new List<string>();
            dataBlock.OpenConnection();
            namesIds = dataBlock.cardsTable.GetAllCardIds(orgId, dataBlock.cardsTable.driversCardTypeId);
            cardNames = dataBlock.cardsTable.GetCardNames(namesIds);

            dataBlock.CloseConnection();
            data = new List<MapItem>();
            for (int i = 0; i < namesIds.Count; i++)
            {
                data.Add(new MapItem(namesIds[i].ToString(), cardNames[i]));
            }
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
        return data;
    }
Beispiel #17
0
    private static List<Driver> LoadAllDriversLists(int cardId)
    {
        List<Driver> driversStructureList = new List<Driver>();
        int number = 0;
        string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        Driver driversStructureTemp;
        List<int> dataBlockIds = new List<int>();
        try
        {
            dataBlock.OpenConnection();
            dataBlockIds = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);
            int cardType;
            List<DateTime> startEnd = new List<DateTime>();
            foreach (int dataBlockId in dataBlockIds)
            {
                number++;
                driversStructureTemp = new Driver();
                driversStructureTemp.DataBlockId = dataBlockId;
                driversStructureTemp.Number = number;
                driversStructureTemp.Name = dataBlock.GetDataBlock_FileName(dataBlockId);
                driversStructureTemp.RecordsCount = dataBlock.GetDataBlock_RecorsCount(dataBlockId);
                driversStructureTemp.CreationTime = dataBlock.GetDataBlock_EDate(dataBlockId);
                cardType = dataBlock.GetDataBlock_CardType(dataBlockId);
                driversStructureTemp.CardTypeName = dataBlock.GetCardTypeName(dataBlockId);
                if (cardType == 0)
                {
                    startEnd = dataBlock.cardUnitInfo.Get_StartEndPeriod(dataBlockId);
                    driversStructureTemp.setFromDate(startEnd[0]);
                    driversStructureTemp.setToDate(startEnd[1]);
                }
                else
                    if (cardType == 2)
                    {
                        driversStructureTemp.setFromDate(dataBlock.plfUnitInfo.Get_START_PERIOD(dataBlockId));
                        driversStructureTemp.setToDate(dataBlock.plfUnitInfo.Get_END_PERIOD(dataBlockId));
                    }
                    else
                    {
                        driversStructureTemp.setFromDate(new DateTime());
                        driversStructureTemp.setToDate(new DateTime());
                    }

                driversStructureList.Add(driversStructureTemp);
            }
            dataBlock.CloseConnection();

            return driversStructureList;
        }
        catch (Exception ex)
        {
            dataBlock.CloseConnection();
            return null;
        }
    }
Beispiel #18
0
    public static List<DataBlockID> GetUnparsedDataBlocks(String OrgID)
    {
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

            int orgId = Convert.ToInt32(OrgID);

            List<DataBlockID> dataBlockIDList = new List<DataBlockID>();
            DataBlockID dataBlockIDItem;
            List<int> dataBlockIDs = new List<int>();
            int number = 0;

            dataBlock.OpenConnection();
            dataBlockIDs = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
            foreach (int id in dataBlockIDs)
            {
                number++;
                dataBlockIDItem = new DataBlockID();
                dataBlockIDItem.ID = id;
                dataBlockIDItem.Number = number;
                dataBlockIDItem.Name = dataBlock.GetDataBlock_FileName(id);
                dataBlockIDItem.State = dataBlock.GetDataBlockState(id);
                dataBlockIDItem.ByteSize = Convert.ToInt32(dataBlock.GetDataBlock_BytesCount(id));

                dataBlockIDList.Add(dataBlockIDItem);
            }

            dataBlock.CloseConnection();

            return dataBlockIDList;
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
    }
Beispiel #19
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;
    }
Beispiel #20
0
 public static Boolean RemoveDataBlockID(int DataBlockID)
 {
     string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
     DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
     dataBlock.OpenConnection();
     dataBlock.RemoveDataBlockId(DataBlockID);
     dataBlock.CloseConnection();
     return true;
 }
Beispiel #21
0
    private List<DeleteStructure> LoadAllDeleteLists()
    {
        try
        {
            int userId = 0;
            List<DeleteStructure> deleteStructureList = new List<DeleteStructure>();
            int i = 0;
            string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            DeleteStructure deleteStructureTemp;
            List<int> dataBlockIds = new List<int>();
            dataBlock.OpenConnection();
            dataBlockIds = dataBlock.GetAllParsedDataBlockIDs(userId);
            foreach (int dataBlockId in dataBlockIds)
            {
                i++;
                deleteStructureTemp = new DeleteStructure();
                deleteStructureTemp.dataBlockId = dataBlockId;
                deleteStructureTemp.number = i;
                deleteStructureTemp.name = dataBlock.GetDriversNameOrVehiclesNumberByBlockId(dataBlockId);
                deleteStructureTemp.cardTypeName = dataBlock.GetCardTypeName(dataBlockId);
                deleteStructureTemp.recordsCount = dataBlock.GetDataBlock_RecorsCount(dataBlockId);
                deleteStructureTemp.createTime = dataBlock.GetDataBlock_EDate(dataBlockId);
                deleteStructureTemp.dataBlockState = dataBlock.GetDataBlockState(dataBlockId);

                deleteStructureList.Add(deleteStructureTemp);
            }
            if (dataBlockIds.Count == 0)
                Status.Text = "Нет записей для отображения";

            AddGrid.DataSource = CreateDeleteDataSource(deleteStructureList);
            AddGrid.DataBind();
            dataBlock.CloseConnection();
            return deleteStructureList;
        }
        catch (Exception ex)
        {
            Status.Text = "Произошла ошибка: " + ex.Message + " Возможо просто нету данных в БД. Исправление в след. версии";
            return null;
        }
        finally
        {
        }
    }
Beispiel #22
0
    protected void AddGridCommand(object sender, DataGridCommandEventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        List<int> dataBlockIds = new List<int>();
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        Status.Text = "";
        DriverPreviewButtonsPanel.Visible = false;
        VehiclePreviewButtonsPanel.Visible = false;
        FilesPreviewDataGrid.DataSource = null;
        FilesPreviewDataGrid.DataBind();
        try
        {
            if (e.CommandName == "ViewData")
            {
                if (Session["DeleteCommmand"] == "ViewDriversFile")
                {
                    int tableIndex = Convert.ToInt32(e.Item.Cells[2].Text) - 1;
                    int cardId = Convert.ToInt32(DriversSelectTree.SelectedValue);
                    List<Driver> driversStructureList = new List<Driver>();
                    dataBlock.OpenConnection();
                    driversStructureList = LoadAllDriversLists(cardId);
                    dataBlockIds.Add(driversStructureList[tableIndex].DataBlockId);
                    onlyForInternal.Value = driversStructureList[tableIndex].DataBlockId.ToString();

                    if (driversStructureList[tableIndex].CardTypeName != "Plf")
                    {
                        DriverPreviewButtonsPanel.Visible = true;
                        Driver_FileContents(null, null);
                    }
                    else
                    {
                        PLFUnit.PLFUnitClass plf = new PLFUnit.PLFUnitClass();
                        plf.Records = dataBlock.plfUnitInfo.Get_Records(dataBlockIds, cardId);
                        FilesPreviewDataGrid.DataSource = PlfReportsDataTables.PLF_Data(plf.Records);
                        FilesPreviewDataGrid.DataBind();
                        FilesPreviewPanel.Visible = true;
                    }
                    ShowDriversStatisticsForOneFile(sender, e);
                    dataBlock.CloseConnection();
                }
                if (Session["DeleteCommmand"] == "ViewVehiclesFile")
                {
                    int tableIndex = Convert.ToInt32(e.Item.Cells[2].Text) - 1;
                    int cardId = Convert.ToInt32(VehiclesSelectTree.SelectedValue);
                    List<int> cardDataBlockIds = new List<int>();
                    dataBlock.OpenConnection();
                    cardDataBlockIds = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);
                    dataBlockIds.Add(cardDataBlockIds[tableIndex]);
                    onlyForInternal.Value = cardDataBlockIds[tableIndex].ToString();

                    dataBlock.CloseConnection();
                    VehiclePreviewButtonsPanel.Visible = true;
                    Vehicles_FileContents(null, null);
                    ShowVehiclesStatistics(null, null);
                }
            }
            else
                if (Session["DeleteCommmand"].ToString() == "RemoveParsedData")
                {
                    DelGridCommand(sender, e);
                }
                else
                    if (Session["DeleteCommmand"].ToString() == "RemoveUnparsedData")
                    {
                        int number = Convert.ToInt32(e.Item.Cells[2].Text);
                        dataBlockIds = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
                        int dataBlockId = dataBlockIds[number - 1];
                        dataBlock = new DataBlock(connectionString, dataBlockId, ConfigurationManager.AppSettings["language"]);
                        dataBlock.DeleteDataBlockAndRecords();
                        LoadAllLists();
                    }
                    else
                        if (Session["DeleteCommmand"].ToString() == "RemoveDriversFile")
                        {
                            int rightIdToDelete = -1;
                            string name = e.Item.Cells[3].Text;
                            int recordsCount = int.Parse(e.Item.Cells[7].Text);
                            dataBlockIds = dataBlock.GetDataBlockIdByRecordsCount(recordsCount);

                            if (dataBlockIds.Count == 1)
                                rightIdToDelete = dataBlockIds[0];
                            else
                                if (dataBlockIds.Count > 1)
                                {
                                    string nameTemp;
                                    foreach (int blockId in dataBlockIds)
                                    {
                                        nameTemp = dataBlock.GetDriversNameOrVehiclesNumberByBlockId(blockId);
                                        if (nameTemp == name)
                                        {
                                            rightIdToDelete = blockId;
                                            break;
                                        }
                                    }
                                }

                                else
                                    throw new Exception("Нет доступа к информации(или нет данных для удаления)");
                            if (rightIdToDelete != -1)
                            {
                                dataBlock = new DataBlock(connectionString, rightIdToDelete, ConfigurationManager.AppSettings["language"]);
                                dataBlock.DeleteDataBlockAndRecords();
                                ManagmentLoadedInfo_SelectedNodeChanged(null, null);
                            }
                        }
                        else
                            if (Session["DeleteCommmand"].ToString() == "RecoverDriversFile")
                            {
                                int tableIndex = Convert.ToInt32(e.Item.Cells[2].Text) - 1;
                                int cardId = Convert.ToInt32(UserFileRecover_TreeView.SelectedValue);
                                List<int> filesIds = new List<int>();
                                dataBlock.OpenConnection();
                                filesIds = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);
                                int dataBlockId = filesIds[tableIndex];
                                onlyForInternal.Value = dataBlockId.ToString();
                                byte[] fileBytes = dataBlock.GetDataBlock_BytesArray(dataBlockId);
                                string fileName = dataBlock.GetDataBlock_FileName(dataBlockId);
                                dataBlock.CloseConnection();

                                Response.Clear();
                                Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
                                Response.AddHeader("Content-Length", fileBytes.Length.ToString());
                                Response.ContentType = "application/octet-stream";
                                Response.OutputStream.Write(fileBytes, 0, fileBytes.Length);
                                Response.End();
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "submit", "javascript:document.form1.submit()", true);
                            }
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
            StatusUpdatePanel.Update();
        }
        finally
        {
            ModalPopupExtender1.Hide();
        }
    }
Beispiel #23
0
    private List<AddStructure> LoadAllLists()
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            List<AddStructure> addStructureList = new List<AddStructure>();
            int i = 0;

            AddStructure addStructureTemp;
            List<int> dataBlockIds = new List<int>();

            dataBlock.OpenConnection();
            dataBlockIds = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
            foreach (int dataBlockId in dataBlockIds)
            {
                i++;
                addStructureTemp = new AddStructure();
                addStructureTemp.dataBlockId = dataBlockId;
                addStructureTemp.number = i;
                addStructureTemp.name = dataBlock.GetDataBlock_FileName(dataBlockId);
                addStructureTemp.state = dataBlock.GetDataBlockState(dataBlockId);
                addStructureTemp.byteSize = Convert.ToInt32(dataBlock.GetDataBlock_BytesCount(dataBlockId));

                addStructureList.Add(addStructureTemp);
            }
            if (dataBlockIds.Count == 0)
            {
                Parse_Button.Enabled = false;
                Status.Text = "Нет записей для отображения";
            }
            else
            {
                Parse_Button.Enabled = true;
                Status.Text = "";
            }

            AddGrid.DataSource = CreateDataSource(addStructureList);
            AddGrid.DataBind();
            SetDelColVisible(true);
            setParseButtonVisible(true);
            dataBlock.CloseConnection();
            return addStructureList;
        }
        catch (Exception ex)
        {
            dataBlock.CloseConnection();
            Status.Text = "Произошла ошибка: " + ex.Message;
            return null;
        }
        finally
        {
            StatusUpdatePanel.Update();
        }
    }
    protected void InvoicesTab_PayInvoiceButton_Click(object sender, EventArgs e)
    {
        string currentLanguage = ConfigurationManager.AppSettings["language"];
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, currentLanguage);
        try
        {
            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int curUserId = dataBlock.usersTable.Get_UserID_byName(Page.User.Identity.Name);
            int invoiceId = Convert.ToInt32(Selected_InvoicesDataGrid_Index.Value);

            //old version
          /*  dataBlock.invoiceTable.OpenConnection();
            dataBlock.invoiceTable.OpenTransaction();
            dataBlock.invoiceTable.PayABill(invoiceId);
            string invoiceName = dataBlock.invoiceTable.GetInvoiceName(invoiceId);
            dataBlock.invoiceTable.CommitTransaction();
            dataBlock.invoiceTable.CloseConnection();*/

            //test version
            dataBlock.invoiceTable.PayABill(invoiceId);
            string invoiceName = dataBlock.invoiceTable.GetInvoiceName(invoiceId);
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
            //

            LoadInvoicesTable();
            InvoicesDataGridUpdatePanel.Update();
            InvoicesTab_ButtonsUpdateTable.Update();
            ////    добавление записи в журнал. потом возможно перенести куда надо(в логику).
            DB.SQL.SQLDB sqlDb = new DB.SQL.SQLDB(connectionString);
            HistoryTable history = new HistoryTable(connectionString, currentLanguage, sqlDb);
            sqlDb.OpenConnection();
            history.AddHistoryRecord("FN_INVOICE", "INVOICE_STATUS_ID", dataBlock.invoiceTable.Status_Paid, curUserId, history.invoicePaid, "#" + invoiceId + @" :""" + invoiceName + @"""", sqlDb);
            sqlDb.CloseConnection();
            ////
        }
        catch (Exception ex)
        {
            dataBlock.invoiceTable.RollbackConnection();
            dataBlock.invoiceTable.CloseConnection();
            RaiseException(ex);
        }
    }
Beispiel #25
0
    ////////////////////drivers tab!!!!!!!!!!!/////////////////////////////
    private void LoadDriversEveryWhere(bool managmentTo)
    {
        try
        {
            string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            List<int> namesIds = new List<int>();
            List<string> cardNames = new List<string>();
            dataBlock.OpenConnection();
            namesIds = dataBlock.cardsTable.GetAllCardIds(orgId, dataBlock.cardsTable.driversCardTypeId);
            cardNames = dataBlock.cardsTable.GetCardNames(namesIds);
            string orgName = dataBlock.organizationTable.GetOrganizationName(orgId);
            dataBlock.CloseConnection();
            if (managmentTo)
            {
                ManagmentLoadedInfo.Nodes.Add(new TreeNode("Водители", "-1"));
                UserFileRecover_TreeView.Nodes.Add(new TreeNode("Водители", "-1"));
            }
            DriversSelectTree.Nodes.Add(new TreeNode(orgName, ""));
            DriversSelectTree.Nodes[0].ChildNodes.Add(new TreeNode("Группа 1", ""));

            for (int i = 0; i < namesIds.Count; i++)
            {
                DriversSelectTree.Nodes[0].Value += namesIds[i].ToString() + ", ";
                DriversSelectTree.Nodes[0].ChildNodes[0].Value += namesIds[i].ToString() + ", ";
                DriversSelectTree.Nodes[0].ChildNodes[0].ChildNodes.Add(new TreeNode(cardNames[i], namesIds[i].ToString()));
                if (managmentTo)
                {
                    ManagmentLoadedInfo.Nodes[ManagmentLoadedInfo.Nodes.Count - 1].ChildNodes.Add(new TreeNode(cardNames[i], namesIds[i].ToString()));
                    UserFileRecover_TreeView.Nodes[UserFileRecover_TreeView.Nodes.Count - 1].ChildNodes.Add(new TreeNode(cardNames[i], namesIds[i].ToString()));
                }
            }
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
            StatusUpdatePanel.Update();
        }
    }
    protected void InvoicesTab_UNPayInvoiceButton_Click(object sender, EventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int invoiceId = Convert.ToInt32(Selected_InvoicesDataGrid_Index.Value);

           dataBlock.OpenConnection();
           dataBlock.OpenTransaction();
           dataBlock.invoiceTable.UnPayABill(invoiceId);
           dataBlock.CommitTransaction();
           dataBlock.CloseConnection();
          /*  dataBlock.invoiceTable.OpenConnection();
            dataBlock.invoiceTable.OpenTransaction();
            dataBlock.invoiceTable.UnPayABill(invoiceId);
            dataBlock.invoiceTable.CommitTransaction();
            dataBlock.invoiceTable.CloseConnection();*/
            LoadInvoicesTable();
            InvoicesDataGridUpdatePanel.Update();
            InvoicesTab_ButtonsUpdateTable.Update();
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            /*dataBlock.invoiceTable.RollbackConnection();
            dataBlock.invoiceTable.CloseConnection();*/
            RaiseException(ex);
        }
    }
Beispiel #27
0
    private void SelectDriverForPLF()
    {
        string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        List<string> cardNamesList = new List<string>();
        List<int> CardIdsList = new List<int>();
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);

        dataBlock.OpenConnection();
        CardIdsList = dataBlock.cardsTable.GetAllCardIds(orgId, dataBlock.cardsTable.driversCardTypeId);
        cardNamesList = dataBlock.cardsTable.GetCardNames(CardIdsList);
        dataBlock.CloseConnection();

        cardNamesList.Insert(0, "Выберите водителя...");
        CardIdsList.Insert(0, -1);

        Session.Add("CardIdsList", CardIdsList);
        SelectPLFDriver.DataSource = cardNamesList;
        SelectPLFDriver.DataBind();
        SelectPLFDriver.Visible = true;

        List<filenameAndBytesStruct> fileUpload = (List<filenameAndBytesStruct>)Session["FileUpload"];
        string fileList = "";
        foreach (filenameAndBytesStruct curFile in fileUpload)
        {
            fileList += curFile.filename;
        }
        FileList.Text = fileList;
        FileList.Visible = true;

        UploadPanel.Visible = false;
    }
    private void LoadStatisticGrid()
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);

        DataTable dt = new DataTable();
        DataRow dr;
        dt.Columns.Add(new DataColumn(" ", typeof(string)));
        dt.Columns.Add(new DataColumn("Текущее", typeof(string)));
        dt.Columns.Add(new DataColumn("Доступно", typeof(string)));
        dataBlock.OpenConnection();
        dr = dt.NewRow();
        dr[" "] = "Количество пользователей";
        dr["Текущее"] = dataBlock.usersTable.Get_AllUsersId(orgId).Count;
        dr["Доступно"] = "20";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[" "] = "Количество водителей";
        dr["Текущее"] = dataBlock.cardsTable.GetAllCardIds(orgId, dataBlock.cardsTable.driversCardTypeId).Count;
        dr["Доступно"] = "25";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[" "] = "Количество машин";
        dr["Текущее"] = dataBlock.cardsTable.GetAllCardIds(orgId, dataBlock.cardsTable.vehicleCardTypeId).Count;
        dr["Доступно"] = "30";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[" "] = "Количество отчетов";
        dr["Текущее"] = "???";
        dr["Доступно"] = "???";
        dt.Rows.Add(dr);

        dataBlock.CloseConnection();

        StatisticGrid.DataSource = dt;
        StatisticGrid.DataBind();
    }
Beispiel #29
0
 private int UploadFileToBase(string fileName, byte[] _bytes)
 {
     int DataBlockId = -1;
     try
     {
         string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
         DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
         int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
         dataBlock.OpenConnection();
         dataBlock.AddData(orgId, _bytes, fileName);
         dataBlock.CloseConnection();
         DataBlockId = dataBlock.GET_DATA_BLOCK_ID();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return DataBlockId;
 }
Beispiel #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string Type=Request.Form.Get("type");

        //Section "Восстановить у пользователя"
        if (Type == DOWNLOAD_FILE_RECOVER_USER)
        {
            if (Request.Form.Get("dataBlockId") != null)
            {
                int dataBlockId = Convert.ToInt32(Request.Form.Get("dataBlockId"));
                string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
                DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
                dataBlock.OpenConnection();
                byte[] fileBytes = dataBlock.GetDataBlock_BytesArray(dataBlockId);
                string fileName = dataBlock.GetDataBlock_FileName(dataBlockId);
                dataBlock.CloseConnection();

                Response.Clear();
                Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", fileName));
                Response.AddHeader("Content-Length", fileBytes.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.OutputStream.Write(fileBytes, 0, fileBytes.Length);
                Response.End();
                return;
            }
        }

        //Section "PLF Файлы"
        if (Type == GET_PLF_REPORT)
        {
            string CardID=Request.Form.Get("CardID");
            string PLFID=Request.Form.Get("PLFID");
            string UserName = Request.Form.Get("UserName");
            string Format = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int dataBlockId = int.Parse(PLFID);
            List<int> dataBlockIDS = new List<int>();
            dataBlockIDS.Add(dataBlockId);
            int cardID = int.Parse(CardID);

            string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            BLL.DataBlock dataBlock = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DateTime from = new DateTime();
            from = dataBlock.plfUnitInfo.Get_START_PERIOD(dataBlockId);

            DateTime to = new DateTime();
            to = dataBlock.plfUnitInfo.Get_END_PERIOD(dataBlockId);

            string vehicle = dataBlock.plfUnitInfo.Get_VEHICLE(dataBlockId);
            string deviceID = dataBlock.plfUnitInfo.Get_ID_DEVICE(dataBlockId);

            DataSet dataset = new DataSet();

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            List<PLFUnit.PLFRecord> records = new List<PLFUnit.PLFRecord>();
            dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS,
                new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day),
                cardID, userId, ref records);

            dataBlock.CloseConnection();

            //gets table PlfHeader_1
            DataTable dt = dataset.Tables[0];
            //gets the first row
            DataRow dr = dt.Rows[0];
            string driverName = dr["Имя водителя"].ToString();

            //load needed template
            string path = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType+".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
                case "html": report.ExportToHtml(reportStream); break;
                case "pdf": report.ExportToPdf(reportStream); break;
                case "rtf": report.ExportToRtf(reportStream); break;
                case "png": report.ExportToImage(reportStream,ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " +
                new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }

        if (Type == GET_PLF_REPORT_FOR_PERIOD)
        {
            string CardID = Request.Form.Get("CardID");
            string StartDate = Request.Form.Get("StartDate");
            string EndDate = Request.Form.Get("EndDate");
            string UserName = Request.Form.Get("UserName");
            string Format = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int cardID = int.Parse(CardID);

            string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            BLL.DataBlock dataBlock = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DateTime from = DateTime.Parse(StartDate);
            DateTime to = DateTime.Parse(EndDate);

            DataSet dataset = new DataSet();
            List<int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardID);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            List<PLFUnit.PLFRecord> records = new List<PLFUnit.PLFRecord>();
            dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS,
                new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day),
                cardID, userId, ref records);

            dataBlock.CloseConnection();

            //gets table PlfHeader_1
            DataTable dt = dataset.Tables[0];
            //gets the first row
            DataRow dr = dt.Rows[0];
            string driverName = dr["Имя водителя"].ToString();

            //load needed template
            string path = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
                case "html": report.ExportToHtml(reportStream); break;
                case "pdf": report.ExportToPdf(reportStream); break;
                case "rtf": report.ExportToRtf(reportStream); break;
                case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " +
                new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();

            return;
        }

        //Section "Транспортные средства"
        if (Type == GET_DDD_REPORT)
        {
            string DataBlockID = Request.Form.Get("DataBlockID");
            string UserName = Request.Form.Get("UserName");
            string Format = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int dataBlockId = int.Parse(DataBlockID);
            List<int> dataBlockIDS = new List<int>();
            dataBlockIDS.Add(dataBlockId);

            string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DataSet dataset = new DataSet();

            string VIN = dataBlock.vehicleUnitInfo.Get_VehicleOverview_IdentificationNumber(dataBlockId).ToString();
            string RegNumb = dataBlock.vehicleUnitInfo.Get_VehicleOverview_RegistrationIdentification(dataBlockId).vehicleRegistrationNumber.ToString();
            int vehicleId = dataBlock.vehiclesTables.GetVehicleId_byVinRegNumbers(VIN, RegNumb);

            List<DateTime> vehsCardPeriod = dataBlock.vehicleUnitInfo.Get_StartEndPeriod(dataBlockId);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId,
                dataBlockIDS, vehsCardPeriod[0], vehsCardPeriod[1], userId);

            dataBlock.CloseConnection();

            //load needed template
            string path = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
                case "html": report.ExportToHtml(reportStream); break;
                case "pdf": report.ExportToPdf(reportStream); break;
                case "rtf": report.ExportToRtf(reportStream); break;
                case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " +
                vehsCardPeriod[0].ToString("dd_MM_yyyy") + "-" + vehsCardPeriod[1].ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }

        //Section "Транспортные средства"
        if (Type == GET_DDD_REPORT_FOR_PERIOD)
        {
            string CardID = Request.Form.Get("CardID");
            string StartDate = Request.Form.Get("StartDate");
            string EndDate = Request.Form.Get("EndDate");
            string UserName = Request.Form.Get("UserName");
            string Format = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DataSet dataset = new DataSet();
            int cardId = int.Parse(CardID);

            string VIN = dataBlock.vehiclesTables.GetVehicleVin(cardId);
            string RegNumb = dataBlock.vehiclesTables.GetVehicleGOSNUM(cardId);

            int vehicleId = dataBlock.vehiclesTables.GetVehicle_byCardId(cardId);
            List<int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            DateTime from = DateTime.Parse(StartDate);
            DateTime to = DateTime.Parse(EndDate);

            dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId,
                dataBlockIDS, from, to, userId);

            dataBlock.CloseConnection();

            //load needed template
            string path = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
                case "html": report.ExportToHtml(reportStream); break;
                case "pdf": report.ExportToPdf(reportStream); break;
                case "rtf": report.ExportToRtf(reportStream); break;
                case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " +
                from.ToString("dd_MM_yyyy") + "-" + to.ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }
    }
Beispiel #31
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string Type = Request.Form.Get("type");

        //Section "Восстановить у пользователя"
        if (Type == DOWNLOAD_FILE_RECOVER_USER)
        {
            if (Request.Form.Get("dataBlockId") != null)
            {
                int       dataBlockId      = Convert.ToInt32(Request.Form.Get("dataBlockId"));
                string    connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
                DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
                dataBlock.OpenConnection();
                byte[] fileBytes = dataBlock.GetDataBlock_BytesArray(dataBlockId);
                string fileName  = dataBlock.GetDataBlock_FileName(dataBlockId);
                dataBlock.CloseConnection();

                Response.Clear();
                Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", fileName));
                Response.AddHeader("Content-Length", fileBytes.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.OutputStream.Write(fileBytes, 0, fileBytes.Length);
                Response.End();
                return;
            }
        }

        //Section "PLF Файлы"
        if (Type == GET_PLF_REPORT)
        {
            string CardID     = Request.Form.Get("CardID");
            string PLFID      = Request.Form.Get("PLFID");
            string UserName   = Request.Form.Get("UserName");
            string Format     = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int        dataBlockId  = int.Parse(PLFID);
            List <int> dataBlockIDS = new List <int>();
            dataBlockIDS.Add(dataBlockId);
            int cardID = int.Parse(CardID);

            string        connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            BLL.DataBlock dataBlock        = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DateTime from = new DateTime();
            from = dataBlock.plfUnitInfo.Get_START_PERIOD(dataBlockId);

            DateTime to = new DateTime();
            to = dataBlock.plfUnitInfo.Get_END_PERIOD(dataBlockId);

            string vehicle  = dataBlock.plfUnitInfo.Get_VEHICLE(dataBlockId);
            string deviceID = dataBlock.plfUnitInfo.Get_ID_DEVICE(dataBlockId);

            DataSet dataset = new DataSet();

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            List <PLFUnit.PLFRecord> records = new List <PLFUnit.PLFRecord>();
            dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS,
                                                          new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day),
                                                          cardID, userId, ref records);

            dataBlock.CloseConnection();

            //gets table PlfHeader_1
            DataTable dt = dataset.Tables[0];
            //gets the first row
            DataRow dr         = dt.Rows[0];
            string  driverName = dr["Имя водителя"].ToString();

            //load needed template
            string     path   = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
            case "html": report.ExportToHtml(reportStream); break;

            case "pdf": report.ExportToPdf(reportStream); break;

            case "rtf": report.ExportToRtf(reportStream); break;

            case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " +
                                                                    new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }

        if (Type == GET_PLF_REPORT_FOR_PERIOD)
        {
            string CardID     = Request.Form.Get("CardID");
            string StartDate  = Request.Form.Get("StartDate");
            string EndDate    = Request.Form.Get("EndDate");
            string UserName   = Request.Form.Get("UserName");
            string Format     = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int cardID = int.Parse(CardID);

            string        connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            BLL.DataBlock dataBlock        = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DateTime from = DateTime.Parse(StartDate);
            DateTime to   = DateTime.Parse(EndDate);

            DataSet    dataset      = new DataSet();
            List <int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardID);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            List <PLFUnit.PLFRecord> records = new List <PLFUnit.PLFRecord>();
            dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS,
                                                          new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day),
                                                          cardID, userId, ref records);

            dataBlock.CloseConnection();

            //gets table PlfHeader_1
            DataTable dt = dataset.Tables[0];
            //gets the first row
            DataRow dr         = dt.Rows[0];
            string  driverName = dr["Имя водителя"].ToString();

            //load needed template
            string     path   = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
            case "html": report.ExportToHtml(reportStream); break;

            case "pdf": report.ExportToPdf(reportStream); break;

            case "rtf": report.ExportToRtf(reportStream); break;

            case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }


            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " +
                                                                    new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();

            return;
        }

        //Section "Транспортные средства"
        if (Type == GET_DDD_REPORT)
        {
            string DataBlockID = Request.Form.Get("DataBlockID");
            string UserName    = Request.Form.Get("UserName");
            string Format      = Request.Form.Get("Format");
            string ReportType  = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int        dataBlockId  = int.Parse(DataBlockID);
            List <int> dataBlockIDS = new List <int>();
            dataBlockIDS.Add(dataBlockId);

            string    connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DataSet dataset = new DataSet();

            string VIN       = dataBlock.vehicleUnitInfo.Get_VehicleOverview_IdentificationNumber(dataBlockId).ToString();
            string RegNumb   = dataBlock.vehicleUnitInfo.Get_VehicleOverview_RegistrationIdentification(dataBlockId).vehicleRegistrationNumber.ToString();
            int    vehicleId = dataBlock.vehiclesTables.GetVehicleId_byVinRegNumbers(VIN, RegNumb);

            List <DateTime> vehsCardPeriod = dataBlock.vehicleUnitInfo.Get_StartEndPeriod(dataBlockId);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId,
                                                              dataBlockIDS, vehsCardPeriod[0], vehsCardPeriod[1], userId);

            dataBlock.CloseConnection();

            //load needed template
            string     path   = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
            case "html": report.ExportToHtml(reportStream); break;

            case "pdf": report.ExportToPdf(reportStream); break;

            case "rtf": report.ExportToRtf(reportStream); break;

            case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " +
                                                                    vehsCardPeriod[0].ToString("dd_MM_yyyy") + "-" + vehsCardPeriod[1].ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }

        //Section "Транспортные средства"
        if (Type == GET_DDD_REPORT_FOR_PERIOD)
        {
            string CardID     = Request.Form.Get("CardID");
            string StartDate  = Request.Form.Get("StartDate");
            string EndDate    = Request.Form.Get("EndDate");
            string UserName   = Request.Form.Get("UserName");
            string Format     = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            string    connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DataSet dataset = new DataSet();
            int     cardId  = int.Parse(CardID);

            string VIN     = dataBlock.vehiclesTables.GetVehicleVin(cardId);
            string RegNumb = dataBlock.vehiclesTables.GetVehicleGOSNUM(cardId);

            int        vehicleId    = dataBlock.vehiclesTables.GetVehicle_byCardId(cardId);
            List <int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            DateTime from = DateTime.Parse(StartDate);
            DateTime to   = DateTime.Parse(EndDate);

            dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId,
                                                              dataBlockIDS, from, to, userId);

            dataBlock.CloseConnection();

            //load needed template
            string     path   = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
            case "html": report.ExportToHtml(reportStream); break;

            case "pdf": report.ExportToPdf(reportStream); break;

            case "rtf": report.ExportToRtf(reportStream); break;

            case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " +
                                                                    from.ToString("dd_MM_yyyy") + "-" + to.ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }
    }