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();
    }
 protected void ClientsDataGrid_RadioButton_Checked(object sender, EventArgs e)
 {
     try
     {
         string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
         DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
         foreach (DataGridItem oldrow in ClientsDataGrid.Items)
         {
             ((RadioButton)oldrow.FindControl("ClientsDataGrid_RadioButton")).Checked = false;
         }
         //Set the new selected row
         RadioButton rb = (RadioButton)sender;
         DataGridItem row = (DataGridItem)rb.NamingContainer;
         ((RadioButton)row.FindControl("ClientsDataGrid_RadioButton")).Checked = true;
         int clientId = ((List<int>)Session["ClientsTab_UserControl_ClientsIds"])[row.DataSetIndex];
         Selected_ClientsDataGrid_Index.Value = clientId.ToString();
         LoadClientAdditionalInfo(clientId);
         ClientsDataGridUpdatePanel.Update();
         DetailedInformationUpdatePanel.Update();
     }
     catch (Exception ex)
     {
         RaiseException(ex);
     }
 }
    protected void AccessTab_SaveButton_Click(object sender, EventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        int userRoleId = -1;
        bool isActive = false;
        try
        {
            dataBlock.reportsTable.OpenConnection();
            dataBlock.reportsTable.OpenTransaction();
            int curUserId = dataBlock.usersTable.Get_UserID_byName(Page.User.Identity.Name);
            int selectedReportId = Convert.ToInt32(Selected_ReportsDataGrid_Index.Value);
            foreach (DataGridItem oldrow in AccessDataGrid.Items)
            {
                userRoleId = Convert.ToInt32(oldrow.Cells[0].Text);
                isActive = ((CheckBox)oldrow.FindControl("AccessDataGrid_CheckBox")).Checked;
                dataBlock.reportsTable.AddOrSetReportUserRoles_SETDATE(selectedReportId, orgId, userRoleId, isActive, curUserId);
            }

            dataBlock.reportsTable.CommitTransaction();
            dataBlock.reportsTable.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.reportsTable.RollbackConnection();
            dataBlock.reportsTable.CloseConnection();
            RaiseException(ex);
        }
    }
    protected void SaveButtonPressed(object sender, EventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int countryId = Convert.ToInt32(RegistrationDataTab_CityDropDown.SelectedValue);
            int regionId = Convert.ToInt32(RegistrationDataTab_TownDropDown.SelectedValue);
            string address = RegistrationDataTab_AddressTextBox.Text;
            string selectedLanguage = RegistrationDataTab_LanguageDropDown.SelectedValue;
            int saveDataPeriod = Convert.ToInt32(RegistrationDataTab_SaveDataPeriodTextBox.Text);

            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);

            dataBlock.organizationTable.OpenConnection();
            dataBlock.organizationTable.OpenTransaction();
            dataBlock.organizationTable.AddOrEditAdditionalOrgInfo(orgId, DataBaseReference.OrgInfo_Address, address);
            dataBlock.organizationTable.AddOrEditAdditionalOrgInfo(orgId, DataBaseReference.OrgInfo_SiteLang, selectedLanguage);
            dataBlock.organizationTable.AddOrEditAdditionalOrgInfo(orgId, DataBaseReference.OrgInfo_StorageDataPeriod, saveDataPeriod.ToString());
            dataBlock.organizationTable.SetOrgCountryAndRegion(orgId, countryId, regionId);
            dataBlock.organizationTable.CommitTransaction();
            dataBlock.organizationTable.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.organizationTable.RollbackConnection();
            dataBlock.organizationTable.CloseConnection();
            Session["AdministrationTabException"] = ex;
            RaiseBubbleEvent(null, new EventArgs());
        }
    }
