public ActionResult EditDeviceSubCategory(SubcategoryModel model) { using (var con = new SqlConnection(_connectionString)) { var result = con.Query <int>("Add_Modify_Delete_SubCategory", new { model.CatId, model.SubCatName, model.SortOrder, model.SubCatId, model.IsRequiredIMEI1, model.IsRequiredIMEI2, model.IsRequiredSerialNo, model.SRNOLength, model.IsRepair, model.IsActive, model.Comments, model.IMEILength, User = CurrentUser.UserId, Action = "edit", CurrentUser.CompanyId }, commandType: CommandType.StoredProcedure).FirstOrDefault(); var response = new ResponseModel(); if (result == 2) { response.IsSuccess = true; response.Response = "Updated Successfully"; TempData["response"] = response; } } return(RedirectToAction("DeviceSubCategory")); }
public static SubcategoryModel DataReader_to_SubcategoryModel(SqlDataReader reader) { SubcategoryModel subcategory = new SubcategoryModel(); subcategory.Category = new CategoryParentModel { CategoryID = (Guid)reader["CategoryID"], CategoryName = (String)reader["CategoryName"], CategoryNameKey = (String)reader["CategoryNameKey"], FullyQualifiedName = (String)reader["CategoryNameKey"], LocationPath = "/" }; subcategory.SubcategoryID = (Guid)reader["SubcategoryID"]; subcategory.CategoryID = (Guid)reader["CategoryID"]; subcategory.SubcategoryName = (String)reader["SubcategoryName"]; subcategory.SubcategoryNameKey = (String)reader["SubcategoryNameKey"]; subcategory.OrderID = (int)reader["OrderID"]; subcategory.Visible = (bool)reader["Visible"]; subcategory.CreatedDate = (DateTime)reader["CreatedDate"]; subcategory.Description = (String)reader["Description"]; return(subcategory); }
//-------------------------------------------------------- SUBCATEGORY ------------------------------------------- //Add Subcategory public Task <TranStatus> addSubcategory(SubcategoryModel model) { using (categoryRepository = new Category_SubcategoryRepository()) { return(categoryRepository.addSubcategory(model)); } }
public ActionResult DeleteConfirmed(int id) { SubcategoryModel subcategoryModel = db.Subcategory.Find(id); db.Subcategory.Remove(subcategoryModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddSubCategory() { SubcategoryModel sm = new SubcategoryModel(); sm.CategoryList = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"); return(View(sm)); }
private void AddButton_Click(object sender, EventArgs e) { BrandModel brand = (BrandModel)BrandComboBox.SelectedItem; SubcategoryModel subcategory = (SubcategoryModel)SubcategoryComboBox.SelectedItem; bool taxes = true; if (exentoRadioButton.Checked) { taxes = false; } try { if (!string.IsNullOrEmpty(codeTextBox.Text) && ProductManagement.SelectProductByCode(codeTextBox.Text) == null) { if (!string.IsNullOrEmpty(stockTextBox.Text)) { if (!string.IsNullOrEmpty(unityPriceTextBox.Text)) { if (!string.IsNullOrEmpty(descriptionTextBox.Text)) { if (ProductManagement.InsertProduct(codeTextBox.Text, brand.Id_Brand.ToString(), subcategory.Id_Subcategory.ToString(), descriptionTextBox.Text, stockTextBox.Text, unityPriceTextBox.Text, lowerPriceTextBox1.Text, ImageManagement.ImageToByte(ImageManagement.TemporaryImage(ImgpictureBox.Image)), taxes)) { FrmMain.Instance.ToolStripLabel.Text = "Producto agregado de manera exitosa."; CleanProduct(); } else { MetroMessageBox.Show(this, $"Ha ocurrido un error al agregar el producto. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MetroMessageBox.Show(this, "La descripción no puede estar vacía.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MetroMessageBox.Show(this, "El precio no puede ser vacía.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MetroMessageBox.Show(this, "La catidad stock no puede ser vacía", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MetroMessageBox.Show(this, "El código de el producto no puede estar vacío, ni puede ser repetido.", "Error en el código", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception) { throw; } }
public ActionResult DeviceSubCategoryTable() { SubcategoryModel objSubcategoryModel = new SubcategoryModel(); using (var con = new SqlConnection(_connectionString)) { var result1 = con.Query <SubcategoryModel>("GetSubCategoryDetails ", new { companyId = CurrentUser.CompanyId }, commandType: CommandType.StoredProcedure).ToList(); return(View(result1)); }; }
public ActionResult Edit([Bind(Include = "ID,Name,CategoryID")] SubcategoryModel subcategoryModel) { if (ModelState.IsValid) { db.Entry(subcategoryModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Category, "ID", "Name", subcategoryModel.CategoryID); return(View(subcategoryModel)); }
public async Task <bool> SubmitSubcategory(SubcategoryModel subCategoryModel) { if (subCategoryModel.SubcategoryId == 0) { await this.metaDataDBContext.AddAsync(subCategoryModel); } else { this.metaDataDBContext.Update(subCategoryModel); } return(await this.metaDataDBContext.SaveChangesAsync() > 0); }
public ActionResult Create([Bind(Include = "ID,Name,CategoryID")] SubcategoryModel subcategoryModel) { if (ModelState.IsValid) { db.Subcategory.Add(subcategoryModel); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Category, "ID", "Name", subcategoryModel.CategoryID); return(View(subcategoryModel)); }
// GET: SubcategoryModels/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubcategoryModel subcategoryModel = db.Subcategory.Find(id); if (subcategoryModel == null) { return(HttpNotFound()); } return(View(subcategoryModel)); }
public static bool UpdateSubCategoryById(SubcategoryModel subCategoryModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("UPDATE Tbl_Subcategory SET Name = @Name, Id_Category = @Id_Category WHERE Id_Subcategory = @Id_Subcategory", subCategoryModel); return(true); } } catch (Exception ex) { throw; } }
public static bool DeleteSubCategoryById(SubcategoryModel subCategoryModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("DELETE FROM Tbl_Subcategory WHERE Id_Subcategory = @Id_Subcategory", subCategoryModel); return(true); } } catch (Exception ex) { throw; } }
//-----------METODOS DE ACME DE LA SUBCATEGORIA--------------------- public static bool InsertSubCategory(SubcategoryModel subCategoryModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("INSERT INTO Tbl_Subcategory (Id_Category, Name) VALUES(@Id_Category, @Name)", subCategoryModel); return(true); } } catch (Exception ex) { throw; } }
// GET: SubcategoryModels/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubcategoryModel subcategoryModel = db.Subcategory.Find(id); if (subcategoryModel == null) { return(HttpNotFound()); } ViewBag.CategoryID = new SelectList(db.Category, "ID", "Name", subcategoryModel.CategoryID); return(View(subcategoryModel)); }
public static SubcategoryModel SelectSubCategoryById(SubcategoryModel subCategoryModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { var output = cnn.Query <SubcategoryModel>("SELECT * FROM Tbl_Subcategory WHERE Id_Subcategory = @Id_Subcategory", subCategoryModel); return(output.Single()); } } catch (Exception ex) { return(null); } }
public static List <SubcategoryModel> SelectSubCategoriesByCategoryId(SubcategoryModel subCategoryModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { var output = cnn.Query <SubcategoryModel>("SELECT * FROM Tbl_Subcategory WHERE Id_Category = @Id_Category ORDER BY Name", subCategoryModel); return(output.ToList()); } } catch (Exception ex) { return(null); } }
public static SubcategoryModel SelectSubCategoryById(int id) { try { SubcategoryModel subCategoryModel = new SubcategoryModel() { Id_Subcategory = id }; return(SubcategoryConnection.SelectSubCategoryById(subCategoryModel)); } catch (Exception ex) { throw; } }
public static List <SubcategoryModel> SelectSubCategoriesByName(string name) { try { SubcategoryModel subCategoryModel = new SubcategoryModel() { Name = name }; return(SubcategoryConnection.SelectSubCategoriesByName(subCategoryModel)); } catch (Exception ex) { throw; } }
public ActionResult Createsubcategory(int id = -1) { using (_dbContext = new karrykartEntities()) { var category = _dbContext.Categories.Find(id); if (category != null) { var subcategoryModel = new SubcategoryModel(); subcategoryModel.CategoryName = category.Name; subcategoryModel.CategoryID = category.CategoryID; return(View(subcategoryModel)); } } return(View()); }
//-----------METODOS SE ACME DE LA SUBCATEGORIAS--------------------- public static bool InsertSubCategory(int id, string name) { try { SubcategoryModel subCategoryModel = new SubcategoryModel() { Id_Category = id, Name = name }; return(SubcategoryConnection.InsertSubCategory(subCategoryModel)); } catch (Exception ex) { throw; } }
public static bool UpdateSubCategoryById(int id, int categoryId, string name) { try { SubcategoryModel subCategoryModel = new SubcategoryModel() { Id_Subcategory = id, Id_Category = categoryId, Name = name }; return(SubcategoryConnection.UpdateSubCategoryById(subCategoryModel)); } catch (Exception ex) { throw; } }
public ActionResult EditSubCategory(SubcategoryModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var scategory = _dbContext.Subcategories.Find(model.ScategoryID); scategory.Name = model.Name; _dbContext.Entry(scategory).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "The sub category has been edited successfully, subcategory ID= " + model.ScategoryID, "EditSubCategory", "CategoryController", User.Identity.Name); Success("The subcategory has been edited successfully.", true); return(RedirectToAction("SubCategory", "Category", new { id = model.CategoryID })); } } return(View()); }
public ActionResult EditDeviceSubCategory(int SubCatId) { SubcategoryModel sm = new SubcategoryModel(); using (var con = new SqlConnection(_connectionString)) { var result = con.Query <SubcategoryModel>("select CatId,SubCatId,SubCatName,SortOrder,IsRequiredIMEI1,IsRequiredIMEI2,IsRequiredSerialNo,Comments,SRNOLength,IsActive,IsRepair,Sr_no_req,IMEILength from MstSubCategory where SubCatId=@SubCatId", new { SubCatId }, commandType: CommandType.Text).FirstOrDefault(); result.CategoryList = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"); if (result != null) { //result.DeviceCategory = result.CatId.ToString(); result.CatId = result.CatId; } return(PartialView("EditDeviceSubCategory", result)); } }
public async Task <IActionResult> addSubcategory([FromBody] SubcategoryModel model) { Dictionary <String, Object> dctData = new Dictionary <string, object>(); HttpStatusCode statusCode = HttpStatusCode.OK; TranStatus transaction = new TranStatus(); try { transaction = await icategory.addSubcategory(model); } catch (Exception ex) { transaction = CommonHelper.TransactionErrorHandler(ex); statusCode = HttpStatusCode.BadRequest; } dctData.Add("Status", transaction); return(this.StatusCode(Convert.ToInt32(statusCode), dctData)); }
private void SubCategoryDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { if (SubCategoryDataGridView.Rows.Count != 0) { SubCategoryNameTextBox.Text = SubCategoryDataGridView.CurrentRow.Cells[2].Value.ToString(); SubcategoryModel subCategoryModel = SubcategoryManagement.SelectSubCategoryById(int.Parse(SubCategoryDataGridView.CurrentRow.Cells[0].Value.ToString())); foreach (CategoryModel categoryModel in CategoryComboBox.Items) { if (categoryModel.Id_Category == subCategoryModel.Id_Category) { CategoryComboBox.SelectedItem = categoryModel; break; } } } }
public ActionResult Createsubcategory(SubcategoryModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var Subcategory = new Subcategory(); Subcategory.CategoryID = model.CategoryID; Subcategory.Name = model.Name; _dbContext.Subcategories.Add(Subcategory); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "New sub category added successfully with id=" + Subcategory.SCategoryID, "CreateSubcategory", "CategoryController", User.Identity.Name); Success("Subcategory added successfully"); return(RedirectToAction("Subcategory", "Category", new { id = model.CategoryID })); } } return(View(model)); }
public static List <SubcategoryModel> SelectSubCategoriesByName(SubcategoryModel subCategoryModel) { try { SubcategoryModel auxModel = new SubcategoryModel() { Name = $"%{ subCategoryModel.Name }%" }; using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { var output = cnn.Query <SubcategoryModel>("SELECT * FROM Tbl_Subcategory WHERE Name like @Name", auxModel); return(output.ToList()); } } catch (Exception ex) { throw; } }
//-------------------------------------------------------- SUBCATEGORY -------------------------------------------- //Insert SubCategory public async Task <TranStatus> addSubcategory(SubcategoryModel model) { using (var connection = new SqlConnection(ConnectionString)) { await connection.OpenAsync(); TranStatus transaction = new TranStatus(); DynamicParameters parameter = new DynamicParameters(); parameter.Add("@Sname", model.Sname); parameter.Add("@Cid", model.Cid); parameter.Add("@Createdby", model.Createdby); parameter.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 500); parameter.Add("@Code", dbType: DbType.Int32, direction: ParameterDirection.Output); await connection.QueryAsync("addSubcategory", parameter, commandType : CommandType.StoredProcedure); transaction.returnMessage = parameter.Get <string>("@Message"); transaction.code = parameter.Get <int>("@Code"); return(transaction); } }
public static SubcategoryDetailsJson Subcategory(string accountNameKey, SubcategoryModel subcategoryIn, bool includeItems, bool includeHidden) { var subcategoryObjectOut = new SubcategoryDetailsJson(); subcategoryObjectOut.subcategory = new Models.Json.Categorization.SubcategoryJson(); subcategoryObjectOut.subcategory.subsubcategories = new List <CategorizationListItemJson>(); #region include parent objects subcategoryObjectOut.category = new CategorizationParentItemJson { name = subcategoryIn.Category.CategoryName, nameKey = subcategoryIn.Category.CategoryNameKey, fullyQualifiedName = subcategoryIn.Category.FullyQualifiedName }; #endregion #region Build out subcategorization list foreach (SubsubcategoryListModel subsubcategoryModel in subcategoryIn.Subsubcategories) { var subsubcategoryListItem = new CategorizationListItemJson { //id = subsubcategoryModel.SubsubcategoryID.ToString(), name = subsubcategoryModel.SubsubcategoryName, nameKey = subsubcategoryModel.SubsubcategoryNameKey, fullyQualifiedName = subsubcategoryModel.FullyQualifiedName }; //Get listing images for each subcategory in the list subsubcategoryListItem.images = Dynamics.Images.BuildDynamicImagesListForJson(accountNameKey, "subsubcategory", subsubcategoryModel.SubsubcategoryID.ToString(), true); subcategoryObjectOut.subcategory.subsubcategories.Add(subsubcategoryListItem); } #endregion #region Build out product list if (includeItems && subcategoryIn.Subsubcategories.Count == 0) { var account = Common.GetAccountObject(accountNameKey); //Search products string filter = "(locationPath eq '" + subcategoryIn.FullyQualifiedName + "')"; var productResults = DataAccess.Search.SearchProducts(account, null, filter, "orderId asc", 0, 1000, false, null, includeHidden); subcategoryObjectOut.subcategory.items = Dynamics.Products.TransformDynamicProductsListForJson(productResults.Results); } #endregion //categoryObjectOut.count = categoryObjectOut.categories.Count; //Get images for this category subcategoryObjectOut.subcategory.images = Dynamics.Images.BuildDynamicImagesListForJson(accountNameKey, "subcategory", subcategoryIn.SubcategoryID.ToString(), false); //subcategoryObjectOut.subcategory.id = subcategoryIn.SubcategoryID.ToString(); subcategoryObjectOut.subcategory.name = subcategoryIn.SubcategoryName; subcategoryObjectOut.subcategory.nameKey = subcategoryIn.SubcategoryNameKey; subcategoryObjectOut.subcategory.fullyQualifiedName = subcategoryIn.FullyQualifiedName; subcategoryObjectOut.subcategory.description = subcategoryIn.Description; return(subcategoryObjectOut); }
public ActionResult AddSubCategory(SubcategoryModel model) { if (ModelState.IsValid) { using (ClothesShopEntities entity = new ClothesShopEntities()) { if (entity.Categories.Where(category => category.ID == model.CategoryID).Count() != 0) { if (entity.SubCategories.Where(subcategory => subcategory.SubCategoryName == model.SubcategoryName && subcategory.CategoryID == model.CategoryID).Count() == 0) { SubCategory newSubcategory = new SubCategory() { SubCategoryName = model.SubcategoryName, CategoryID = model.CategoryID }; entity.AddToSubCategories(newSubcategory); entity.SaveChanges(); } else { ModelState.AddModelError("", "A subcategory with the same name already exists."); } } else { ModelState.AddModelError("", "A category with the given ID does not exist."); } } } return RedirectToAction("SubCategories"); }