Beispiel #1
0
        void GridViewBind()
        {
            GoodsActions goodsActions = new GoodsActions();
            List <Goods> listGoods    = goodsActions.GetGoods(selectedCategoryID);

            if (listGoods.Count > 0)
            {
                dataTable.Columns.Add("ID");
                dataTable.Columns.Add("Image");
                dataTable.Columns.Add("Name");
                dataTable.Columns.Add("Price");
                dataTable.Columns.Add("IsDiscount");
                dataTable.Columns.Add("Discount");

                for (int i = 0; i < listGoods.Count; i++)
                {
                    dataTable.Rows.Add(listGoods[i].ID,
                                       string.Format(@"ImageHelp.aspx?imgID={0}",
                                                     listGoods[i].ID),
                                       listGoods[i].Name,
                                       listGoods[i].Price + "грн",
                                       listGoods[i].IsDiscount,
                                       listGoods[i].Discount
                                       );
                }
                ViewState.Add("dataTable", dataTable);

                GridViewGoods.DataSource = dataTable;
                GridViewGoods.DataBind();
            }
            else
            {
                Label1.Text = "This category don`t have a goods";
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GoodsPreviewLastAdded.repeater.ItemCommand += new RepeaterCommandEventHandler(LastAddedNext_ItemCommand);
            GoodsPreviewDiscount.repeater.ItemCommand  += new RepeaterCommandEventHandler(DiscountNext_ItemCommand);
            GoodsPreviewMostSold.repeater.ItemCommand  += new RepeaterCommandEventHandler(MostSoldNext_ItemCommand);

            //if (Cache["LastAdded"] != null)
            //{
            //    GoodsPreviewLastAdded.DataSource = (IList<DataSourceAdapter>)Cache["LastAdded"];
            //}
            //else
            //{
            //    GoodsActions goodsActions = new GoodsActions();
            //    IList<Goods> listGoods = goodsActions.LastAddedGoods(0, 10);
            //    DataSourceAdapterBinding dataSourceAdapterBinding = new DataSourceAdapterBinding();

            //    GoodsPreviewLastAdded.DataSource = dataSourceAdapterBinding.AdapterFill(listGoods);
            //    Cache.Insert("LastAdded", GoodsPreviewLastAdded.DataSource, null,
            //        DateTime.Now.AddMinutes(60), TimeSpan.Zero);
            //}

            if (!Page.IsPostBack)
            {
                GoodsActions             goodsActions             = new GoodsActions();
                IList <Goods>            listGoods                = goodsActions.LastAddedGoods(0, 10);
                DataSourceAdapterBinding dataSourceAdapterBinding = new DataSourceAdapterBinding();

                GoodsPreviewLastAdded.DataSource = dataSourceAdapterBinding.AdapterFill(listGoods);
                ViewState["LastAdded"]           = GoodsPreviewLastAdded.DataSource;


                listGoods.Clear();
                listGoods = goodsActions.HaveDiscountGoods(0, 10);
                GoodsPreviewDiscount.DataSource = dataSourceAdapterBinding.AdapterFill(listGoods);
                ViewState["Discount"]           = GoodsPreviewDiscount.DataSource;

                listGoods.Clear();
                listGoods = goodsActions.GetGoodsMostSold();
                GoodsPreviewMostSold.DataSource = dataSourceAdapterBinding.AdapterFill(listGoods);
                ViewState["MostSold"]           = GoodsPreviewMostSold.DataSource;
            }
            else
            {
                if (ViewState["LastAdded"] != null)
                {
                    GoodsPreviewLastAdded.DataSource = (IList <DataSourceAdapter>)ViewState["LastAdded"];
                }

                if (ViewState["Discount"] != null)
                {
                    GoodsPreviewDiscount.DataSource = (IList <DataSourceAdapter>)ViewState["Discount"];
                }
                if (ViewState["MostSold"] != null)
                {
                    GoodsPreviewMostSold.DataSource = (IList <DataSourceAdapter>)ViewState["MostSold"];
                }
            }
        }
        public void ButtonAdd_Click(object sender, EventArgs e)
        {
            string name = TextBoxName.Text;
            float  price;

            float.TryParse(TextBoxPrice.Text, out price);
            bool isDiscount = CheckBox1.Checked;
            int  discount;

            int.TryParse(TextBoxDiscount.Text, out discount);
            byte[] image     = null;
            byte[] miniImage = null;

            if (FileUploadImage.HasFile)
            {
                image = FileUploadImage.FileBytes;
            }

            if (FileUploadMiniImage.HasFile)
            {
                miniImage = FileUploadMiniImage.FileBytes;
            }

            var args = new ButtonSubmitEventArgs(name, price, isDiscount, discount,
                                                 image, miniImage);


            ButtonAdd_OnClick(args);

            var goods = new Goods();

            goods.Name       = name;
            goods.Price      = price;
            goods.IsDiscount = isDiscount;

            if (discount > 0)
            {
                goods.Discount = discount;
            }

            goods.AdditionDate = DateTime.Now;

            var goodsImages = new GoodsImages();

            goodsImages.Image     = image;
            goodsImages.MiniImage = miniImage;

            GoodsActions goodsActions = new GoodsActions();

            goodsActions.AddGoods(goods, goodsImages, goodsID);
            Response.Redirect("~/Administrator/GoodsPreview.aspx");
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string imgID = Request.Params.Get("imgID");
            int    goodsID;

            if (int.TryParse(imgID, out goodsID))
            {
                GoodsActions goodsActions    = new GoodsActions();
                byte[]       responsePicture = goodsActions.FindPicture(goodsID);

                Response.BinaryWrite(responsePicture);
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["selectedID"] != null)
            {
                int selectedID = (int)Session["selectedID"];

                goods = new Goods();
                GoodsActions goodsActions = new GoodsActions();
                goods = goodsActions.FindSelectedGoods(selectedID);
                DataSourceAdapterBinding dataSourceAdapterBinding = new DataSourceAdapterBinding();
                GoodsPreview1.DataSource = dataSourceAdapterBinding.AdapterFill(goods);
            }
        }
Beispiel #6
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["SelectedGoodsID"] != null)
            {
                selectedGoodsID           = int.Parse(Session["SelectedGoodsID"].ToString());
                GoodsEditControl1.GoodsID = selectedGoodsID;

                GoodsActions goodsActions = new GoodsActions();
                var          goods        = goodsActions.FindSelectedGoods(selectedGoodsID);

                DataSourceAdapterBinding dataSourceAdapterBinding = new DataSourceAdapterBinding();
                GoodsPreviewControl1.DataSource = dataSourceAdapterBinding.AdapterFill(goods);
            }
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                GoodsActions goodsActions = new GoodsActions();
                var          goods        = goodsActions.FindSelectedGoods(goodsID);
                TextBoxName.Text     = goods.Name;
                TextBoxPrice.Text    = goods.Price.ToString();
                TextBoxDiscount.Text = goods.Discount.ToString();
                CheckBox1.Checked    = goods.IsDiscount;

                if (CheckBox1.Checked)
                {
                    TextBoxDiscount.Enabled = true;
                }
            }
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            TreeViewControl1.SelectedNodeChanged += new TestWork_Nix.Categoties.Controls.TreeViewCategoriesControl.TreeViewManageEventHandler(TreeViewControl1_SelectedNodeChanged);

            if (Session["SelectedGoodsID"] != null)
            {
                SelectedGoodsID = int.Parse(Session["SelectedGoodsID"].ToString());

                if (!Page.IsPostBack)
                {
                    categoriesGoodsList = new List <Categories>();
                    RelationsCategoriesGoodsActions R_C_G_Actions = new RelationsCategoriesGoodsActions();
                    categoriesGoodsList = R_C_G_Actions.GetCategoriesForGoods(SelectedGoodsID);
                    ViewState["categoriesGoodsList"]   = categoriesGoodsList;
                    RepeaterGoodsCategories.DataSource = categoriesGoodsList;
                    RepeaterGoodsCategories.DataBind();
                    GoodsActions goodsActions = new GoodsActions();
                    Label1.Text = "Manage categories for " + (goodsActions
                                                              .FindSelectedGoods(SelectedGoodsID)).Name + ":";
                }
            }
        }
Beispiel #9
0
        protected void GridViewGoods_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int index = e.RowIndex;

            if (ViewState["dataTable"] != null)
            {
                dataTable = (DataTable)ViewState["dataTable"];

                object[] row = dataTable.Rows[index].ItemArray;

                int goodsID;
                int.TryParse(row[0].ToString(), out goodsID);

                if (goodsID != null)
                {
                    GoodsActions goodsActions = new GoodsActions();
                    goodsActions.DeleteGoods(goodsID);
                }
                dataTable.Rows.RemoveAt(index);
                GridViewGoods.DataSource = dataTable;
                ViewState.Add("dataTable", dataTable);
                GridViewGoods.DataBind();
            }
        }