コード例 #1
0
        private void modelDataGrid_SelectionChanged(object sender, EventArgs e)
        {
            UploadNewPhoto = false;
            if (SelectedModel == null)
            {
                DisableButtons();
                return;
            }
            modelNameTextBox.Text        = SelectedModel.Name;
            modelDescriptionTextBox.Text = SelectedModel.Description;
            PictureViewUtils.LoadImageToControl(SelectedModel.Photo, modelPictureBox);
            costNumericUpDown.Value  = (decimal)SelectedModel.Cost;
            sexComboBox.SelectedItem = SelectedModel.Sex;
            kidsCheckBox.Checked     = SelectedModel.IsForKids;
            bool allowModify = !ShoesClientDataServices.StockRoomServices.ExistAnyStockEntryByModelId(SelectedModel.ModelId);

            costNumericUpDown.Enabled       = allowModify;
            removeButton.Enabled            = allowModify;
            updateButton.Enabled            = true;
            shoesTypeComboBox.SelectedValue = SelectedModel.ShoesTypeId;
            colorCheckedListBox.Items.Clear();
            if (SelectedModel.AvailablesColors.Count > 0)
            {
                SelectedModel.AvailablesColors.ForEach(dto => colorCheckedListBox.Items.Add(dto.Name, true));
            }
            else
            {
                colorCheckedListBox.Items.Add(AVAILABLE_FOR_ALL_COLORS, true);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 private void ReloadShoesModelPicture(ModelDto selectedModel)
 {
     this.shoesPictureBox.Image = null;
     if (selectedModel != null)
     {
         PictureViewUtils.LoadImageToControl(selectedModel.Photo, shoesPictureBox);
     }
 }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }