protected void SaveCreate_Click(object sender, EventArgs e)
        {
            var name = (CategoryCreate.FindControl("CreateCategory") as TextBox).Text;

            if (string.IsNullOrEmpty(name))
            {
                Error_Handler_Control.ErrorSuccessNotifier.AddErrorMessage("Title cannot be empty");
                return;
            }
            else if (name.Length < 5 || name.Length > 50)
            {
                Error_Handler_Control.ErrorSuccessNotifier.AddErrorMessage("Title must be between 5 and 50 symbols");
                return;
            }

            LibrarySystemDbContext context = new LibrarySystemDbContext();

            context.Categories.Add(new Category
            {
                Name = name,
            });

            context.SaveChanges();

            CategoryCreate.DataSource = null;
            CategoryCreate.DataBind();
            CategoriesGrid.DataBind();
        }
    protected void Save_btn_Click(object sender, EventArgs e)
    {
        using (SqlConnection Conn = new SqlConnection())
        {
            Conn.ConnectionString = ConfigurationManager.ConnectionStrings["DBPath2"].ConnectionString;
            SqlCommand Comm = new SqlCommand();
            Comm.Connection = Conn;
            Conn.Open();
            Comm.CommandText = "INSERT INTO VADIMSERVICES(NAME,LONG) VALUES(@NAME,@LONG)";
            Comm.Parameters.Add("@NAME", SqlDbType.NVarChar);
            Comm.Parameters["@NAME"].Value = name_edt.Text;
            Comm.Parameters.Add("@LONG", SqlDbType.NVarChar);
            Comm.Parameters["@LONG"].Value = long_edt.Text;


            try
            {
                Comm.ExecuteScalar();
                Error_lb.Text = "Данные успешно добавлены";
            }
            catch (SqlException E)
            {
                Error_lb.Text = E.Message;
                return;
            }
            CategoriesGrid.DataBind();
        }
    }
        private void AddToCart_Click(object sender, EventArgs e)
        {
            var ingredients = GetIngredients().ToList();

            var row  = FoodItemsGrid.CurrentRow;
            var item = new CartItem
            {
                Quantity    = (int)ItemQuantity.Value,
                Ingredients = ingredients,
                FoodItemId  = (int)row.Cells["ItemId"].Value,
                Name        = row.Cells["ItemName"].Value.ToString(),
                ShopId      = _id,
                Price       = (double)row.Cells["Price"].Value
            };

            _service.Cart.Add(item);

            ItemQuantity.Value = 1;
            AddToCart.Enabled  = false;

            IngredientsGrid.DataSource = null;
            FoodItemsGrid.DataSource   = null;
            CategoriesGrid.ClearSelection();

            var currentPrice = double.Parse(Price.Text);
            var itemPrice    = item.Quantity * (item.Price + item.Ingredients.Sum(y => y.Price));

            var finalPrice = currentPrice + itemPrice;

            Price.Text = finalPrice.ToString();
        }
        protected void SaveEdit_Click(object sender, EventArgs e)
        {
            var newName = (CategoryDetails.FindControl("EditCategory") as TextBox).Text;

            if (string.IsNullOrEmpty(newName))
            {
                Error_Handler_Control.ErrorSuccessNotifier.AddErrorMessage("Title cannot be empty");
                return;
            }
            else if (newName.Length < 5 || newName.Length > 50)
            {
                Error_Handler_Control.ErrorSuccessNotifier.AddErrorMessage("Title must be between 5 and 50 symbols");
                return;
            }

            var id = int.Parse(CategoryDetails.DataKey.Value.ToString());

            LibrarySystemDbContext data = new LibrarySystemDbContext();
            var category = data.Categories.FirstOrDefault(x => x.Id == id);

            category.Name = newName;

            data.SaveChanges();

            CategoryDetails.DataSource = null;
            CategoryDetails.DataBind();
            CategoriesGrid.DataBind();
        }
Beispiel #5
0
        protected void Update_Click(object sender, EventArgs e)
        {
            List <Object> dataKeys = CategoriesGrid.GetSelectedDataKeyValues();

            foreach (Object dataKey in dataKeys)
            {
                int      categoryId = AlwaysConvert.ToInt(dataKey);
                Category category   = CategoryDataSource.Load(categoryId);
                category.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(CategoryDisplayPages.SelectedValue));
                category.Save();
            }

            CategoriesGrid.DataBind();
        }
Beispiel #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _webpageId = AbleCommerce.Code.PageHelper.GetWebpageId();
     if (!Page.IsPostBack)
     {
         CategoryPageList.DataBind();
         ListItem item = CategoryPageList.Items.FindByValue(_webpageId.ToString());
         if (item != null)
         {
             item.Selected = true;
         }
         CategoriesGrid.DataBind();
     }
 }
        protected void SaveDelete_Click(object sender, EventArgs e)
        {
            var id = int.Parse(CategoryDelete.DataKey.Value.ToString());

            LibrarySystemDbContext data = new LibrarySystemDbContext();
            var category = data.Categories.FirstOrDefault(x => x.Id == id);

            data.Books.RemoveRange(category.Books);
            data.Categories.Remove(category);

            data.SaveChanges();

            CategoryDelete.DataSource = null;
            CategoryDelete.DataBind();
            CategoriesGrid.DataBind();
        }
Beispiel #8
0
    protected void edit_btn_Click(object sender, EventArgs e)
    {
        using (SqlConnection Conn = new SqlConnection())
        {
            Size s = new Size(400, 400);
            Conn.ConnectionString = ConfigurationManager.ConnectionStrings["DBPath2"].ConnectionString;
            Conn.Open();
            SqlCommand Comm = new SqlCommand();
            Comm.Connection  = Conn;
            Comm.CommandText = @"UPDATE VADIMTYPES SET NAME=@NAME,LONG=@LONG,CODE=@CODE WHERE ID=@ID";
            Comm.Parameters.Add("@NAME", SqlDbType.NVarChar);
            Comm.Parameters["@NAME"].Value = name_edt.Text;
            Comm.Parameters.Add("@LONG", SqlDbType.NVarChar);
            Comm.Parameters["@LONG"].Value = long_edt.Text;

            Comm.Parameters.AddWithValue("@ID", ID_lb.Text);
            Comm.Parameters.AddWithValue("@CODE", code_edt.Text);
            int ID = Convert.ToInt32(ID_lb.Text);
            try
            {
                Comm.ExecuteNonQuery();


                Error_lb.ForeColor = System.Drawing.Color.Green;
                CategoriesGrid.DataBind();

                Error_lb.Text = "Данные успешно добавлены";
            }
            catch (SqlException E)
            {
                Error_lb.ForeColor = System.Drawing.Color.Red;
                Error_lb.Text      = string.Format("При загрузке в Базу Данных произошла ошибка. Текст ошибки:{0}", E.Message);
                return;
            }
            Save_btn.Visible   = false;
            edit_btn.Visible   = true;
            Cancel_btn.Visible = true;
        }
    }
 private void FormShown(object sender, EventArgs e)
 {
     CategoriesGrid.ClearSelection();
 }
Beispiel #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     CategoriesGrid.DataSource = ServerModel.DB.FullCached <TblCategory>();
     CategoriesGrid.DataBind();
 }
Beispiel #11
0
 protected void CategoryPageList_SelectedIndexChanged(object sender, EventArgs e)
 {
     CategoriesGrid.DataBind();
 }