示例#5
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;
 }
    protected void ApplyLogFilterButton_Click(object sender, EventArgs e)
    {
        string currentLanguage = ConfigurationManager.AppSettings["language"];
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, currentLanguage);
        HistoryTable historyTable = new HistoryTable(connectionString, currentLanguage, dataBlock.sqlDb);
        try
        {
            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            List<int> usersIds = new List<int>();
            List<UserFromTable> userFromTableList = new List<UserFromTable>();
            DateTime from;
            DateTime to;
            if (DateTime.TryParse(LogFilterTable_StartDateTextBox.Text, out from))
            {
                if (LogFilterTable_StartTimeTextBox.Text != "")
                    from = from.Add(TimeSpan.Parse(LogFilterTable_StartTimeTextBox.Text));
            }
            else
                from = new DateTime();
            if (DateTime.TryParse(LogFilterTable_EndDateTextBox.Text, out to))
            {
                if (LogFilterTable_EndTimeTextBox.Text != "")
                    to = to.Add(TimeSpan.Parse(LogFilterTable_EndTimeTextBox.Text));
                else
                {
                    to = to.AddHours(23);
                    to = to.AddMinutes(59);
                }
            }
            else
                to = DateTime.Now;

            int actionId = Convert.ToInt32(LogFilterTable_EventDropDown.SelectedValue);
            string searchString = LogFilterTable_NoteTextTextBox.Text.Trim();

            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, from, to, actionId, searchString);
            LogDataGrid.DataSource = data;
            LogDataGrid.DataBind();

            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
        }
        finally
        {
            dataBlock.CloseConnection();
        }
    }
    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();
    }
示例#8
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;
        }
    }
    protected void RegistrationDataTab_TownDropDown_SelectedIndexChanged(object sender, EventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int countryId = Convert.ToInt32(RegistrationDataTab_CityDropDown.SelectedValue);
        RegistrationDataTab_TownDropDown.Items.Clear();

        List<KeyValuePair<string, int>> orgRegions = new List<KeyValuePair<string, int>>();
        orgRegions = dataBlock.organizationTable.GetAllRegions(countryId);
        foreach (KeyValuePair<string, int> region in orgRegions)
        {
            RegistrationDataTab_TownDropDown.Items.Add(new ListItem(region.Key, region.Value.ToString()));
        }
    }
    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();
    }
    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);
        }
    }
示例#13
0
    public static String GetDDDReport(String DataBlockID, String UserName, String 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();
        if (string.IsNullOrEmpty(ReportType))
        {
            ReportType = "Полный отчет";
        }
        report.LoadLayout(path + ReportType + ".repx");
        report.DataSource = dataset;
        MemoryStream reportStream = new MemoryStream();
        report.ExportToHtml(reportStream);
        reportStream.Seek(0, SeekOrigin.Begin);

        // convert stream to string
        StreamReader reader = new StreamReader(reportStream);
        string textReport = reader.ReadToEnd();

        return textReport;
    }
示例#14
0
    protected void DeleteDriversCardWithAllInfo(object sender, EventArgs e)
    {
        try
        {
            string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int cardId = Convert.ToInt32(ManagmentLoadedInfo.SelectedValue);

            dataBlock.cardsTable.DeleteCardAndAllFiles(cardId);
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
        }
    }
示例#15
0
    protected void ChangeDriversNumberClick(object sender, EventArgs e)
    {
        try
        {
            setNameChangeVisible(false);

            string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int cardId = Convert.ToInt32(ManagmentLoadedInfo.SelectedValue);
            List<int> arrayIds = new List<int>();
            arrayIds.Add(cardId);
            string number = dataBlock.cardsTable.GetCardNumbers(arrayIds)[0];

            new_DriversCardNumber.Text = number;
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
        }
    }
示例#16
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;
    }
    private void LoadMessagesGrid()
    {
        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)));
        dt.Columns.Add(new DataColumn("Срок окончания", typeof(string)));

        dr = dt.NewRow();
        dr["Отправитель"] = "GoldMedium";
        dr["Тема"] = "Необходимо обновить регистрационную информацию";
        dr["Дата"] = "17.01.2011";
        dr["Срок окончания"] = "25.01.2011";
        dt.Rows.Add(dr);

        MessagesGrid.DataSource = dt;
        MessagesGrid.DataBind();
    }
    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();
    }
