public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
decimal maliyet = Convert.ToDecimal(textBox_Maliyet.Text);
decimal karoranı = Convert.ToDecimal(textBox_KarOran.Text) / 100;
decimal satışoranı = 1 + karoranı;
//Math.Round kullanma sebebi para birimlerinde virgülden sonra 2 hane olması gerekiyor.
decimal kdvhariçfiyat = Math.Round(maliyet * satışoranı, 2, MidpointRounding.AwayFromZero);
decimal kdvdahilfiyat = Math.Round(kdvhariçfiyat * 1.18m, 2, MidpointRounding.AwayFromZero);
textBox_KDVHariç.Text = String.Format("{0:C2}", kdvhariçfiyat); // Parabirimini görmemek için {0:F2} kullanın
textBox_KDVDahil.Text = String.Format("{0:C2}", kdvdahilfiyat);
}
catch (Exception ex)
{
MessageBox.Show("Hata:" + ex.Message);
}
}
}