public bool RestoreBDByTime(DateTime dateTimeRestore) { QueryStrings.CurrentPathDevice = ExecuteQuery <String> .Execute(ConnectionInfo, QueryStrings.GetDevicePath, (sqlDataReader) => { return(SqlSupport.Read <String>(sqlDataReader, "physical_name")); }).FirstOrDefault(); QueryStrings.ThirdRestoreDBByTime = dateTimeRestore.ToString("yyyy-MM-dd HH:mm:ss"); try { ExecuteQuery <int> .ExecuteNonQuery(ConnectionInfo, QueryStrings.FirstRestoreDbByTime); ExecuteQuery <int> .Execute(ConnectionInfo, QueryStrings.SecondRestoreDBByTime, null); ExecuteQuery <int> .ExecuteNonQuery(ConnectionInfo, QueryStrings.ThirdRestoreDBByTime); ExecuteQuery <int> .ExecuteNonQuery(ConnectionInfo, QueryStrings.LastRestoreDBByTime); return(true); } catch (SqlException sqlEx) { return(false); } }
public bool CreateDevice() { String currentPath = this.GetType().Assembly.Location; String folderPath = currentPath.Substring(0, currentPath.LastIndexOf("\\")); DirectoryInfo directoryInfo = null; if (!Directory.Exists($"{folderPath}\\BackupFiles\\{CurrentDataBase.Name}")) { directoryInfo = Directory.CreateDirectory($"{folderPath}\\BackupFiles\\{CurrentDataBase.Name}"); } if (directoryInfo == null) { QueryStrings.CurrentPathDevice = $"{folderPath}\\BackupFiles\\{CurrentDataBase.Name}\\{CurrentDataBase.Name}.bak"; } else { QueryStrings.CurrentPathDevice = $"{directoryInfo.FullName}\\{CurrentDataBase.Name}.bak"; } IEnumerable <Boolean> result = ExecuteQuery <Boolean> .Execute(ConnectionInfo, QueryStrings.CreateDevice, (sqlDataReader) => { return(SqlSupport.Read <Boolean>(sqlDataReader, "")); }); this.CurrentDataBase = _currentDB; return(result.FirstOrDefault()); }
public PageAttendance() { InitializeComponent(); var ListSV = new ObservableCollection <AttendanceStudents>(SqlSupport.GetAllStudentsByIdClass("420300224601")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var tables = SqlSupport.GetTables(); ddlTables.Bind(tables.FindAll(t => t.Columns != null && t.Columns.Any() && t.Columns.Count < 7), "FullTableName", "Name"); } }
private string GetCurrentDeviceOfDB() { IEnumerable <String> devicesname = ExecuteQuery <String> .Execute(ConnectionInfo, QueryStrings.GetAllDeviceNameByDBName , (sqlDataReader) => { return(SqlSupport.Read <String>(sqlDataReader, "logical_device_name")); }); return(devicesname.FirstOrDefault()); }
private bool CurrentDBHadDevice() { IEnumerable <String> devicesname = ExecuteQuery <String> .Execute(ConnectionInfo, QueryStrings.GetAllDeviceName , (sqlDataReader) => { return(SqlSupport.Read <String>(sqlDataReader, "name")); }); return(devicesname.Where(x => x.Contains(CurrentDataBase.Name)).Count() > 0); }
protected void btnAddNew_Click(object sender, EventArgs e) { if (ddlTables.SelectedIndex <= 0) { return; } var columns = SqlSupport.GetTablesColumns(ddlTables.SelectedValue); gvColumns.Bind(columns); }
public IEnumerable <ProductModel> GetAllProductModels() { return(GetAll().Select( c => new ProductModel() { Name = c.Name, ProductID = c.ProductID, Picture = c.Picture.LoadImage(), PriceOnOrder = c.UnitOnOrder, UnitPrice = c.UnitPrice, Quantity = SqlSupport.GetQuantityByProductId(c.ProductID) })); }
private IEnumerable <PositionBackupInfo> GetAllPositionBackupVersions() { return(ExecuteQuery <PositionBackupInfo> .Execute(ConnectionInfo, QueryStrings.GetAllPositionOfBackupVersions, (sqlDataReader) => { return new PositionBackupInfo() { Position = SqlSupport.Read <Int32>(sqlDataReader, "position"), Description = SqlSupport.Read <String>(sqlDataReader, "description"), BackupDateTime = SqlSupport.Read <DateTime>(sqlDataReader, "backup_start_date"), UserBackup = SqlSupport.Read <String>(sqlDataReader, "user_name"), }; } )); }
public IEnumerable <ProductModel> GetProductModelsFilter(Func <Product, bool> predicate) { var ds = GetFilter(predicate); return(ds.Select( c => new ProductModel() { Name = c.Name, ProductID = c.ProductID, Picture = c.Picture.LoadImage(), PriceOnOrder = c.UnitOnOrder, UnitPrice = c.UnitPrice, Quantity = SqlSupport.GetQuantityByProductId(c.ProductID) })); }
public async Task <IEnumerable <ProductModel> > GetAllProductModelsAsync() { var ds = await GetAllAsync(); return(ds.Select( c => new ProductModel() { Name = c.Name, ProductID = c.ProductID, Picture = c.Picture.LoadImage(), PriceOnOrder = c.UnitOnOrder, UnitPrice = c.UnitPrice, Quantity = SqlSupport.GetQuantityByProductId(c.ProductID) })); }
public bool ValidateRestoreDBByTime() { try { int result = ExecuteQuery <int> .Execute(ConnectionInfo, QueryStrings.ValidateRestoreDBByTime, (sqlDataReader) => { return(SqlSupport.Read <Int32>(sqlDataReader, "result")); }).FirstOrDefault <int>(); if (result == 0) { return(false); } return(true); } catch (SqlException sqlEx) { return(false); } }
public BK(ConnectionInfo connectionInfo, ListDatabaseBaseChanged changed, CurrentDatabaseChanged currentChanged) { ConnectionInfo = connectionInfo; this.OnListDatabaseBaseChanged = changed; this.OnCurrentDatabaseChanged = currentChanged; DatabaseBases = ExecuteQuery <DatabaseBase> .Execute(connectionInfo, QueryStrings.GetAllDatabaseName, (sqlDataReader) => { return(new DatabaseBase() { ID = SqlSupport.Read <Int32>(sqlDataReader, "database_id"), Name = SqlSupport.Read <String>(sqlDataReader, "name"), }); }).ToList <DatabaseBase>(); if (DatabaseBases.Count != 0) { CurrentDataBase = DatabaseBases[0]; } }
protected void ddlTables_SelectedIndexChanged(object sender, EventArgs e) { if (ddlTables.SelectedIndex <= 0) { return; } var columns = SqlSupport.GetTablesColumns(ddlTables.SelectedValue).FindAll( c => c.DbFieldType != DbFieldType.Binary && c.DbFieldType != DbFieldType.VarBinary && c.DbFieldType != DbFieldType.Image); gvColumns.Bind(columns); ViewState["_columns"] = columns; var queryBuilder = string.Format("SELECT * FROM {0}", ddlTables.SelectedItem.Text); using (var data = new RecordSet(queryBuilder, QueryType.TransectSQL, null)) { Session["_tabledata"] = data; gvData.Bind(data); } }