예제 #1
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            if (SelectedClient == null)
            {
                return;
            }

            if (ClientName.Length == 0)
            {
                MessageBox.Show(String.Format(Messages.ElEMENT_NAME_REQUIRED, EntityNames.CLIENT_ENTITY_NAME), Constants.MESSAGE_CAPTION);
                return;
            }

            if (SelectedClient.Name != ClientName &&
                ClientDataServices.ExistClientByName(ClientName))
            {
                MessageBox.Show(Messages.ELEMENT_EXISTS, Constants.MESSAGE_CAPTION);
                return;
            }

            byte[] newUploadPhoto = SelectedClient.Photo;
            if (UploadNewPhoto)
            {
                newUploadPhoto = PictureViewUtils.ReadImageFromFilePath(openFileDialog1.FileName);
            }

            var clientDto = new ClientDto
            {
                ClientId = SelectedClient.ClientId,
                Name     = ClientName,
                Address  = SellerAddress,
                Photo    = newUploadPhoto
            };

            ClientDataServices.UpdateClient(clientDto);
            UpdateView(clientDto);
            MessageBox.Show(string.Format(Messages.ELEMENT_UPDATED_SUCCESS, EntityNames.SELLER_ENTITY_NAME), Constants.MESSAGE_CAPTION);
        }
예제 #2
0
        private void insertButton_Click(object sender, EventArgs e)
        {
            if (ClientName.Length == 0)
            {
                MessageBox.Show(String.Format(Messages.ElEMENT_NAME_REQUIRED, EntityNames.CLIENT_ENTITY_NAME), Constants.MESSAGE_CAPTION);
                return;
            }

            if (ClientDataServices.ExistClientByName(ClientName))
            {
                MessageBox.Show(Messages.ELEMENT_EXISTS, Constants.MESSAGE_CAPTION);
                return;
            }

            byte[] photoUploaded = null;
            if (clientPictureBox.Image != null)
            {
                photoUploaded = PictureViewUtils.ReadImageFromFilePath(openFileDialog1.FileName);
            }

            ClientDataServices.InsertClient(ClientName, Address, photoUploaded);
            ResetView();
            MessageBox.Show(String.Format(Messages.ELEMENT_INSERT_SUCESS, EntityNames.CLIENT_ENTITY_NAME, ClientName), Constants.MESSAGE_CAPTION);
        }