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);
            }
        }
예제 #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;
 }
예제 #3
0
        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);
        }
예제 #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;
 }
예제 #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;
 }
예제 #6
0
 partial void DeleteCategory(Category instance);
예제 #7
0
 partial void UpdateCategory(Category instance);
예제 #8
0
 partial void InsertCategory(Category instance);
예제 #9
0
 public bool Update(Category category)
 {
     db.Entry(category).State = EntityState.Modified;
     db.SaveChanges();
     return(true);
 }
예제 #10
0
 public bool Save(Category category)
 {
     db.Categories.Add(category);
     db.SaveChanges();
     return(true);
 }