コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                omnivoxEntities = new DBOmnivoxEntities();
                Int32 refMemb = Convert.ToInt32(Session["MemberID"]);

                Member myUser = omnivoxEntities.Members.FirstOrDefault(u => u.RefMember == refMemb);


                var msge = (from Message message in omnivoxEntities.Messages
                            join Member member in omnivoxEntities.Members
                            on message.Sender equals member.RefMember
                            where message.Receiver == refMemb
                            select new { message.RefMessage, message.Title, message.Sender, message.New, message.Receiver, member.StudentName }).ToList();

                for (int i = 0; i < msge.Count; i++)
                {
                    TableRow aRow = new TableRow();

                    TableCell aCell = new TableCell();
                    aCell.Controls.Add(new LiteralControl(msge[i].StudentName.ToString()));
                    aCell.DataBind();

                    TableCell bCell = new TableCell();
                    bCell.Controls.Add(new LiteralControl(msge[i].Title.ToString()));
                    bCell.DataBind();

                    TableCell  cCell    = new TableCell();
                    LinkButton btnRdMsg = new LinkButton();
                    btnRdMsg.ID          = "btnRdMsg" + msge[i].RefMessage.ToString();
                    btnRdMsg.Text        = "Read ";
                    btnRdMsg.PostBackUrl = "readMessage.aspx?refmsg=" + msge[i].RefMessage.ToString() + "&sndr=" + msge[i].StudentName;
                    cCell.Controls.Add(btnRdMsg);

                    LinkButton btnDlMsg = new LinkButton();
                    btnDlMsg.ID          = "btnDlMsg" + msge[i].RefMessage.ToString();
                    btnDlMsg.Text        = "  Delete";
                    btnDlMsg.PostBackUrl = "deletemessage.aspx?refmsg=" + msge[i].RefMessage.ToString();
                    cCell.Controls.Add(btnDlMsg);

                    aRow.Cells.Add(aCell);
                    aRow.Cells.Add(bCell);
                    aRow.Cells.Add(cCell);
                    if (Convert.ToBoolean(msge[i].New) == true)
                    {
                        aRow.BackColor = System.Drawing.Color.DarkSalmon;
                        count++;
                    }


                    tabMessages.Rows.Add(aRow);
                }
                litInfo.Text = "Welcome, you have " + count + " new message(s)";
            }
        }
コード例 #2
0
        private TableCell CreateBlockTypeCell(
            string controlId,
            ContentType selectedPageType,
            ContentType disabledPageType)
        {
            TableCell    tableCell    = new TableCell();
            DropDownList dropDownList = new DropDownList();

            dropDownList.ID                    = controlId;
            dropDownList.DataSource            = _contentTypeRepository.List().OfType <BlockType>();
            dropDownList.AutoPostBack          = true;
            dropDownList.DataTextField         = "LocalizedName";
            dropDownList.DataValueField        = nameof(ID);
            dropDownList.SelectedIndexChanged += BlockTypeChanged;
            if (controlId == ToBlockTypeId)
            {
                _ddlTo = dropDownList;
            }

            tableCell.Style.Add("border-bottom", "none");
            tableCell.Controls.Add(dropDownList);
            tableCell.DataBind();

            int id;

            if (disabledPageType != null)
            {
                ListItemCollection items = dropDownList.Items;
                id = disabledPageType.ID;
                string   str     = id.ToString();
                ListItem byValue = items.FindByValue(str);
                if (byValue != null)
                {
                    dropDownList.Items.Remove(byValue);
                }
            }
            if (!(selectedPageType != null))
            {
                return(tableCell);
            }
            ListItemCollection items1 = dropDownList.Items;

            id = selectedPageType.ID;
            string   str1     = id.ToString();
            ListItem byValue1 = items1.FindByValue(str1);

            if (byValue1 == null)
            {
                return(tableCell);
            }
            byValue1.Selected = true;
            return(tableCell);
        }
コード例 #3
0
        protected void Load_Cart()
        {
            List <Product>    product = ProductRepo.getProduct();
            List <Model.Cart> cart    = CartRepo.getListCart();

            for (int i = 0; i < cart.Count; i++)
            {
                TableRow newRow = new TableRow();
                ListCart.Controls.Add(newRow);

                TableCell productNumberCell = new TableCell();
                productNumberCell.Controls.Add(new Label()
                {
                    Text = (i + 1) + "."
                });
                newRow.Cells.Add(productNumberCell);

                TableCell idCartCell = new TableCell();
                idCartCell.Visible = false;
                idCartCell.Controls.Add(new Label()
                {
                    Text = cart.ElementAt(i).CartID.ToString()
                });
                newRow.Cells.Add(idCartCell);


                TableCell productCartCell = new TableCell();
                productCartCell.Controls.Add(new Label()
                {
                    Text = product.ElementAt(i).ProductName
                });
                newRow.Cells.Add(productCartCell);
                productCartCell.DataBind();

                TableCell productPriceCell = new TableCell();
                productPriceCell.Controls.Add(new Label()
                {
                    Text = product.ElementAt(i).Price.ToString()
                });
                newRow.Cells.Add(productPriceCell);

                TableCell productQuantityCell = new TableCell();
                productQuantityCell.Controls.Add(new Label()
                {
                    Text = cart.ElementAt(i).Quantity.ToString()
                });
                newRow.Cells.Add(productQuantityCell);

                TableCell productTotalCell = new TableCell();
                productTotalCell.Controls.Add(new Label()
                {
                    Text = (product.ElementAt(i).Price *cart.ElementAt(i).Quantity).ToString()
                });
                newRow.Cells.Add(productTotalCell);

                TableCell deleteButtonCell = new TableCell();
                Button    deleteButton     = new Button()
                {
                    ID       = (i + 1) + "_D",
                    Text     = "Delete",
                    CssClass = "btn btn-danger"
                };
                deleteButton.Click += deleteButton_Click;
                deleteButtonCell.Controls.Add(deleteButton);
                newRow.Cells.Add(deleteButtonCell);
            }
        }