private void AddPhoneBtn_Click(object sender, EventArgs e) { AddPhoneForm addPhoneForm = new AddPhoneForm(); if (addPhoneForm.ShowDialog(this) == DialogResult.OK) { String filePath = addPhoneForm.pictureBox1.ImageLocation; String imageName = null; if (filePath != null) { imageName = (phonesCount + 1).ToString() + Path.GetExtension(filePath); FileStream file; try { file = File.OpenRead(filePath); } catch (IOException ex) { Console.WriteLine(ex.ToString()); throw ex; } StreamContractClient imageClient = new StreamContractClient(); imageClient.setMStream(imageName, file.Length, file); } Phone phone = new Phone { Producer = addPhoneForm.producerTextBox.Text, ReleaseYear = int.Parse(addPhoneForm.releaseYearTextBox.Text), Name = addPhoneForm.nameTextBox.Text, Weight = double.Parse(addPhoneForm.weightTextBox.Text), Thickness = double.Parse(addPhoneForm.thicknessTextBox.Text), OperatingSystem = addPhoneForm.operatingSystemTextBox.Text, DualSim = addPhoneForm.dualSimCheckbox.Checked, MicroSDCardSlot = addPhoneForm.microSDCardCheckbox.Checked, Image = imageName, Description = addPhoneForm.descriptionTextBox.Text }; client.AddPhone(phone); } }
public DescriptionForm(string description, string imageName) { InitializeComponent(); if (imageName != null) { imageClient = new StreamContractClient(); string filePath = Path.Combine(System.Environment.CurrentDirectory, imageName); Stream fs; long size; string fileName = imageName; fileName = imageClient.getMStream(fileName, out size, out fs); filePath = Path.Combine(System.Environment.CurrentDirectory, fileName); SaveFile(fs, filePath, size); pictureBox.ImageLocation = filePath; } textBox.Text = description; }