Example #1
0
    protected void ReportsTab_AddReportButton_Click(object sender, EventArgs e)
    {
        string    connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

        try
        {
            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int curUserId = dataBlock.usersTable.Get_UserID_byName(Page.User.Identity.Name);
            int orgId     = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            int reportId  = Convert.ToInt32(Selected_ReportsDataGrid_Index.Value);

            dataBlock.reportsTable.AddOrSetReportUserOrg_ActivateReportForORG(reportId, orgId, curUserId);
            string billName = @"Invoice for report """ + dataBlock.reportsTable.GetReportName(reportId) + @"""";
            ///Выставляем счет, когда добавляем отчет. Потом по-любому все убрать!!!!
            dataBlock.invoiceTable.AddInvoice(dataBlock.invoiceTable.InvoiceType_addReportInvoice, dataBlock.invoiceTable.Status_NotPaid,
                                              orgId, billName, DateTime.Now, DateTime.Now.AddDays(7), new DateTime());
            /////////////////////////////////////////////////////
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();

            RaiseException(ex);
        }
        LoadReportsTable();
        ReportsTab_AddReportButton.Enabled = false;
        AccessPanel1.Enabled = false;
        ReportsUpdatePanel.Update();
    }
    protected void SaveUserButton_Click(object sender, EventArgs e)
    {
        string    connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

        try
        {
            int    userId          = -1;
            int    orgId           = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            string Login           = DetailedInfo_Login_TextBox.Text;
            string password        = DetailedInfo_Password_TextBox.Text;
            string passwordConfirm = DetailedInfo_PasswordConfirm_TextBox.Text;
            int    UserRoleId      = Convert.ToInt32(DetailedInfo_UserRole_DropDown.SelectedValue);
            int    userTypeId      = Convert.ToInt32(DetailedInfo_UserType_DropDown.SelectedValue);

            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int curUserId = dataBlock.usersTable.Get_UserID_byName(Page.User.Identity.Name);

            switch (NewOrEditUser_hdnField.Value)
            {
            case "new":
            {
                UserFromTable newUser = new UserFromTable(Login, password, "", "", DateTime.Now, "");
                userId = dataBlock.usersTable.AddNewUser(newUser, userTypeId, UserRoleId, orgId, curUserId);
            } break;

            case "edit":
            {
                userId = Convert.ToInt32(Selected_UsersDataGrid_Index.Value);
                string        OldPass = dataBlock.usersTable.Get_UserPassword(userId);
                string        oldName = dataBlock.usersTable.Get_UserName(userId);
                UserFromTable newUser = new UserFromTable(Login, password, "", "", DateTime.Now, "");
                dataBlock.usersTable.EditUser(OldPass, oldName, newUser, userTypeId, UserRoleId, orgId, curUserId);
            } break;
            }
            if (userId < 0)
            {
                throw new Exception("Не выбран пользователь!");
            }

            SaveAdditionalInformation(userId, dataBlock);
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            RaiseException(ex);
        }
        finally
        {
            DetailedInformationPanel.Enabled = false;
            EditUser(false);
            LoadUsersTable();
            //UsersTabContainer.ActiveTab = UsersTab;
            UpdatePanel1.Update();
        }
    }
Example #3
0
    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);
        }
    }
Example #4
0
    protected void ReportsDataGrid_RadioButton_Checked(object sender, EventArgs e)
    {
        string    connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

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

            /*  foreach (DataGridItem oldrow in ReportsDataGrid.Items)
             * {
             *    ((RadioButton)oldrow.FindControl("ReportsDataGrid_RadioButton")).Checked = false;
             * }*/
            //Set the new selected row
            RadioButton  rb  = (RadioButton)sender;
            DataGridItem row = (DataGridItem)rb.NamingContainer;
            ((RadioButton)row.FindControl("ReportsDataGrid_RadioButton")).Checked = true;
            int reportId = ((List <int>)Session["ReportsTab_UserControl_ReportsIds"])[row.DataSetIndex];
            Selected_ReportsDataGrid_Index.Value = reportId.ToString();

            dataBlock.OpenConnection();
            //Загружаем описание отчета
            LoadReportNote(reportId, dataBlock);
            //делает кнопку добавить неактивной, если отчет уже добавлен и наоборот
            DateTime outdatetime = new DateTime();
            if (DateTime.TryParse(dataBlock.reportsTable.GetReportUserOrg_BDATE(reportId, orgId), out outdatetime))
            {
                ReportsTab_AddReportButton.Enabled = false;
                AccessPanel1.Enabled = true;
                //Загружаем закладку доступа
                LoadReportsAccessInfo(reportId, orgId, dataBlock);
                AccessTab_SaveButton.Enabled              = true;
                AccessTab_AvailableForAllButton.Enabled   = true;
                AccessTab_UnAvailableForAllButton.Enabled = true;
            }
            else
            {
                AccessPanel1.Enabled = false;
                ReportsTab_AddReportButton.Enabled = true;
            }
            ///////////////////////
            ReportsUpdatePanel.Update();

            /*ReportsTab_ButtonsUpdateTable.Update();
             * ReportsDataGridUpdatePanel.Update();
             * AccessTab_DataGridUpdateTable.Update();
             * AccessTab_ButtonsUpdateTable.Update();*/
            //////////////////////
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.CloseConnection();
            RaiseException(ex);
        }
    }
Example #5
0
    protected void ReloadStats_Click(object s, EventArgs e)
    {
        string    connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

        try
        {
            bool       isDDD       = IsDDDFile();
            List <int> selectedIds = new List <int>();
            selectedIds = (List <int>)Session["StatisticsDataBlockIds"];
            int yearVal     = Convert.ToInt32(YearsGrid.SelectedRow.Cells[0].Text);
            int monthNumber = MonthGrid.SelectedIndex + 1;
            dataBlock.OpenConnection();

            if (isDDD)
            {
                if (dataBlock.GetDataBlock_CardType(selectedIds[0]) == 0)//dddDriverCard
                {
                    MonthGrid_Values.DataSource = GetDDDMonthValuesDataTable(dataBlock, selectedIds, yearVal);
                    DaysGrid.DataSource         = GetDDDDayValuesDataTable(dataBlock, selectedIds, yearVal, monthNumber);
                }
                else//DDDVehicleCard
                {
                    MonthGrid_Values.DataSource = GetVehicleMonthValuesDataTable(dataBlock, selectedIds, yearVal);
                    DaysGrid.DataSource         = GetVehicleDayValuesDataTable(dataBlock, selectedIds, yearVal, monthNumber);
                }
            }
            else
            {
                MonthGrid_Values.DataSource = GetPLFMonthValuesDataTable(dataBlock, selectedIds, yearVal);
                DaysGrid.DataSource         = GetPLFDayValuesDataTable(dataBlock, selectedIds, yearVal, monthNumber);
            }
            MonthGrid_Values.DataBind();
            DaysGrid.DataBind();

            dataBlock.CloseConnection();
            DateUpdate.Update();
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
            DateUpdate.Update();
        }
        finally
        {
            dataBlock.CloseConnection();
        }
    }
    private void LoadAllDropDowns()
    {
        string    connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int       orgId            = Convert.ToInt32(Session["CURRENT_ORG_ID"]);

        DetailedInfo_TimeZone_DropDown.Items.Clear();
        DetailedInfo_Country_DropDown.Items.Clear();
        DetailedInfo_SiteLang_DropDown.Items.Clear();
        DetailedInfo_ReportsLang_DropDown.Items.Clear();
        dataBlock.OpenConnection();
        List <KeyValuePair <string, int> > orgCountries = dataBlock.organizationTable.GetAllCountry();

        dataBlock.CloseConnection();
        foreach (KeyValuePair <string, int> country in orgCountries)
        {
            DetailedInfo_Country_DropDown.Items.Add(new ListItem(country.Key, country.Value.ToString()));
        }
        string Russian = ConfigurationManager.AppSettings["language"];
        string English = ConfigurationManager.AppSettings["language"];

        DetailedInfo_SiteLang_DropDown.Items.Add(new ListItem("Русский", Russian));
        DetailedInfo_SiteLang_DropDown.Items.Add(new ListItem("English", English));
        DetailedInfo_ReportsLang_DropDown.Items.Add(new ListItem("Русский", Russian));
        DetailedInfo_ReportsLang_DropDown.Items.Add(new ListItem("English", English));

        //TIMEZONE
        DetailedInfo_TimeZone_DropDown.Items.Add(new ListItem("Minsk +2", "0"));
    }
Example #7
0
    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();
    }
Example #8
0
    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);
        }
    }
Example #9
0
    public void LoadAllVehiclesDateStatistics(List <int> dataBlockIds)
    {
        string    connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

        try
        {
            DateTime        mindate        = DateTime.Now;
            DateTime        maxdate        = new DateTime();
            List <DateTime> startEndPeriod = new List <DateTime>();
            List <int>      selectedIds    = new List <int>();
            dataBlock.OpenConnection();
            Session["AllDataBlockIds"] = dataBlockIds;
            int fileType = 0;
            foreach (int id in dataBlockIds)
            {
                fileType = dataBlock.GetDataBlock_CardType(id);
                if (fileType == 0 || fileType == 2)    //0 - drivers DDD; 1 for vehicle
                {
                    continue;
                }
                else
                {
                    selectedIds.Add(id);
                    startEndPeriod = new List <DateTime>();
                    startEndPeriod = dataBlock.vehicleUnitInfo.Get_StartEndPeriod(id);
                }

                if (mindate > startEndPeriod[0])
                {
                    mindate = startEndPeriod[0];
                }
                if (maxdate < startEndPeriod[1])
                {
                    maxdate = startEndPeriod[1];
                }
            }

            Session["StatisticsDataBlockIds"] = selectedIds;
            List <int> yearsList = GetYearList(mindate, maxdate);

            LoadAllForVehicleFile(dataBlock, selectedIds, yearsList);

            Status.Text             = "";
            YearsGrid.SelectedIndex = 0;
            MonthGrid.SelectedIndex = 0;
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
        }
        finally
        {
            dataBlock.CloseConnection();
            DateUpdate.Update();
        }
    }
Example #10
0
    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();
    }
Example #11
0
    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();
    }
Example #12
0
    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);
        }
    }
    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();
    }
    public void SelectItemInDataGrid(int orgId)
    {
        string    connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

        Selected_AccountsDataGrid_Index.Value = orgId.ToString();
        int userId = -1;

        dataBlock.OpenConnection();
        List <int> usersList = dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.DealerUserTypeId);

        dataBlock.CloseConnection();
        if (usersList.Count > 0)
        {
            userId = usersList[0];
        }
        // else throw new Exception("Нет пользователей для этого дилера");
        LoadAccountAdditionalInfo(orgId, userId);
        DetailedInformationUpdatePanel.Update();
    }
Example #15
0
    public void LoadUsersTable()
    {
        string               connectionString  = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock            dataBlock         = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        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));
        usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.DealerUserTypeId));
        foreach (int id in usersIds)
        {
            userFromTableList.Add(new UserFromTable().FillWithInfo(id, dataBlock.usersTable));
        }
        Session["UsersTab_UserControl_UsersIds"] = usersIds;

        DataTable dt = new DataTable();
        DataRow   dr;

        dt.Columns.Add(new DataColumn("DEALER", typeof(string)));
        dt.Columns.Add(new DataColumn("SURNAME", typeof(string)));
        dt.Columns.Add(new DataColumn("NAME", typeof(string)));
        dt.Columns.Add(new DataColumn("PAtronimic", typeof(string)));
        dt.Columns.Add(new DataColumn("LOGIN", typeof(string)));
        dt.Columns.Add(new DataColumn("REG_DATE", typeof(string)));
        dt.Columns.Add(new DataColumn("ROLE", typeof(string)));
        dt.Columns.Add(new DataColumn("USER_TYPE", typeof(string)));
        dt.Columns.Add(new DataColumn("STATE", typeof(string)));

        int      userInfoId = 0;
        int      dealerId;
        string   dealerName = "";
        DateTime date       = new DateTime();

        foreach (UserFromTable users in userFromTableList)
        {
            dr = dt.NewRow();
            //DEALER
            userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_DealerId);
            if (int.TryParse(dataBlock.usersTable.GetUserInfoValue(users.id, userInfoId), out dealerId))
            {
                dealerName = dataBlock.organizationTable.GetOrganizationName(dealerId);
            }
            else
            {
                dealerName = "???";
            }
            if (dealerName.Trim() == "")
            {
                dealerName = "???";
            }
            dr["DEALER"] = dealerName;
            //SURNAME
            userInfoId    = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Surname);
            dr["SURNAME"] = dataBlock.usersTable.GetUserInfoValue(users.id, userInfoId);
            //NAME
            userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Name);
            dr["NAME"] = dataBlock.usersTable.GetUserInfoValue(users.id, userInfoId);
            //Patronimic
            userInfoId       = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Patronimic);
            dr["PAtronimic"] = dataBlock.usersTable.GetUserInfoValue(users.id, userInfoId);
            //LOGIN
            dr["LOGIN"] = users.name;
            //REG_DATE
            if (DateTime.TryParse(dataBlock.usersTable.GetUserInfoValue(users.id, DataBaseReference.UserInfo_RegDate), out date))
            {
                dr["REG_DATE"] = date.ToLongDateString() + " " + date.ToShortTimeString();
            }
            //ROLE
            dr["ROLE"] = users.userRole;
            //USER_TYPE
            dr["USER_TYPE"] = users.userType;
            //STATE
            if (users.timeConnection == (new DateTime()))
            {
                dr["STATE"] = "Вход не производился";
            }
            else
            {
                dr["STATE"] = "Последний вход " + users.timeConnection.ToLongDateString() + " " + users.timeConnection.ToShortTimeString();
            }
            //
            dt.Rows.Add(dr);
        }
        dataBlock.CloseConnection();
        UsersDataGrid.DataSource = dt;
        UsersDataGrid.DataBind();
    }
    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();
    }
Example #17
0
    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();
        }
    }
Example #18
0
    protected void ApplyUsersFilter_Click(object sender, EventArgs e)
    {
        try
        {
            int userTypeId       = Convert.ToInt32(UsersFilterTable_TypeDropDownList.SelectedValue);
            int userRoleId       = Convert.ToInt32(UsersFilterTable_RoleDropDownList.SelectedValue);
            int selectedDealerId = Convert.ToInt32(UsersFilterTable_DealerDropDownList.SelectedValue);


            string     connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
            DataBlock  dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int        orgId            = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            List <int> usersIds         = new List <int>();

            dataBlock.OpenConnection();
            if (userTypeId != -1)
            {
                usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, userTypeId));
            }
            else
            {
                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));
            }
            Session["UsersTab_UserControl_UsersIds"] = usersIds;

            DataTable dt = new DataTable();
            DataRow   dr;
            dt.Columns.Add(new DataColumn("DEALER", typeof(string)));
            dt.Columns.Add(new DataColumn("SURNAME", typeof(string)));
            dt.Columns.Add(new DataColumn("NAME", typeof(string)));
            dt.Columns.Add(new DataColumn("PAtronimic", typeof(string)));
            dt.Columns.Add(new DataColumn("LOGIN", typeof(string)));
            dt.Columns.Add(new DataColumn("REG_DATE", typeof(string)));
            dt.Columns.Add(new DataColumn("ROLE", typeof(string)));
            dt.Columns.Add(new DataColumn("USER_TYPE", typeof(string)));
            dt.Columns.Add(new DataColumn("STATE", typeof(string)));

            int userInfoId = 0;
            //int dealerId;
            string   dealerName = "";
            DateTime date       = new DateTime();
            int      dealerId;
            foreach (int userId in usersIds)
            {
                if (userRoleId != -1)
                {
                    if (dataBlock.usersTable.GetUserRoleId(userId) != userRoleId)
                    {
                        continue;
                    }
                }

                /*if (userTypeId != -1)
                 *  if (dataBlock.usersTable.Get_UserTypeId(userId) != userTypeId)
                 *      continue;*/
                if (selectedDealerId != -1)
                {
                    userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_DealerId);
                    if (int.TryParse(dataBlock.usersTable.GetUserInfoValue(userId, userInfoId), out dealerId))
                    {
                        if (selectedDealerId != dealerId)
                        {
                            continue;
                        }
                        else
                        {
                            dealerName = dataBlock.organizationTable.GetOrganizationName(dealerId);
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_DealerId);
                    if (int.TryParse(dataBlock.usersTable.GetUserInfoValue(userId, userInfoId), out dealerId))
                    {
                        dealerName = dataBlock.organizationTable.GetOrganizationName(dealerId);
                    }
                    else
                    {
                        dealerName = "???";
                    }
                    if (dealerName.Trim() == "")
                    {
                        dealerName = "???";
                    }
                }
                dr = dt.NewRow();
                //DEALER
                dr["DEALER"] = dealerName;
                //SURNAME
                userInfoId    = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Surname);
                dr["SURNAME"] = dataBlock.usersTable.GetUserInfoValue(userId, userInfoId);
                //NAME
                userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Name);
                dr["NAME"] = dataBlock.usersTable.GetUserInfoValue(userId, userInfoId);
                //Patronimic
                userInfoId       = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Patronimic);
                dr["PAtronimic"] = dataBlock.usersTable.GetUserInfoValue(userId, userInfoId);
                //LOGIN
                dr["LOGIN"] = dataBlock.usersTable.Get_UserName(userId);
                //REG_DATE
                if (DateTime.TryParse(dataBlock.usersTable.GetUserInfoValue(userId, DataBaseReference.UserInfo_RegDate), out date))
                {
                    dr["REG_DATE"] = date.ToLongDateString() + " " + date.ToShortTimeString();
                }
                //ROLE
                dr["ROLE"] = dataBlock.usersTable.Get_UserRoleName(userId);
                //USER_TYPE
                dr["USER_TYPE"] = dataBlock.usersTable.Get_UserTypeStr(userId);
                //STATE
                date = dataBlock.usersTable.Get_TimeConnect(userId);
                if (date == (new DateTime()))
                {
                    dr["STATE"] = "Вход не производился";
                }
                else
                {
                    dr["STATE"] = "Последний вход " + date.ToLongDateString() + " " + date.ToShortTimeString();
                }
                //
                dt.Rows.Add(dr);
            }
            dataBlock.CloseConnection();
            UsersDataGrid.DataSource = dt;
            UsersDataGrid.DataBind();
            UsersDataGridUpdatePanel.Update();
        }
        catch (Exception ex)
        {
            RaiseException(ex);
        }
    }
    protected void SaveAccountButton_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"]);

        try
        {
            int accountId = -1;
            int userId    = -1;

            string Login           = DetailedInfo_Login_TextBox.Text;
            string password        = DetailedInfo_Password_TextBox.Text;
            string passwordConfirm = DetailedInfo_PasswordConfirm_TextBox.Text;
            string accountName     = DetailedInfo_AccountName_TextBox.Text;
            int    accountType     = Convert.ToInt32(AccountTypeDropDown.SelectedValue);
            int    countryId       = Convert.ToInt32(DetailedInfo_Country_DropDown.SelectedValue);

            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int curUserId = dataBlock.usersTable.Get_UserID_byName(Page.User.Identity.Name);
            int orgTypeId = dataBlock.organizationTable.GetOrgTypeId(orgId);
            switch (NewOrEditUser_hdnField.Value)
            {
            case "new":
            {
                accountId = dataBlock.organizationTable.AddNewOrganization(accountName, accountType, countryId, 1, orgId);
                UserFromTable newUser = new UserFromTable(Login, password, "", "", DateTime.Now, "");
                if (accountType != dataBlock.organizationTable.ClientTypeId)
                {
                    userId = dataBlock.usersTable.AddNewUser(newUser, dataBlock.usersTable.DealerUserTypeId, 1, accountId, 0);
                }
                else
                {
                    userId = dataBlock.usersTable.AddNewUser(newUser, dataBlock.usersTable.AdministratorUserTypeId, 1, accountId, curUserId);
                    dataBlock.usersTable.AddUserInfoValue(userId, DataBaseReference.UserInfo_DealerId, orgId.ToString());
                }
            } break;

            case "edit":
            {
                accountId = Convert.ToInt32(Selected_AccountsDataGrid_Index.Value);
                string oldName = dataBlock.organizationTable.GetOrganizationName(accountId);
                //dataBlock.organizationTable.SetOrganizationName(accountName, accountId);
                //dataBlock.organizationTable.SetOrgCountryAndRegion(accountId, countryId, 1);//тут регион ставится в 1, если надо будет регать где-то регион - поправить!
                dataBlock.organizationTable.EditOrganization(oldName, accountName, accountType, countryId, 1);

                /*userId = dataBlock.usersTable.Get_AllUsersId(accountId, dataBlock.usersTable.AccountUserTypeId)[0];
                 * int userRoleId = dataBlock.usersTable.GetUserRoleId(userId);
                 * string OldPass = dataBlock.usersTable.Get_UserPassword(userId);
                 * string oldName = dataBlock.usersTable.Get_UserName(userId);
                 * UserFromTable newUser = new UserFromTable(Login, password, "", "", DateTime.Now, "");
                 * dataBlock.usersTable.EditUser(OldPass, oldName, newUser, dataBlock.usersTable.AccountUserTypeId, userRoleId, accountId, curUserId);*/
            } break;
            }
            if (accountId < 0)
            {
                throw new Exception("Не выбран аккаунт или произошла ошибка редактирования!");
            }

            SaveAdditionalInformation(accountId, dataBlock);
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            RaiseException(ex);
        }
        finally
        {
            DetailedInformationPanel.Enabled = false;
            EditAccount(false);
            LoadAccountsTable();
            //AccountsTabContainer.ActiveTab = AccountsTab;   Сделать переключение вкладок!
            DetailedInformationUpdatePanel.Update();
            //this.Parent.
            // ((UpdatePanel)Page.FindControl("AccountsTreeUpdatePanel")).Update();
        }
    }
Example #20
0
    protected void SaveClientButton_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"]);

        try
        {
            int newClientId = -1;
            int userId      = -1;

            string clientName = DetailedInfo_ClientName_TextBox.Text;
            int    countryId  = Convert.ToInt32(DetailedInfo_Country_DropDown.SelectedValue);

            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int curUserId = dataBlock.usersTable.Get_UserID_byName(Page.User.Identity.Name);
            int orgTypeId = dataBlock.organizationTable.GetOrgTypeId(orgId);
            switch (NewOrEditUser_hdnField.Value)
            {
            case "new":
            {
                int neworgTypeId = dataBlock.organizationTable.ClientTypeId;
                newClientId = dataBlock.organizationTable.AddNewOrganization(clientName, neworgTypeId, countryId, 1, orgId);
                if (clientName.Length > 9)
                {
                    clientName = clientName.Substring(0, 9);
                }

                UserFromTable newUser = new UserFromTable(clientName, "123", "", "", DateTime.Now, "");
                userId = dataBlock.usersTable.AddNewUser(newUser, dataBlock.usersTable.AdministratorUserTypeId, 1, newClientId, 0);
                dataBlock.usersTable.AddUserInfoValue(userId, DataBaseReference.UserInfo_DealerId, orgId.ToString());
            } break;

            case "edit":
            {
                newClientId = Convert.ToInt32(Selected_ClientsDataGrid_Index.Value);
                dataBlock.organizationTable.SetOrganizationName(clientName, newClientId);
                dataBlock.organizationTable.SetOrgCountryAndRegion(newClientId, countryId, 1);        //тут регион ставится в 1, если надо будет регать где-то регион - поправить!
            } break;
            }
            if (userId < 0)
            {
                throw new Exception("Не выбран пользователь или произошла ошибка редактирования!");
            }

            SaveAdditionalInformation(newClientId, dataBlock);
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            RaiseException(ex);
        }
        finally
        {
            DetailedInformationPanel.Enabled = false;
            EditClient(false);
            LoadClientsTable();
            //DealersTabContainer.ActiveTab = DealersTab;   Сделать переключение вкладок!
            UpdatePanel1.Update();
        }
    }
Example #21
0
    private void LoadAllDropDowns()
    {
        string    connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int       orgId            = Convert.ToInt32(Session["CURRENT_ORG_ID"]);

        DetailedInfo_TimeZone_DropDown.Items.Clear();
        DetailedInfo_Country_DropDown.Items.Clear();
        DetailedInfo_UserRole_DropDown.Items.Clear();
        DetailedInfo_UserType_DropDown.Items.Clear();
        DetailedInfo_Dealer_DropDown.Items.Clear();
        DetailedInfo_SiteLang_DropDown.Items.Clear();
        DetailedInfo_ReportsLang_DropDown.Items.Clear();
        UsersFilterTable_RoleDropDownList.Items.Clear();
        UsersFilterTable_TypeDropDownList.Items.Clear();
        UsersFilterTable_DealerDropDownList.Items.Clear();

        dataBlock.OpenConnection();
        List <KeyValuePair <string, int> > orgCountries = dataBlock.organizationTable.GetAllCountry();

        foreach (KeyValuePair <string, int> country in orgCountries)
        {
            DetailedInfo_Country_DropDown.Items.Add(new ListItem(country.Key, country.Value.ToString()));
        }

        UsersFilterTable_RoleDropDownList.Items.Add(new ListItem("Все", "-1"));
        List <KeyValuePair <string, int> > userRoles = dataBlock.usersTable.GetAllUsersRoles();

        foreach (KeyValuePair <string, int> role in userRoles)
        {
            DetailedInfo_UserRole_DropDown.Items.Add(new ListItem(role.Key, role.Value.ToString()));
            UsersFilterTable_RoleDropDownList.Items.Add(new ListItem(role.Key, role.Value.ToString()));
        }

        UsersFilterTable_TypeDropDownList.Items.Add(new ListItem("Все", "-1"));
        List <KeyValuePair <string, int> > userTypes = dataBlock.usersTable.GetAllUsersTypes();

        foreach (KeyValuePair <string, int> type in userTypes)
        {
            if (type.Value == dataBlock.usersTable.DealerUserTypeId)
            {
                continue;
            }
            DetailedInfo_UserType_DropDown.Items.Add(new ListItem(type.Key, type.Value.ToString()));
            UsersFilterTable_TypeDropDownList.Items.Add(new ListItem(type.Key, type.Value.ToString()));//фильтр
        }

        string Russian = ConfigurationManager.AppSettings["language"];
        string English = ConfigurationManager.AppSettings["language"];

        DetailedInfo_SiteLang_DropDown.Items.Add(new ListItem("Русский", Russian));
        DetailedInfo_SiteLang_DropDown.Items.Add(new ListItem("English", English));
        DetailedInfo_ReportsLang_DropDown.Items.Add(new ListItem("Русский", Russian));
        DetailedInfo_ReportsLang_DropDown.Items.Add(new ListItem("English", English));

        //DEALER
        DetailedInfo_Dealer_DropDown.Items.Add(new ListItem("Нет дилера", "-1"));
        UsersFilterTable_DealerDropDownList.Items.Add(new ListItem("Все", "-1"));
        List <int> dealersIds = dataBlock.organizationTable.Get_AllDealersId(orgId);

        foreach (int dealerId in dealersIds)
        {
            DetailedInfo_Dealer_DropDown.Items.Add(new ListItem(dataBlock.organizationTable.GetOrganizationName(dealerId), dealerId.ToString()));
            UsersFilterTable_DealerDropDownList.Items.Add(new ListItem(dataBlock.organizationTable.GetOrganizationName(dealerId), dealerId.ToString()));
        }
        //TIMEZONE
        DetailedInfo_TimeZone_DropDown.Items.Add(new ListItem("Minsk +2", "0"));

        dataBlock.CloseConnection();
    }
Example #22
0
        public void LoadAllInfo()
        {
            Console.WriteLine("Conerting starts");
            DateTime startLoadTime = DateTime.Now;


            PLFUnit.PLFUnitClass plf;

            CARS cars = new CARS(fb_con);

            cars.LoadAllCars();

            DEPARTMENTS depar = new DEPARTMENTS(fb_con);

            depar.LoadAllDepartments();

            WORKERS workers = new WORKERS(fb_con);

            workers.LoadAllWorkers();

            DEVICES devices = new DEVICES(fb_con);

            devices.LoadAllDevices();

            READCYCLE readcycle = new READCYCLE(fb_con);

            readcycle.LoadAllReadCycles();

            DataBlock datablock = new DataBlock(connectionStringMysql, currentLanguage);

            try
            {
                List <KeyValuePair <int, int> > orgOldNewIds  = new List <KeyValuePair <int, int> >();
                List <KeyValuePair <int, int> > workOldNewIds = new List <KeyValuePair <int, int> >();
                List <KeyValuePair <int, int> > carsOldNewIds = new List <KeyValuePair <int, int> >();
                List <KeyValuePair <READCYCLE.readcycle, int> > readCycleAndorgIdList = new List <KeyValuePair <READCYCLE.readcycle, int> >();

                List <int> allIds      = new List <int>();
                int        newDeviceId = -1;
                int        userInfoId;
                KeyValuePair <int, int> tempOldNewIds;
                List <int> addedWorkers = new List <int>();
                datablock.OpenConnection();
                datablock.OpenTransaction();
                //Создание организация, работников и ТС
                foreach (DEPARTMENTS.department department in depar.departments)
                {
                    addedWorkers = new List <int>();
                    int orgId = datablock.organizationTable.AddNewOrganization(department.DEPARTMENT, 1, 1, 1);
                    tempOldNewIds = new KeyValuePair <int, int>(department.ID, orgId);
                    orgOldNewIds.Add(tempOldNewIds);
                    int carId = -1;
                    #region "cars"
                    IEnumerable <CARS.car> carsList =
                        from car in cars.carsArray
                        where car.DEPARTMENTID == department.ID
                        select car;

                    foreach (CARS.car car in carsList)
                    {
                        IEnumerable <int> scoreQuery =
                            from devId in readcycle.cycles
                            where devId.CARID == car.ID
                            select devId.DEVICEID;
                        allIds = scoreQuery.ToList();

                        if (allIds.Count > 0)
                        {
                            IEnumerable <DEVICES.device> oneDevice =
                                from devId in devices.devices
                                where devId.ID == allIds[0]
                                select devId;

                            if (oneDevice.ToList().Count > 0)
                            {
                                DEVICES.device NewDevice = oneDevice.ToList()[0];
                                newDeviceId = datablock.deviceTable.AddNewDevice(1, NewDevice.DEVICE, NewDevice.VERSION, DateTime.Now, 1, 23442324);
                            }
                            else
                            {
                                newDeviceId = datablock.deviceTable.AddNewDevice(1, "UndefinedDevice", "UndefinedVersion", DateTime.Now, 1, 23442324);
                            }
                        }
                        else
                        {
                            newDeviceId = datablock.deviceTable.AddNewDevice(1, "UndefinedDevice", "UndefinedVersion", DateTime.Now, 1, 23442324);
                        }

                        if (car.DEPARTMENTID == department.ID)
                        {
                            int cardId = datablock.cardsTable.CreateNewCard(car.REGNUMBER, "Unknown", datablock.cardsTable.vehicleCardTypeId, orgId, 0, "Created from FIREBIRD database", 0, 1);
                            carId         = datablock.vehiclesTables.AddNewVehicle(car.REGNUMBER, car.CARMODEL, "Unknown", 1, newDeviceId, cardId, DateTime.Now, 1);
                            tempOldNewIds = new KeyValuePair <int, int>(car.ID, carId);
                            carsOldNewIds.Add(tempOldNewIds);
                        }
                    }
                    #endregion
                    #region "workers"
                    IEnumerable <WORKERS.worker> workersList =
                        from worker in workers.workers
                        where worker.DEPARTMENTID == department.ID
                        select worker;

                    foreach (WORKERS.worker workerForAdd in workersList)
                    {
                        int newWId = datablock.cardsTable.CreateNewCard(workerForAdd.FIRSTNAME + " " + workerForAdd.SURNAME, workerForAdd.WORKERINTID.ToString(), datablock.cardsTable.driversCardTypeId,
                                                                        orgId, 0, "Created from firebird", 0, 1);

                        /*userInfoId = datablock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Patronimic);
                         * datablock.usersTable.EditUserInfo(newWId, userInfoId, workerForAdd.MIDDLENAME);
                         * userInfoId = datablock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Name);
                         * datablock.usersTable.EditUserInfo(newWId, userInfoId, workerForAdd.FIRSTNAME);
                         * userInfoId = datablock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Surname);
                         * datablock.usersTable.EditUserInfo(newWId, userInfoId, workerForAdd.SURNAME);
                         * userInfoId = datablock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Birthday);
                         * datablock.usersTable.EditUserInfo(newWId, userInfoId, workerForAdd.BIRTHDAY.ToShortDateString());
                         * userInfoId = datablock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_DriversCertificate);
                         * datablock.usersTable.EditUserInfo(newWId, userInfoId, workerForAdd.LICENCE);*/
                        addedWorkers.Add(workerForAdd.ID);
                        tempOldNewIds = new KeyValuePair <int, int>(workerForAdd.ID, newWId);
                        workOldNewIds.Add(tempOldNewIds);
                    }
                    #endregion
                    #region "set orgId to READCYCLES"
                    if (addedWorkers.Count > 0)
                    {
                        for (int i = 0; i < readcycle.cycles.Count; i++)
                        {
                            if (addedWorkers.Contains(readcycle.cycles[i].WORKER1ID) || addedWorkers.Contains(readcycle.cycles[i].WORKER2ID))
                            {
                                KeyValuePair <READCYCLE.readcycle, int> readCycleAndorgId = new KeyValuePair <READCYCLE.readcycle, int>(readcycle.cycles[i], orgId);
                                readCycleAndorgIdList.Add(readCycleAndorgId);
                            }
                        }
                    }
                    #endregion
                }
                Console.WriteLine("Added workers, departmens, cars");

                if (readCycleAndorgIdList.Count != readcycle.cycles.Count)
                {
                    if (false) //база фигово связана
                    {
                        throw new Exception("Куда-то пропала часть инфы");
                    }
                }
                //Загрузка файлов ПЛФ в ранее созданные организации.
                foreach (KeyValuePair <READCYCLE.readcycle, int> readedcycle in readCycleAndorgIdList)
                {
                    SQLDB                     sqlDb     = datablock.sqlDb;
                    SQLDB_Records             sqlDB_rec = new SQLDB_Records(connectionStringMysql, sqlDb.GETMYSQLCONNECTION());
                    ReflectObjectToTableClass reflectedItemsList;
                    byte[]                    bytes = Guid.NewGuid().ToByteArray();
                    int    orgId         = readedcycle.Value;
                    Type   type          = null;
                    object myParseObject = new object();
                    plf          = new PLFUnitClass();
                    plf          = LoadLogBook(readedcycle.Key);
                    plf.cardType = 2;

                    IEnumerable <string> selCar =
                        from car in cars.carsArray
                        where car.ID == readedcycle.Key.CARID
                        select car.REGNUMBER;
                    if (selCar.ToList().Count > 0)
                    {
                        plf.VEHICLE = selCar.ToList()[0];
                    }


                    IEnumerable <string> selDeviceName =
                        from dev in devices.devices
                        where dev.ID == readedcycle.Key.DEVICEID
                        select dev.DEVICE;
                    if (selDeviceName.ToList().Count > 0)
                    {
                        plf.ID_DEVICE = selDeviceName.ToList()[0];
                    }


                    int driverId = -1;
                    foreach (KeyValuePair <int, int> oldNew in workOldNewIds)
                    {
                        if (oldNew.Key == readedcycle.Key.WORKER1ID)
                        {
                            driverId = oldNew.Value;
                        }
                    }
                    int dataBlockId = datablock.AddPlfTypeData(orgId, bytes,
                                                               "AutoGenerated " + plf.VEHICLE + " " + plf.START_PERIOD.ToString() + " - " + plf.END_PERIOD.ToString(),
                                                               driverId);
                    DataRecords dataRecord = new DataRecords(connectionString, dataBlockId, currentLanguage, sqlDb);

                    //////////////////////устанавливаем PLF карту нужного водителя. Незнаю почему именно здесь, но так получилось.
                    int plfDriversCardType = sqlDB_rec.Get_DataBlockCardType(dataBlockId);
                    sqlDb.SetDataBlock_CardId(dataBlockId, plfDriversCardType);
                    // sqlDB.OpenConnection();
                    int cardTypeParamId = sqlDb.AddParam("cardType", 0, 255);
                    //sqlDB.OpenConnection();
                    sqlDb.DeleteDataRecord(dataBlockId, cardTypeParamId);
                    // sqlDB.CloseConnection();
                    //////////////////////
                    type          = plf.GetType();
                    myParseObject = plf;

                    //sqlDB.OpenConnection();
                    SetParseBDate(sqlDb, dataBlockId);
                    //sqlDB.CloseConnection();

                    List <ReflectObjectToTableClass> allRecordsToAdd = new List <ReflectObjectToTableClass>();

                    foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
                    {
                        reflectedItemsList = new ReflectObjectToTableClass();
                        string fieldName = pi.Name;
                        object field2    = pi.GetValue(myParseObject, null);

                        if (field2 != null)
                        {
                            reflectedItemsList.ReflectObjectToTable(fieldName, field2); //Не удалять!
                            allRecordsToAdd.Add(AddRecords(reflectedItemsList, sqlDb)); //не удалять
                        }
                    }

                    foreach (ReflectObjectToTableClass recordList in allRecordsToAdd)
                    {
                        dataRecord.AddDataArray(recordList.reflectedItemsList);
                    }

                    //sqlDB.OpenConnection();
                    SetParseEDate(sqlDb, dataBlockId);
                    sqlDb.SetDataBlockState(dataBlockId, 2);
                    int dataBlockParseRecords = sqlDb.SetDataBlockParseRecords(dataBlockId);
                    Console.WriteLine("" + dataBlockParseRecords.ToString() + " records added");
                }

                Console.WriteLine("\n\r" + "Время начала импорта " + startLoadTime.ToShortDateString() + " " + startLoadTime.ToShortTimeString());
                Console.WriteLine("\n\r" + "Время окончания импорта " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
                //throw new Exception();
                datablock.CommitTransaction();
                datablock.CloseConnection();
            }
            catch (Exception ex)
            {
                datablock.RollbackConnection();
                datablock.CloseConnection();
                Console.WriteLine(ex.Message);
            }
        }
Example #23
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;
        }
    }
    public bool LoadDealersTable()//Возвращает False, если организация субдилер, у которой не может быть субдилеров
    {
        string     connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock  dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int        orgId            = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        List <int> dealersIds       = new List <int>();

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

        if (orgTypeId == dataBlock.organizationTable.DealerTypeId || orgTypeId == dataBlock.organizationTable.PredealerTypeId)
        {
            //dealersIds = dataBlock.organizationTable.Get_AllOrganizationsId(dataBlock.organizationTable.DealerTypeId);
            dealersIds = dataBlock.organizationTable.Get_AllDealersId(orgId);

            Session["DealersTab_UserControl_DealersIds"] = dealersIds;

            DataTable dt = new DataTable();
            DataRow   dr;
            dt.Columns.Add(new DataColumn("DEALERNAME", typeof(string)));
            dt.Columns.Add(new DataColumn("LOGIN", 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      dealerInfoId = 0;
            DateTime date         = new DateTime();
            int      userId       = 1;
            foreach (int id in dealersIds)
            {
                userId = 0;

                dr = dt.NewRow();
                dr["DEALERNAME"] = dataBlock.organizationTable.GetOrganizationName(id);
                //LOGIN
                if (dataBlock.usersTable.Get_AllUsersId(id, dataBlock.usersTable.DealerUserTypeId) != null)
                {
                    userId      = dataBlock.usersTable.Get_AllUsersId(id, dataBlock.usersTable.DealerUserTypeId)[0];
                    dr["LOGIN"] = dataBlock.usersTable.Get_UserName(userId);
                }
                //REG_DATE
                if (DateTime.TryParse(dataBlock.usersTable.GetUserInfoValue(userId, DataBaseReference.UserInfo_RegDate), out date))
                {
                    dr["REG_DATE"] = date.ToLongDateString() + " " + date.ToShortTimeString();
                }
                //END_REG_DATE
                if (DateTime.TryParse(dataBlock.usersTable.GetUserInfoValue(userId, DataBaseReference.UserInfo_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);
            }
            DealersDataGrid.DataSource = dt;
            DealersDataGrid.DataBind();
        }
        else
        {
            return(false);
        }
        dataBlock.CloseConnection();

        return(true);
    }
    protected void SaveDealerButton_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"]);

        try
        {
            int dealerId = -1;
            int userId   = -1;

            string Login           = DetailedInfo_Login_TextBox.Text;
            string password        = DetailedInfo_Password_TextBox.Text;
            string passwordConfirm = DetailedInfo_PasswordConfirm_TextBox.Text;
            string dealerName      = DetailedInfo_DealerName_TextBox.Text;
            int    countryId       = Convert.ToInt32(DetailedInfo_Country_DropDown.SelectedValue);

            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int curUserId = dataBlock.usersTable.Get_UserID_byName(Page.User.Identity.Name);
            int orgTypeId = dataBlock.organizationTable.GetOrgTypeId(orgId);
            switch (NewOrEditUser_hdnField.Value)
            {
            case "new":
            {
                int neworgTypeId;
                if (orgTypeId == dataBlock.organizationTable.DealerTypeId)
                {
                    neworgTypeId = dataBlock.organizationTable.SubdealerTypeId;
                }
                else
                {
                    neworgTypeId = dataBlock.organizationTable.DealerTypeId;
                }

                dealerId = dataBlock.organizationTable.AddNewOrganization(dealerName, neworgTypeId, countryId, 1, orgId);
                UserFromTable newUser = new UserFromTable(Login, password, "", "", DateTime.Now, "");
                userId = dataBlock.usersTable.AddNewUser(newUser, dataBlock.usersTable.DealerUserTypeId, 1, dealerId, 0);
            } break;

            case "edit":
            {
                dealerId = Convert.ToInt32(Selected_DealersDataGrid_Index.Value);
                dataBlock.organizationTable.SetOrganizationName(dealerName, dealerId);
                dataBlock.organizationTable.SetOrgCountryAndRegion(dealerId, countryId, 1);        //тут регион ставится в 1, если надо будет регать где-то регион - поправить!

                userId = dataBlock.usersTable.Get_AllUsersId(dealerId, dataBlock.usersTable.DealerUserTypeId)[0];
                int           userRoleId = dataBlock.usersTable.GetUserRoleId(userId);
                string        OldPass    = dataBlock.usersTable.Get_UserPassword(userId);
                string        oldName    = dataBlock.usersTable.Get_UserName(userId);
                UserFromTable newUser    = new UserFromTable(Login, password, "", "", DateTime.Now, "");
                dataBlock.usersTable.EditUser(OldPass, oldName, newUser, dataBlock.usersTable.DealerUserTypeId, userRoleId, dealerId, curUserId);
            } break;
            }
            if (userId < 0)
            {
                throw new Exception("Не выбран пользователь или произошла ошибка редактирования!");
            }

            SaveAdditionalInformation(dealerId, dataBlock);
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            RaiseException(ex);
        }
        finally
        {
            DetailedInformationPanel.Enabled = false;
            EditDealer(false);
            LoadDealersTable();
            //DealersTabContainer.ActiveTab = DealersTab;   Сделать переключение вкладок!
            UpdatePanel1.Update();
        }
    }
Example #26
0
    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();
    }