Esempio n. 1
0
 private Color FormateColor(GemDTO packet)
 {
     return(new Color
     {
         Id = packet.Id,
         Name = packet.ColorName
     });
 }
Esempio n. 2
0
 private Color FormateColor( GemDTO packet )
 {
     return new Color
     {
         Id = packet.Id,
         Name = packet.ColorName
     };
 }
Esempio n. 3
0
        public void Save(GemDTO packet)
        {
            Validate(packet);

            Color color = FormateColor(packet);
            Gem   gem   = FormateGem(packet, color);

            ColorDAO.Save(color);
            GemDAO.Save(gem);
        }
Esempio n. 4
0
        public void Save( GemDTO packet )
        {
            Validate ( packet );

            Color color = FormateColor ( packet );
            Gem gem = FormateGem ( packet, color );

            ColorDAO.Save ( color );
            GemDAO.Save ( gem );
        }
Esempio n. 5
0
 private Gem FormateGem(GemDTO packet, Color color)
 {
     return(new Gem
     {
         Color = color,
         Id = packet.Id,
         ColorId = packet.ColorId,
         Name = packet.Name,
         Transparency = packet.Transparency,
         Type = packet.Type,
         Description = packet.Description
     });
 }
Esempio n. 6
0
        private void buttonSave_Click( object sender, EventArgs e )
        {
            GemDTO packet = new GemDTO
            {
                Id = -1,
                ColorId = -1,
                ColorName = textBoxColor.Text,
                Name = textBoxName.Text,
                Transparency = checkBoxTransparency.Checked,
                Description = textBoxDescription.Text
            };

            if ( comboBoxType.SelectedIndex == 0 )
            {
                packet.Type = Gem.Types.ORNAMENTAL;
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                packet.Type = Gem.Types.SEMIPRECIOUS;
            }
            else
            {
                packet.Type = Gem.Types.PRECIOUS;
            }

            try
            {
                if( gem != null )
                {
                    this.Close ();
                    return;
                }
                servis.Save ( packet );
                if (listBoxGem.Items.Count > 0 )
                {
                    listBoxGem.Items.Clear ();
                }
                servis.FindAll ( listBoxGem );

                comboBoxColor.Items.Clear ();
                servis.GetExistingColors ( comboBoxColor );

                this.Close ();
            }
            catch ( Exception ex)
            {
                MessageBox.Show ( ex.Message );
            }
        }
Esempio n. 7
0
        private void Validate(GemDTO packet)
        {
            Regex rgx = new Regex(@"[a-zA-Z]*");

            if (string.IsNullOrWhiteSpace(packet.Name))
            {
                throw new ArgumentException("Name is not determined.");
            }
            if (rgx.IsMatch(packet.Name) == false)
            {
                throw new ArgumentException("Name is not valid. Use only letters.");
            }

            if (string.IsNullOrWhiteSpace(packet.ColorName))
            {
                throw new ArgumentException("Color name is not determined.");
            }
            if (rgx.IsMatch(packet.ColorName) == false)
            {
                throw new ArgumentException("Color name is not valid. Use only letters.");
            }
        }
Esempio n. 8
0
 private Gem FormateGem( GemDTO packet, Color color )
 {
     return new Gem
     {
         Color = color,
         Id = packet.Id,
         ColorId = packet.ColorId,
         Name = packet.Name,
         Transparency = packet.Transparency,
         Type = packet.Type,
         Description = packet.Description
     };
 }
Esempio n. 9
0
        private void Validate( GemDTO packet )
        {
            Regex rgx = new Regex ( @"[a-zA-Z]*" );
            if ( string.IsNullOrWhiteSpace ( packet.Name ) )
                throw new ArgumentException ( "Name is not determined." );
            if ( rgx.IsMatch ( packet.Name ) == false )
                throw new ArgumentException ( "Name is not valid. Use only letters." );

            if ( string.IsNullOrWhiteSpace ( packet.ColorName ) )
                throw new ArgumentException ( "Color name is not determined." );
            if ( rgx.IsMatch ( packet.ColorName ) == false )
                throw new ArgumentException ( "Color name is not valid. Use only letters." );
        }