protected void gvResult_DeleteCommand(object source, DataGridCommandEventArgs e) { ProductFormatCollection dt = ((ProductFormatCollection)this.gvResult.DataSource); PubEntAdmin.BLL.ProductFormat l_conf = dt[e.Item.ItemIndex]; int Pftid = l_conf.PftID; string Pftname = l_conf.PftName; string Activestatus = ((Button)e.Item.Cells[4].Controls[7]).Text; if (Activestatus == "Inactive") { Boolean pftExist = LU_DAL.PftExist(Pftid); if (pftExist == false) { LU_DAL.DeleteProductFormatLU(Pftid); Response.Redirect("~/LookupMgmt.aspx?sub=prodformat"); } else if (pftExist == true) { string confirm = "Unable to Inactivate, value associated with Publication."; ((Label)e.Item.Cells[5].Controls[1]).Text = confirm; } } if (Activestatus == "Active") { int Active = 1; LU_DAL.UpdateProductFormatLU(Pftid, Pftname, Active); Response.Redirect("~/LookupMgmt.aspx?sub=prodformat"); } }
protected void gvResult_UpdateCommand(object source, DataGridCommandEventArgs e) { ProductFormatCollection dt = ((ProductFormatCollection)this.gvResult.DataSource); PubEntAdmin.BLL.ProductFormat l_conf = dt[e.Item.ItemIndex]; int Pftid = l_conf.PftID; string Pftname = ((TextBox)e.Item.Cells[1].Controls[1]).Text; int Active = 0; string sActive = ((Label)e.Item.Cells[2].Controls[1]).Text; if (sActive == "Active") { Active = 1; } else { Active = 0; } Boolean valid = false; Boolean validnum = false; Boolean validlen = false; if (Pftname.Length != 0) { valid = PubEntAdminManager.OtherVal(Pftname); validnum = PubEntAdminManager.SpecialVal2(Pftname); validlen = PubEntAdminManager.LenVal(Pftname, 50); } if ((valid == false) && (validnum == false) && (validlen == true)) { LU_DAL.UpdateProductFormatLU(Pftid, Pftname, Active); Response.Redirect("~/LookupMgmt.aspx?sub=prodformat"); } else { Response.Redirect("InvalidInput.aspx"); } }
protected void gvResult_ItemDataBound(object sender, DataGridItemEventArgs e) { ProductFormatCollection dt = ((ProductFormatCollection)this.gvResult.DataSource); if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { PubEntAdmin.BLL.ProductFormat l_conf = dt[e.Item.ItemIndex]; ((Label)e.Item.Cells[1].Controls[1]).Text = Server.HtmlEncode(l_conf.PftName); //delete btn col Button l_able = e.Item.Cells[5].FindControl("lnkbtnDel") as Button; if (l_conf.Checked) { ((Label)e.Item.Cells[2].Controls[1]).Text = "Active"; l_able.Text = "Inactivate"; Panel l_pnl = e.Item.Cells[5].FindControl("pnlConfirmDel") as Panel; ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to inactivate this Lookup Value [" + Server.HtmlEncode(l_conf.PftName) + "]?"; } else { ((Label)e.Item.Cells[2].Controls[1]).Text = "Inactive"; l_able.Text = "Activate"; Panel l_pnl = e.Item.Cells[5].FindControl("pnlConfirmDel") as Panel; ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to activate this Lookup Value [" + Server.HtmlEncode(l_conf.PftName) + "]?"; } } else if (e.Item.ItemType == ListItemType.EditItem) { PubEntAdmin.BLL.ProductFormat l_conf = dt[e.Item.ItemIndex]; String status = ""; if (l_conf.Checked == true) { status = "Active"; } else { status = "Inactive"; } ((Label)e.Item.Cells[2].Controls[1]).Text = status; if (e.Item.Cells[3].Controls[2] is Button) { Button l_btnCancel = ((Button)e.Item.Cells[3].Controls[2]); l_btnCancel.ID = "gvResult_Cancel"; Panel l_panel = new Panel(); l_panel.ID = "l_panel"; l_panel.CssClass = "modalPopup"; l_panel.Style.Add("display", "none"); l_panel.Width = Unit.Pixel(233); Label l_label = new Label(); l_label.Text = "Are you sure you want to continue?"; HtmlGenericControl l_div = new HtmlGenericControl(); Button l_ok = new Button(); Button l_cancel = new Button(); l_ok.ID = "l_ok"; l_ok.Text = "OK"; l_cancel.ID = "l_cancel"; l_cancel.Text = "Cancel"; l_div.Controls.Add(l_ok); l_div.Controls.Add(new LiteralControl(" ")); l_div.Controls.Add(l_cancel); l_div.Attributes.Add("align", "center"); l_panel.Controls.Add(l_label); l_panel.Controls.Add(new LiteralControl("<br>")); l_panel.Controls.Add(new LiteralControl("<br>")); l_panel.Controls.Add(l_div); ModalPopupExtender l_mpe = new ModalPopupExtender(); l_mpe.ID = "l_mpe"; l_mpe.TargetControlID = l_btnCancel.ID; l_mpe.PopupControlID = l_panel.ID; l_mpe.BackgroundCssClass = "modalBackground"; l_mpe.DropShadow = true; l_mpe.OkControlID = l_ok.ID; l_mpe.CancelControlID = l_cancel.ID; ConfirmButtonExtender l_cbe = new ConfirmButtonExtender(); l_cbe.TargetControlID = l_btnCancel.ID; l_cbe.ConfirmText = ""; l_cbe.DisplayModalPopupID = l_mpe.ID; e.Item.Cells[3].Controls.Add(l_panel); e.Item.Cells[3].Controls.Add(l_mpe); e.Item.Cells[3].Controls.Add(l_cbe); } //delete btn col Button l_able = e.Item.Cells[5].FindControl("lnkbtnDel") as Button; if (l_conf.Checked) { ((Label)e.Item.Cells[2].Controls[1]).Text = "Active"; l_able.Text = "Inactivate"; Panel l_pnl = e.Item.Cells[5].FindControl("pnlConfirmDel") as Panel; ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to inactivate this Lookup Value [" + Server.HtmlEncode(l_conf.PftName) + "]?"; } else { ((Label)e.Item.Cells[2].Controls[1]).Text = "Active"; l_able.Text = "Activate"; Panel l_pnl = e.Item.Cells[5].FindControl("pnlConfirmDel") as Panel; ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to activate this Lookup Value [" + Server.HtmlEncode(l_conf.PftName) + "]?"; } } }