private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (proGrid1.SelectedRows.Count <= 0)
            {
                return;
            }

            DialogResult confurmDelete = MessageBox.Show("Are you sure?", "Confirmation.", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (confurmDelete != DialogResult.Yes)
            {
                return;
            }

            DAL.Category categoryDelete = new DAL.Category();
            string       ids            = "";

            for (int i = 0; i < proGrid1.SelectedRows.Count; i++)
            {
                ids += proGrid1.SelectedRows[i].Cells["ColId"].Value.ToString() + ", ";
            }

            ids = ids.Substring(0, ids.Length - 2);

            if (categoryDelete.Delete(ids))
            {
                MessageBox.Show("Data deleted");
                buttonSearch.PerformClick();
            }
            else
            {
                MessageBox.Show(categoryDelete.Error);
            }
        }
Example #2
0
 public int AddCategory(Category cat)
 {
     int addedAuthorId;
     using (var context = new LibraryEntities())
     {
         context.Categorys.Add(cat);
         context.SaveChanges();
         addedAuthorId = cat.Id;
     }
     return addedAuthorId;
 }
        public static List <ParameterDTO> getParametersOfCategory(int CategoryId)
        {
            List <ParameterDTO> l1 = new List <ParameterDTO>();

            DAL.Category d  = db.Categories.FirstOrDefault(p => p.CategoryId == CategoryId);
            int          id = 0;

            if (d == null)
            {
                id = d.ParentId.Value;
            }
            List <Parameter> l = db.Parameters.Where(p => p.CategoryId == CategoryId || id != 0 && p.CategoryId == id).ToList();

            foreach (var item in l)
            {
                l1.Add(BLL.Convertions.ParameterToDto(item));
            }
            return(l1);
        }
Example #4
0
 public int UpdateCategory(Category category)
 {
     int result = 0;
     try
     {
         String[] columnNames = {categoryName, status};
         Object[] values = {category.CategoryName, category.Status};
         String[] keyColumnNames = {categoryId};
         Object[] keyColumnValues = {category.CategoryID};
         result = DALBase.UpdateTable(tableName, columnNames, values, keyColumnNames, keyColumnValues);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return result;
 }
Example #5
0
 public int InsertCategory(Category category)
 {
     int result = 0;
     try
     {
         String[] columns = {categoryName, status};
         Object[] values = {category.CategoryName, category.Status};
         result = DALBase.InsertTable(tableName, columns, values) ;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return result;
 }
Example #6
0
 partial void DeleteCategory(Category instance);
Example #7
0
 partial void UpdateCategory(Category instance);
Example #8
0
 partial void InsertCategory(Category instance);
Example #9
0
 public bool Update(Category category)
 {
     db.Entry(category).State = EntityState.Modified;
     db.SaveChanges();
     return(true);
 }
Example #10
0
 public bool Save(Category category)
 {
     db.Categories.Add(category);
     db.SaveChanges();
     return(true);
 }