private void insertButton_Click(object sender, EventArgs e) { if (SupplierName.Length == 0) { MessageBox.Show(String.Format(Messages.ElEMENT_NAME_REQUIRED, EntityNames.SUPPLIER_ENTITY_NAME), Constants.MESSAGE_CAPTION); return; } if (SupplierDataServices.ExistSupplierByName(SupplierName)) { MessageBox.Show(Messages.ELEMENT_EXISTS, Constants.MESSAGE_CAPTION); return; } byte[] photoUploaded = null; if (supplierPictureBox.Image != null) { photoUploaded = PictureViewUtils.ReadImageFromFilePath(openFileDialog1.FileName); } SupplierDataServices.InsertSupplier(SupplierName, Address, photoUploaded); ResetView(); MessageBox.Show(String.Format(Messages.ELEMENT_INSERT_SUCESS, EntityNames.SUPPLIER_ENTITY_NAME, SupplierName), Constants.MESSAGE_CAPTION); }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { var uploadPicture = PictureViewUtils.ReadImageFromFilePath(openFileDialog1.FileName); ShoesDataClientServices.ModelServices.UpdateShoesModelPicture(SelectedModelDto.ModelId, uploadPicture); SelectedModelDto.Photo = uploadPicture; LoadNewPhoto(openFileDialog1.FileName); } }
private void updateButton_Click(object sender, EventArgs e) { if (SelectedModel == null) { return; } if (ModelName.Length == 0) { MessageBox.Show(String.Format(Messages.ElEMENT_NAME_REQUIRED, EntityNames.MODEL_ENTITY_NAME), Constants.MESSAGE_CAPTION); return; } if (SelectedModel.Name != ModelName && ShoesClientDataServices.ModelServices.ExistModelByName(ModelName)) { MessageBox.Show(Messages.ELEMENT_EXISTS, Constants.MESSAGE_CAPTION); return; } byte[] newUploadPhoto = SelectedModel.Photo; if (UploadNewPhoto) { newUploadPhoto = PictureViewUtils.ReadImageFromFilePath(openFileDialog1.FileName); } var updatedModelDto = new ModelDto { ModelId = SelectedModel.ModelId, Name = ModelName, Description = ModelDescription, Photo = newUploadPhoto, ShoesTypeId = (int)shoesTypeComboBox.SelectedValue, Cost = (double)costNumericUpDown.Value, Sex = sexComboBox.SelectedItem as string, IsForKids = kidsCheckBox.Checked }; ShoesClientDataServices.ModelServices.UpdateModel(updatedModelDto); UpdateView(updatedModelDto); MessageBox.Show(string.Format(Messages.ELEMENT_UPDATED_SUCCESS, EntityNames.MODEL_ENTITY_NAME), Constants.MESSAGE_CAPTION); }
private void updateButton_Click(object sender, EventArgs e) { if (SelectedSeller == null) { return; } if (SellerName.Length == 0) { MessageBox.Show(String.Format(Messages.ElEMENT_NAME_REQUIRED, EntityNames.SELLER_ENTITY_NAME), Constants.MESSAGE_CAPTION); return; } if (SelectedSeller.Name != SellerName && SellerDataServices.ExistSellerByName(SellerName)) { MessageBox.Show(Messages.ELEMENT_EXISTS, Constants.MESSAGE_CAPTION); return; } byte[] newUploadPhoto = SelectedSeller.Photo; if (UploadNewPhoto) { newUploadPhoto = PictureViewUtils.ReadImageFromFilePath(openFileDialog1.FileName); } var sellerDto = new SellerDto { SellerId = SelectedSeller.SellerId, Name = SellerName, Address = SellerAddress, Photo = newUploadPhoto }; SellerDataServices.UpdateSeller(sellerDto); UpdateView(sellerDto); MessageBox.Show(string.Format(Messages.ELEMENT_UPDATED_SUCCESS, EntityNames.SELLER_ENTITY_NAME), Constants.MESSAGE_CAPTION); }
private void insertButton_Click(object sender, EventArgs e) { if (ModelName.Length == 0) { MessageBox.Show(string.Format(Messages.ElEMENT_NAME_REQUIRED, EntityNames.MODEL_ENTITY_NAME), Constants.MESSAGE_CAPTION); return; } if (ShoesDbServices.ModelServices.ExistModelByName(ModelName)) { MessageBox.Show(Messages.ELEMENT_EXISTS, Constants.MESSAGE_CAPTION); return; } byte[] photoUpload = null; if (modelPictureBox.Image != null) { photoUpload = PictureViewUtils.ReadImageFromFilePath(modelOpenFileDialog.FileName); } var newModelDto = new ModelDto { Name = ModelName, Description = ModelDescription, Photo = photoUpload, Cost = (double)costNumericUpDown.Value, ShoesTypeId = SelectedShoesType.Id, AvailablesColors = GetColorDtoFromSelectedNames(), Sex = (string)sexComboBox.SelectedItem, IsForKids = kidsCheckBox.Checked }; ShoesDbServices.ModelServices.InsertModel(newModelDto); ResetView(); MessageBox.Show(string.Format(Messages.ELEMENT_INSERT_SUCESS, EntityNames.MODEL_ENTITY_NAME, ModelName), Constants.MESSAGE_CAPTION); }