Пример #1
0
        protected void gvResult_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            SubjectCollection dt = ((SubjectCollection)this.gvResult.DataSource);

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                PubEntAdmin.BLL.Subject l_conf = dt[e.Item.ItemIndex];

                e.Item.Cells[0].Text = l_conf.CannotRem.ToString();

                ((Label)e.Item.Cells[2].Controls[1]).Text = Server.HtmlEncode(l_conf.SubjName);

                //----------------------------------------
                string a = "";

                if (l_conf.InNCIPL)
                {
                    a = "NCIPL";
                }
                if (l_conf.InROO)
                {
                    if (a.Length != 0)
                    {
                        a += "<br />";
                    }
                    a += "NCIPLcc";
                }
                if (l_conf.InExh)
                {
                    if (a.Length != 0)
                    {
                        a += "<br />";
                    }
                    a += "Exhibit";
                }
                if (l_conf.InCatalog)
                {
                    if (a.Length != 0)
                    {
                        a += "<br />";
                    }
                    a += "Catalog";
                }

                if (a.Length != 0)
                {
                    ((Label)e.Item.Cells[3].Controls[1]).Text = a;
                }
                else
                {
                    ((Label)e.Item.Cells[3].Controls[1]).Text = "N/A";
                }

                //----------------------------------------
                ((Label)e.Item.Cells[4].Controls[1]).Text = l_conf.HasSubCat.ToString();
                //----------------------------------------
                ((Label)e.Item.FindControl("lblStatus1")).Text = l_conf.Active ? "Active" : "Inactive";
                //----------------------------------------
                //delete btn col
                Button l_able = e.Item.Cells[7].FindControl("lnkbtnDel") as Button;

                if (l_conf.Active)
                {
                    l_able.Text = "Inactivate";
                    Panel l_pnl = e.Item.Cells[7].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to inactivate this Subject [" + Server.HtmlEncode(l_conf.SubjName) + "]?<br />NOTE: If the Category has SubCategories they will also be inactivated!";
                }
                else
                {
                    l_able.Text = "Activate";
                    Panel l_pnl = e.Item.Cells[7].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to activate this Subject [" + Server.HtmlEncode(l_conf.SubjName) + "]?";
                }
            }
            else if (e.Item.ItemType == ListItemType.EditItem)
            {
                PubEntAdmin.BLL.Subject l_conf = dt[e.Item.ItemIndex];

                e.Item.Cells[0].Text = l_conf.CannotRem.ToString();

                ((TextBox)e.Item.Cells[2].Controls[1]).Text = Server.HtmlEncode(l_conf.SubjName);
                //----------------------------------------

                if (l_conf.InNCIPL)
                {
                    ((LiveIntSel)e.Item.Cells[3].Controls[1]).InNCIPL = true;
                }
                if (l_conf.InROO)
                {
                    ((LiveIntSel)e.Item.Cells[3].Controls[1]).InROO = true;
                }
                if (l_conf.InExh)
                {
                    ((LiveIntSel)e.Item.Cells[3].Controls[1]).InExh = true;
                }
                if (l_conf.InCatalog)
                {
                    ((LiveIntSel)e.Item.Cells[3].Controls[1]).InCatalog = true;
                }

                //----------------------------------------
                if (e.Item.Cells[4].Controls[1] is CheckBox)
                {
                    CheckBox l_chkboxRemove = ((CheckBox)e.Item.FindControl("ckboxHasSubCat"));

                    l_chkboxRemove.Attributes.Add("onclick", @"(!this.checked)?alert('NOTE:\nALL the SubCategories and SubSubCategories assigned\nto this Category will be disabled!'):''");
                    ((CheckBox)e.Item.Cells[4].Controls[1]).Checked = l_conf.HasSubCat;
                }
                //----------------------------------------
                ((Label)e.Item.FindControl("lblStatus2")).Text = l_conf.Active ? "Active" : "Inactive";
                //----------------------------------------

                if (e.Item.Cells[6].Controls[2] is Button)
                {
                    Button l_btnCancel = ((Button)e.Item.Cells[6].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_ok.CssClass     = "btn";
                    l_cancel.ID       = "l_cancel";
                    l_cancel.Text     = "Cancel";
                    l_cancel.CssClass = "btn";
                    l_div.Controls.Add(l_ok);
                    l_div.Controls.Add(new LiteralControl("&nbsp;"));
                    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[5].Controls.Add(l_panel);
                    e.Item.Cells[5].Controls.Add(l_mpe);
                    e.Item.Cells[5].Controls.Add(l_cbe);
                }
                //----------------------------------------
                //delete btn col
                Button l_able = e.Item.Cells[7].FindControl("lnkbtnDel") as Button;

                if (l_conf.Active)
                {
                    l_able.Text = "Inactivate";
                    Panel l_pnl = e.Item.Cells[7].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to inactivate this Subject [" + Server.HtmlEncode(l_conf.SubjName) + "]?<br />NOTE: If the Category has SubCategories they will also be inactivated!";
                }
                else
                {
                    l_able.Text = "Activate";
                    Panel l_pnl = e.Item.Cells[7].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to activate this Subject [" + Server.HtmlEncode(l_conf.SubjName) + "]?";
                }
            }
        }