示例#1
0
        /// <summary>
        /// Load Controls on OnInit event
        /// </summary>
        /// <param name="e"></param>
        override protected void OnInit(EventArgs e)
        {
            BuyerValidations buyerValidationObj = new BuyerValidations();
            int             BuyerID_login       = int.Parse(Session["userId"].ToString());
            List <Property> propertyList        = new List <Property>();

            propertyList = buyerValidationObj.showCart(BuyerID_login);

            if (propertyList == null)
            {
                Response.Write("<script>alert('No Properties');</script>");
            }

            else
            {
                foreach (var k in propertyList)
                {
                    string imgpath = @"Images\home_back.jpeg";


                    // Intializing the UI Controls...

                    Label lblPropname = new Label {
                        CssClass = "space", ForeColor = System.Drawing.Color.DarkBlue
                    };



                    Label lblType = new Label {
                        CssClass = "space"
                    };
                    Label lblPropOption = new Label {
                        CssClass = "space"
                    };
                    Label lblPropDescription = new Label();
                    Label lblAddress         = new Label();
                    Label lblPrice           = new Label();
                    Label lblIntialdeposit   = new Label();
                    Label lblLandMArk        = new Label();


                    //Create Group Container Div
                    HtmlGenericControl div = new HtmlGenericControl("div");
                    div.Attributes.Add("class", "form-group");

                    // dynamic image

                    System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
                    img.ImageUrl = imgpath;

                    // styles

                    lblPropname.Style.Add("font-size", "25px");
                    lblPropname.Style.Add("font-family", "Century Gothic");
                    lblPropname.Style.Add("font-weight", "bold");

                    lblType.Style.Add("font-family", "Century Gothic");
                    lblType.Style.Add("font-weight", "bold");

                    lblPropOption.Style.Add("font-family", "Century Gothic");
                    lblPropOption.Style.Add("font-weight", "bold");



                    lblPropDescription.Style.Add("font-family", "Century Gothic");
                    lblPropDescription.Style.Add("font-weight", "bold");

                    lblAddress.Style.Add("font-family", "Century Gothic");
                    lblAddress.Style.Add("font-weight", "bold");

                    lblPrice.Style.Add("font-family", "Century Gothic");
                    lblPrice.Style.Add("font-weight", "bold");

                    lblIntialdeposit.Style.Add("font-family", "Century Gothic");
                    lblIntialdeposit.Style.Add("font-weight", "bold");

                    lblLandMArk.Style.Add("font-family", "Century Gothic");
                    lblLandMArk.Style.Add("font-weight", "bold");



                    // Mapping the Property data with UI controls...

                    lblPropname.Text = k.PropertyName;

                    lblType.Text       = "Type :  " + k.PropertyType + "    ||    ";
                    lblPropOption.Text = "Option :  " + k.PropertyOption + "    ||    ";
                    // lblPropDescription.Text = "Description : \t" + k.Description;
                    lblAddress.Text       = "Address :  " + k.Address + "        ";
                    lblPrice.Text         = "Price :  " + (int)k.PriceRange + "    ||    ";
                    lblIntialdeposit.Text = "Intial Deposit :  " + (int)k.InitialDeposit + "    ||    ";

                    lblLandMArk.Text = "LandMark :  " + k.Landmark + "  ||  ";


                    // Appending All the UI Controls to stackpanel
                    div.Controls.Add(new LiteralControl("<br/>"));
                    div.Controls.Add(lblPropname);
                    div.Controls.Add(new LiteralControl("<br/><br/>"));
                    div.Controls.Add(img);
                    div.Controls.Add(lblType);

                    div.Controls.Add(lblPropOption);
                    div.Controls.Add(lblPrice);
                    div.Controls.Add(lblIntialdeposit);
                    div.Controls.Add(lblLandMArk);

                    div.Controls.Add(lblAddress);

                    div.Controls.Add(lblPropDescription);

                    //// label for type
                    //div.Controls.Add(new Label()
                    //{
                    //    Text = "Type :" + k.PropertyType,
                    //    CssClass = "col-md-2 control-label"

                    //});



                    //button..
                    string propertyId = k.PropertyId.ToString();
                    var    btnAddcart = new Button
                    {
                        Text     = "Delete from Cart",
                        CssClass = "btn btn-info"
                    };


                    btnAddcart.Style.Add("font-family", "Century Gothic");
                    bodydiv.Controls.Add(div);
                    bodydiv.Controls.Add(btnAddcart);
                    btnAddcart.Click += (s, RoutedEventArgs) => { ConfirmCart(s, e, propertyId); };

                    // GetDataItem owner details..



                    // Adding all the childs to div



                    // After adding all the childs..



                    // After adding all the childs..
                    bodydiv.Controls.Add(new LiteralControl("<br /><br/>"));
                }
            }
        }
        private void btnShow_Click(object sender, RoutedEventArgs e)
        {
            BuyerValidations buval = new BuyerValidations();

            WrapPanel wp = new WrapPanel();


            // border for stackpanel
            Border myBorder1 = new Border();

            if (onlyonce == 0)
            {
                onlyonce++;

                myBorder1.Background      = Brushes.Blue;
                myBorder1.BorderBrush     = Brushes.Orange;
                myBorder1.BorderThickness = new Thickness(1);

                // fetching all the property data from DB

                List <Property> propertyList = new List <Property>();
                propertyList = buval.showCart();

                foreach (var k in propertyList)
                {
                    StackPanel StackOFDetails = new StackPanel();
                    removeIndex++;
                    // Intializing the UI Controls...
                    Button btn                = new Button();
                    Label  lblPropname        = new Label();
                    Label  lblType            = new Label();
                    Label  lblPropOption      = new Label();
                    Label  lblPropDescription = new Label();
                    Label  lblAddress         = new Label();
                    Label  lblPrice           = new Label();
                    Label  lblIntialdeposit   = new Label();
                    Label  lblLandMArk        = new Label();


                    // Mapping the Property data with UI controls...
                    int propId = k.PropertyId;
                    lblPropname.Content        = "Name: " + k.PropertyName;
                    lblType.Content            = "Type: " + k.PropertyType;
                    lblPropOption.Content      = "Option :" + k.PropertyOption;
                    lblPropDescription.Content = "Description :" + k.Description;
                    lblAddress.Content         = "Address :" + k.Address;
                    lblPrice.Content           = "Price: " + k.PriceRange;
                    lblIntialdeposit.Content   = "Intial Deposit: " + k.InitialDeposit;

                    lblLandMArk.Content = "LandMark:" + k.Landmark;
                    btn.Content         = "Delete From Cart";


                    // Appending All the UI Controls to stackpanel

                    StackOFDetails.Children.Add(lblPropname);
                    StackOFDetails.Children.Add(lblType);
                    StackOFDetails.Children.Add(lblPropOption);
                    StackOFDetails.Children.Add(lblPrice);
                    StackOFDetails.Children.Add(lblIntialdeposit);
                    StackOFDetails.Children.Add(lblLandMArk);

                    StackOFDetails.Children.Add(lblAddress);

                    StackOFDetails.Children.Add(lblPropDescription);


                    StackOFDetails.Children.Add(btn);

                    wp.Children.Add(StackOFDetails);

                    // ConfirmCart method will be called and name will be passed to same method...

                    btn.Click += (s, RoutedEventArgs) => { ConfirmCart(sender, e, propId, StackOFDetails, wp); };
                }



                // Adding stackpanel to the WrapPanel...
                MyWrapPanel.Children.Add(wp);
                MyWrapPanel.Children.Add(myBorder1);
            }

            else
            {
                MessageBox.Show("We have listed all the properties in the Cart...!");


                // MyWrapPanel.Children.Remove(wp);
                // MyWrapPanel.Children.Remove(myBorder1);
                // btnShow_Click(sender, e);
            }
        }