示例#19
0
    protected void DelGridCommand(Object sender, DataGridCommandEventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        List<int> dataBlockIds = new List<int>();
        int cardType;
        Status.Text = "";
        try
        {
            if (((ImageButton)e.CommandSource).CommandName == "RemoveData")
            {
                DeleteStructure delStr = new DeleteStructure();
                int rightIdToDelete = -1;
                delStr.name = e.Item.Cells[3].Text;
                delStr.createTime = e.Item.Cells[6].Text;
                delStr.recordsCount = int.Parse(e.Item.Cells[5].Text);
                dataBlockIds = dataBlock.GetDataBlockIdByRecordsCount(delStr.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 == delStr.name)
                            {
                                rightIdToDelete = blockId;
                                break;
                            }
                        }
                        //Обязательно сделать проверку, по дате добавления...(будет не лишним по-любому!)
                    }
                    else
                        throw new Exception("Нет доступа к информации(или нет данных для удаления)");
                if (rightIdToDelete != -1)
                {
                    dataBlock = new DataBlock(connectionString, rightIdToDelete, ConfigurationManager.AppSettings["language"]);
                    dataBlock.DeleteDataBlockAndRecords();
                    LoadAllDeleteLists();
                }
                else throw new Exception("Не найдена запись для удаления");
            }
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
        }
    }
    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);
        }
    }
示例#21
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;
    }
    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);
        }
    }
示例#23
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;
        }
    }
