private void btnCategoryAdd_Click(object sender, EventArgs e) { try { if (txtCategoryValue.Text != "") { bool b = SubCategoryRepo.checkIfSubCategoryExists(txtCategoryValue.Text); if (b) { MessageBox.Show("This sub category already exists."); txtCategoryValue.Clear(); } else { SubCategoryRepo.insert(Guid.NewGuid(), txtCategoryValue.Text); fillListView(); MessageBox.Show("Sub Category has been inserted."); txtCategoryValue.Clear(); } } else { MessageBox.Show("Sub-Category value can not be empty, please try again."); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + "Please contact your software provider."); } }
private void btnCategoryDelete_Click(object sender, EventArgs e) { int index = 0; try { if (txtCategoryValue.Text != "") { index = lvSubCategory.SelectedIndices[0]; SubCategoryRepo.delete(Guid.Parse(lvSubCategory.Items[index].SubItems[1].Text)); fillListView(); MessageBox.Show("Sub Category has been deleted."); txtCategoryValue.Clear(); btnCategoryDelete.Enabled = false; btnCategoryUpdate.Enabled = false; btnCategoryAdd.Enabled = true; } else { MessageBox.Show("Delete Value can not be empty, please try again."); btnCategoryDelete.Enabled = false; btnCategoryUpdate.Enabled = false; btnCategoryAdd.Enabled = true; } } catch (Exception) { MessageBox.Show("Please select an item to delete."); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (txtSubCatName.Text == "") { MessageBox.Show("Please enter SubcategoryName", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSubCatName.Focus(); return; } string strSubCategoryName = string.Empty; int CategoryId; string strSubCategoryDescription = string.Empty; byte Product; strSubCategoryName = txtSubCatName.Text; CategoryId = Convert.ToInt32(cbCategory.SelectedValue.ToString()); strSubCategoryDescription = txtSubCatDescription.Text; Image image = pictureBox1.Image; byte[] imageBt = null; string imageName; int CreatedBy = GlobalVariables.glbUserId; if (image != null) { MemoryStream memoryStream = new MemoryStream(); image.Save(memoryStream, ImageFormat.Jpeg); imageBt = memoryStream.ToArray(); } else { imageName = @"~/Resource/images/no-image-icon-15.png"; //Initialize a file stream to read the image file FileStream fs = new FileStream(@imageName, FileMode.Open, FileAccess.Read); //Initialize a byte array with size of stream imageBt = new byte[fs.Length]; //Read data from the file stream and put into the byte array } SubCategoryRepo repoSubCat = new SubCategoryRepo(); int isInserted = repoSubCat.CreateSubCategory(strSubCategoryName, strSubCategoryDescription, CategoryId, imageBt, CreatedBy); if (isInserted > 0) { txtSubCatName.Clear(); txtSubCatDescription.Clear(); pictureBox1.Image = null; MessageBox.Show("SubCategory Created Successfully", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("SubCategory Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { throw; } }
private void SetRepo() { _ingredientRepo = new IngredientRepo(_context); _tableRepo = new TableRepo(_context); _reservationRepo = new ReservationRepo(_context); _categoryRepo = new CategoryRepo(_context); _salesRepo = new SaleRepo(_context); _occupancyRepo = new OccupanciesRepo(_context); _recipeRepo = new RecipeRepo(_context); _productRepo = new ProductRepo(_context); _supplierRepo = new SupplierRepo(_context); _subCategoryRepo = new SubCategoryRepo(_context); _logRepo = new LogRepo(_context); }
private void fillListView() { lvSubCategory.Items.Clear(); var subcat = SubCategoryRepo.retrieve(); if (subcat.Count > 0) { for (int i = 0; i < subcat.Count; i++) { ListViewItem itm = new ListViewItem(subcat[i].SubCategoryValue); itm.SubItems.Add(subcat[i].SubCategoryId.ToString()); lvSubCategory.Items.Add(itm); } } }
private void AddProduct_Load(object sender, EventArgs e) { try { Guid categoryId = CategoryRepo.getCategoryId(cmbCategory.Text); if (categoryId != null) { this.CategoryId = categoryId; } Guid SubcategoryId = SubCategoryRepo.getSubCategoryId(cmbSubCategory.Text); if (SubcategoryId != null) { this.subcategory = SubcategoryId; } Guid SupplierId = SupplierRepo.getSupplierId(cmbSupplier.Text); if (SupplierId != null) { this.supplier = SupplierId; } Guid WarehouseId = WarehouseRepo.getWarehouseId(cmbWarehouse.Text); if (WarehouseId != null) { this.warehouse = WarehouseId; } Guid statusId = StatusRepo.getStatusId(cmbStatus.Text); if (statusId != null) { this.status = statusId; } Guid StoreId = StoreRepo.getStoreId(cmbStore.Text); if (StoreId != null) { this.store = StoreId; } Guid id = UnitOfMeasurementRepo.retrieveId(cmbUnitOfMeasurement.Text); if (id != null) { this.unitOfMeasurementId = id; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void pictureBox1_Click(object sender, EventArgs e) { DialogResult d = MessageBox.Show("Are you sure you want to exit?", "Exit", MessageBoxButtons.YesNo); if (d == DialogResult.Yes) { this.cmbSubCategory.Items.Clear(); var subcat = SubCategoryRepo.retrieve(); if (subcat.Count > 0) { for (int i = 0; i < subcat.Count; i++) { this.cmbSubCategory.Items.Add(subcat[i].SubCategoryValue.ToString()); } } this.Hide(); } }
private void button1_Click(object sender, EventArgs e) { try { var subcat = SubCategoryRepo.retrieveByName(txtCategorySearch.Text); if (subcat.Count > 0) { lvSubCategory.Items.Clear(); ListViewItem itm = new ListViewItem(subcat[0].SubCategoryValue); itm.SubItems.Add(subcat[0].SubCategoryId.ToString()); lvSubCategory.Items.Add(itm); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnCategoryUpdate_Click(object sender, EventArgs e) { int index = 0; try { if (txtCategoryValue.Text != "") { bool b = SubCategoryRepo.checkIfSubCategoryExists(txtCategoryValue.Text); if (b) { MessageBox.Show("This sub-category already exists, please try a new name"); } else { index = lvSubCategory.SelectedIndices[0]; SubCategoryRepo.update(Guid.Parse(lvSubCategory.Items[index].SubItems[1].Text), txtCategoryValue.Text); MessageBox.Show("Sub Category has been updated."); btnCategoryAdd.Enabled = true; btnCategoryDelete.Enabled = false; btnCategoryUpdate.Enabled = false; fillListView(); txtCategoryValue.Clear(); } } else { MessageBox.Show("Update value can not be empty, please try again."); btnCategoryAdd.Enabled = true; btnCategoryDelete.Enabled = false; btnCategoryUpdate.Enabled = false; } } catch (Exception) { MessageBox.Show("Please select an item to update"); } }
public static int getSubCategoryId(string subcategoryName) { int subcategoryId = SubCategoryRepo.getSubCategoryIdByName(subcategoryName); return(subcategoryId); }
public static List <String> getSubCategory(int catID) { return(SubCategoryRepo.getSubCategoryById(catID)); }
private void cmbSubCategory_SelectedIndexChanged(object sender, EventArgs e) { this.subcategory = SubCategoryRepo.getSubCategoryId(cmbSubCategory.Text); }
public void initCombo() { var unitOfMeasurement = UnitOfMeasurementRepo.retrieve(); if (unitOfMeasurement.Count > 0) { foreach (var item in unitOfMeasurement) { cmbUnitOfMeasurement.Items.Add(item.UnitOfMeasurementName.ToString()); } } var categories = CategoryRepo.retrieve(); if (categories.Count > 0) { foreach (var item in categories) { cmbCategory.Items.Add(item.CategoryValue); } } var subcategory = SubCategoryRepo.retrieve(); if (subcategory.Count > 0) { foreach (var item in subcategory) { cmbSubCategory.Items.Add(item.SubCategoryValue); } } var supplier = SupplierRepo.suppliers(); if (supplier.Count > 0) { foreach (var item in supplier) { cmbSupplier.Items.Add(item.SupplierName); } } var warehouse = WarehouseRepo.retrieve(); if (warehouse.Count > 0) { foreach (var item in warehouse) { cmbWarehouse.Items.Add(item.WarehouseName); } } var status = StatusRepo.retrieve(); if (status.Count > 0) { foreach (var item in status) { cmbStatus.Items.Add(item.StatusValue); } } List <SMLIB.Entity.ProductAttribute> attributes = ProductAttributeRepo.retrieve(); if (attributes.Count > 0) { foreach (var item in attributes) { cmbAttributes.Items.Add(item.AttributeName); } } var store = StoreRepo.retrieve(); if (store.Count > 0) { foreach (var item in store) { cmbStore.Items.Add(item.StoreName); } } }
public Sub_Category() { _errorLogs = new ErrorLogs(); _objSubCat = new SubCategoryRepo(); InitializeComponent(); }
public SubCategoryAccessor() { _uow = new KBUOW <KBContext>(); _repo = new SubCategoryRepo(_uow); }