protected void ListView2_ItemInserting(object sender, ListViewInsertEventArgs e) { ListView lv = (ListView)sender; HtmlTableCell lvi = (HtmlTableCell)lv.Parent; covertKey = new Guid(((Label)lvi.FindControl("CovertIdLabel")).Text); string post_userId = ((Label)lvi.FindControl("UserIdLabel")).Text; TextBox txtb = (e.Item.FindControl("CommentTextBox")) as TextBox; //txt = txtb.Text; string connectionString = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString; string insertSql = "INSERT INTO CovertComments(Comment, CommentUser, CovertId,CommentUserId) VALUES(@Comment, @CommentUser, @CovertId,@CommentUserId)"; using (SqlConnection myConnection = new SqlConnection(connectionString)) { myConnection.Open(); SqlCommand myCommand = new SqlCommand(insertSql, myConnection); myCommand.Parameters.AddWithValue("@Comment", txtb.Text.Trim()); myCommand.Parameters.AddWithValue("@CovertId", covertKey); myCommand.Parameters.AddWithValue("@CommentUserId", currentUserId); myCommand.Parameters.AddWithValue("@CommentUser", HttpContext.Current.Session["user"]); myCommand.ExecuteNonQuery(); myConnection.Close(); } if (currentUserId.ToString() != post_userId) { string connectionString12 = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString; string insertSql2 = "INSERT INTO Notifications(UserId,Type,NotifyTo) VALUES(@UserId,@Type,@NotifyTo)"; using (SqlConnection myConnection = new SqlConnection(connectionString12)) { myConnection.Open(); SqlCommand myCommand = new SqlCommand(insertSql2, myConnection); myCommand.Parameters.AddWithValue("@Type", "Covert_Comment"); myCommand.Parameters.AddWithValue("@UserId", currentUserId); myCommand.Parameters.AddWithValue("@NotifyTo", post_userId); myCommand.ExecuteNonQuery(); myConnection.Close(); } } e.Cancel = true; this.DataBind(); }
/// <summary> /// xóa các module nội dung ra khỏi bảng nội dung mẫu /// </summary> /// <param name="tdDisplay"></param> /// <param name="td_id_module"></param> private void RemoveModuleFromColumn(HtmlTableCell tdDisplay, Dictionary <string, ArrayList> td_id_module) { HtmlTableCell td; ArrayList modules; //duyệt qua mảng các ID của TD cần đưa module vào foreach (KeyValuePair <string, ArrayList> td_id in td_id_module) { //tìm ra các TD cần đưa module vào td = tdDisplay.FindControl(td_id.Key) as HtmlTableCell; //lấy ra module tương ứng với ID của TD đó modules = td_id.Value; //nếu TD đó có chứ module , tức là không phải để chứa cột khác , thì xóa module khỏi column đó if (modules != null && modules.Count > 0) { try { td.InnerHtml = ""; } catch { } } } }
protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e) { ListView lv = (ListView)sender; HtmlTableCell lvi = (HtmlTableCell)lv.Parent; //ListViewItem item = (ListViewItem)lv.NamingContainer; //ListViewDataItem dataItem = (ListViewDataItem)item; String tx = (((CheckBoxList)lvi.FindControl("CheckBoxList1")).Text); }
protected void Rptlist_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Label _status = (Label)e.Item.FindControl("lblstatus"); Label _due = (Label)e.Item.FindControl("lbldue"); string _sta = _status.Text; HtmlTableRow _tr = new HtmlTableRow(); _tr = (HtmlTableRow)e.Item.FindControl("trow"); if (Convert.ToInt32(_due.Text) > 0 && _status.Text == "OPEN") { _tr.Style.Add("color", "red"); } else { _due.Text = ""; } HtmlTableCell _td3 = (HtmlTableCell)e.Item.FindControl("td3"); HtmlTableCell _td_3 = (HtmlTableCell)e.Item.FindControl("td_3"); if (lblprj.Text != "11736") { _td3.Visible = false; } if (lblprj.Text != "HMIM" && lblprj.Text != "HMHS") { _td_3.Visible = false; } if (lblaccess.Text != "ADMIN GROUP" && lblaccess.Text != "SYS.ADMIN GROUP") { HtmlTableCell _td4 = (HtmlTableCell)e.Item.FindControl("td4"); Button _btn = (Button)_td4.FindControl("Button1"); _btn.Enabled = false; } } else if (e.Item.ItemType == ListItemType.Header) { HtmlTableCell _td1 = (HtmlTableCell)e.Item.FindControl("td1"); HtmlTableCell _td2 = (HtmlTableCell)e.Item.FindControl("td2"); HtmlTableCell _td_1 = (HtmlTableCell)e.Item.FindControl("td_1"); HtmlTableCell _td_2 = (HtmlTableCell)e.Item.FindControl("td_2"); if (lblprj.Text != "11736") { _td1.Visible = false; _td2.Visible = false; } if (lblprj.Text != "HMIM" && lblprj.Text != "HMHS") { _td_1.Visible = false; _td_2.Visible = false; } } //if ((string)Session["group"] != "ADMIN GROUP" && (string)Session["group"] != "SYS.ADMIN GROUP") // e.Row.Cells[10].Enabled = false; }
protected override void OnItemDataBound(RepeaterItemEventArgs e) { base.OnItemDataBound(e); switch (e.Item.ItemType) { case ListItemType.Header: for (int i = 1; i < ColumnCount + 1; i++) { HtmlTableCell cell = (HtmlTableCell)e.Item.FindControl("HeaderCell" + i); LinkButton lb = (LinkButton)cell.FindControl("LinkButton" + i); Image existingImage = SiteUtils.FindControlRecursive(cell, "ArrowImage") as Image; Literal lit = SiteUtils.FindControlRecursive(cell, "ArrowImageSpacer") as Literal; if (existingImage != null) { cell.Controls.Remove(existingImage); } if (lit != null) { cell.Controls.Remove(lit); } if (lb.CommandArgument == SortExpression) { Image image = new Image { ID = "ArrowImage", ImageUrl = (SortAscending) ? SiteUtils.GetIconPath("arrowU.gif") : SiteUtils.GetIconPath("arrowD.gif"), AlternateText = (SortAscending) ? "[Ascending]" : "[Descending]" }; lit = new Literal { ID = "ArrowImageSpacer", Text = " " }; cell.Controls.Add(lit); cell.Controls.Add(image); } } break; } }
protected void rptDayWeekList_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem rptItem = e.Item as RepeaterItem; HtmlTableCell cell = rptItem.FindControl("dayNameCell") as HtmlTableCell; if (this.MenuTypeId == (int)MenuTypeEnum.Weekly) { cell.Style["background-image"] = "url('Images/WeeklyBackground.jpg')"; } else if (this.MenuTypeId == (int)MenuTypeEnum.ManyWeeks) { cell.Style["background-image"] = "url('Images/MonthlyBackground.jpg')"; } cell = rptItem.FindControl("dayWeekCell") as HtmlTableCell; Repeater rptMealTypes = cell.FindControl("rptMealTypes") as Repeater; rptMealTypes.DataSource = this.MealTypes; rptMealTypes.DataBind(); }
protected void rptCourseTypes_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem rptItem = e.Item as RepeaterItem; HtmlTableCell cell = rptItem.FindControl("mealTypeCell") as HtmlTableCell; HtmlTableCell parentCell = rptItem.Parent.Parent as HtmlTableCell; object courseTypeItem = rptItem.DataItem; int courseTypeId = (rptItem.DataItem as SRL_CourseType).CourseTypeId; SRL_Meal meal = this.MealsList.SingleOrDefault(ml => ml.CourseTypeId == courseTypeId); if (meal != null) { Repeater rpt = cell.FindControl("rptMealRecipes") as Repeater; if (rpt != null) { rpt.DataSource = meal.MealRecipes; rpt.DataBind(); } } }
/// <summary> /// Hàm đưa module vào TD theo ID của TD /// </summary> /// <param name="tdDisplay">Table tổng chứa các TD có các ID cần đưa</param> /// <param name="td_id_module">Các module tương úng với các TD</param> /// <param name="tab">Tab hiện thời</param> private void GenerateModuleToColumn(HtmlTableCell tdDisplay, Dictionary <string, ArrayList> td_id_module, PortalDefinition.Tab tab) { HtmlTableCell td; ArrayList modules; //duyệt qua mảng các ID của TD cần đưa module vào foreach (KeyValuePair <string, ArrayList> td_id in td_id_module) { //tìm ra các TD cần đưa module vào td = tdDisplay.FindControl(td_id.Key) as HtmlTableCell; //lấy ra module tương ứng với ID của TD đó modules = td_id.Value; if (td != null) { //nếu TD đó có chứ module , tức là không phải để chứa cột khác , thì đưa module vào if (modules != null && modules.Count > 0) { RenderModules(td, tab, modules); } } } }
protected void rptMealTypes_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem rptItem = e.Item as RepeaterItem; HtmlTableCell cell = rptItem.FindControl("mealTypeCell") as HtmlTableCell; HtmlTableCell parentCell = rptItem.Parent.Parent as HtmlTableCell; HiddenField hidDayIndex = parentCell.FindControl("hidDayIndex") as HiddenField; object mealTypeItem = rptItem.DataItem; int mealTypeId = (rptItem.DataItem as SRL_MealType).MealTypeId; if (hidDayIndex.Value != "") { int dayIndex = int.Parse(hidDayIndex.Value) + 7 * CurrentWeek; cell.Attributes["dayIndex"] = dayIndex.ToString(); SRL_Meal meal = this.MealsList.SingleOrDefault(ml => ml.DayIndex == dayIndex && ml.MealTypeId == mealTypeId); if (meal != null) { Repeater rpt = cell.FindControl("rptMealRecipes") as Repeater; if (rpt != null) { rpt.DataSource = meal.MealRecipes; rpt.DataBind(); } } //cell = rptItem.FindControl("dinersCell") as HtmlTableCell; //TextBox txtDiners = cell.FindControl("txtDiners") as TextBox; //if (meal != null) //{ // txtDiners.Text = meal.Diners.ToString(); //} //txtDiners.Attributes["OnChange"] = string.Format("DinersChange(this,{0},{1},{2})", this.MenuId, dayIndex, mealTypeId); } }
protected void mydetails_ItemDataBound(object sender, ListViewItemEventArgs e) { Label _id = (Label)e.Item.FindControl("so_itm_idLabel"); BLL_Dml _objbll = new BLL_Dml(); _database _objdb = new _database(); _objdb.DBName = "DB_" + lblprjcode.Text; _clsSO _objcls = new _clsSO(); _objcls.so_id = Convert.ToInt32(_id.Text); Label _details = (Label)e.Item.FindControl("lblDetails"); _details.Text = (_details.Text.ToString()).Replace("\n", " <br /> "); Label _commentText = (Label)e.Item.FindControl("lblCMLComment"); _commentText.Text = (_commentText.Text.ToString()).Replace("\n", " <br /> "); Label _responseText = (Label)e.Item.FindControl("lblSOResponse"); _responseText.Text = (_responseText.Text.ToString()).Replace("\n", " <br /> "); ListView _sophoto = (ListView)e.Item.FindControl("lvPhoto"); _sophoto.DataSource = _objbll.Load_SO_Photo(_objcls, _objdb); _sophoto.DataBind(); Button _edit = (Button)e.Item.FindControl("EditButton"); Button _comment = (Button)e.Item.FindControl("CommetButton"); if (lblprjcode.Text == "11736" || lblprjcode.Text == "HMIM" || lblprjcode.Text == "HMHS" || lblprjcode.Text == "123" || lblprjcode.Text == "demo") { if ((string)Session["group"] != "ADMIN GROUP" && (string)Session["group"] != "SYS.ADMIN GROUP") { _comment.Visible = false; } } else { _comment.Visible = false; } if ((string)Session["uid"].ToString().ToLower() != lbissued.Text.ToLower()) { _edit.Visible = false; } if (lblPermission.Text == "1") { _edit.Visible = true; } HtmlTableCell _th3 = (HtmlTableCell)mydetails.FindControl("th3"); _th3.Visible = (_edit.Visible || _comment.Visible) ? true : false; Th33.Visible = _th3.Visible; if (e.Item.ItemType == ListViewItemType.DataItem) { HtmlTableCell _td1 = (HtmlTableCell)e.Item.FindControl("td1"); HtmlTableCell _td2 = (HtmlTableCell)e.Item.FindControl("tdStatus"); HtmlTableCell _th1 = (HtmlTableCell)mydetails.FindControl("th1"); HtmlTableCell _th2 = (HtmlTableCell)mydetails.FindControl("th2"); HtmlTableCell _td3 = (HtmlTableCell)e.Item.FindControl("tdButton"); _td3.Visible = _th3.Visible; if (lblprjcode.Text != "11736" && lblprjcode.Text != "HMIM" && lblprjcode.Text != "HMHS" && lblprjcode.Text != "123" && lblprjcode.Text != "demo") { _td1.Visible = false; if (lblprjcode.Text != "MOE") { //Show status column for MOE _td2.Visible = false; Th22.Visible = false; _th2.Visible = false; } _th1.Visible = false; Th11.Visible = false; trViewCMLComment.Visible = false; trViewCMLCommentLabel.Visible = false; RadWindow_Response.Style.Add("height", "300px"); } else { if (_th3.Visible) { HtmlTableCell _tdPhoto = (HtmlTableCell)e.Item.FindControl("tdPhoto"); ListView _lvPhoto = (ListView)_tdPhoto.FindControl("lvPhoto"); if (_lvPhoto.Controls.Count > 0) { for (int k = 0; k < _lvPhoto.Controls[0].Controls.Count; k++) { for (int i = 0; i < _lvPhoto.Controls[0].Controls[k].Controls.Count; i++) { HtmlTable _tbl = (HtmlTable)_lvPhoto.Controls[0].Controls[k].Controls[i].FindControl("tblPhoto"); _tbl.Style.Add("Width", "100%"); } } } } } } }
// Deleta o(s) recurso(s) selecionado(s) protected void butDeletar_Click(object sender, ImageClickEventArgs e) { ImageButton butDel = (ImageButton)sender; // O checkbox list está dentro da célula da tabela... HtmlTableCell cell = (HtmlTableCell)butDel.Parent; CheckBoxList cbList = (CheckBoxList)cell.FindControl("cbRecursos"); // Para chegar no DataGridItem correspondente... bleargh! DataGridItem grid = (DataGridItem)cell.Parent.Parent.Parent.Parent.Parent; DropDownList ddlDisponiveis = (DropDownList)grid.FindControl("ddlDisponiveis"); string dataString = ((Label)grid.FindControl("lblData")).Text; DateTime data = Convert.ToDateTime(dataString); string horario = ((Label)grid.FindControl("lblHora")).Text; string aulaString = ((Label)grid.FindControl("lblAulaId")).Text; Guid aulaId = new Guid(aulaString); Aula aula = aulaBo.GetAulaById(aulaId); // Varre o checkbox list do fim para o início, // e remove todos os recursos selecionados (da tela e do BD) List <Recurso> listaRecLib = new List <Recurso>(); for (int r = cbList.Items.Count - 1; r >= 0; r--) { ListItem recurso = cbList.Items[r]; if (recurso.Selected) { Guid recId = new Guid(recurso.Value); Recurso rec = recursosBO.GetRecursoById(recId); Alocacao aloc = new Alocacao(rec, data, horario, null, null); alocBO.UpdateAlocacao(aloc); cbList.Items.RemoveAt(r); // TODO: melhorar isso - só envia email se forem recursos com a palavra "lab" em algum lugar if (rec.Categoria.Descricao.ToLower().Contains("lab")) { listaRecLib.Add(rec); } } } //ImageButton butDel = (ImageButton)grid.FindControl("butDeletar"); ImageButton butTransf = (ImageButton)grid.FindControl("butTransferir"); ImageButton butTrocar = (ImageButton)grid.FindControl("butTrocar"); // Se nenhum restou, esconde botões if (cbList.Items.Count == 0) { butDel.Visible = false; butTransf.Visible = false; butTrocar.Visible = false; } // Recria o dropdownlist de recursos disponíveis //ddlDisponiveis.Items.Clear(); List <Recurso> livres = recursosBO.GetRecursosDisponiveis(data, horario); livres.Sort(); Recurso dummy = new Recurso(); dummy.Descricao = "Selecionar..."; dummy.Id = dummyGuid; livres.Insert(0, dummy); ddlDisponiveis.DataValueField = "Id"; ddlDisponiveis.DataTextField = "Descricao"; ddlDisponiveis.DataSource = livres; ddlDisponiveis.DataBind(); AtualizaTodaGrade(); if (listaRecLib.Count > 0) { EnviarEmailLiberacao("*****@*****.**", listaRecLib, data, horario); } }
protected void FillMagazineData(object sender, EventArgs e) { GetSelectedIssuePublicationDate(); lbl_edit_book_links.Text = "Edit magazine info for the " + Server.HtmlEncode(dd_issues.SelectedItem.Text) + " publication."; String qry = "SELECT * FROM db_magazinelinks WHERE IssueName=@book_name"; DataTable dt_links = SQL.SelectDataTable(qry, "@book_name", dd_issues.SelectedItem.Text); String link = String.Empty; String img_url = String.Empty; TextBox tb_link = null; foreach (HtmlTableRow ctrl in div_mags.Controls[0].Controls) { foreach (HtmlTableCell tc in ctrl.Controls) { for (int j = 0; j < tc.Controls.Count; j++) { Control c = tc.Controls[j]; if (c is TextBox) { TextBox tb = (TextBox)c; tb.Text = String.Empty; if (tb.ID.Contains("tb_url")) { link = tb.Text.Trim(); tb_link = tb; } else if (tb.ID.Contains("tb_img")) { String mag_id = tb.ID.Substring(tb.ID.IndexOf("-") + 1); img_url = tb.Text.Trim(); for (int i = 0; i < dt_links.Rows.Count; i++) { if (dt_links.Rows[i]["MagazineID"].ToString() == mag_id) { tb.Text = dt_links.Rows[i]["MagazineImageURL"].ToString(); tb_link.Text = dt_links.Rows[i]["MagazineLink"].ToString(); // Add a preview image to preview cell if (tb.Text != String.Empty) { HtmlTableCell cell = ((HtmlTableRow)tb.Parent.Parent).Cells[3]; HyperLink hl = new HyperLink(); hl.ID = "img_" + mag_id; hl.ImageUrl = tb.Text + "?v=" + DateTime.Now.Ticks; if (tb_link.Text.Trim() != String.Empty && (tb_link.Text.Contains("http") || tb_link.Text.Contains("www"))) { hl.NavigateUrl = tb_link.Text; hl.Target = "_blank"; } hl.Attributes.Add("style", "display:none;"); String dead_img_alert = String.Empty; if (!Util.UrlExists(tb.Text)) { dead_img_alert = "alert('The URL to this cover thumbnail image is broken. Please update the Cover Image URL, save, and re-check OR make sure the image exists at the existing URL and click the Refresh Cover Images button.'); "; } Button btn_preview = ((Button)cell.FindControl("btn_" + mag_id)); btn_preview.Attributes.Clear(); btn_preview.Attributes.Add("enabled", "true"); btn_preview.OnClientClick = "var img = grab('Body_" + hl.ClientID + "'); " + "if(img.style.display=='block'){ " + " img.style.display='none';} " + "else{ " + " img.style.display='block'; " + dead_img_alert + " } " + "return false;"; //cell.Controls.Add(hl); ((HtmlTableRow)tb.Parent.Parent).Cells[1].Controls.Add(hl); } break; } } link = img_url = String.Empty; tb_link = null; } } } } } }