コード例 #1
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);
        }
    }
コード例 #2
0
ファイル: Data.aspx.cs プロジェクト: ShunkevichDV/FIS
    protected void Upload_PLFFile(object Sender, EventArgs e)
    {
        SelectPLFDriver.Visible = false;
        FileList.Visible = false;

        UploadPanel.Visible = true;

        string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            if (SelectPLFDriver.SelectedIndex == 0)
            {
                return;
            }
            else
            {
                List<filenameAndBytesStruct> fileUpload = new List<filenameAndBytesStruct>();
                fileUpload = (List<filenameAndBytesStruct>)Session["FileUpload"];
                List<int> CardIdsList = new List<int>();
                CardIdsList = (List<int>)Session["CardIdsList"];

                foreach (filenameAndBytesStruct curFile in fileUpload)
                {
                    if (curFile.isPLF)
                        dataBlock.AddPlfTypeData(orgId, curFile._bytes, curFile.filename, CardIdsList[SelectPLFDriver.SelectedIndex]);
                    else
                        dataBlock.AddData(orgId, curFile._bytes, curFile.filename);
                }

                Session["FileUpload"] = "";
            }
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();

            ErrorMessage.Text = "Ошибка: " + ex.Message;
            //show error block
            ErrorMessageBlock.Visible = true;
        }
        finally
        {
            SelectPLFDriver.Visible = false;
            FileList.Visible = false;

            UploadPanel.Visible = true;

            StatusUpdatePanel.Update();
        }
    }
コード例 #3
0
ファイル: Data.aspx.cs プロジェクト: ShunkevichDV/FIS
    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;
        }
    }
コード例 #4
0
    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();
        }
    }
コード例 #5
0
ファイル: Data.aspx.cs プロジェクト: ShunkevichDV/FIS
    protected void Parse_Click(object Sender, EventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        PLFUnit.PLFUnitClass plfForXml = new PLFUnit.PLFUnitClass();
        List<int> dataBlockIDs = new List<int>();
        int cardType = 0;
        int filesCounter = 0;
        object parsedObject;

        try
        {
            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int userId = dataBlock.usersTable.Get_UserID_byName(User.Identity.Name);
            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            dataBlockIDs = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
            if (dataBlockIDs.Count == 0)
                throw new Exception("Отсутствуют данные для разбора.");

            string output = "";
            foreach (int blockId in dataBlockIDs)
            {
                dataBlock.SetDataBlockIdForParse(blockId);
                dataBlock.SetOrgIdForParse(orgId);
                //dataBlock = new DataBlock(connectionString, blockId, ConfigurationManager.AppSettings["language"], orgId);
                if (dataBlock.GetDataBlockState(blockId) == "Not parsed")
                {
                    output = Server.MapPath("~/XML_PLF") + "\\";
                    parsedObject = dataBlock.ParseRecords(true, output, userId);
                    filesCounter++;
                }
                else
                    continue;

            }
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
            LoadAllLists();
            if (filesCounter > 0)
                Status.Text = "Файлы разобраны успешно! Разобрано " + filesCounter.ToString() + " файлов.";
            else
                Status.Text = "Не разобрано ни одного файла.";
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            LoadAllLists();
            Status.Text = "Ошибка: " + ex.Message;
        }
        finally
        {
            StatusUpdatePanel.Update();
            ModalPopupExtender1.Hide();
        }
    }
コード例 #6
0
ファイル: FirebirdSQLClass.cs プロジェクト: ShunkevichDV/FIS
        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);
            }
        }
コード例 #7
0
    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();
        }
    }
コード例 #8
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();
        }
    }
コード例 #9
0
    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();
        }
    }
コード例 #10
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();
    }