private void button18_Click(object sender, EventArgs e)
    {
        Form1 stForm = new Form1();
        DialogResult result = stForm.ShowDialog(this);
        if (result == DialogResult.Cancel)
            return;
        Inscrierea__pentru_burs_sau_contract media = new Inscrierea__pentru_burs_sau_contract();
        media.Media_MNDP = stForm.MNDP.Text;
        media.Media_MNEA = stForm.MNEA.Text;
        media.Media_Concurs = stForm.MediaConcurs.Text;
        db.Media.Add(media);
        db.SaveChanges();
        MessageBox.Show("Salvarea a avut loc cu succes!!!");
    }
error" Cannot implicitly convert type 'string' to 'decimal'"
make use of Decimal.TryParse(string, out val)
Example :
decimal val;
if(Decimal.TryParse(stForm.MNDP.Text, out val))
    media.Media_MNDP = val;
better to use tryparse method because it avoid runtime exception to be thrown
Try like this
 media.Media_MNDP = Decimal.Parse(stForm.MNDP.Text);
For emtpy textbox that will throw error .
To make error free try this
decimal demo;
if(Decimal.TryParse(stForm.MNDP.Text,out demo)){
  media.Media_MNDP = Decimal.Parse(stForm.MNDP.Text);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With