示例#24
0
        static void Main(string[] args)
        {
            string connectionString = "server=localhost;port=3306;default command timeout=3000;Connection Timeout=6000;User Id=root;password = ;Persist Security Info=True;database=smartfis";
            string connectionString1 = "server=mysql62.1gb.ru;default command timeout=600;Connection Timeout=600;database=gb_x_smartfis;User Id=gb_x_smartfis;password=fb1db947kl;";
            string currentLanguage = "STRING_RU";
            DataBlock dataBlock = new DataBlock(connectionString, currentLanguage);

            dataBlock.OpenConnection();

            bool ex = false;
            ConsoleKeyInfo ch;
            //MY CODE
            /*int id=dataBlock.usersTable.GetUserInfoNameId("Surname");

            List<KeyValuePair<string, int>> list = dataBlock.usersTable.GetAllUserInfoNames();
            foreach (KeyValuePair<string, int> pair in list) {
                System.Console.WriteLine(pair.Key+"="+pair.Value);
            }*/

            /*List<KeyValuePair<string, string>> list = dataBlock.bannersTable.GetAllBanners();
            foreach (KeyValuePair<string, string> pair in list)
            {
                System.Console.WriteLine(pair.Key + "->" + pair.Value);
            }*/
            //dataBlock.GetAllUnparsedDataBlockIDs(1);
            //System.Console.WriteLine(dataBlock.cardsTable.GetCardNumber(4));
            /*dataBlock.SetDataBlockIdForParse(1);
            dataBlock.SetOrgIdForParse(1);
            dataBlock.ParseRecords(true,"D:\\BSUIR\\Other\\UnitedProject\\DDDWebSite\\XML_PLF\\",1);*/
            //byte[] arr=new byte[100];
            //dataBlock.AddData(1,arr,"file.plf");

            List<int> dataBlockIds = new List<int>();
            dataBlockIds.Add(2);
            DateTime date = new DateTime(2013,7,19);
            dataBlock.plfUnitInfo.Get_Records(dataBlockIds,date,date,38);

            System.Console.WriteLine("END");
            System.Console.ReadKey();
                //SCRIPT TO ADD COMMON GROUP
                /*List<Int32> orgIds = dataBlock.organizationTable.Get_AllOrganizationsId();
                int k = 0;
                foreach (int id in orgIds)
                {
                    List<Int32> groupIds = dataBlock.cardsTable.GetAllGroupIds(id,0);
                    if (groupIds.Count == 0) {
                        k++;
                        dataBlock.cardsTable.CreateDefaultGroup(id);
                    }
                }

                System.Console.WriteLine(k);
                System.Console.ReadKey();*/

                return;

               /*while (ex != true)
            {
                Console.Clear();
                Console.WriteLine("Connection string = " + connectionString + "\r\n");
                Console.WriteLine("Data Block Id = " + dataBlock.GET_DATA_BLOCK_ID());
                Console.WriteLine("Data Block STATE : " + dataBlock.GetDataState() + "\r\n");
                Console.WriteLine("1.Change Connection String");
                Console.WriteLine("2.Add History Test");
                Console.WriteLine("3.Get HistoryTest");
                Console.WriteLine("4.Get Firebird test");
                Console.WriteLine("5.Get shedules test");

                Console.WriteLine("v.init Country_Regions tables");

                ch = Console.ReadKey(true);

                switch (ch.KeyChar)
                {
                    case '1':
                        {
                            string newConnectionString;
                            Console.Clear();
                            Console.WriteLine(connectionString + "\r\n (write exit to cancel)\r\n");
                            Console.WriteLine("New string: \r\n");
                            newConnectionString = Console.ReadLine();
                            if (newConnectionString != "exit")
                                connectionString = newConnectionString;
                        }
                        break;

                    case '2':
                        {
                            HistoryTable history = new HistoryTable(connectionString, currentLanguage, new SQLDB(connectionString));
                            try
                            {
                                history.OpenConnection();
                                history.OpenTransaction();
                                history.AddOrGetAction("Изменение учетных данных пользователя/водителя");
                                history.AddOrGetAction("Загружен блок данных PLF");
                                history.AddOrGetAction("Загружен блок данных карты");
                                history.AddOrGetAction("Загружен блок данных бортового устройства");
                                history.AddOrGetAction("Регистрация нового пользователя в системе");
                                history.AddOrGetAction("Регистрация нового водителя");
                                history.AddOrGetAction("Регистрация нового транспортного средства");
                                history.CommitTransaction();
                                history.CloseConnection();
                            }
                            catch (Exception except)
                            {
                                history.RollbackConnection();
                                history.CloseConnection();
                                Console.WriteLine(except.Message);
                            }

                            Console.ReadKey(false);
                        }
                        break;

                    case '3':
                        {
                            try
                            {
                                SQLDB sql = new SQLDB(connectionString);
                                sql.OpenConnection();
                                sql.CloseConnection();
                            }
                            catch (Exception except)
                            {
                                Console.WriteLine(except.Message);
                            }

                            Console.ReadKey(false);
                        }
                        break;
                    case '4':
                        {
                            try
                            {
                                FirebirdSQLClass fireClass = new FirebirdSQLClass(connectionString);
                                fireClass.LoadAllInfo();
                            }
                            catch (Exception except)
                            {
                                Console.WriteLine(except.Message);
                            }

                            Console.ReadKey(false);
                        }
                        break;
                    case '5':
                        {
                            try
                            {
                                dataBlock.OpenConnection();
                                dataBlock.emailScheduleTable.GetAllEmailShedules_ForSending();
                            }
                            catch (Exception except)
                            {
                                Console.WriteLine(except.Message);
                            }
                            finally
                            {
                                dataBlock.CloseConnection();
                            }

                            Console.ReadKey(false);
                        }
                        break;

                    case 'v':
                        {
                            Console.Clear();
                            Console.WriteLine("type password to init Country_Regions tables");
                            string password = Console.ReadLine();
                            try
                            {
                                dataBlock.organizationTable.FillCountryAndRegionsTable(password,"nothing");
                                DataBaseInit(password);
                                Console.WriteLine("Выполнено успешно!");
                            }
                            catch (Exception except)
                            {
                                Console.WriteLine(except.Message);
                            }

                            Console.ReadKey(false);
                        }
                        break;
                    case '6': ex = true;
                        break;
                }
            }     */
        }
示例#25
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;
        }
    }
    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();
    }
示例#27
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;
 }
示例#28
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;
        }
    }
示例#29
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();
        }
    }
示例#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;
        }
    }
示例#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;
        }
    }