Ejemplo n.º 1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     int i = dataGridViewCategories.CurrentRow.Index;
     string cat = dataGridViewCategories.Rows[i].Cells[1].Value.ToString();
     LibraryEntities context = new LibraryEntities();
     Category newCategory = new Category()
     {
         Name = cat
     };
     context.Category.AddObject(newCategory);
     context.SaveChanges();
 }
Ejemplo n.º 2
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtCateName.Text.Trim()))
     {
         Category c = new Category();
         c.CateName = txtCateName.Text.Trim();
         c.CateSlugName = LanguageConvert.GenerateDesc(txtCateName.Text.Trim());
         c.Active = true;
         c.Order = 0;
         CategoryDA.Insert(c);
         mess = "Thêm mục thành công.";
         GridView1.DataBind();
     }
 }
Ejemplo n.º 3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int i = dataGridViewCategories.CurrentRow.Index;
            int categoryID = (int)dataGridViewCategories.Rows[i].Cells[0].Value;
            string category = dataGridViewCategories.Rows[i].Cells[1].Value.ToString();
            LibraryEntities1 context = new LibraryEntities1();
            if (categoryID != 0)
            {
                Category newCategory = new Category()
                {
                    CategoryName = category
                };
                context.Categories.AddObject(newCategory);
                context.SaveChanges();
                MessageBox.Show("Категорията е добавена!");
                buttonAdd.Enabled = false;

            }
            else
            {
                MessageBox.Show("Грешка! Не сте въвели категория.");
                this.Close();
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Categories EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCategories(Category category)
 {
     base.AddObject("Categories", category);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a new Category object.
 /// </summary>
 /// <param name="categoryID">Initial value of the CategoryID property.</param>
 /// <param name="categoryName">Initial value of the CategoryName property.</param>
 public static Category CreateCategory(global::System.Int32 categoryID, global::System.String categoryName)
 {
     Category category = new Category();
     category.CategoryID = categoryID;
     category.CategoryName = categoryName;
     return category;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a new Category object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Category CreateCategory(global::System.Int32 id, global::System.String name)
 {
     Category category = new Category();
     category.ID = id;
     category.Name = name;
     return category;
 }