protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var comData = CommunicationDataAccess.GetAllActiveNewsItems(); rptComm.DataSource = comData; rptComm.DataBind(); var documents = CommunicationDataAccess.GetAllDocuments().ToList(); rptDocs.DataSource = documents; rptDocs.DataBind(); using (var dataAccess = new UsersAndRolesDataAccess()) { var employeeId = ApplicationAuthentication.GetEmployeeId(); var userType = dataAccess.GetUserType(employeeId); var countryAdmins = dataAccess.GetCountryAdmin(userType); gvCountryAdmins.DataSource = countryAdmins.OrderBy(d => d.Country).ThenBy(d => d.Name); } using (var dataAccess = new UserTrainingDataAccess()) { var trainingEntities = dataAccess.GetActiveEntries(); rptTraining.DataSource = trainingEntities; } gvCountryAdmins.DataBind(); rptTraining.DataBind(); } }
private void EditNewsItem(int intNewsID) { pnlAddNews.Visible = true; var comDataRow = CommunicationDataAccess.SelectNewsItem(intNewsID); txtDetails.Text = comDataRow.Details; txtHeading.Text = comDataRow.Heading; if ((comDataRow.IsActive == true)) { rblIsActive.Items[0].Selected = true; } else { rblIsActive.Items[1].Selected = true; } if ((comDataRow.Priority == true)) { rblIsPriority.Items[0].Selected = true; } else { rblIsPriority.Items[1].Selected = true; } }
protected void NewsGrid() { var comData = CommunicationDataAccess.GetAllNewsItems(); grdNews.DataSource = comData; grdNews.DataBind(); }
protected void btnSave_Click(object sender, EventArgs e) { string strUserID = ""; string strHeading = ""; string strDetails = ""; bool isActive = false; bool isPriority = false; strHeading = txtHeading.Text; strDetails = txtDetails.Text; //Validation if ((txtHeading.Text == "")) { lblErrorMessage.Text = "Please enter in a Heading"; return; } if ((txtDetails.Text == "")) { lblErrorMessage.Text = "Please enter in Details"; return; } strUserID = this.Page.RadUserId(); if ((rblIsActive.Items[0].Selected == true)) { isActive = true; } else { isActive = false; } if ((rblIsPriority.Items[0].Selected == true)) { isPriority = true; } else { isPriority = false; } if (!String.IsNullOrEmpty(hfNewsID.Value)) //Update { int newsID; newsID = int.Parse(hfNewsID.Value); CommunicationDataAccess.UpdateNews(newsID, strUserID, strHeading, strDetails, isActive, isPriority); } else //Save { CommunicationDataAccess.SaveNews(strUserID, strHeading, strDetails, isActive, isPriority); } pnlAddNews.Visible = false; NewsGrid(); ClearItems(); }
private void DeleteNewsItem(int intNewsID) { CommunicationDataAccess.DeleteNewsItem(intNewsID); ClearItems(); NewsGrid(); }