protected void DiscoveryUrl_Update(object sender, DataGridCommandEventArgs e) { Page.Validate(); if (Page.IsValid) { int index = grid.EditItemIndex; if (index == discoveryUrls.Count) { discoveryUrls.Add(); } DiscoveryUrl discoveryUrl = discoveryUrls[index]; DataGridItem item = grid.Items[index]; discoveryUrl.Value = ((TextBox)item.FindControl("discoveryUrl")).Text; discoveryUrl.UseType = ((TextBox)item.FindControl("useType")).Text; parentEntity.Save(); grid.EditItemIndex = -1; grid.ShowFooter = true; CancelEditMode(); this.discoveryUrls = ShuffleData(parentEntity.DiscoveryUrls); PopulateDataGrid(); } }
protected void dgPriceMarckups_ItemDataBound(object sender, DataGridItemEventArgs e) { DataGridItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is IGrouping <int, DistributorPriceMarkupBO> ) { var lstPriceMarckups = ((IGrouping <int, DistributorPriceMarkupBO>)item.DataItem).ToList(); DistributorPriceMarkupBO objPriceMarckup = lstPriceMarckups[0]; ((System.Web.UI.WebControls.WebControl)(item)).CssClass = "irow_" + objPriceMarckup.Distributor.ToString(); Literal litDistributor = (Literal)item.FindControl("litDistributor"); litDistributor.Text = objPriceMarckup.Distributor.ToString(); Literal lblDistributor = (Literal)item.FindControl("lblDistributor"); lblDistributor.Text = ((objPriceMarckup.Distributor > 0) ? objPriceMarckup.objDistributor.Name : "PLATINUM"); Repeater rptDistributorPriceLevels = (Repeater)item.FindControl("rptDistributorPriceLevels"); rptDistributorPriceLevels.DataSource = lstPriceMarckups; rptDistributorPriceLevels.DataBind(); HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit"); linkEdit.Attributes.Add("qid", objPriceMarckup.Distributor.ToString()); linkEdit.Attributes.Add("isType", "distributor"); HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objPriceMarckup.Distributor.ToString()); linkDelete.Attributes.Add("isType", "distributor"); if (lblDistributor.Text == "PLATINUM") { linkDelete.Visible = false; } } }
protected void dataGridCompany_ItemDataBound(object sender, DataGridItemEventArgs e) { DataGridItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is CompanyBO) { CompanyBO objCompany = (CompanyBO)item.DataItem; //HyperLink lnkEdit = (HyperLink)item.FindControl("lnkEdit"); HyperLink lnkDelete = (HyperLink)item.FindControl("lnkDelete"); Label lblCompanyType = (Label)item.FindControl("lblCompanyType"); lblCompanyType.Text = objCompany.objType.Name.ToString(); Label lblCoordinator = (Label)item.FindControl("lblCoordinator"); if (objCompany.Coordinator != 0) { lblCoordinator.Text = objCompany.objCoordinator.GivenName + "" + objCompany.objCoordinator.FamilyName; } else { lblCoordinator.Text = "No Coordinator"; } } }
private void BindGrilla() { SisPackController.AdministrarGrillas.Configurar(this.dtgGastosDiarios, "GastoDiarioAgenciaID", this.CantidadOpciones); dtgGastosDiarios.AllowPaging = false; if (Session["dsGastos"] == null) { IGastoDiarioAgencia gastoDA = GastoDiarioAgenciaFactory.GetGastoDiarioAgencia(); gastoDA.AgenciaID = this.AgenciaConectadaID; this.dsGastosDA = gastoDA.GetGastosDiariosAgenciasDataSet(); } else { this.dsGastosDA = (DsGastosDiariosAgencias)Session["dsGastos"]; if (this.dtgGastosDiarios.EditItemIndex != -1) { DataGridItem item = this.dtgGastosDiarios.Items[this.dtgGastosDiarios.EditItemIndex]; DsGastosDiariosAgencias.DatosRow dr = (DsGastosDiariosAgencias.DatosRow) this.dsGastosDA.Datos.Rows[item.DataSetIndex]; try { dr.ConceptoGastoID = ((DropDownList)item.FindControl("ddlConceptoGasto")).SelectedValue == "" ? 0 : Convert.ToInt32(((DropDownList)item.FindControl("ddlConceptoGasto")).SelectedValue); dr.GastoImporte = ((TextBox)item.FindControl("txtGastoImporte")).Text == "" ? 0 : Convert.ToDouble(((TextBox)item.FindControl("txtGastoImporte")).Text); } catch (Exception) {} dr.Observaciones = ((TextBox)item.FindControl("txtObservaciones")).Text; } } Session["dsGastos"] = this.dsGastosDA; this.dtgGastosDiarios.DataSource = this.dsGastosDA; this.dtgGastosDiarios.CurrentPageIndex = 0; this.dtgGastosDiarios.DataBind(); }
private void Update(DataGridItem e) { try { Label lblId = e.FindControl("lblId") as Label; var id = lblId.Text; string name = (e.FindControl("txtCatName") as TextBox).Text; bool isSub = (e.FindControl("chkSubCat") as CheckBox).Checked; bool active = (e.FindControl("chkActive") as CheckBox).Checked; int parentId = 0; if (isSub) { parentId = Convert.ToInt32((e.FindControl("ddlCat") as DropDownList).SelectedValue); } List <SqlParameter> pars = new List <SqlParameter>(); pars.Add(new SqlParameter("@Id", id)); pars.Add(new SqlParameter("@Name", name)); pars.Add(new SqlParameter("@IsSubCat", isSub)); pars.Add(new SqlParameter("@Active", active)); pars.Add(new SqlParameter("@ParentId", parentId)); DBHelper.ExecuteNonQuery("sp_Category_Update", pars); Notify.ShowAdminMessageSuccess("Update thành công", this.Page); dtgCategory.CurrentPageIndex = 0; LoadGrid(); } catch { Notify.ShowAdminMessageError("Lỗi", this.Page); LoadGrid(); return; } }
protected void butTrocar_Click(object sender, EventArgs e) { ImageButton but = (ImageButton)sender; DataGridItem grid = (DataGridItem)but.Parent.Parent.Parent.Parent.Parent.Parent; Label lblData = (Label)grid.FindControl("lblData"); Label lblHora = (Label)grid.FindControl("lblHora"); Label lblaulaId = (Label)grid.FindControl("lblAulaId"); List <string> recursos = new List <string>(); CheckBoxList cbRecursos = (CheckBoxList)grid.FindControl("cbRecursos"); foreach (ListItem rec in cbRecursos.Items) { recursos.Add(rec.Value); } Session["RecursosIds"] = recursos; // abre a popup de transferir recursos Session["DataAula"] = lblData.Text; Session["Horario"] = lblHora.Text; string id = lblaulaId.Text; ScriptManager.RegisterClientScriptBlock(this, GetType(), "OnClick", @"popitup('TrocarRecurso.aspx?AulaId=" + id + "',350,300);", true); // Salva a grade antes de selecionar os recursos AtualizaTodaGrade(); }
// Atualiza o dropdownlist de seleção de recursos e o checkbox list dos selecionados, // para uma determinada linha da tabela private void AtualizaComponentes(DataGridItem grid, String dataString, String horario, String aulaString) { CheckBoxList cbRecursos = (CheckBoxList)grid.FindControl("cbRecursos"); ImageButton butDel = (ImageButton)grid.FindControl("butDeletar"); ImageButton butTransf = (ImageButton)grid.FindControl("butTransferir"); ImageButton butTrocar = (ImageButton)grid.FindControl("butTrocar"); DateTime data = Convert.ToDateTime(dataString); AlocacaoBO alocBO = new AlocacaoBO(); List <Recurso> recAlocados = alocBO.GetRecursoAlocadoByAula(data, horario, new Guid(aulaString)); cbRecursos.Items.Clear(); if (recAlocados.Count != 0) { // Habilita botões butDel.Visible = true; butTransf.Visible = true; butTrocar.Visible = true; foreach (Recurso r in recAlocados) { cbRecursos.Items.Add(new ListItem(r.Descricao, r.Id.ToString())); } } else { // Desabilita botões butDel.Visible = false; butTransf.Visible = false; butTrocar.Visible = false; } }
protected void ddltextbook_SelectedIndexchanged(object sender, EventArgs e) { DataAccess da = new DataAccess(); DataSet ds = new DataSet(); DropDownList list = (DropDownList)sender; TableCell cell = list.Parent as TableCell; DataGridItem item = cell.Parent as DataGridItem; int index = item.ItemIndex; DropDownList dltextbook = new DropDownList(); DropDownList dlunit = new DropDownList(); DropDownList dllesson = new DropDownList(); dltextbook = (DropDownList)item.FindControl("ddltextbook"); dlunit = (DropDownList)item.FindControl("ddlunitname"); dllesson = (DropDownList)item.FindControl("ddllesson"); strsql = "select distinct strunitno from tblschooltextbookunits where inttextbook=" + dltextbook.SelectedValue; ds = da.ExceuteSql(strsql); dlunit.DataSource = ds; dlunit.DataTextField = "strunitno"; dlunit.DataValueField = "strunitno"; dlunit.Items.Clear(); dlunit.DataBind(); strsql = ""; strsql = "select distinct strlessonname from tblschoolsyllabus where inttextbook=" + dltextbook.SelectedValue + " and strunitno='" + dlunit.SelectedValue + "'"; ds = da.ExceuteSql(strsql); dllesson.DataSource = ds; dllesson.DataTextField = "strlessonname"; dllesson.DataValueField = "strlessonname"; dllesson.Items.Clear(); dllesson.DataBind(); }
private void Update(DataGridItem e) { try { Label lblId = e.FindControl("lblId") as Label; var id = lblId.Text; TextBox txtName = e.FindControl("txtName") as TextBox; TextBox txtAddress = e.FindControl("txtAddress") as TextBox; DropDownList ddlType = e.FindControl("ddlType") as DropDownList; List <SqlParameter> pars = new List <SqlParameter>(); pars.Add(new SqlParameter("@Name", txtName.Text)); pars.Add(new SqlParameter("@Address", txtAddress.Text)); pars.Add(new SqlParameter("@Type", ddlType.SelectedValue)); pars.Add(new SqlParameter("@Id", id)); DBHelper.ExecuteNonQuery("sp_Support_Update", pars); Notify.ShowAdminMessageSuccess("Cập nhật thành công", this.Page); dtgSupport.CurrentPageIndex = 0; LoadGrid(); } catch { Notify.ShowAdminMessageError("Lỗi", this.Page); LoadGrid(); return; } }
protected void btnupdate_Click(object sender, EventArgs e) { try { DataAccess da = new DataAccess(); DataSet ds; for (int i = 0; i < dglesson.Items.Count; i++) { DataGridItem dg = dglesson.Items[i]; DropDownList strunit = (DropDownList)dg.FindControl("ddlunitname"); DropDownList strlesson = (DropDownList)dg.FindControl("ddllesson"); TextBox strtopic = new TextBox(); strtopic = (TextBox)dg.FindControl("txttopic"); TextBox strdescription = new TextBox(); strdescription = (TextBox)dg.FindControl("txtdescription"); sql = "update tblsetlesson set dtdate='" + dg.Cells[1].Text + "',strlessonname ='" + strlesson.SelectedValue + "',strtopic='" + strtopic.Text + "',strdescription='" + strdescription.Text + "',strunitname='" + strunit.SelectedValue + "' where intid='" + dg.Cells[0].Text + "'"; Functions.UserLogs(Session["UserID"].ToString(), "tblsetlesson", dg.Cells[0].Text, "Updated", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 60); ds = new DataSet(); ds = da.ExceuteSql(sql); } sql = "update tblsetlessonreqchanges set intchanges=1 where intidlessondetails='" + editintid + "'"; Functions.UserLogs(Session["UserID"].ToString(), "tblsetlesson", editintid, "Updated", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 60); DataSet ds5 = new DataSet(); ds5 = da.ExceuteSql(sql); Response.Redirect("edit_lesson_plan.aspx?up=1"); } catch { } }
protected void ddlunitname_SelectedIndexChanged(object sender, EventArgs e) { DataAccess da = new DataAccess(); DataSet ds; string strsql = ""; DropDownList list = (DropDownList)sender; TableCell cell = list.Parent as TableCell; DataGridItem item = cell.Parent as DataGridItem; int index = item.ItemIndex; DropDownList dlu = new DropDownList(); DropDownList dlL = new DropDownList(); TextBox txttopic = new TextBox(); TextBox txtdescript = new TextBox(); dlu = (DropDownList)item.FindControl("ddlunitname"); dlL = (DropDownList)item.FindControl("ddllesson"); txttopic = (TextBox)item.FindControl("txttopic"); txtdescript = (TextBox)item.FindControl("txtdescription"); DataGridItem dgi = dglesson.Items[index]; string[] unitname = dlu.SelectedValue.ToString().Split('-'); strsql = "select strlessonName,intid from dbo.tblschoolsyllabus where strstandard='" + lblstandard.Text + " - " + lblsection.Text + "' and strsubject='" + lblsubject.Text + "' and strtextbook='" + lbltextbook.Text + "' and strunitno='" + unitname[0] + "'"; ds = new DataSet(); ds = da.ExceuteSql(strsql); dlL.DataSource = ds; dlL.DataTextField = "strlessonName"; dlL.DataValueField = "intid"; dlL.DataBind(); }
private void dtgLocalidades_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { this.dtgLocalidades.EditItemIndex = -1; Session["dsKmsLocalidad"] = null; this.BindGrilla(0); this.dtgLocalidades.DataSource = (DsKmsLocalidad)Session["dsKmsLocalidad"]; this.dtgLocalidades.EditItemIndex = e.Item.ItemIndex; this.dtgLocalidades.DataBind(); DataGridItem item = this.dtgLocalidades.Items[e.Item.ItemIndex]; string localidad = ((DropDownList)item.FindControl("ddlLocalidadTabla")).ClientID; string provinciaTabla = ((DropDownList)item.FindControl("ddlProvinciaTabla")).ClientID; string script2 = "<script language='javascript'>BindLocalidadGrilla" + this.ID + "('" + localidad + "'" + "," + "'" + provinciaTabla + "');</script>" + "<script language='javascript'>ChangeLocalidadGrilla" + this.ID + "('" + localidad + "');</script>"; Page.RegisterStartupScript("BindLocalidadGrilla" + this.ID, script2); string script = "<script language='javascript'>DeshabilitarCombos" + this.ID + "('" + localidad + "'" + "," + "'" + provinciaTabla + "')</script>"; Page.RegisterStartupScript("DeshabilitarCombos2" + this.ID, script); //SisPackController.LlenarCombos.LlenarStringLocalidades(this.txtLocalidadesGrilla); //this.txtLocalidadSelecGrilla.Text = ((Label)item.Cells[4].FindControl("lblLocalidadDestinoID")).Text;//((DropDownList)item.FindControl("ddlLocalidadTabla")).SelectedValue; this.txtLocalidadSelecGrilla.Text = ((Label)item.FindControl("lblLocalidadDestinoID2")).Text; }
private void grdShippingRates_ItemCommand(object source, DataGridCommandEventArgs e) { // Add the new item to the database. if (e.CommandName == "Add" && Page.IsValid) { DataGridItem item = e.Item; TextBox txtNewDescription = (TextBox)item.FindControl("txtNewDescription"); string description = txtNewDescription.Text; TextBox txtNewMinWeight = (TextBox)item.FindControl("txtNewMinWeight"); Decimal newMinWeight = Decimal.Parse(txtNewMinWeight.Text); TextBox txtNewMaxWeight = (TextBox)item.FindControl("txtNewMaxWeight"); Decimal newMaxWeight = Decimal.Parse(txtNewMaxWeight.Text); TextBox txtNewCost = (TextBox)item.FindControl("txtNewCost"); Decimal newCost = Decimal.Parse(txtNewCost.Text); ShippingInfo newShippingInfo = new ShippingInfo { Description = description, MinWeight = newMinWeight, MaxWeight = newMaxWeight, Cost = newCost, ApplyTaxRate = cbApplyTaxRate.Checked }; _controller.AddShippingRate(PortalId, newShippingInfo); BindShippingRates(); } }
protected void dgPatternAccessory_ItemDataBound(object sender, DataGridItemEventArgs e) { DataGridItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is PatternAccessoryBO) { PatternAccessoryBO objPatterAccessory = (PatternAccessoryBO)item.DataItem; Literal lblpattern = (Literal)item.FindControl("lblpattern"); lblpattern.Text = objPatterAccessory.objPattern.Number; Literal lblAccessory = (Literal)item.FindControl("lblAccessory"); lblAccessory.Text = (objPatterAccessory.Accessory != null && objPatterAccessory.Accessory > 0) ? objPatterAccessory.objAccessory.Name : string.Empty; Literal lblAccessoryCategory = (Literal)item.FindControl("lblAccessoryCategory"); lblAccessoryCategory.Text = (objPatterAccessory.Accessory != null && objPatterAccessory.Accessory > 0) ? objPatterAccessory.objAccessory.objAccessoryCategory.Name : string.Empty; HtmlAnchor linkEdit = (HtmlAnchor)item.FindControl("linkEdit"); linkEdit.Attributes.Add("qid", objPatterAccessory.ID.ToString()); linkEdit.Attributes.Add("patid", objPatterAccessory.Pattern.ToString()); linkEdit.Attributes.Add("catid", objPatterAccessory.objAccessory.AccessoryCategory.ToString()); linkEdit.Attributes.Add("accid", objPatterAccessory.Accessory.ToString()); HtmlAnchor linkDelete = (HtmlAnchor)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objPatterAccessory.ID.ToString()); } }
private void Update(DataGridItem e) { try { string id = (e.FindControl("lblId") as Label).Text; string url = (e.FindControl("txtUrl") as TextBox).Text; string detail = (e.FindControl("txtDetail") as TextBox).Text; bool isChecked = (e.FindControl("chkActive") as CheckBox).Checked; List <SqlParameter> pars = new List <SqlParameter>(); pars.Add(new SqlParameter("@Id", id)); pars.Add(new SqlParameter("@Url", url)); pars.Add(new SqlParameter("@Detail", detail)); pars.Add(new SqlParameter("@Active", isChecked)); DBHelper.ExecuteNonQuery("sp_Video_Update", pars); Notify.ShowAdminMessageSuccess("Update thành công", this.Page); dtgVideo.CurrentPageIndex = 0; LoadGrid(); } catch { Notify.ShowAdminMessageError("Lỗi !!!", this.Page); LoadGrid(); return; } }
public void BindGrilla() { SisPackController.AdministrarGrillas.Configurar(this.dtgConceptosGastos, "ConceptoGastoID", this.CantidadOpciones); if (Session["dsGastosAgencia"] == null) { IGastoAgencia gastos = GastoAgenciaFactory.GetGastoAgencia(); gastos.AgenciaID = Convert.ToInt32(this.txtAgenciaID.Text); this.dsGastosAgencia = gastos.GetGastosAgenciasALLDataSet(); } else { this.dsGastosAgencia = (DsGastosAgencias)Session["dsGastosAgencia"]; if (this.dtgConceptosGastos.EditItemIndex != -1) { DataGridItem item = this.dtgConceptosGastos.Items[this.dtgConceptosGastos.EditItemIndex]; DsGastosAgencias.DatosRow dr = (DsGastosAgencias.DatosRow) this.dsGastosAgencia.Datos.Rows[item.DataSetIndex]; TextBox impGastos = (TextBox)item.FindControl("txtGastoImporte"); try { dr.GastoImporte = impGastos.Text != "" ? Convert.ToDouble(impGastos.Text): 0; } catch (Exception) {} dr.ConceptoGastoID = Convert.ToInt32(((Label)item.FindControl("lblConceptoGasto")).Text); } } Session["dsGastosAgencia"] = this.dsGastosAgencia; this.dtgConceptosGastos.CurrentPageIndex = 0; this.dtgConceptosGastos.DataSource = this.dsGastosAgencia; this.dtgConceptosGastos.DataBind(); }
private void BindRow(DataGridItem dgi, DataRowView drv, string type) { ((Label)dgi.FindControl("lbl" + type + "AuxCost")).Text = drv["AuxCostParm"].ToString(); ((Label)dgi.FindControl("lbl" + type + "PerUse")).Text = Convert.ToBoolean(drv["AllowPerUse"]) ? "Yes" : "No"; ((Label)dgi.FindControl("lbl" + type + "PerPeriod")).Text = Convert.ToBoolean(drv["AllowPerPeriod"]) ? "Yes" : "No"; ((Label)dgi.FindControl("lbl" + type + "Description")).Text = drv["Description"].ToString(); }
protected void btnaddunit_Click(object sender, ImageClickEventArgs e) { ImageButton view = (ImageButton)sender; TableCell cell = view.Parent as TableCell; DataGridItem item = cell.Parent as DataGridItem; lblsame.Text = item.Cells[0].Text; ImageButton btnaddunit = (ImageButton)item.FindControl("btnaddunit"); Label lbltextbookname = (Label)item.FindControl("lbltextbookname"); TextBox txttextbookname = (TextBox)item.FindControl("txttextbookname"); Label lblauthorname = (Label)item.FindControl("lblauthorname"); TextBox txtauthorname = (TextBox)item.FindControl("txtauthorname"); da = new DataAccess(); if (btnaddunit.ImageUrl == "../media/images/edit.gif") { btnaddunit.ImageUrl = "../media/images/update.gif"; txttextbookname.Visible = true; lbltextbookname.Visible = false; txtauthorname.Visible = true; lblauthorname.Visible = false; } else { strsql = "update tblschooltextbook set strtextbookname='" + txttextbookname.Text.Replace("'", "''") + "',strauthorname='" + txtauthorname.Text + "' where intid=" + item.Cells[0].Text; Functions.UserLogs(Session["UserID"].ToString(), "tblschooltextbook", item.Cells[0].Text, "Updated", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 190); da.ExceuteSqlQuery(strsql); filltextbook(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Details Update Successfully')", true); } }
protected void DataGrid_Update(object sender, DataGridCommandEventArgs e) { Page.Validate(); if (Page.IsValid) { int index = grid.EditItemIndex; if (index >= phones.Count) { phones.Add(""); } Phone phone = phones[index]; DataGridItem item = grid.Items[index]; phone.Value = ((TextBox)item.FindControl("phone")).Text; phone.UseType = ((TextBox)item.FindControl("useType")).Text; entity.Save(); grid.EditItemIndex = -1; CancelEditMode(); PopulateDataGrid(); } }
protected void dgLabelPriceMarckups_ItemDataBound(object sender, DataGridItemEventArgs e) { DataGridItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is IGrouping <int, LabelPriceMarkupBO> ) { var lstLabelPriceMarckups = ((IGrouping <int, LabelPriceMarkupBO>)item.DataItem).ToList(); LabelPriceMarkupBO objLabelPriceMarckup = lstLabelPriceMarckups[0]; ((System.Web.UI.WebControls.WebControl)(item)).CssClass = "irow_" + objLabelPriceMarckup.Label.ToString(); Literal litLabel = (Literal)item.FindControl("litLabel"); litLabel.Text = objLabelPriceMarckup.Label.ToString(); Literal lblLabel = (Literal)item.FindControl("lblLabel"); lblLabel.Text = objLabelPriceMarckup.objLabel.Name; Repeater rptLabelPriceLevels = (Repeater)item.FindControl("rptLabelPriceLevels"); rptLabelPriceLevels.DataSource = lstLabelPriceMarckups; rptLabelPriceLevels.DataBind(); HyperLink linkLabelEdit = (HyperLink)item.FindControl("linkLabelEdit"); linkLabelEdit.Attributes.Add("qid", objLabelPriceMarckup.Label.ToString()); linkLabelEdit.Attributes.Add("isType", "label"); HyperLink linkLabelDelete = (HyperLink)item.FindControl("linkLabelDelete"); linkLabelDelete.Attributes.Add("qid", objLabelPriceMarckup.Label.ToString()); linkLabelDelete.Attributes.Add("isType", "label"); } }
protected void btndelete_Click(object sender, ImageClickEventArgs e) { ImageButton view = (ImageButton)sender; TableCell cell = view.Parent as TableCell; DataGridItem item = cell.Parent as DataGridItem; TextBox txtunitname = (TextBox)item.FindControl("txtunitname"); ImageButton btnaddunit = (ImageButton)item.FindControl("btnaddunit"); da = new DataAccess(); strsql = "select * from tblschooltextbookunits where inttextbook=" + item.Cells[0].Text; ds = new DataSet(); ds = da.ExceuteSql(strsql); if (ds.Tables[0].Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Sorry Cannont Be Deleted! This Textbook Has Units')", true); } else { da = new DataAccess(); strsql = "delete tblschooltextbook where intid=" + item.Cells[0].Text; Functions.UserLogs(Session["UserID"].ToString(), "tblschooltextbook", item.Cells[0].Text, "Deleted", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 190); da.ExceuteSqlQuery(strsql); filltextbook(); } }
protected void ddlRecurso_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddlRecurso = (DropDownList)sender; string recString = ddlRecurso.SelectedValue; TableCell cell = (TableCell)ddlRecurso.Parent; DataGridItem gridItem = (DataGridItem)cell.Parent; // Salva dados digitados SalvarTodos(); // SalvaDados(gridItem); // abre a popup de selecao de recursos //string id = lblaulaId.Text; //ScriptManager.RegisterClientScriptBlock(this, GetType(), "onClick", "popitup('SelecaoRecursos.aspx?AulaId=" + id + "');", true); Label lblaulaId = (Label)gridItem.FindControl("lblAulaId"); Guid idAula = new Guid(lblaulaId.Text); Aula aulaAtual = aulaBo.GetAulaById(idAula); RequisicoesBO controleRequisicoes = new RequisicoesBO(); IList <Requisicao> requisicoesExistentes = controleRequisicoes.GetRequisicoesPorAula(idAula, cal); int pri = 0; foreach (Requisicao req in requisicoesExistentes) { if (req.Prioridade > pri) { pri = req.Prioridade; } } CategoriaRecursoBO controladorCategorias = new CategoriaRecursoBO(); Guid catId = new Guid(ddlRecurso.SelectedValue); CategoriaRecurso categoria = controladorCategorias.GetCategoriaRecursoById(catId); Requisicao novaReq = Requisicao.NewRequisicao(aulaAtual, categoria, pri + 1); // teste! sempre prioridade + 1 // Insere a nova requisição controleRequisicoes.InsereRequisicao(novaReq); requisicoesExistentes.Add(novaReq); // Atualiza label com os recursos selecionados Label lblRecursosSelecionados = (Label)gridItem.FindControl("lblRecursosSelecionados"); string recursos = ""; foreach (Requisicao r in requisicoesExistentes) { if (recursos != String.Empty) { recursos += "<br/>"; } recursos += r.Prioridade + ": " + r.CategoriaRecurso.Descricao; } lblRecursosSelecionados.Text = recursos; // Remove a categoria selecionada do drop down list ddlRecurso.Items.Remove(ddlRecurso.Items.FindByValue(ddlRecurso.SelectedValue)); ddlRecurso.SelectedIndex = 0; }
protected void BtnShowOrders_Click(object sender, EventArgs e) { Button BtnShowOrders = (Button)sender; DataGridItem dgi = (DataGridItem)BtnShowOrders.NamingContainer; DataGrid DtgCustomerOrderList = (DataGrid)dgi.FindControl("DtgCustomerOrderList"); HtmlControl DivCustomerOrderList = (HtmlControl)dgi.FindControl("DivCustomerOrderList"); if (BtnShowOrders.Text == "+") { //discovery index for Customer int customerIndex; customerIndex = (this.customerList.PageSize * this.customerList.CurrentPageIndex) + dgi.ItemIndex; Customer customerFromLine = this.CustomersLoadedOncePerConvList[customerIndex]; DtgCustomerOrderList.DataSource = customerFromLine.Orders; DtgCustomerOrderList.DataBind(); DtgCustomerOrderList.Visible = true; DivCustomerOrderList.Visible = true; //background-color:White; position:absolute; left:-180px. Positioning, just visual. DivCustomerOrderList.Style[HtmlTextWriterStyle.BackgroundColor] = "White"; DivCustomerOrderList.Style[HtmlTextWriterStyle.Position] = "absolute"; DivCustomerOrderList.Style[HtmlTextWriterStyle.Left] = "-380px"; BtnShowOrders.Text = "-"; } else { DtgCustomerOrderList.Visible = false; DivCustomerOrderList.Visible = false; BtnShowOrders.Text = "+"; } }
private void BindGrilla() { SisPackController.AdministrarGrillas.Configurar(this.dtgDocumentosCobrados, "DocumentoCobradoAgenciaID", this.CantidadOpciones); dtgDocumentosCobrados.AllowPaging = false; if (Session["dsDocumentos"] == null) { IDocumentoCobradoAgencia gastoCA = DocumentoCobradoAgenciaFactory.GetDocumentoCobradoAgencia(); gastoCA.AgenciaID = this.AgenciaConectadaID; this.dsDocumentosCA = gastoCA.GetDocumentosCobradosAgenciasDataSet(); } else { this.dsDocumentosCA = (DsDocumentosCobradosAgencias)Session["dsDocumentos"]; if (this.dtgDocumentosCobrados.EditItemIndex != -1) { DataGridItem item = this.dtgDocumentosCobrados.Items[this.dtgDocumentosCobrados.EditItemIndex]; DsDocumentosCobradosAgencias.DatosRow dr = (DsDocumentosCobradosAgencias.DatosRow) this.dsDocumentosCA.Datos.Rows[item.DataSetIndex]; try { dr.DocumentoNro = ((TextBox)item.FindControl("txtDocumentoNro")).Text; dr.Importe = ((TextBox)item.FindControl("txtImporte")).Text == "" ? 0 : Convert.ToDouble(((TextBox)item.FindControl("txtImporte")).Text); } catch (Exception) {} dr.Observaciones = ((TextBox)item.FindControl("txtObservaciones")).Text; } } Session["dsDocumentos"] = this.dsDocumentosCA; this.dtgDocumentosCobrados.DataSource = this.dsDocumentosCA; this.dtgDocumentosCobrados.CurrentPageIndex = 0; this.dtgDocumentosCobrados.DataBind(); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="value"></param> protected void FetchSubscribers(DataGridItem item) { DropDownList cboSubscribers = (DropDownList)item.FindControl("cboSubscribers"); if (cboSubscribers != null) { // Caricamento dei sottoscrittori configurati e raggiungibili tramite l'url indicato using (Subscriber.Proxy.SubscriberWebService ws = new Subscriber.Proxy.SubscriberWebService()) { ws.Url = Properties.Settings.Default.SubscriberWebServices; cboSubscribers.DataValueField = "Name"; cboSubscribers.DataTextField = "Name"; cboSubscribers.DataSource = ws.GetChannelList(); cboSubscribers.DataBind(); HiddenField hdSubscriber = (HiddenField)item.FindControl("hdSubscriber"); if (hdSubscriber != null && !string.IsNullOrEmpty(hdSubscriber.Value)) { cboSubscribers.SelectedValue = hdSubscriber.Value; } } } }
public void DataBindDependentList(object Sender, System.EventArgs E) { DropDownList ddlType = (DropDownList)Sender; int intType = int.Parse(ddlType.SelectedItem.Value); DropDownList ddlShape = default(DropDownList); DataGridItem item = (DataGridItem)ddlType.Parent.Parent; DataTable sqlTable = new DataTable(); SqlCommand sqlCmd = default(SqlCommand); SqlConnection sqlConn = SMARTSConnectionOpen(); switch (((DropDownList)Sender).ID) { case "ddlRelatedBusiness": ddlShape = (DropDownList)item.FindControl("ddlRelated"); sqlCmd = new SqlCommand(String.Format("GetItem_Contained {0},{1},{2}", Common.TABLE_SHAPE, intType, Common.ABSTRACTION_BUSINESSSTEP), sqlConn); sqlTable = sqlCmd.ExecuteDataTable(sqlConn); ddlShape.DataSource = sqlTable; ddlShape.DataBind(); break; case "ddlStepObjectSystem": case "ddlStepObjectShapeType": ddlShape = (DropDownList)item.FindControl("ddlStepObjectShape"); if (intType == Common.EMPTY_INT) { ddlShape.Items.Clear(); } else { DropDownList ddlSystem = (DropDownList)item.FindControl("ddlStepObjectSystem"); sqlCmd = new SqlCommand(String.Format("GetItem_Contained {0},{1},{2}", Common.TABLE_SHAPE, ddlSystem.SelectedItem.Value, Common.ABSTRACTION_SYSTEMOBJECT), sqlConn); sqlTable = sqlCmd.ExecuteDataTable(sqlConn); //DataRow drTemp = default(DataRow); DropDownList ddlShapeType = (DropDownList)item.FindControl("ddlStepObjectShapeType"); foreach (DataRow drTemp in sqlTable.Rows) { if ((string)drTemp["Related_TypeID"] != ddlShapeType.SelectedItem.Value) { drTemp.Delete(); } } { ddlShape.DataSource = sqlTable; ddlShape.DataBind(); } } grdStepObject.SelectedIndex = grdStepObject.Items.Count; break; } sqlConn.Close(); }
protected void btnaddunit_Click(object sender, ImageClickEventArgs e) { ImageButton view = (ImageButton)sender; TableCell cell = view.Parent as TableCell; DataGridItem item = cell.Parent as DataGridItem; ImageButton btnaddunit = (ImageButton)item.FindControl("btnaddunit"); DropDownList ddlunitno = (DropDownList)item.FindControl("ddlunitno"); //Label lblunitno = (Label)item.FindControl("lblunitno"); //TextBox txtunitname = (TextBox)item.FindControl("txtunitname"); //Label lblunitname = (Label)item.FindControl("lblunitname"); TextBox txtlessonname = (TextBox)item.FindControl("txtlessonname"); //Label lbllessonname = (Label)item.FindControl("lbllessonname"); if (btnaddunit.ImageUrl == "../media/images/add.gif") { da = new DataAccess(); strsql = "select * from tblschoolsyllabus where strstandard='" + ddlstandard.SelectedValue + "' and strsubject='" + ddlsubject.SelectedValue + "' and inttextbook=" + ddltextbook.SelectedValue + " and strunitno='" + ddlunitno.SelectedValue + "' and strlessonname='" + txtlessonname.Text + "' and intschool=" + Session["SchoolID"].ToString(); ds = new DataSet(); ds = da.ExceuteSql(strsql); if (ds.Tables[0].Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Sorry Lesson Name Cannont Be Duplicated')", true); } else { da = new DataAccess(); strsql = "insert into tblschoolsyllabus (strstandard,strsubject,inttextbook,strunitno,strlessonname,intschool,intedit) values("; strsql = strsql + "'" + ddlstandard.SelectedValue + "','" + ddlsubject.SelectedValue + "'," + ddltextbook.SelectedValue + ",'" + ddlunitno.SelectedValue + "','" + txtlessonname.Text + "'," + Session["SchoolID"].ToString() + ",0)"; da.ExceuteSqlQuery(strsql); DataSet ds2 = new DataSet(); strsql = "select max(intid) as intid from tblschoolsyllabus"; ds2 = da.ExceuteSql(strsql); Functions.UserLogs(Session["UserID"].ToString(), "tblschoolsyllabus", ds2.Tables[0].Rows[0]["intid"].ToString(), "Added", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 101); } } else { da = new DataAccess(); strsql = "select * from tblschoolsyllabus where strstandard='" + ddlstandard.SelectedValue + "' and strsubject='" + ddlsubject.SelectedValue + "' and inttextbook=" + ddltextbook.SelectedValue + " and strunitno='" + ddlunitno.SelectedValue + "' and strlessonname='" + txtlessonname.Text + "' and intschool=" + Session["SchoolID"].ToString() + " and intid !=" + item.Cells[0].Text; ds = new DataSet(); ds = da.ExceuteSql(strsql); if (ds.Tables[0].Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Sorry Lesson Name Cannont Be Duplicated')", true); } else { da = new DataAccess(); strsql = "update tblschoolsyllabus set strunitno='" + ddlunitno.SelectedValue + "',strlessonname='" + txtlessonname.Text + "' where intid=" + item.Cells[0].Text; Functions.UserLogs(Session["UserID"].ToString(), "tblschoolsyllabus", item.Cells[0].Text, "Updated", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 101); da.ExceuteSqlQuery(strsql); } } fillgrid(); }
}//End of Remove Button //private void SetData() //{ // int currentCount = 0; // ArrayList arr = (ArrayList)ViewState["SelectedRecords"]; // for (int i = 0; i < DataGrid1.Items.Count; i++) // { // DataGridItem item = DataGrid1.Items[i]; // CheckBox chkAll = ((CheckBox)(item.FindControl("checkAll"))); // if (chkAll != null && chkAll.Checked) // { // chkAll.Checked = true; // } // HtmlInputCheckBox chk = ((HtmlInputCheckBox)(item.FindControl("SelectCheckBox"))); // if (chk != null && chk.Checked) // { // chk.Checked = arr.Contains(item.Cells[i].Text); // if (!chk.Checked && chkAll != null) // chkAll.Checked = false; // else // currentCount++; // } // } // hfCount.Value = (arr.Count - currentCount).ToString(); //} //The GetData function simply retrieves the records for which the user has checked the checkbox, adds them to an ArrayList and then saves the ArrayList to ViewState private void GetData() { ArrayList arr; if (ViewState["SelectedRecords"] != null) { arr = (ArrayList)ViewState["SelectedRecords"]; } else { arr = new ArrayList(); } go = DataGrid1.Items.Count; for (int i = 0; i < DataGrid1.Items.Count; i++) { DataGridItem item = DataGrid1.Items[i]; CheckBox chkAll = ((CheckBox)(item.FindControl("checkAll"))); //CheckBox chkAll = (CheckBox)item.Cells[0].FindControl("chkAll"); //DataGridItem item = DataGrid1.Items[i]; // // Access the CheckBox // CheckBox cb = ((CheckBox)(item.FindControl("SelectCheckBox"))); if (chkAll != null && chkAll.Checked) { //tranid = item.Cells[1].Text; if (!arr.Contains(item.Cells[1].Text)) { arr.Add(item.Cells[1].Text); } } else { // CheckBox cb = ((CheckBox)(item.FindControl("SelectCheckBox"))); HtmlInputCheckBox chk = ((HtmlInputCheckBox)(item.FindControl("SelectCheckBox"))); if (chk != null && chk.Checked) { if (!arr.Contains(item.Cells[1].Text)) { arr.Add(item.Cells[1].Text); } } else { if (arr.Contains(item.Cells[1].Text)) { arr.Remove(item.Cells[1].Text); } } } } ViewState["SelectedRecords"] = arr; }//End of GetData
protected void dgPrices_ItemDataBound(object sender, DataGridItemEventArgs e) { DataGridItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is IGrouping <int, PriceBO> ) { var lstPrices = ((IGrouping <int, PriceBO>)item.DataItem).ToList(); PriceBO objPrice = lstPrices[0]; if (sportsCategory == string.Empty || (sportsCategory != objPrice.objPattern.objCoreCategory.Name)) { Label lblSportsCategory = (Label)item.FindControl("lblSportsCategory"); lblSportsCategory.Text = objPrice.objPattern.objCoreCategory.Name; sportsCategory = objPrice.objPattern.objCoreCategory.Name; } Label lblPatternNo = (Label)item.FindControl("lblPatternNo"); lblPatternNo.Text = objPrice.objPattern.Number; Label lblOtherCategories = (Label)item.FindControl("lblOtherCategories"); lblOtherCategories.Text = (objPrice.objPattern.PatternOtherCategorysWhereThisIsPattern.Count > 0) ? objPrice.objPattern.PatternOtherCategorysWhereThisIsPattern[0].Name : ""; Label lblNickName = (Label)item.FindControl("lblNickName"); lblNickName.Text = objPrice.objPattern.NickName; HtmlContainerControl dvFabricCodes = (HtmlContainerControl)item.FindControl("dvFabricCodes"); for (int i = 0; i < lstPrices.Count; i++) { if (i == 0) { dvFabricCodes.InnerHtml += "<Label>" + lstPrices[i].objFabricCode.Name + "</label>"; } else { dvFabricCodes.InnerHtml += "<Label class=\"iseparator\">" + lstPrices[i].objFabricCode.Name + "</label>"; } } Label lblModifiedDate = (Label)item.FindControl("lblModifiedDate"); lblModifiedDate.Text = objPrice.ModifiedDate.ToString("MMM dd yyyy"); HyperLink linkEditFactoryCost = (HyperLink)item.FindControl("linkEditFactoryCost"); linkEditFactoryCost.NavigateUrl = "/EditFactoryPrice.aspx?id=" + objPrice.Pattern.ToString(); linkEditFactoryCost.ToolTip = "Edit Factory Cost"; HyperLink linkEditIndimanCost = (HyperLink)item.FindControl("linkEditIndimanCost"); linkEditIndimanCost.NavigateUrl = "/EditIndimanPrice.aspx?id=" + objPrice.Pattern.ToString(); linkEditIndimanCost.ToolTip = "Edit Manufature Cost"; HyperLink linkEditIndicoCost = (HyperLink)item.FindControl("linkEditIndicoCost"); linkEditIndicoCost.NavigateUrl = "/EditIndicoPrice.aspx?pat=" + objPrice.Pattern.ToString(); linkEditIndicoCost.ToolTip = "Edit Sales Cost"; HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objPrice.Pattern.ToString()); } }
private void BindGrid(int currentPage) { try { SisPackController.AdministrarGrillas.Configurar(this.dtgEmails, "EmailID", this.CantidadOpciones); if (Session["dsEmails"] == null) { IEmail emails = EmailFactory.GetEmail(); emails.TipoAvisoID = this.ddlTipoAvisoConsul.SelectedValue.Trim().Equals("")?0:Convert.ToInt32(this.ddlTipoAvisoConsul.SelectedValue.Trim()); this.dsEmails = emails.GetEmailDataSet(); emails = null; } else { this.dsEmails = (DsEmail)Session["dsEmails"]; if (this.dtgEmails.EditItemIndex != -1) { /* Si se desea editar o agregar un registro. */ DataGridItem item = this.dtgEmails.Items[this.dtgEmails.EditItemIndex]; DsEmail.DatosRow dr = (DsEmail.DatosRow) this.dsEmails.Datos.Rows[item.DataSetIndex]; TextBox emailID = (TextBox)item.FindControl("txtEmailID"); dr.EmailID = Convert.ToInt32(emailID.Text.Trim()); TextBox denominacion = (TextBox)item.FindControl("txtDenominacion"); dr.Denominacion = denominacion.Text.Trim(); TextBox direccion = (TextBox)item.FindControl("txtDireccion"); dr.Direccion = direccion.Text.Trim(); DropDownList tipoAviso = (DropDownList)item.FindControl("ddlTipoAviso"); string selValue = tipoAviso.SelectedValue; dr.TipoAvisoID = selValue == "" ? 0 : Convert.ToInt32(selValue); item = null; dr = null; emailID = null; denominacion = null; direccion = null; tipoAviso = null; } } Session["dsEmails"] = this.dsEmails; this.dtgEmails.DataSource = this.dsEmails; this.dtgEmails.CurrentPageIndex = currentPage; this.dtgEmails.DataBind(); } catch (Exception ex) { throw ex; } }
// Atualiza o dropdownlist de seleção de recursos e o checkbox list dos selecionados, // para uma determinada linha da tabela private void AtualizaComponentes(DataGridItem grid, String dataString, String horario, String aulaString) { CheckBoxList cbRecursos = (CheckBoxList)grid.FindControl("cbRecursos"); ImageButton butDel = (ImageButton)grid.FindControl("butDeletar"); ImageButton butTransf = (ImageButton)grid.FindControl("butTransferir"); ImageButton butTrocar = (ImageButton)grid.FindControl("butTrocar"); DateTime data = Convert.ToDateTime(dataString); AlocacaoBO alocBO = new AlocacaoBO(); List<Recurso> recAlocados = alocBO.GetRecursoAlocadoByAula(data, horario, new Guid(aulaString)); cbRecursos.Items.Clear(); if (recAlocados.Count != 0) { // Habilita botões butDel.Visible = true; butTransf.Visible = true; butTrocar.Visible = true; foreach (Recurso r in recAlocados) cbRecursos.Items.Add(new ListItem(r.Descricao, r.Id.ToString())); } else { // Desabilita botões butDel.Visible = false; butTransf.Visible = false; butTrocar.Visible = false; } }
// Salva os dados da linha corrente (chamados pelos eventos de select das drop down lists, etc) private void SalvaDados(DataGridItem gridItem) { // Salva dados digitados Label lblData = (Label)gridItem.FindControl("lblData"); Label lblHora = (Label)gridItem.FindControl("lblHora"); TextBox txtDescricao = (TextBox)gridItem.FindControl("txtDescricao"); DropDownList ddlAtividade = (DropDownList)gridItem.FindControl("ddlAtividade"); Label lblCorDaData = (Label)gridItem.FindControl("lblCorDaData"); Label lblDescData = (Label)gridItem.FindControl("lblDescData"); Label lblaulaId = (Label)gridItem.FindControl("lblAulaId"); Guid idaula = new Guid(lblaulaId.Text); Guid idturma = (Guid)Session["TurmaId"]; Turma turma = turmaBo.GetTurmaById(idturma); string hora = lblHora.Text; DateTime data = Convert.ToDateTime(lblData.Text); string aux = txtDescricao.Text; string descricao = aux.Substring(aux.IndexOf('\n') + 1); Guid idcategoria = new Guid(ddlAtividade.SelectedValue); CategoriaAtividade categoria = categoriaBo.GetCategoriaAtividadeById(idcategoria); if (gridItem.BackColor != Color.LightGray && lblCorDaData.Text.Equals("False")) gridItem.BackColor = categoria.Cor; Aula aula = Aula.GetAula(idaula, turma, hora, data, descricao, categoria); aulaBo.UpdateAula(aula); //txtDescricao.Text = lblDescData.Text + "\n" + descricao; txtDescricao.Text = descricao; }