public FavouritesWindow(DBRepository repo, User user) { InitializeComponent(); _repo = repo; _user = user; ListBoxFavourites.ItemsSource = _repo.Context.Favourites.Where(f => f.User.Id == _user.Id).ToList(); }
public AdminUserPageViewModel() { DBRepository <User> dBUser = new DBRepository <User>(new BuildEntities()); foreach (var item in dBUser.GetAll().Where(s => s.Type != "Admin")) { Users.Add(item); } var windows = Application.Current.Windows; if (windows.Count > 1) { Window window = null; try { foreach (var item in windows) { if (item as Loading != null) { window = (item as Window); } } } catch { } window.Close(); } dBUser.Dispose(); }
/// <summary> /// 新增,返回的是主键 /// </summary> /// <param name="btn"></param> /// <returns></returns> public static string AddStudent(Students Stu, SYSAccount sys, SYSAccountRole sysR) { string ret; DBRepository db = new DBRepository(DBKeys.PRX); db.BeginTransaction();//事务开始 try { ret = db.Insert <Students>(Stu); //添加学生表 int max = db.Insert <SYSAccount>(sys); //添加用户表 sysR.AR_AccountId = max; //sysR.AR_AccountId = max.ContainsValue(0); db.Insert <SYSAccountRole>(sysR); //添加权限表 db.Commit(); //事务提交 db.Dispose(); //资源释放 } catch (Exception ex) { db.Rollback(); db.Dispose(); throw new Exception(ex.Message + "。" + ex.InnerException.Message); } return(ret); }
void btnGetAll_Click(object sender, EventArgs e) { DBRepository dbr = new DBRepository(); var result = dbr.GetAllRecords(); Toast.MakeText(this, result, ToastLength.Short).Show(); }
public override DataSet List(Filter f, out int RecordCount) { DataSet resultSet = new DataSet(); try { FiltroTicket filtro = (FiltroTicket)f; DBRepository repository = DBRepository.GetDbRepository(); List <IDbDataParameter> paramList = new List <IDbDataParameter>(); paramList.Add(repository.DbFactory.getDataParameter("P_ID", DbType.Int32, filtro.ID)); paramList.Add(repository.DbFactory.getDataParameter("P_IDOPERADOR", DbType.Int32, filtro.IDOperador)); paramList.Add(repository.DbFactory.getDataParameter("P_IDAFILIADO", DbType.Int32, filtro.IDAfiliado)); paramList.Add(repository.DbFactory.getDataParameter("P_CIUDAD_ORIGEN", DbType.Int32, filtro.IDCiudadOrigen)); paramList.Add(repository.DbFactory.getDataParameter("P_CIUDAD_DESTINO", DbType.Int32, filtro.IDCiudadDestino)); paramList.Add(repository.DbFactory.getDataParameter("P_IDPRESTADOR", DbType.Int32, filtro.IDPrestador)); paramList.Add(repository.DbFactory.getDataParameter("P_SEARCH", DbType.String, filtro.Search)); repository.ExecuteListProcedure(CONST_LIST_PROCEDURE_NAME, paramList, f, resultSet, out RecordCount); } catch (Exception ex) { throw ex; } return(resultSet); }
public int Create(System.Data.DataRow r, DBRepository repository) { int result = 0; try { Datasets.Observaciones.OBSERVACIONESRow dr = (Datasets.Observaciones.OBSERVACIONESRow)r; List <IDbDataParameter> Paramlist = new List <IDbDataParameter>(); Paramlist.Add(repository.DbFactory.getDataParameter("P_IDOPERADOR", DbType.Int32, dr.IDOPERADOR)); Paramlist.Add(repository.DbFactory.getDataParameter("P_DESCRIPCION", DbType.String, dr.DESCRIPCION)); Paramlist.Add(repository.DbFactory.getDataParameter("P_IDTICKET", DbType.Int32, dr.IDTICKET)); result = repository.ExecuteCreateProcedure(CONST_CREATE_PROCEDURE_NAME, Paramlist, dr.OBJECTHASH.ToString()); } catch (Exception ex) { throw ex; } return(result); }
private void Filter() { Projects.Clear(); DBRepository <Project> dBProject = new DBRepository <Project>(new BuildEntities()); DBRepository <User> dBUser = new DBRepository <User>(new BuildEntities()); DBRepository <UserProject> dbUP = new DBRepository <UserProject>(new BuildEntities()); if (CurUser == null) { foreach (var item in dbUP.GetAll().ToList()) { var user = dBUser.GetAll().First(s => s.ID_User == item.ID_User); var project = dBProject.GetAll().First(s => s.ID_Project == item.ID_Project); if (user.Login.Contains(Find) || project.ID_Project.ToString().Contains(Find) || project.Project_name.Contains(Find) || project.Date_of_change.ToString().Contains(find)) { Projects.Add(new UserProj(dBUser.GetAll().First(s => s.ID_User == item.ID_User), dBProject.GetAll().First(s => s.ID_Project == item.ID_Project))); } } } else { foreach (var item in dbUP.GetAll().Where(s => s.ID_User == CurUser.ID_User)) { var project = dBProject.GetAll().First(s => s.ID_Project == item.ID_Project); if (CurUser.Login.Contains(Find) || project.ID_Project.ToString().Contains(Find) || project.Project_name.Contains(Find) || project.Date_of_change.ToString().Contains(find)) { Projects.Add(new UserProj(dBUser.GetAll().First(s => s.ID_User == item.ID_User), dBProject.GetAll().First(s => s.ID_Project == item.ID_Project))); } } } dBProject.Dispose(); dBUser.Dispose(); dbUP.Dispose(); }
public MainWindow() { bool db = false; using (var connection = new OleDbConnection(@"Server = (localdb)\mssqllocaldb; Trusted_Connection = True; ")) { try { connection.Open(); db = true; } catch (Exception e) { } } IRepository repository; if (db) { repository = new DBRepository(); } else { repository = new CSVRepository(); } InitializeComponent(); DataContext = new SamuraiBattleViewModel(repository); }
public AdminProjectPageViewModel() { DBRepository <Project> dBProject = new DBRepository <Project>(new BuildEntities()); DBRepository <User> dBUser = new DBRepository <User>(new BuildEntities()); DBRepository <UserProject> dbUP = new DBRepository <UserProject>(new BuildEntities()); foreach (var item in dbUP.GetAll()) { Projects.Add(new UserProj(dBUser.GetAll().First(s => s.ID_User == item.ID_User), dBProject.GetAll().First(s => s.ID_Project == item.ID_Project))); } var windows = Application.Current.Windows; if (windows.Count > 1) { Window window = null; try { foreach (var item in windows) { if (item as Loading != null) { window = (item as Window); } } } catch { } window.Close(); } dBProject.Dispose(); dBUser.Dispose(); dbUP.Dispose(); }
public ActionResult OrderDetails(string ordNo) { DBRepository dbr = new DBRepository(); List <OrderDetail> orderDetails = dbr.getOrderDetails(ordNo); return(PartialView("_orderDetails", orderDetails)); }
public AddFavouritesWindow(DBRepository repo, User user) { InitializeComponent(); _repo = repo; _user = user; StationsList.ItemsSource = _repo.Context.Stations.ToList() ; }
public void Insert_NewJobEntity_EntityInserted() { //Arrange var options = new DbContextOptionsBuilder <OoptiRHContext>() .UseInMemoryDatabase(databaseName: "InsertNewJobEntityEntityInserted") .Options; Job NewJob = new Job { Guid = Guid.NewGuid(), title = "Senior .Net developper", Description = "a .net how has a signeficant experience", }; //Act using (var context = new OoptiRHContext(options)) { IDBRepository <Job> jobRepository = new DBRepository <Job>(context); jobRepository.Insert(NewJob); } //Assert using (var context = new OoptiRHContext(options)) { int count = context.Jobs.CountAsync().Result; Assert.Equal(1, count); } }
void item_Click(object sender, EventArgs e) { try { string connectionString = Helper.FixConnectionString(this.Parent.Connection.ConnectionString, this.Parent.Connection.ConnectionTimeout); using (IRepository repository = new DBRepository(connectionString)) { using (RenameOptions ro = new RenameOptions(this.Parent.Name)) { if (ro.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(ro.NewName)) { repository.RenameTable(this.Parent.Name, ro.NewName); RefreshTree(); } } } } catch (System.Data.SqlServerCe.SqlCeException sqlCe) { Connect.ShowErrors(sqlCe); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
static void Main(string[] args) { DbContextOptions <Project0DBContext> dbContextOptions = SetupContextOptions(); if (dbContextOptions == null) { Console.WriteLine("Exiting Program . . ."); return; } IDbRepository repo = new DBRepository(dbContextOptions); Console.WriteLine("Welcome to the store!"); Console.WriteLine("Loading database data . . ."); repo.LoadDBDataToModel(); //basically hold the current state of the program IMenu CurrentMenu = new StartMenu(repo); while (CurrentMenu != null) { CurrentMenu = CurrentMenu.DisplayMenu(); Console.WriteLine(); } }
// GET: Customer public ActionResult customer() { DBRepository dbr = new DBRepository(); List <Customer> customers = dbr.getCustomers(); return(View("customer", customers)); }
private void DisplayData() { var repo = new DBRepository(); Note note = repo.GetNoteById(Convert.ToInt32(_Id)); lblNum.Text = _Id; lblName.Text = note.Name; lblEmail.Text = string.Format("<a href='mailto:{0}'>{0}</a>", note.Email); lblTitle.Text = note.Title; string content = note.Content; // 인코딩 방식 : Text, Html, Mixed string encoding = note.Encoding; if (encoding == "Text") { lblContent.Text = Helpers.HtmUtillity.EncodeWithTabAndSpace(content); } else if (encoding == "Mixed") { lblContent.Text = content.Replace("\r\n", "<br />"); } else //Html { lblContent.Text = content; //변환없이 찍어주기 } lblReadCount.Text = note.ReadCount.ToString(); lblHomepage.Text = $"<a href='{note.Homepage}' target='_blank'>{note.Homepage}</a>"; lblPostDate.Text = note.PostDate.ToString(); lblPostIP.Text = note.PostIp; }
/// <summary> /// Change the status of the lesson (Published / draft) /// </summary> private void ChangeStatusLesson() { //If a lesson has been selected if (CB_Lessons.SelectedIndex > -1) { //Make a new instance of the DB class DBRepository DB = DBRepository.GetInstance(); //Get the current status by the ID of the lesson var Status = DB.FindLessonStatusByID(DB.FindLessonIDByName(CB_Lessons.SelectedItem.ToString())); //If status is published if (Status.LessonStatus == "Published") { //Update the status to Draft DB.UpdateLessonStatusByID(DB.FindLessonIDByName(CB_Lessons.SelectedItem.ToString()), "Draft"); } //If status is draft else if (Status.LessonStatus == "Draft") { //Update the status to published DB.UpdateLessonStatusByID(DB.FindLessonIDByName(CB_Lessons.SelectedItem.ToString()), "Published"); } } else { } }
/// <summary> /// Delete a lesson made by the teacher /// </summary> private void DeleteLesson() { //If a lesson has been selected if (CB_Lessons.SelectedIndex > -1) { //Open new instance of db class DBRepository DB = DBRepository.GetInstance(); //Find the lesson by ID int Lesson_ID = DB.FindLessonIDByName(CB_Lessons.SelectedItem.ToString()); //Delete this lesson from the lessons and from the Groups DB.DeleteLessonByID(Lesson_ID); DB.DeleteLessonAtGroupsByID(Lesson_ID); //Get new list of lessons GetAllLessons(); MessageBox.Show("Les verwijderd!"); } else { MessageBox.Show("Selecteer item om te verwijderen"); } }
/// <summary> /// Add images to system function /// </summary> private void Add_Images_To_System() { try { //Open new file dialog OpenFileDialog open = new OpenFileDialog(); //Only allow these file types open.Filter = "Image Files(*.jpg; *.jpeg; *.png;)|*.jpg; *.jpeg; *.png;"; if (open.ShowDialog() == DialogResult.OK) { //Create new bitmap Bitmap bit = new Bitmap(open.FileName); //Make new instance of DB Class DBRepository DB = DBRepository.GetInstance(); //Create byte array byte[] arr; using (MemoryStream ms = new MemoryStream()) { bit.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); arr = ms.ToArray(); } //Insert image into DB DB.InsertImageInDB(open.FileName, arr); } } catch (Exception e) { MessageBox.Show(e.Message); } }
/// <summary> /// Add images to lesson /// </summary> private void Add_Images_To_Lesson() { //Open instance DBRepository DB = DBRepository.GetInstance(); //New instance of system images var SystemImages = new SystemImages(); //Open Dialog for System images SystemImages.ShowDialog(); //Get ID from Image to Add int ToAddImageID = SystemImages.ReturnImageID(); //Get all the images from database var images = DB.ReceiveImagesFromDB(); //for every image in the images list foreach (var image in images) { if (ToAddImageID == image.ReturnImageID()) { LB_Images.Items.Add(image.ReturnFileName()); } } }
private void btnCreateTable_Click(object sender, EventArgs e) { DBRepository dbr = new DBRepository(); var result = dbr.CreateTable(); Toast.MakeText(this, result, ToastLength.Short).Show(); }
/// <summary> /// Fill the saved lesson data (If editing a lesson) /// </summary> /// <param name="Lesson_ID">ID of the lesson to edit</param> private void Fill_Saved_Lesson_Data(int Lesson_ID) { //Open instance DBRepository DB = DBRepository.GetInstance(); //Get lesson object by the ID var Lesson = DB.GetLessonDataByID(Lesson_ID); LessonToEditID = Lesson_ID; try { //Get data string subject = Lesson.GetLessonSubject(); string title = Lesson.GetLessonName(); int Teacher_ID = Lesson.GetTeacherID(); string desc = Lesson.GetLessonDesc(); string status = Lesson.LessonStatus; //Fill the boxes with received DB data TB_Title.Text = title; TB_Subject.Text = subject; TB_Desc.Text = desc; TB_Made_By.Text = DB.FindTeacherName(Teacher_ID).GetTeacherName(); CB_Lesson_Status.SelectedItem = status; //Get Group ID if (DB.FindGroupIDBasedOnLessonID(Lesson_ID).Get_Group_ID() != 0) { int groupid = DB.FindGroupIDBasedOnLessonID(Lesson_ID).Get_Group_ID(); string groupname = DB.FindGroupDataBasedOnGroupID(groupid).GetGroupName(); CB_Classes.SelectedItem = groupname; } else { CB_Classes.SelectedItem = "All"; } //Get Images in Lesson var images = DB.ReceiveImagesInLesson(Lesson); foreach (var image in images) { LB_Images.Items.Add(image.ReturnFileName()); } //Get Art objects in lesson var Art = DB.ReceiveArtObjInLesson(Lesson); foreach (var Single_Art in Art) { LB_Art_Items.Items.Add(Single_Art.ReturnArtTitle()); } } catch (NullReferenceException) { //Do nothing } }
public IHttpActionResult DeleteTemplate(ChartTemplate_ViewModel dto) { var repos = new DBRepository(); bool result = repos.DeleteTemplate(dto); return(Json(result)); }
public override System.Data.DataSet List(Filter f, out int RecordCount) { DataSet ds = new DataSet(); try { FiltroEmpresa filtro = (FiltroEmpresa)f; List <IDbDataParameter> paramList = new List <IDbDataParameter>(); DBRepository repository = DBRepository.GetDbRepository(); paramList.Add(repository.DbFactory.getDataParameter("P_ID", DbType.Int32, filtro.ID)); paramList.Add(repository.DbFactory.getDataParameter("P_SEARCH", DbType.String, filtro.Search)); bool result = repository.ExecuteListProcedure(CONST_LIST_PROCEDURE_NAME, paramList, f, ds, out RecordCount); } catch (Exception ex) { throw ex; } return(ds); }
private void OnLoginButtonClickEvent(object sender, EventArgs e) { var userName = FindViewById <EditText>(Resource.Id.userName1); var password = FindViewById <EditText>(Resource.Id.password2); Regex regexUserName = new Regex(@"(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{5,12})$"); Regex regexpassword = new Regex(@"^([a-zA-Z0-9@*#]{5,12})$"); Match matchUserName = regexUserName.Match(userName.Text); Match matchPassword = regexpassword.Match(password.Text); if (matchUserName.Success && matchPassword.Success) { User user = new User(); DBRepository db = new DBRepository(); user.Name = userName.Text; user.Password = password.Text; bool exists = db.CheckIfUserExist(user); if (exists) { var intent = new Intent(this, typeof(ShowListActivity)); StartActivity(intent); } else { var textmessage = FindViewById <TextView>(Resource.Id.listViewMessage); textmessage.Text = "User Name or Password is incorrect. Login with correct user name and password."; } } else { var textmessage = FindViewById <TextView>(Resource.Id.listViewMessage); textmessage.Text = "User Name or Password is incorrect. Login with correct user name and password."; } }
public AdminElementsPageViewModel() { DBRepository <Elements> dBRepository = new DBRepository <Elements>(new BuildEntities()); foreach (var item in dBRepository.GetAll()) { AllElements.Add(item); } var windows = Application.Current.Windows; if (windows.Count > 1) { Window window = null; try { foreach (var item in windows) { if (item as Loading != null) { window = (item as Window); } } } catch { } window.Close(); } dBRepository.Dispose(); CustomMessageBox.Show("Warning", "Warning: remember that any of your changes affect customer projects, be careful", MessageBoxButton.OK); }
public override DataSet List(Filter f, out int RecordCount) { DataSet ds = new DataSet(); try { FiltroCiudad filtro = (FiltroCiudad)f; List <IDbDataParameter> paramList = new List <IDbDataParameter>(); DBRepository repository = DBRepository.GetDbRepository(); paramList.Add(repository.DbFactory.getDataParameter("P_ID", DbType.Int32, filtro.ID)); paramList.Add(repository.DbFactory.getDataParameter("P_IDPAIS", DbType.Int32, filtro.IDPais)); paramList.Add(repository.DbFactory.getDataParameter("P_IDPROVINCIA", DbType.Int32, filtro.IDProvinca)); bool result = repository.ExecuteListProcedure(CONST_LIST_PROCEDURE_NAME, paramList, f, ds, out RecordCount); } catch (Exception ex) { throw ex; } return(ds); }
/// <summary> /// Filling the panel with images from the database /// </summary> private void Fill_Panel_With_Images() { //Open DB instance DBRepository DB = DBRepository.GetInstance(); //Get images from the database var images = DB.ReceiveImagesFromDB(); //For every image in the received images list foreach (var image in images) { //Make a picturebox for every image PictureBox p = new PictureBox(); p.Image = ByteToImage(image.ReturnImageData()); p.SizeMode = PictureBoxSizeMode.StretchImage; p.BorderStyle = BorderStyle.FixedSingle; p.Click += (s, e) => { //Add a clickfunction that adds the image to the lesson this.Hide(); SetImageID(image.ReturnImageID()); }; //Add picturebox to layoutpanel FlowLayoutPanelIMG.Controls.Add(p); } }
public override System.Data.DataSet List(Filter f, out int RecordCount) { DataSet ds = new DataSet(); try { FiltroAfiliado filtro = (FiltroAfiliado)f; List <IDbDataParameter> paramList = new List <IDbDataParameter>(); DBRepository repository = DBRepository.GetDbRepository(); paramList.Add(repository.DbFactory.getDataParameter("P_ID", DbType.Int32, filtro.ID)); paramList.Add(repository.DbFactory.getDataParameter("P_APELLIDO", DbType.String, filtro.Apellido)); paramList.Add(repository.DbFactory.getDataParameter("P_NOMBRE", DbType.String, filtro.Nombre)); paramList.Add(repository.DbFactory.getDataParameter("P_POLIZA", DbType.String, filtro.Poliza)); paramList.Add(repository.DbFactory.getDataParameter("P_IDDOCUMENTO", DbType.String, filtro.Documento)); paramList.Add(repository.DbFactory.getDataParameter("P_PATENTE", DbType.String, filtro.Patente)); paramList.Add(repository.DbFactory.getDataParameter("P_ID_EMPRESA", DbType.Int32, filtro.IDEmpresa)); paramList.Add(repository.DbFactory.getDataParameter("P_SEARCH", DbType.String, filtro.Search)); bool result = repository.ExecuteListProcedure(CONST_LIST_PROCEDURE_NAME, paramList, f, ds, out RecordCount); } catch (Exception ex) { throw ex; } return(ds); }
/// <summary> /// 保存转班记录 /// </summary> /// <param name="btn"></param> /// <returns></returns> public static bool SaveClass_transfe(Enroll en, ClassesTrans ct) { bool ret = false; DBRepository db = new DBRepository(DBKeys.PRX); try { db.BeginTransaction();//事务开始 Enroll en_old = db.GetById <Enroll>(en.ID); string oldclassid = en_old.ClassID;//原来的班级号 en_old.ClassID = en.ClassID; en_old.UpdateTime = en.UpdateTime; en_old.UpdatorId = en.UpdatorId; db.Update(en_old); //把报名表中的classid改成新的 string strsql = "delete from AttendanceRecord where AttendanceTypeID = 1 and StudentID = '" + en_old.StudentID + "' and ClassID = '" + oldclassid + "'"; db.Execute(strsql); //删除未考勤多余的学员课程记录 if (AddClassesTrans(ct, db) > 0) { db.Commit(); //事务提交 db.Dispose(); //资源释放 ClassListData.RefreshClassList(en.ClassID, en.UpdatorId); //刷新排课 ret = true; //新增成功 } } catch (Exception ex) { db.Rollback(); db.Dispose();//资源释放 throw new Exception(ex.Message + "。" + ex.InnerException.Message); } return(ret); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.PoemsScreen); DBRepository repository = new DBRepository(); poems = repository.GetPoems(); CreateButtons(poems.Select(p => p.Title)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.AddScreen); repository = new DBRepository(); List<string> groupsList = repository.GetGroupNames(); List<string> subgroupsList = repository.GetSubgroupNames(); Spinner typeSpinner = FindViewById<Spinner>(Resource.Id.typeSpinner); groupSpinner = FindViewById<Spinner>(Resource.Id.groupSpinner); subgroupSpinner = FindViewById<Spinner>(Resource.Id.subgroupSpinner); groupSpinnerTitle = FindViewById<TextView>(Resource.Id.groupSpinner_Title); subgroupSpinnerTitle = FindViewById<TextView>(Resource.Id.subgroupSpinner_Title); poemTitle = FindViewById<TextView>(Resource.Id.poem_Title); contentTitle = FindViewById<TextView>(Resource.Id.content_Title); poemTitleText = FindViewById<EditText>(Resource.Id.poem_TitleEdit); contentText = FindViewById<EditText>(Resource.Id.content_Text); Button saveButton = FindViewById<Button>(Resource.Id.saveButton); saveButton.Click += SaveButton_Click; Button cancelButton = FindViewById<Button>(Resource.Id.cancelButton); cancelButton.Click += CancelButton_Click; typeSpinner.ItemSelected += TypeSpinner_ItemSelected; var typeAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.TypesArray, Android.Resource.Layout.SimpleSpinnerItem); typeAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); typeSpinner.Adapter = typeAdapter; var groupAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem); groupAdapter.AddAll(groupsList); groupSpinner.Adapter = groupAdapter; var subgroupAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem); subgroupAdapter.AddAll(subgroupsList); subgroupSpinner.Adapter = subgroupAdapter; }
private void PrepareUI() { if (this.IsNew) { btnSample.Visibility = System.Windows.Visibility.Hidden; txtSubscriber.Text = Environment.MachineName; } else { try { if (!string.IsNullOrWhiteSpace(Publication)) { using (IRepository repository = new DBRepository(Database)) { DateTime date = repository.GetLastSuccessfulSyncTime(Publication); if (date != DateTime.MinValue) { lblLastSync.Content = "Last sync: " + date.ToString(); } ReplicationProperties props = SqlCeReplicationHelper.GetProperties(Database, Publication); txtUrl.Text = props.InternetUrl; txtPublisher.Text = props.Publisher; txtPublisherDatabase.Text = props.PublisherDatabase; txtPublisherUsername.Text = props.PublisherLogin; txtPublication.Text = props.Publication; txtSubscriber.Text = props.Subscriber; txtHostname.Text = props.HostName; txtInternetUsername.Text = props.InternetLogin; if (props.UseNT) { comboBox1.SelectedIndex = 1; } } } } catch (Exception ex) { MessageBox.Show(Helpers.DataConnectionHelper.ShowErrors(ex)); } } }
private void TestConnection(bool showMessage) { try { if (createDb) { if (!System.IO.File.Exists(dataSourceTextBox.Text)) { var engineHelper = new SqlCeHelper(); engineHelper.CreateDatabase(_connectionString); } } using (var repository = new DBRepository(_connectionString)) { if (showMessage) { System.Windows.MessageBox.Show("Connection OK!"); } else { this.DialogResult = true; } } } catch (Exception ex) { System.Windows.MessageBox.Show(DataConnectionHelper.ShowErrors(ex)); } }
void item_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; string fileName = string.Empty; Action action = (Action)item.OwnerItem.Tag; Output output = (Output)item.Tag; try { string connectionString = Helper.FixConnectionString(this.Parent.Connection.ConnectionString, this.Parent.Connection.ConnectionTimeout); using (IRepository repository = new DBRepository(connectionString)) { var generator = new Generator(repository); using (ImportOptions imo = new ImportOptions(this.Parent.Name)) { imo.SampleHeader = generator.GenerateTableColumns(this.Parent.Name); imo.Separator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToCharArray()[0]; if (imo.ShowDialog() == DialogResult.OK) { switch (output) { case Output.Editor: // create new document ServiceCache.ScriptFactory.CreateNewBlankScript(Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ScriptType.SqlCe); break; case Output.File: SaveFileDialog fd = new SaveFileDialog(); fd.AutoUpgradeEnabled = true; fd.Title = "Save generated database script as"; fd.Filter = "SQL Server Compact Script (*.sqlce)|*.sqlce|SQL Server Script (*.sql)|*.sql|All Files(*.*)|"; fd.OverwritePrompt = true; fd.ValidateNames = true; if (fd.ShowDialog() == DialogResult.OK) { fileName = fd.FileName; } break; default: break; } switch (action) { case Action.Csv: using (var reader = new CsvReader(imo.FileName)) { reader.ValueSeparator = imo.Separator; HeaderRecord hr = reader.ReadHeaderRecord(); if (generator.ValidColumns(this.Parent.Name, hr.Values)) { foreach (DataRecord record in reader.DataRecords) { generator.GenerateTableInsert(this.Parent.Name, hr.Values, record.Values); } } } break; default: break; } switch (output) { case Output.Editor: // insert SQL script to document EnvDTE.TextDocument doc = (EnvDTE.TextDocument)ServiceCache.ExtensibilityModel.Application.ActiveDocument.Object(null); doc.EndPoint.CreateEditPoint().Insert(generator.GeneratedScript); doc.DTE.ActiveDocument.Saved = true; break; case Output.File: if (!string.IsNullOrEmpty(fileName)) { System.IO.File.WriteAllText(fileName, generator.GeneratedScript); } break; case Output.Clipboard: Clipboard.Clear(); Clipboard.SetText(generator.GeneratedScript, TextDataFormat.UnicodeText); break; default: break; } } } } } catch (System.Data.SqlServerCe.SqlCeException sqlCe) { Connect.ShowErrors(sqlCe); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public TUserRoleService() : base() { _userroleRepository = new DBRepository<T_UserRole>(Db); }
private string[] GetGroup(string parameter) { DBRepository repository = new DBRepository(); return repository.GetGroup(parameter).ToArray(); }
private string[] GetAllWords() { DBRepository repository = new DBRepository(); return repository.GetAllWords().ToArray(); }
public TOnlineService() : base() { _onlineRepository = new DBRepository<T_Online>(Db); }
public TUserService() : base() { _userRepository = new DBRepository<T_User>(Db); }
void item_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; string fileName = string.Empty; Action action = (Action)item.OwnerItem.Tag; Output output = (Output)item.Tag; try { string connectionString = Helper.FixConnectionString(this.Parent.Connection.ConnectionString, this.Parent.Connection.ConnectionTimeout); using (IRepository repository = new DBRepository(connectionString)) { var generator = new Generator(repository); switch (output) { case Output.Editor: // create new document ServiceCache.ScriptFactory.CreateNewBlankScript(Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ScriptType.SqlCe); break; case Output.File: SaveFileDialog fd = new SaveFileDialog(); fd.AutoUpgradeEnabled = true; fd.Title = "Save generated database script as"; fd.Filter = "SQL Server Compact Script (*.sqlce)|*.sqlce|SQL Server Script (*.sql)|*.sql|All Files(*.*)|"; fd.OverwritePrompt = true; fd.ValidateNames = true; if (fd.ShowDialog() == DialogResult.OK) { fileName = fd.FileName; } break; default: break; } switch (action) { case Action.Create: generator.GenerateTableScript(this.Parent.Name); break; case Action.Drop: generator.GenerateTableDrop(this.Parent.Name); break; case Action.DropAndCreate: generator.GenerateTableDrop(this.Parent.Name); generator.GenerateTableScript(this.Parent.Name); break; case Action.Select: generator.GenerateTableSelect(this.Parent.Name); break; case Action.Insert: generator.GenerateTableInsert(this.Parent.Name); break; case Action.Update: generator.GenerateTableUpdate(this.Parent.Name); break; case Action.Delete: generator.GenerateTableDelete(this.Parent.Name); break; case Action.Data: generator.GenerateTableData(this.Parent.Name, false); break; default: break; } switch (output) { case Output.Editor: // insert SQL script to document EnvDTE.TextDocument doc = (EnvDTE.TextDocument)ServiceCache.ExtensibilityModel.Application.ActiveDocument.Object(null); doc.EndPoint.CreateEditPoint().Insert(generator.GeneratedScript); doc.DTE.ActiveDocument.Saved = true; break; case Output.File: if (!string.IsNullOrEmpty(fileName)) { System.IO.File.WriteAllText(fileName, generator.GeneratedScript); } break; case Output.Clipboard: Clipboard.Clear(); Clipboard.SetText(generator.GeneratedScript, TextDataFormat.UnicodeText); break; default: break; } } } catch (System.Data.SqlServerCe.SqlCeException sqlCe) { Connect.ShowErrors(sqlCe); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public TRoleService() : base() { _roleRepository = new DBRepository<T_Role>(Db); }
private void GetSubscriptions(object sender, RoutedEventArgs args, KeyValuePair<string, string> database) { var viewItem = sender as DatabaseTreeViewItem; // Prevent loading again and again if (viewItem != null && (viewItem.Items.Count > 0 && viewItem.Items[0].ToString() == "Loading...")) { List<string> nameList; try { using (var _repository = new DBRepository(database.Value)) { nameList = _repository.GetAllSubscriptionNames(); } } catch (Exception e) { MessageBox.Show("Exception getting subscription list: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Dispatcher.BeginInvoke(new FillSubscriptionItemsHandler(FillSubItems), database, viewItem, nameList); } args.Handled = true; }
public TMenuService() : base() { _menuRepository = new DBRepository<T_Menu>(Db); }
void item_Click(object sender, EventArgs e) { string connectionString = Helper.FixConnectionString(this.Parent.Connection.ConnectionString, this.Parent.Connection.ConnectionTimeout); string fileName; ToolStripMenuItem item = (ToolStripMenuItem)sender; Scope scope = (Scope)item.Tag; SaveFileDialog fd = new SaveFileDialog(); fd.AutoUpgradeEnabled = true; fd.Title = "Save generated database script as"; fd.Filter = "SQL Server Compact Script (*.sqlce)|*.sqlce|SQL Server Script (*.sql)|*.sql|All Files(*.*)|"; fd.OverwritePrompt = true; fd.ValidateNames = true; if (fd.ShowDialog() == DialogResult.OK) { fileName = fd.FileName; try { using (IRepository repository = new DBRepository(connectionString)) { var generator = new Generator(repository, fd.FileName); System.Windows.Forms.MessageBox.Show(generator.ScriptDatabaseToFile(scope)); } } catch (System.Data.SqlServerCe.SqlCeException sqlCe) { Connect.ShowErrors(sqlCe); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }