private void Initialize() { try { user = new Logic.Projects.User(BTSS.Common.Core.ProjectConnectionString, BTSS.Common.Core.ProjectDataProvider); validation = new BTSS.Common.Validation(); validation.Validate(this); SetControlListingAccessRights(); menuStrip = new ContextMenuStrip(); menuStrip.Items.Add("Display Projects"); menuStrip.Items[0].Click += new EventHandler(displayProjectsMenuStrip_ItemClicked); userControlListing.dataGridViewList.CellMouseDown +=new DataGridViewCellMouseEventHandler(dataGridViewList_CellMouseDown); } catch (Exception) { throw; } }
private void Initialize() { try { user = new Logic.Projects.User(BTSS.Common.Core.ProjectConnectionString, BTSS.Common.Core.ProjectDataProvider); validation = new BTSS.Common.Validation(); validation.Validate(this); InitializeGrid(); if (Operation == BTSS.Common.Core.Operation.UPDATE || Operation == BTSS.Common.Core.Operation.VIEW) { DataRow dr; dr = user.GetUserDetails(UserId); textBoxID.Text = UserId; textBoxLastName.Text = dr["user_last_name"].ToString(); textBoxFirstName.Text = dr["user_first_name"].ToString(); textBoxUserName.Text = dr["user_name"].ToString(); textBoxUserName.Tag = dr["user_name"].ToString(); accountName = dr["user_name"].ToString().Substring(4, dr["user_name"].ToString().Length - 4).ToString(); if (Operation == BTSS.Common.Core.Operation.VIEW) { userControlButtonsSave.Visible = false; Lock(); } } LoadGroupAccess(); textBoxLastName.Focus(); } catch (Exception) { throw; } }
private void displayProjectsMenuStrip_ItemClicked(object sender, EventArgs e) { try { //Initialize datatable for reporting DataTable dtUserProjects = new DataTable(); dtUserProjects.Columns.Add("ProjectName"); dtUserProjects.Columns.Add("Description"); dtUserProjects.Columns.Add("BusinessOwner"); dtUserProjects.Columns.Add("IsActive", typeof(bool)); dtUserProjects.Columns.Add("Provider"); dtUserProjects.Columns.Add("File"); dtUserProjects.Columns.Add("Datasource"); dtUserProjects.Columns.Add("DatabaseName"); //Connection Variables Logic.Project project = new BTSS.Logic.Project(Common.Core.ConnectionString); Logic.Connection connection = null; Common.Core.DataProvider provider = BTSS.Common.Core.DataProvider.OLEDB; string connectionString = ""; string selectedUserName; selectedUserName = userControlListing.dataGridViewList.SelectedRows[0].Cells["user_name"].Value.ToString(); //User's project object Logic.Interfaces.Projects.IUser user; //Iterate ALL projects foreach (Logic.Project p in project.GetAllProjects()) { if (p.Provider == "OLEDB") { connectionString = Common.Core.GetConnectionString(p.File, p.UserID, p.Password, p.HasOtherDetails, p.MDW); connection = new BTSS.Logic.Connection(connectionString, BTSS.Common.Core.DataProvider.OLEDB); provider= BTSS.Common.Core.DataProvider.OLEDB; } else if (p.Provider == "SQL") { connectionString = Common.Core.GetConnectionString(p.Datasource, p.DatabaseName, p.UserID, p.Password); connection = new BTSS.Logic.Connection(connectionString, BTSS.Common.Core.DataProvider.SQL); provider= BTSS.Common.Core.DataProvider.SQL; } //check if database has connection if (connection.HasConnection()) { user = new Logic.Projects.User(connectionString, provider); if (user.IsExist(selectedUserName)) dtUserProjects.Rows.Add(p.Name, p.Desc, p.BusinessOwner, p.IsActive, p.Provider, p.File, p.Datasource, p.DatabaseName); } } using (var reportViewer = new Common.ReportViewer()) { reportViewer.ReportTitle = selectedUserName + " Projects"; reportViewer.XMLName = "UsersProjectList"; reportViewer.ReportSource = (new Reports.ReportUsersProjectList()); reportViewer.SetDatasource(dtUserProjects); reportViewer.ShowReport(); } } catch (Exception) { throw; } }