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(); }
public void EditUserType(int curUserId, int type) { sqlDb.EditUserType(curUserId, type); if (curUserId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fd_user", "USER_ID", curUserId, curUserId, log.driversRegDataChanged, "Code: " + curUserId.ToString(), sqlDb); } }
public void EditVehicle(int VehicleId, string GosNomer, string Marka, string VIN, int vehicleTypeId, int deviceId, DateTime BLOCKED, int priority, int userId) { sqlDB.EditVehicle(VehicleId, GosNomer, Marka, VIN, vehicleTypeId, deviceId, BLOCKED, priority, CurrentLanguage); if (userId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDB); log.AddHistoryRecord("fn_vehicle", "vehicle_id", VehicleId, userId, log.vehiclesRegDataChanged, " Vehicle number: " + GosNomer + ", VIN: " + VIN + ", code: " + VehicleId, sqlDB); } }
protected void ApplyLogFilterButton_Click(object sender, EventArgs e) { string currentLanguage = ConfigurationManager.AppSettings["language"]; string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"]; DataBlock dataBlock = new DataBlock(connectionString, currentLanguage); HistoryTable historyTable = new HistoryTable(connectionString, currentLanguage, dataBlock.sqlDb); try { int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]); List<int> usersIds = new List<int>(); List<UserFromTable> userFromTableList = new List<UserFromTable>(); DateTime from; DateTime to; if (DateTime.TryParse(LogFilterTable_StartDateTextBox.Text, out from)) { if (LogFilterTable_StartTimeTextBox.Text != "") from = from.Add(TimeSpan.Parse(LogFilterTable_StartTimeTextBox.Text)); } else from = new DateTime(); if (DateTime.TryParse(LogFilterTable_EndDateTextBox.Text, out to)) { if (LogFilterTable_EndTimeTextBox.Text != "") to = to.Add(TimeSpan.Parse(LogFilterTable_EndTimeTextBox.Text)); else { to = to.AddHours(23); to = to.AddMinutes(59); } } else to = DateTime.Now; int actionId = Convert.ToInt32(LogFilterTable_EventDropDown.SelectedValue); string searchString = LogFilterTable_NoteTextTextBox.Text.Trim(); dataBlock.OpenConnection();//выборка по типам пользователей usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.DriverUserTypeId)); usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.AdministratorUserTypeId)); usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.ManagerUserTypeId)); DataTable data = historyTable.GetAllHistorysForUsers(usersIds, from, to, actionId, searchString); LogDataGrid.DataSource = data; LogDataGrid.DataBind(); dataBlock.CloseConnection(); } catch (Exception ex) { } finally { dataBlock.CloseConnection(); } }
public void AddOrSetReportUserOrg_ActivateReportForORG(int reportsUserId, int orgId, int curUserId) { sqlDBR.AddOrSetReportUserOrg_SETDATE(reportsUserId, orgId, true); if (curUserId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDBR); string reportName = GetReportName(reportsUserId); log.AddHistoryRecord("fn_report_user_org", "REPORT_USER_ID", reportsUserId, curUserId, log.setReportUserOrg, @"Report """ + reportName + @""" is active now", sqlDBR); } }
/// <summary> /// Создать новую карту /// </summary> /// <param name="cardHolderName">Имя владельца карты</param> /// <param name="cardNumber">Номер карты</param> /// <param name="cardTypeId">Тип карты</param> /// <param name="orgId">Идентификатор организации</param> /// <param name="CardNote">Комментарий к карту</param> /// <param name="curUserId">Текущий пользователь, создающий карты(для лога)</param> /// <returns>Id новой карты</returns> public int CreateNewCard(string cardHolderName, string cardNumber, int cardTypeId, int orgId, int userId, string CardNote, int curUserId, int groupID) { Exception userNameAllreadyExists = new Exception("Пользователь с таким именем уже существует!"); int returnValue = -1; string Login = ""; //SQLDB sqlDB = new SQLDB(connectionString); //sqlDB.OpenConnection(); if (cardTypeId == driversCardTypeId) { /*UsersTables userTables = new UsersTables(connectionString, CurrentLanguage, sqlDb); * int userId = sqlDb.GetUserId_byUserName(cardHolderName); * if (userId > 0) * throw userNameAllreadyExists; * if(cardHolderName.Length>10) * Login = cardHolderName.Substring(0, 10); * else * Login = cardHolderName; * userId = sqlDb.AddNewUser(Login, cardNumber, userTables.DriverUserTypeId, 1, orgId, cardHolderName, cardNumber); * //userTables.OpenConnection(); * userTables.AddUserInfoValue(userId, DataBaseReference.UserInfo_Name, cardHolderName); * userTables.AddUserInfoValue(userId, DataBaseReference.UserInfo_RegDate, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());*/ //userTables.CloseConnection(); returnValue = sqlDb.CreateNewCard(cardHolderName, cardNumber, cardTypeId, orgId, CardNote, userId, groupID); if (curUserId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fn_card", "card_id", returnValue, curUserId, log.newDriverRegistered, "Drivers name: " + cardHolderName + ", code: " + returnValue, sqlDb); } } else { returnValue = sqlDb.CreateNewCard(cardHolderName, cardNumber, cardTypeId, orgId, CardNote, groupID); if (curUserId > 0 && cardTypeId == vehicleCardTypeId) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fn_card", "card_id", returnValue, curUserId, log.newVehicleRegistered, "Vehicles number: " + cardHolderName + ", code: " + returnValue, sqlDb); } } //sqlDB.CloseConnection(); return(returnValue); }
public void AddOrSetReportUserRoles_SETDATE(int reportsUserId, int orgId, int userRoleId, bool IsActive, int curUserId) { sqlDBR.AddOrSetReportUserRoles_SETDATE(reportsUserId, orgId, userRoleId, IsActive); if (curUserId > 0) //Пока убрал, потому что слишком много обновлений за одну секунду( { string isItActive = "active"; if (!IsActive) { isItActive = "not active"; } HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDBR); string reportName = GetReportName(reportsUserId); //userrolename UsersTables usrt = new UsersTables(connectionString, CurrentLanguage, sqlDBR); string userRoleName = usrt.GetUserRoleName(userRoleId); HistoryWriter.Instance.AddHistoryRecord("fn_report_user_roles", "REPORT_USER_ID", reportsUserId, curUserId, log.setReportUserRoles, @"Report """ + reportName + @"""" + " for user role " + userRoleName + " is " + isItActive + " now", sqlDBR); } }
public void EditUser(string oldPass, string oldName, UserFromTable newUser, int userTypeId, int userRoleId, int orgId, int curUserId) { Exception userNameAllreadyExists = new Exception("Пользователь с таким именем уже существует!"); int userNewId = sqlDb.GetUserId_byUserName(newUser.name); int userOldId = sqlDb.GetUserId_byUserName(oldName); if (userNewId > 0) { if (userOldId != userNewId) { throw userNameAllreadyExists; } } int userId = sqlDb.AddNewUser(newUser.name, newUser.pass, userTypeId, userRoleId, orgId, oldName, oldPass); if (curUserId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fd_user", "USER_ID", userId, curUserId, log.driversRegDataChanged, "Code: " + userId.ToString(), sqlDb); } }
public int AddNewUser(UserFromTable newUser, int userTypeId, int userRoleId, int orgId, int curUserId) { Exception userNameAllreadyExists = new Exception("Пользователь с таким именем уже существует!"); int returnUserId = -1; int userId = sqlDb.GetUserId_byUserName(newUser.name); if (userId > 0) { throw userNameAllreadyExists; } returnUserId = sqlDb.AddNewUser(newUser.name, newUser.pass, userTypeId, userRoleId, orgId, newUser.name, newUser.pass); AddUserInfoValue(returnUserId, DataBaseReference.UserInfo_RegDate, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); AddUserInfoValue(returnUserId, DataBaseReference.UserInfo_EndOfRegistrationDate, DateTime.Now.AddMonths(6).ToShortDateString()); if (curUserId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fd_user", "USER_ID", returnUserId, curUserId, log.newUserRegistered, "Login: "******", code: " + returnUserId, sqlDb); } return(returnUserId); }
/// <summary> /// Парсить блок данных /// </summary> /// <param name="generateXML">генерировать ли XML файл</param> /// <param name="output">путь, куда XML сохранять</param> /// <param name="userId">ID пользователя, от имени которого вызывается этот метод</param> /// <returns>разобранный обьект</returns> public object ParseRecords(bool generateXML, string output, int userId) { Exception noOrg = new Exception("No organization entered"); Exception CardVehicleError = new Exception("Ошибка в базе данных. Нет связи Карта - ТС!"); if (organizationID == 0) throw noOrg; if (DATA_BLOCK_ID == -1) throw (new Exception("Can't find this Data Block")); else { //SQLDB sqlDB = new SQLDB(connectionString); SQLDB_Records sqlDB_rec = new SQLDB_Records(connectionString, sqlDb.GETMYSQLCONNECTION()); ReflectObjectToTableClass reflectedItemsList; Type type = null; object myParseObject = new object(); PARSER.DDDParser dddParser = new DDDParser(); string fileName = ""; try { fileName = sqlDB_rec.Get_ParamValue(DATA_BLOCK_ID, "DataBlock_FileName"); byte[] blockDataBlob = sqlDb.GetDataBlock(DATA_BLOCK_ID); blockDataBlob = UnZipBytes(blockDataBlob);//АнЗипим файл! dddParser.ParseFile(blockDataBlob, fileName); int cardType = dddParser.GetCardType(); currentCardType = cardType; //test //OpenConnection(); //OpenTransaction(); // if (cardType == 0)// 0 - card(driver) { int cardId; if (dddParser.cardUnitClass.ef_identification.driverCardHolderIdentification != null) { string drName = dddParser.cardUnitClass.ef_identification.driverCardHolderIdentification.cardHolderName.ToString(); string drNumber = dddParser.cardUnitClass.ef_identification.cardIdentification.cardNumber.ToString(); //sqlDB.OpenConnection(); cardId = cardsTable.GetCardId(drName, drNumber, cardsTable.driversCardTypeId); if (cardId <= 0) { int grId = cardsTable.GetAllGroupIds(organizationID, 0)[0]; UserFromTable userData = new UserFromTable(); userData.name = ""; userData.pass = ""; int newUserId = usersTable.AddNewUser(userData, usersTable.DriverUserTypeId, 1, organizationID, userId); string[] arr=drName.Split(' '); usersTable.AddUserInfoValue(newUserId, DataBaseReference.UserInfo_Name, arr[0]); usersTable.AddUserInfoValue(newUserId, DataBaseReference.UserInfo_Surname, arr[1]); cardId = cardsTable.CreateNewCard(drName, drNumber, cardsTable.driversCardTypeId, organizationID, newUserId, "Init DataBlockId = " + DATA_BLOCK_ID, userId, grId); } sqlDb.SetDataBlock_CardId(DATA_BLOCK_ID, cardId); //sqlDB.CloseConnection(); } else { //sqlDB.OpenConnection(); sqlDb.SetDataBlockState(DATA_BLOCK_ID, 4); //sqlDB.CloseConnection(); throw new Exception("Поддерживаются только водительские карты и информация с бортового устройства."); } type = dddParser.cardUnitClass.GetType(); myParseObject = dddParser.cardUnitClass; } else if (cardType == 1)//vehicle { ///////////////////////// int vehicleId; if (dddParser.vehicleUnitClass.vehicleOverview.vehicleRegistrationIdentification != null) { int cardId; string vehRegNumber = dddParser.vehicleUnitClass.vehicleOverview.vehicleRegistrationIdentification.vehicleRegistrationNumber.ToString(); string vin = dddParser.vehicleUnitClass.vehicleOverview.vehicleIdentificationNumber.ToString(); cardId = cardsTable.GetCardId(vehRegNumber, vin, cardsTable.vehicleCardTypeId); vehicleId = vehiclesTables.GetVehicleId_byVinRegNumbers(vin, vehRegNumber); if ((vehicleId <= 0 && cardId > 0) || (vehicleId > 0 && cardId <= 0)) throw CardVehicleError; if (cardId <= 0) { string marka = ""; DateTime BLOCKED = dddParser.vehicleUnitClass.vehicleOverview.vuDownloadablePeriod.maxDownloadableTime.getTimeRealDate(); int grId = cardsTable.GetAllGroupIds(organizationID,0)[0]; cardId = cardsTable.CreateNewCard(vehRegNumber, vin, cardsTable.vehicleCardTypeId, organizationID, userId, "Init DataBlockId = " + DATA_BLOCK_ID, userId, grId); //vehiclesTables.OpenConnection(); vehicleId = vehiclesTables.AddNewVehicle(vehRegNumber, marka, vin, 0, 1, cardId, BLOCKED, 1); //vehiclesTables.CloseConnection(); // SetAllVehiclesIDS(vehicleId); } sqlDb.SetDataBlock_CardId(DATA_BLOCK_ID, cardId); } ///////////////////////// type = dddParser.vehicleUnitClass.GetType(); myParseObject = dddParser.vehicleUnitClass; } else if (cardType == 2)//plf { //////////////////////устанавливаем PLF карту нужного водителя. Незнаю почему именно здесь, но так получилось. int plfDriversCardType = sqlDB_rec.Get_DataBlockCardType(DATA_BLOCK_ID); sqlDb.SetDataBlock_CardId(DATA_BLOCK_ID, plfDriversCardType); // sqlDB.OpenConnection(); int cardTypeParamId = sqlDb.AddParam("cardType", 0, 255); //sqlDB.OpenConnection(); sqlDb.DeleteDataRecord(DATA_BLOCK_ID, cardTypeParamId); // sqlDB.CloseConnection(); ////////////////////// type = dddParser.plfUnitClass.GetType(); myParseObject = dddParser.plfUnitClass; } else if (cardType == -1) throw new Exception("Информация непригодна для разбора(не опознан тип карты"); //sqlDB.OpenConnection(); SetParseBDate(sqlDb); //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));//не удалять } } foreach (ReflectObjectToTableClass recordList in allRecordsToAdd) { dataRecord.AddDataArray(recordList.reflectedItemsList); } //sqlDB.OpenConnection(); SetParseEDate(sqlDb); sqlDb.SetDataBlockState(DATA_BLOCK_ID, 2); int dataBlockParseRecords = sqlDb.SetDataBlockParseRecords(DATA_BLOCK_ID); Console.WriteLine("\n\r" + dataBlockParseRecords.ToString() + " records added"); //XML GENERATING if (generateXML) dddParser.GenerateXmlFile(output); // //Добавляем лог для каждого типа блока данных свой. string logNote; HistoryTable historyTable = new HistoryTable(connectionString, CurrentLanguage, sqlDb); if (currentCardType == 0)//driver { string drName = dddParser.cardUnitClass.ef_identification.driverCardHolderIdentification.cardHolderName.ToString(); string drNumber = dddParser.cardUnitClass.ef_identification.cardIdentification.cardNumber.ToString(); logNote = "Driver: " + drName + "(" + drNumber + ")" + ", records number: " + dataBlockParseRecords.ToString(); historyTable.AddHistoryRecord("fn_data_block", "DATA_BLOCK_ID", DATA_BLOCK_ID, userId, historyTable.DDDDriversDataBlockLoaded, logNote, sqlDb); } if (currentCardType == 1)//vehicle { string logVehRegNumber = dddParser.vehicleUnitClass.vehicleOverview.vehicleRegistrationIdentification.vehicleRegistrationNumber.ToString(); string logVin = dddParser.vehicleUnitClass.vehicleOverview.vehicleIdentificationNumber.ToString(); logNote = "Vehicle: " + logVehRegNumber + "(" + logVin + ")" + ", records number: " + dataBlockParseRecords.ToString(); historyTable.AddHistoryRecord("fn_data_block", "DATA_BLOCK_ID", DATA_BLOCK_ID, userId, historyTable.DDDVehiclesDataBlockLoaded, logNote, sqlDb); } if (currentCardType == 2)//plf { string vehPlfIdent = dddParser.plfUnitClass.VEHICLE; string plfDeviceId = dddParser.plfUnitClass.ID_DEVICE; string period = dddParser.plfUnitClass.START_PERIOD.GetSystemTime().ToShortDateString() + " - " + dddParser.plfUnitClass.END_PERIOD.GetSystemTime().ToShortDateString(); logNote = "PLF File: " + vehPlfIdent + "(" + plfDeviceId + ")" + ", period: " + period + ", records number: " + dataBlockParseRecords.ToString(); historyTable.AddHistoryRecord("fn_data_block", "DATA_BLOCK_ID", DATA_BLOCK_ID, userId, historyTable.PLFDataBlockLoaded, logNote, sqlDb); } // //sqlDb.CommitConnection(); //sqlDb.CloseConnection(); } catch (Exception ex) { //sqlDb.RollbackConnection(); //sqlDb.CloseConnection(); throw ex; } finally { } return myParseObject; } }
public void AddOrSetReportUserRoles_SETDATE(int reportsUserId, int orgId, int userRoleId, bool IsActive, int curUserId) { sqlDBR.AddOrSetReportUserRoles_SETDATE(reportsUserId, orgId, userRoleId, IsActive); if (curUserId > 0) //Пока убрал, потому что слишком много обновлений за одну секунду( { string isItActive = "active"; if (!IsActive) isItActive = "not active"; HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDBR); string reportName = GetReportName(reportsUserId); //userrolename UsersTables usrt = new UsersTables(connectionString, CurrentLanguage, sqlDBR); string userRoleName = usrt.GetUserRoleName(userRoleId); HistoryWriter.Instance.AddHistoryRecord("fn_report_user_roles", "REPORT_USER_ID", reportsUserId, curUserId, log.setReportUserRoles, @"Report """ + reportName + @"""" + " for user role " + userRoleName + " is " + isItActive + " now", sqlDBR); } }
public int AddNewUser(UserFromTable newUser, int userTypeId, int userRoleId, int orgId, int curUserId) { Exception userNameAllreadyExists = new Exception("Пользователь с таким именем уже существует!"); int returnUserId = -1; int userId = sqlDb.GetUserId_byUserName(newUser.name); if (userId > 0) throw userNameAllreadyExists; returnUserId = sqlDb.AddNewUser(newUser.name, newUser.pass, userTypeId, userRoleId, orgId, newUser.name, newUser.pass); AddUserInfoValue(returnUserId, DataBaseReference.UserInfo_RegDate, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); AddUserInfoValue(returnUserId, DataBaseReference.UserInfo_EndOfRegistrationDate, DateTime.Now.AddMonths(6).ToShortDateString()); if (curUserId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fd_user", "USER_ID", returnUserId, curUserId, log.newUserRegistered, "Login: "******", code: " + returnUserId, sqlDb); } return returnUserId; }
public void EditUser(string oldPass, string oldName, UserFromTable newUser, int userTypeId, int userRoleId, int orgId, int curUserId) { Exception userNameAllreadyExists = new Exception("Пользователь с таким именем уже существует!"); int userNewId = sqlDb.GetUserId_byUserName(newUser.name); int userOldId = sqlDb.GetUserId_byUserName(oldName); if (userNewId > 0) { if (userOldId != userNewId) throw userNameAllreadyExists; } int userId = sqlDb.AddNewUser(newUser.name, newUser.pass, userTypeId, userRoleId, orgId, oldName, oldPass); if (curUserId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fd_user", "USER_ID", userId, curUserId, log.driversRegDataChanged, "Code: " + userId.ToString(), sqlDb); } }
/// <summary> /// Создать новую карту /// </summary> /// <param name="cardHolderName">Имя владельца карты</param> /// <param name="cardNumber">Номер карты</param> /// <param name="cardTypeId">Тип карты</param> /// <param name="orgId">Идентификатор организации</param> /// <param name="CardNote">Комментарий к карту</param> /// <param name="curUserId">Текущий пользователь, создающий карты(для лога)</param> /// <returns>Id новой карты</returns> public int CreateNewCard(string cardHolderName, string cardNumber, int cardTypeId, int orgId, int userId, string CardNote, int curUserId, int groupID) { Exception userNameAllreadyExists = new Exception("Пользователь с таким именем уже существует!"); int returnValue = -1; string Login = ""; //SQLDB sqlDB = new SQLDB(connectionString); //sqlDB.OpenConnection(); if (cardTypeId == driversCardTypeId) { /*UsersTables userTables = new UsersTables(connectionString, CurrentLanguage, sqlDb); int userId = sqlDb.GetUserId_byUserName(cardHolderName); if (userId > 0) throw userNameAllreadyExists; if(cardHolderName.Length>10) Login = cardHolderName.Substring(0, 10); else Login = cardHolderName; userId = sqlDb.AddNewUser(Login, cardNumber, userTables.DriverUserTypeId, 1, orgId, cardHolderName, cardNumber); //userTables.OpenConnection(); userTables.AddUserInfoValue(userId, DataBaseReference.UserInfo_Name, cardHolderName); userTables.AddUserInfoValue(userId, DataBaseReference.UserInfo_RegDate, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());*/ //userTables.CloseConnection(); returnValue = sqlDb.CreateNewCard(cardHolderName, cardNumber, cardTypeId, orgId, CardNote, userId, groupID); if (curUserId > 0) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fn_card", "card_id", returnValue, curUserId, log.newDriverRegistered, "Drivers name: " + cardHolderName + ", code: " + returnValue, sqlDb); } } else { returnValue = sqlDb.CreateNewCard(cardHolderName, cardNumber, cardTypeId, orgId, CardNote, groupID); if (curUserId > 0 && cardTypeId == vehicleCardTypeId) { HistoryTable log = new HistoryTable(connectionString, CurrentLanguage, sqlDb); log.AddHistoryRecord("fn_card", "card_id", returnValue, curUserId, log.newVehicleRegistered, "Vehicles number: " + cardHolderName + ", code: " + returnValue, sqlDb); } } //sqlDB.CloseConnection(); return returnValue; }
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); } }