private void btnAddCategory_Click(object sender, RoutedEventArgs e) { CategorysClient cc=new CategorysClient(); GestionCommerciale.DomainModel.Entities.Category cat=new GestionCommerciale.DomainModel.Entities.Category {CategoryName=CategoryTxtBox.Text,Description=DescriptionTxtBox.Text}; cc.AddCategory(cat); DialogResult=true; Close(); }
private void button1_OnClick(object sender, RoutedEventArgs e) { var cat = new Categorys(); byte[] photo = null; var image = ImageEdit1.Source as BitmapImage; if (image != null) { var bi = image; var stream = bi.StreamSource as FileStream; if (stream != null) { String photoPath = stream.Name; photo = Validator.ConvertImageToByteArray(photoPath); } } var Categoryname = CategoryNameCbx.Text ?? ""; string subCategoryname = SubCategoryNameTxt.Text; if (String.IsNullOrEmpty(Categoryname)) { DXMessageBox.Show(this, "Erreur dans le Nom du catégorie (ne doit pas etre vide"); return; } if (String.IsNullOrEmpty(subCategoryname.Trim())) { DXMessageBox.Show(this, "Erreur dans le Nom du sous catégorie (ne doit pas etre vide"); return; } if (_CategorysClient.IsSubCategoryExist(subCategoryname.Trim(), Categoryname)) { DXMessageBox.Show(this, "sous catégorie existe déjà"); return; } String description = new TextRange(RichTextBox1.Document.ContentStart, RichTextBox1.Document.ContentEnd).Text; String result = _CategorysClient.AddSubCategory(Categoryname.Trim(), subCategoryname.Trim(), description.Trim(), photo); DXMessageBox.Show(this,result); }