public EditProductViewModel(int temp_ProductId) { this._Category = CategoryServices.GetAllCategory(0); product ob = ProductServices.GetProduct(temp_ProductId); if (ob != null) { ProductId = ob.id; ProductName = ob.product_name; SelectedPath = ob.image_url; Brand = ob.brand; SelectedCategory = CategoryServices.GetCategory(ob.category); SelectedSubCategory = SubCategoryServices.GetSubCategory(ob.sub_category); Weight = ob.weight; CostPrice = ob.cost_price; SellingPrice = ob.sell_price; } }
protected void UpdateSubCatagory(object parameter) { int Sub_category_id = 0; TextBox tb = (TextBox)parameter; int.TryParse(tb.Text, out Sub_category_id); if ((Sub_category_id > 0) && (SelectedCategory != null)) { SubCategoryEntity ob_sub_Category = _lstSubCategory.Where(s => s.id == Sub_category_id).FirstOrDefault(); List <sub_category> temp_list = SubCategoryServices.GetAllSubCategoryByName(ob_sub_Category.sub_category_name.Trim(), SelectedCategory.id); if (temp_list.Count == 0 || temp_list.Count == 1) { if (temp_list.Count == 1) { sub_category temp = temp_list.FirstOrDefault(); if (temp.id != ob_sub_Category.id) { BindGrid(); //RaisedPropertyChanged("Category"); //MessageBox.Show("SubCategory Name alredy Exist."); InventoryHelper.SimpleAlert("Warning", "SubCategory Name alredy Exist."); return; } } sub_category temp_ob_sub_Category = SubCategoryServices.GetSubCategory(ob_sub_Category.id); temp_ob_sub_Category.subcategory_name = ob_sub_Category.sub_category_name; int temp_sub_Category_id = SubCategoryServices.AddUpdateSubCategory(temp_ob_sub_Category); if (temp_sub_Category_id == ob_sub_Category.id) { //MessageBox.Show("Sub-Category " + ob_sub_Category.sub_category_name + " is Updated"); InventoryHelper.SuccessAlert("Success", "Sub-Category " + ob_sub_Category.sub_category_name + " is Updated"); BindGrid(); //RaisedPropertyChanged("Category"); } } else { // MessageBox.Show("Category Name already Exist"); InventoryHelper.SimpleAlert("Warning", "Category Name already Exist"); } } }