//Работа с уже занесенной записью /// <summary> /// Конструктор для работы с уже занессеной записью(использовать например для удаления DataBlock /// </summary> /// <param name="connectionStringTMP">строка подключения</param> /// <param name="dataBlockId">dataBlockId</param> /// <param name="Current_Language">Язык</param> public DataBlock(string connectionStringTMP, int dataBlockId, string Current_Language) { //тестовое подключение sqlDb = new SQLDB(connectionStringTMP); /////// SQLDB sqlDB = new SQLDB(connectionStringTMP); int dataIdTemp = sqlDB.checkTableExistence("fn_data_block", "DATA_BLOCK_ID", dataBlockId); if (dataIdTemp == 0) throw (new Exception("There is no Data Block with id " + dataBlockId.ToString())); connectionString = connectionStringTMP; DATA_BLOCK_ID = dataBlockId; DATA_BLOCK_ID_PREVIOUS = -1; CurrentLanguage = Current_Language; dataRecord = new DataRecords(connectionStringTMP, dataBlockId, Current_Language, sqlDb); vehicleUnitInfo = new VehicleUnitInfo(connectionString, Current_Language, sqlDb); cardUnitInfo = new CardUnitInfo(connectionString, Current_Language, sqlDb); plfUnitInfo = new PLFUnitInfo(connectionString, Current_Language, sqlDb); cardsTable = new CardsTable(connectionString, Current_Language, sqlDb); organizationTable = new OrganizationTable(connectionString, Current_Language, sqlDb); usersTable = new UsersTables(connectionString, CurrentLanguage, sqlDb); stringTable = new StringTable(connectionString, CurrentLanguage); vehiclesTables = new VehiclesTable(connectionString, CurrentLanguage, sqlDb); criteriaTable = new CriteriaTable(connectionString, CurrentLanguage, sqlDb); deviceTable = new DeviceTable(connectionString, CurrentLanguage, sqlDb); //historyTable = new HistoryTable(connectionString, CurrentLanguage, sqlDb); reportsTable = new ReportsTable(connectionString, CurrentLanguage, sqlDb); invoiceTable = new InvoiceTable(connectionString, CurrentLanguage, sqlDb); emailScheduleTable = new EmailScheduleTable(connectionString, CurrentLanguage, sqlDb); remindTable = new RemindTable(connectionString, CurrentLanguage, sqlDb); bannersTable = new BannersTable(connectionString, CurrentLanguage, sqlDb); currentCardType = -1; organizationID = 0; }
public static bool DeleteAllData(int dataBlockId, string connectionString) { SQLDB sqlDB = new SQLDB(connectionString); if (sqlDB.DeleteAllDataRecords(dataBlockId) != -1) return true; else return false; }
public VehiclesTable(string connectionsStringTMP, string Current_Language, SQLDB sql) { connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; //sqlDB = new SQLDB(connectionString); sqlDB = sql; }
/// <summary> /// Конструктор /// </summary> /// <param name="connectionsStringTMP">Строка подключения. МОжет быть любой</param> /// <param name="Current_Language">Язык</param> /// <param name="sql">обьект SQLDB</param> public HistoryTable(string connectionsStringTMP, string Current_Language, SQLDB sql) { bool toCloseConncection = false; connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; //sqlDb = new SQLDB(connectionString); sqlDb = sql; string LanguageForAction = "STRING_RU"; if (!sqlDb.IsConnectionOpened()) { sqlDb.OpenConnection(); toCloseConncection = true; } driversRegDataChanged = AddOrGetAction("Users/drivers registration data changed", LanguageForAction); vehiclesRegDataChanged = AddOrGetAction("Vehicles registration data changed", LanguageForAction); PLFDataBlockLoaded = AddOrGetAction("PLF data block loaded", LanguageForAction); DDDDriversDataBlockLoaded = AddOrGetAction("Cards data block loaded", LanguageForAction); DDDVehiclesDataBlockLoaded = AddOrGetAction("Vehicles unit data block loaded", LanguageForAction); newUserRegistered = AddOrGetAction("New user registered", LanguageForAction); newDriverRegistered = AddOrGetAction("New driver registered", LanguageForAction); newVehicleRegistered = AddOrGetAction("New vehicle registered", LanguageForAction); setReportUserRoles = AddOrGetAction("Change permissions to the report for user role", LanguageForAction); setReportUserOrg = AddOrGetAction("New report type successfully added", LanguageForAction); invoicePaid = AddOrGetAction("Invoice paid", LanguageForAction); if(toCloseConncection) sqlDb.CloseConnection(); }
public static bool DeleteData(int dataIdTemp, string connectionString) { SQLDB sqlDB = new SQLDB(connectionString); if (sqlDB.DeleteDataRecord(dataIdTemp)) return true; else return false; }
/// <summary> /// Конструктор /// </summary> /// <param name="connectionsStringTMP">Строка подключения к базе данных(не обязательна, так как передается подключение</param> /// <param name="Current_Language">Текущий язык</param> /// <param name="sql">Обьект подключения к базе данных</param> public CardsTable(string connectionsStringTMP, string Current_Language, SQLDB sql) { sqlDb = sql; connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; driversCardTypeId = 1; vehicleCardTypeId = 2; orgInitCardTypeId = 3; }
public DataRecords(string connectionStringTMP, int dataBlockId, string Current_Language, SQLDB sql) { sqlDB = sql; connectionString = connectionStringTMP; DATA_RECORD_ID = -1; DATA_RECORD_ID_PREVIOUS = -1; DATA_BLOCK_ID = dataBlockId; paramId = -1; CurrentLanguage = Current_Language; }
public ReportsTable(string connectionsStringTMP, string Current_Language, SQLDB sql) { connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; //sqlDBR = new SQLDB(connectionString); sqlDBR = sql; STRID_REPORT_NAME_Ident = 0; STRID_REPORT_SHORT_NAME_Ident = 1; STRID_REPORT_FULL_NAME_Ident = 2; STRID_REPORT_PRINT_NAME_Ident = 3; }
public string GetString(int stringId) { SQLDB sqldb = new SQLDB(connectionString); string gettedString; sqldb.OpenConnection(); gettedString = sqldb.GetString(stringId, CurrentLanguage); sqldb.CloseConnection(); return gettedString; }
///////////////////////Criteria public CriteriaTable() { connectionString = ""; CurrentLanguage = ""; sqlDB = new SQLDB(connectionString); KeyId = -1; CriteriaName = ""; CriteriaNote = ""; MinValue = -1; MaxValue = -1; MeasureId = -1; MeasureName = ""; }
public CriteriaTable(string connectionsStringTMP, string Current_Language, SQLDB sql) { connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; //sqlDB = new SQLDB(connectionString); sqlDB = sql; KeyId = -1; CriteriaName = ""; CriteriaNote = ""; MinValue = -1; MaxValue = -1; MeasureId = -1; MeasureName = ""; }
/// <summary> /// Конструктор /// </summary> /// <param name="connectionsStringTMP">строка подключение(необязательно ее указывать)</param> /// <param name="Current_Language">Язык</param> /// <param name="sql">обьект SQLDB</param> public InvoiceTable(string connectionsStringTMP, string Current_Language, SQLDB sql) { connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; //тест // sqlDBR = new SQLDB(connectionString); sqlDBR = sql; // string LanguageForStatus = "STRING_RU"; sqlDBR.OpenConnection(); Status_Paid = AddOrGetInvoiceStatusId("Paid", LanguageForStatus); Status_NotPaid = AddOrGetInvoiceStatusId("Not paid", LanguageForStatus); InvoiceType_addReportInvoice = AddOrGetInvoiceTypeId("Additional report invoice", LanguageForStatus); InvoiceType_moreUsers = AddOrGetInvoiceTypeId("Additional users invoice", LanguageForStatus); InvoiceType_licenseFee = AddOrGetInvoiceTypeId("License fee", LanguageForStatus); sqlDBR.CloseConnection(); }
public int AddParam(string name, string parentName, int size, SQLDB sqlDB) { int parentParamId; if (parentName != "") parentParamId = sqlDB.getParamId(parentName); else parentParamId = 0; if (parentParamId == -1) return -1; //нету Parent param. else { int paramId; Object thisLock = new Object(); lock (thisLock) { paramId = sqlDB.AddParam(name, parentParamId, size); } return paramId; } }
//deviceTypes public DeviceTable(string connectionsStringTMP, string Current_Language, SQLDB sql) { connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; sqlDB = sql; }
public int DeleteAllData(SQLDB sqlDB) { return sqlDB.DeleteAllDataRecords(DATA_BLOCK_ID); }
private static int InitTable_ID_String(string tableName, string primaryKeyName, string stringName, string stringValue, SQLDB sqlDb, MySqlConnection sqlConnection) { MySqlCommand cmd = new MySqlCommand(); int stringId = sqlDb.AddOrGetString(stringValue, SQLDB.userString); int generatedId = sqlDb.generateId(tableName, primaryKeyName); if (generatedId == -1) throw (new Exception("Can't generate " + primaryKeyName)); string sql = "INSERT INTO " + tableName + " " + "(" + primaryKeyName + "," + stringName + ")" + "VALUES (@" + primaryKeyName + ",@" + stringName + ")"; cmd = new MySqlCommand(sql, sqlConnection); cmd.Parameters.AddWithValue("@" + primaryKeyName, generatedId); cmd.Parameters.AddWithValue("@" + stringName, stringId); cmd.ExecuteNonQuery(); return generatedId; }
/// <summary> /// Иннициализирует базу данных стартовыми значениями. /// Это нужно для того, чтобы сразу с разворачивания базы данных можно было начать работать в веб интерфейсе. /// </summary> /// <param name="password">пароль нужен просто, чтобы из консоли нечайно не тыкнуть. пароль = qqq</param> public static void DataBaseInit(string password) { string CurrentLanguage = "STRING_RU"; if (password != "qqq") throw new Exception("Неправильный пароль"); string connectionString = "server=localhost;User Id=root;password = 1;Persist Security Info=True;database=fleetnetbase"; string connectionString1 = "server=mysql62.1gb.ru;default command timeout=600;Connection Timeout=600;database=gb_x_smartfis;User Id=gb_x_smartfis;password =5216a0af;"; SQLDB sqlDb = new SQLDB(connectionString); MySqlConnection sqlConnection = new MySqlConnection(connectionString); MySqlCommand cmd = new MySqlCommand(); int stringId = -1; int generatedId = -1; string sql; sql = "INSERT INTO fd_string " + "(STRING_ID, STRING_RU)" + "VALUES (@STRING_ID, @STRING_RU)"; cmd = new MySqlCommand(sql, sqlConnection); cmd.Parameters.AddWithValue("@STRING_ID", 0); cmd.Parameters.AddWithValue("@STRING_RU", ""); sqlConnection.Open(); sqlDb.OpenConnection(); cmd.ExecuteNonQuery(); //dataBlockStates InitTable_ID_String("fd_data_block_state", "DATA_BLOCK_STATE_ID", "STRID_DATA_BLOCK_STATE_NAME", "Ideal", sqlDb, sqlConnection); InitTable_ID_String("fd_data_block_state", "DATA_BLOCK_STATE_ID", "STRID_DATA_BLOCK_STATE_NAME", "Parsed", sqlDb, sqlConnection); InitTable_ID_String("fd_data_block_state", "DATA_BLOCK_STATE_ID", "STRID_DATA_BLOCK_STATE_NAME", "Not parsed", sqlDb, sqlConnection); InitTable_ID_String("fd_data_block_state", "DATA_BLOCK_STATE_ID", "STRID_DATA_BLOCK_STATE_NAME", "Not supported", sqlDb, sqlConnection); //dataRecordsState InitTable_ID_String("fd_data_record_state", "DATA_RECORD_STATE_ID", "STRID_DATA_RECORD_STATE_NAME", "Ideal", sqlDb, sqlConnection); InitTable_ID_String("fd_data_record_state", "DATA_RECORD_STATE_ID", "STRID_DATA_RECORD_STATE_NAME", "Parsed", sqlDb, sqlConnection); InitTable_ID_String("fd_data_record_state", "DATA_RECORD_STATE_ID", "STRID_DATA_RECORD_STATE_NAME", "Not parsed", sqlDb, sqlConnection); //Card_TYPE stringId = sqlDb.AddOrGetString("Card Type: Driver", SQLDB.userString); generatedId = sqlDb.generateId("fd_card_type", "CARD_TYPE_ID"); if (generatedId == -1) throw (new Exception("Can't generate CARD_TYPE_ID")); sql = "INSERT INTO fd_card_type " + "(CARD_TYPE_ID, STRID_CARD_TYPE_NAME, STRID_CARD_TYPE_SHORT_NAME, STRID_CARD_TYPE_PRINT_NAME)" + "VALUES (@CARD_TYPE_ID, @STRID_CARD_TYPE_NAME, @STRID_CARD_TYPE_SHORT_NAME, @STRID_CARD_TYPE_PRINT_NAME)"; cmd = new MySqlCommand(sql, sqlConnection); cmd.Parameters.AddWithValue("@CARD_TYPE_ID", generatedId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_NAME", stringId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_SHORT_NAME", stringId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_PRINT_NAME", stringId); cmd.ExecuteNonQuery(); stringId = sqlDb.AddOrGetString("Card Type: Vehicle", SQLDB.userString); generatedId = sqlDb.generateId("fd_card_type", "CARD_TYPE_ID"); if (generatedId == -1) throw (new Exception("Can't generate CARD_TYPE_ID")); sql = "INSERT INTO fd_card_type " + "(CARD_TYPE_ID, STRID_CARD_TYPE_NAME, STRID_CARD_TYPE_SHORT_NAME, STRID_CARD_TYPE_PRINT_NAME)" + "VALUES (@CARD_TYPE_ID, @STRID_CARD_TYPE_NAME, @STRID_CARD_TYPE_SHORT_NAME, @STRID_CARD_TYPE_PRINT_NAME)"; cmd = new MySqlCommand(sql, sqlConnection); cmd.Parameters.AddWithValue("@CARD_TYPE_ID", generatedId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_NAME", stringId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_SHORT_NAME", stringId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_PRINT_NAME", stringId); cmd.ExecuteNonQuery(); stringId = sqlDb.AddOrGetString("Card Type: Organization Init Card", SQLDB.userString); generatedId = sqlDb.generateId("fd_card_type", "CARD_TYPE_ID"); if (generatedId == -1) throw (new Exception("Can't generate CARD_TYPE_ID")); sql = "INSERT INTO fd_card_type " + "(CARD_TYPE_ID, STRID_CARD_TYPE_NAME, STRID_CARD_TYPE_SHORT_NAME, STRID_CARD_TYPE_PRINT_NAME)" + "VALUES (@CARD_TYPE_ID, @STRID_CARD_TYPE_NAME, @STRID_CARD_TYPE_SHORT_NAME, @STRID_CARD_TYPE_PRINT_NAME)"; cmd = new MySqlCommand(sql, sqlConnection); cmd.Parameters.AddWithValue("@CARD_TYPE_ID", generatedId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_NAME", stringId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_SHORT_NAME", stringId); cmd.Parameters.AddWithValue("@STRID_CARD_TYPE_PRINT_NAME", stringId); cmd.ExecuteNonQuery(); int orgInitCardTypeId = generatedId; //fd_deviceFirmware int deviceFirmWareId = sqlDb.AddNewDeviceFirmware("onboard device by default", DateTime.Now, "0.0.0.0", new byte[1]); //fd_device int deviceTypeId = sqlDb.AddNewDeviceType("DefaultDeviceType"); sqlDb.AddNewDevice(deviceTypeId, "The onboard device by default", "00000", DateTime.Now, deviceFirmWareId, 222222); //InitTable_ID_String("fd_device", "DEVICE_ID", "STRID_DEVICE_NAME", ""); //fd_object InitTable_ID_String("fd_object", "OBJECT_ID", "STRID_OBJECT_NAME", "Object by default", sqlDb, sqlConnection); //FD_ORG_TYPE InitTable_ID_String("fd_org_type", "ORG_TYPE_ID", "STRID_ORG_TYPE_NAME", "Cargo transportation", sqlDb, sqlConnection); InitTable_ID_String("fd_org_type", "ORG_TYPE_ID", "STRID_ORG_TYPE_NAME", "Passengers transportation", sqlDb, sqlConnection); InitTable_ID_String("fd_org_type", "ORG_TYPE_ID", "STRID_ORG_TYPE_NAME", "Anything else transportation", sqlDb, sqlConnection); InitTable_ID_String("fd_org_type", "ORG_TYPE_ID", "STRID_ORG_TYPE_NAME", "Dealer", sqlDb, sqlConnection); InitTable_ID_String("fd_org_type", "ORG_TYPE_ID", "STRID_ORG_TYPE_NAME", "Subdealer", sqlDb, sqlConnection); InitTable_ID_String("fd_org_type", "ORG_TYPE_ID", "STRID_ORG_TYPE_NAME", "Predealer", sqlDb, sqlConnection); //FD_ORG OrganizationTable orgTable = new OrganizationTable(connectionString, CurrentLanguage, sqlDb); orgTable.AddNewOrganization("Init Organization", 1, 1, 1, 6); //fd_param sql = "INSERT INTO fd_param " + "(PARAM_ID, PARENT_PARAM_ID, PARAM_NAME, PARAM_SIZE)" + "VALUES (@PARAM_ID, @PARENT_PARAM_ID, @PARAM_NAME, @PARAM_SIZE)"; cmd = new MySqlCommand(sql, sqlConnection); cmd.Parameters.AddWithValue("@PARAM_ID", 0); cmd.Parameters.AddWithValue("@PARENT_PARAM_ID", 0); cmd.Parameters.AddWithValue("@PARAM_NAME", "Parent_param"); cmd.Parameters.AddWithValue("@PARAM_SIZE", 0); cmd.ExecuteNonQuery(); //fd_user_info_set and fd_user_info sqlDb.AddUserInfoName("Surname", "STRING_RU"); sqlDb.AddUserInfoName("Name", "STRING_RU"); sqlDb.AddUserInfoName("Patronimic", "STRING_RU"); sqlDb.AddUserInfoName("Drivers certificate", "STRING_RU"); sqlDb.AddUserInfoName("Card number", "STRING_RU"); sqlDb.AddUserInfoName("Phone number", "STRING_RU"); sqlDb.AddUserInfoName("Birthday", "STRING_RU"); //fd_user_rights InitTable_ID_String("fd_user_rights", "USER_RIGHTS_ID", "STRID_USER_RIGHTS_NAME", "Administrator", sqlDb, sqlConnection); InitTable_ID_String("fd_user_rights", "USER_RIGHTS_ID", "STRID_USER_RIGHTS_NAME", "SuperAdministrator", sqlDb, sqlConnection); //fd_user_role InitTable_ID_String("fd_user_role", "USER_ROLE_ID", "STRID_USER_ROLE_NAME", "Administrator", sqlDb, sqlConnection); InitTable_ID_String("fd_user_role", "USER_ROLE_ID", "STRID_USER_ROLE_NAME", "SuperAdministrator", sqlDb, sqlConnection); //fd_user_type InitTable_ID_String("fd_user_type", "USER_TYPE_ID", "STRID_USER_TYPE_NAME", "Driver", sqlDb, sqlConnection); InitTable_ID_String("fd_user_type", "USER_TYPE_ID", "STRID_USER_TYPE_NAME", "Manager", sqlDb, sqlConnection); InitTable_ID_String("fd_user_type", "USER_TYPE_ID", "STRID_USER_TYPE_NAME", "Administrator", sqlDb, sqlConnection); InitTable_ID_String("fd_user_type", "USER_TYPE_ID", "STRID_USER_TYPE_NAME", "DealerUser", sqlDb, sqlConnection); //fd_user UsersTables usersTable = new UsersTables(connectionString, "STRING_RU", sqlDb); usersTable.OpenConnection(); usersTable.OpenTransaction(); UserFromTable userFromTable = new UserFromTable("admin", "123", "3", "1", DateTime.Now, "org"); usersTable.AddNewUser(userFromTable, 3, 1, 1, 0); userFromTable = new UserFromTable("admin2", "123", "3", "1", DateTime.Now, "org"); usersTable.AddNewUser(userFromTable, 3, 2, 1, 0); usersTable.CommitTransaction(); usersTable.CloseConnection(); //fd_measure int kgId = sqlDb.AddNewMeasure("Kg", "Kilograms"); int kmId = sqlDb.AddNewMeasure("Km", "Kilometers"); int m3Id = sqlDb.AddNewMeasure("M3", "Cubic metres"); int dateId = sqlDb.AddNewMeasure("Date", "DateTime"); int RPMId = sqlDb.AddNewMeasure("Rpm", "Revolutions per minute"); int KmphId = sqlDb.AddNewMeasure("Km/h", "Kilometers per hour"); int PercentsId = sqlDb.AddNewMeasure("%", "Percents"); int FConsumption = sqlDb.AddNewMeasure("L/h", "Liters per hour"); //fd_key sqlDb.AddNewCriteria(kgId, "Commentary to a vehicle", "Строка для Комментария к ТС", 0, 0); sqlDb.AddNewCriteria(kgId, "Load-carrying capacity", "Грузоподьемность", 5000, 25000); sqlDb.AddNewCriteria(m3Id, "Fuel tank 1", "Коментарий к Топливному баку 1", 1, 250); sqlDb.AddNewCriteria(m3Id, "Fuel tank 2", "Коментарий к Топливному баку 1", 1, 250); sqlDb.AddNewCriteria(dateId, "MRO 1", "Дата ТО 1", 1, 1); sqlDb.AddNewCriteria(dateId, "MRO 2", "Дата ТО 2", 1, 1); sqlDb.AddNewCriteria(RPMId, "Nominal turns", "критерий для номинальных оборотов", 1, 1); sqlDb.AddNewCriteria(KmphId, "Maximum speed", "критерий для максимальной скорости", 1, 1); sqlDb.AddNewCriteria(KmphId, "Manoeuvring", "критерий для маневрирования", 1, 1); sqlDb.AddNewCriteria(PercentsId, "City", "критерий для города", 1, 1); sqlDb.AddNewCriteria(PercentsId, "Highway", " критерий для магистрали", 1, 1); sqlDb.AddNewCriteria(FConsumption, "Nominal fuel consumption", "критерий для номинального расхода топлива", 1, 1); sqlDb.AddNewCriteria(RPMId, "Cold start", "критерий для холодного старта", 1, 1); sqlDb.AddNewCriteria(RPMId, "Hot stop", "критерий для горячего стопа", 1, 1); //fd_fuel_type stringId = sqlDb.AddOrGetString("Unknown fuel type", SQLDB.userString); sql = "INSERT INTO fd_fuel_type " + "(FUEL_TYPE_ID, STRID_FUEL_TYPE_NAME)" + "VALUES (@FUEL_TYPE_ID, @STRID_FUEL_TYPE_NAME)"; cmd = new MySqlCommand(sql, sqlConnection); cmd.Parameters.AddWithValue("@FUEL_TYPE_ID", 0); cmd.Parameters.AddWithValue("@STRID_FUEL_TYPE_NAME", stringId); cmd.ExecuteNonQuery(); stringId = sqlDb.AddOrGetString("Undefined", SQLDB.userString); sql = "INSERT INTO fd_vehicle_type " + "(VEHICLE_TYPE_ID, STRID_VEHICLE_TYPE_NAME, FUEL_TYPE_ID)" + "VALUES (@VEHICLE_TYPE_ID, @STRID_VEHICLE_TYPE_NAME, @FUEL_TYPE_ID)"; cmd = new MySqlCommand(sql, sqlConnection); cmd.Parameters.AddWithValue("@VEHICLE_TYPE_ID", 0); cmd.Parameters.AddWithValue("@STRID_VEHICLE_TYPE_NAME", stringId); cmd.Parameters.AddWithValue("@FUEL_TYPE_ID", 0); cmd.ExecuteNonQuery(); int fuelTypeID = sqlDb.AddNewFuelType("FuelType 1"); sqlDb.AddNewVehicleType("Veh type 1", fuelTypeID); //HISTORY /* HistoryTable history = new HistoryTable(connectionString, CurrentLanguage); history.AddOrGetAction("Изменение учетных данных");*/ // sqlConnection.Close(); sqlDb.CloseConnection(); }
/// <summary> /// Добавляет Новую таблицу, или возвращает ID существующей таблицы /// </summary> /// <param name="tableName">Имя таблицы</param> /// <param name="tableKeyFieldName">Имя primary key в таблице</param> /// <param name="SQLForAdding">sql подключение с открытым подключением</param> /// <returns>ID таблицы</returns> public int GetOrAddTable(string tableName, string tableKeyFieldName, SQLDB SQLForAdding) { int tableId = Get_TableId(tableName,SQLForAdding); if (tableId <= 0) tableId = SQLForAdding.AddTable(tableName, tableKeyFieldName, "Автоматически созданная запись для таблицы " + tableName, CurrentLanguage); return tableId; }
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); } }
/// <summary> /// Инициализировать базу данных /// </summary> /// <param name="password">пароль - ввести qqq</param> public void InitDataBase(string password) { if (password == "qqq") { DBI sqlDB = new SQLDB(connectionString); try { sqlDB.OpenConnection(); sqlDB.OpenTransaction(); sqlDB.DataBaseInit(); sqlDB.CommitConnection(); } catch (Exception ex) { sqlDB.RollbackConnection(); Console.WriteLine(ex.Message); } finally { sqlDB.CloseConnection(); } } }
public UsersTables(string connectionsStringTMP, string Current_Language, SQLDB sql) { connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; //sqlDb = new SQLDB(connectionString); sqlDb = sql; DriverUserTypeId = 1; ManagerUserTypeId = 2; AdministratorUserTypeId = 3; DealerUserTypeId = 4; }
public string GetDataState() { SQLDB sqlDB = new SQLDB(connectionString); int blockStateId;//в таблице fn_data_block int STRIddataBlockState;//в таблице fd_data_block_state string blockStateMessage; sqlDB.OpenConnection(); blockStateId = sqlDB.GetDataBlockState(DATA_BLOCK_ID); STRIddataBlockState = sqlDB.GetSTRIdDataBlockStateName(blockStateId); blockStateMessage = sqlDB.GetString(STRIddataBlockState, CurrentLanguage); sqlDB.CloseConnection(); return blockStateMessage; }
/// <summary> /// Конструктор(рекомендовано пользоваться этим) /// </summary> /// <param name="connectionStringTMP">Строка подключения</param> /// <param name="Current_Language">Язык</param> public DataBlock(string connectionStringTMP, string Current_Language) { //тестовое подключение sqlDb = new SQLDB(connectionStringTMP); /////// connectionString = connectionStringTMP; DATA_BLOCK_ID = -1; DATA_BLOCK_ID_PREVIOUS = -1; CurrentLanguage = Current_Language; vehicleUnitInfo = new VehicleUnitInfo(connectionString, Current_Language, sqlDb); cardUnitInfo = new CardUnitInfo(connectionString, Current_Language, sqlDb); plfUnitInfo = new PLFUnitInfo(connectionString, Current_Language, sqlDb); cardsTable = new CardsTable(connectionString, Current_Language, sqlDb); organizationTable = new OrganizationTable(connectionString, Current_Language, sqlDb); usersTable = new UsersTables(connectionString, CurrentLanguage, sqlDb); stringTable = new StringTable(connectionString, CurrentLanguage); vehiclesTables = new VehiclesTable(connectionString, CurrentLanguage, sqlDb); criteriaTable = new CriteriaTable(connectionString, CurrentLanguage, sqlDb); deviceTable = new DeviceTable(connectionString, CurrentLanguage, sqlDb); //historyTable = new HistoryTable(connectionString, CurrentLanguage, sqlDb); reportsTable = new ReportsTable(connectionString, CurrentLanguage, sqlDb); invoiceTable = new InvoiceTable(connectionString, CurrentLanguage, sqlDb); emailScheduleTable = new EmailScheduleTable(connectionString, CurrentLanguage, sqlDb); remindTable = new RemindTable(connectionString, CurrentLanguage, sqlDb); bannersTable = new BannersTable(connectionString, CurrentLanguage, sqlDb); currentCardType = -1; organizationID = 0; }
/// <summary> /// Установить дату окончания разбора файла /// </summary> /// <param name="sqlDb">обьект подключения</param> private void SetParseEDate(SQLDB sqlDb) { DateTime dt = sqlDb.SetCurrentTime("fn_data_block", "DATA_BLOCK_ID", DATA_BLOCK_ID, "PARSE_EDATE"); Console.WriteLine("Parse End Time " + dt.ToString("dd-MM-yyyy HH:mm:ss")); }
public int DeleteDataBlockAndRecords() { SQLDB sqlDB = new SQLDB(connectionString); int deletedCount = 3; try { sqlDB.OpenConnection(); sqlDB.OpenTransaction(); // deletedCount = dataRecord.DeleteAllData(sqlDB); sqlDB.DeleteAllDataRecordsFast(DATA_BLOCK_ID); sqlDB.DeleteDataBlock(DATA_BLOCK_ID); sqlDB.CommitConnection(); sqlDB.CloseConnection(); } catch (Exception ex) { sqlDB.RollbackConnection(); sqlDB.CloseConnection(); throw ex; } return deletedCount + 1; }
public int DeleteDataRecords() { SQLDB sqlDB = new SQLDB(connectionString); int deletedCount; sqlDB.OpenConnection(); sqlDB.OpenTransaction(); deletedCount = dataRecord.DeleteAllData(sqlDB); sqlDB.SetDataBlockState(DATA_BLOCK_ID, 3); sqlDB.CommitConnection(); sqlDB.CloseConnection(); return deletedCount; }
/// <summary> /// Конструктор /// </summary> /// <param name="connectionsStringTMP">Строка подключения к базе данных(не обязательна, так как передается подключение</param> /// <param name="Current_Language">Текущий язык</param> /// <param name="sql">Обьект подключения к базе данных</param> public BannersTable(string connectionsStringTMP, string Current_Language, SQLDB sql) { sqlDb = sql; connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; }
public List<int> GetAllDataBlockId_byCardType(int cardType) { List<int> gettedIds = new List<int>(); SQLDB sqlDB = new SQLDB(connectionString); int UserId = 0; sqlDB.OpenConnection(); gettedIds = sqlDB.GetAllDataBlocksId_byCardType(UserId, cardType); sqlDB.CloseConnection(); return gettedIds; }
private string CurrentLanguage; //STRING_RU,STRING_RUG etc. #endregion Fields #region Constructors /// <summary> /// Конструктор /// </summary> /// <param name="connectionsStringTMP">Строка подключения</param> /// <param name="Current_Language">Текущий язык</param> /// <param name="sqlTemp">Обьект подключения к базе данных</param> public CardUnitInfo(string connectionsStringTMP, string Current_Language, SQLDB sqlTemp) { connectionString = connectionsStringTMP; CurrentLanguage = Current_Language; sqlDB = sqlTemp; }
public List<string> GetAllDriverNames(int UserId) { List<int> gettedIds = new List<int>(); List<string> gettedNames = new List<string>(); SQLDB sqlDB = new SQLDB(connectionString); SQLDB_Records sqlDB_Records = new SQLDB_Records(connectionString); sqlDB.OpenConnection(); gettedIds = sqlDB.GetAllDataBlocksId_byCardType(UserId, 0); sqlDB.CloseConnection(); gettedNames = sqlDB_Records.Get_DriverNames_ByDataBlockIdList(gettedIds); return gettedNames; }