کد رو تغییری توش دادم که چیزی که نیاز داشتم رو میده بهم
حالا اگه روشی بهتر و بهینه تر هست بگید
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media;
namespace محاسبه_کمیسیون_املاک
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void MohasebeForosh_Click(object sender, EventArgs e)
{
double x = double.Parse(TextboxForosh.Text); //Daryaft Forosh
if (x <= 500000000)
{
double y = 0.005; //Darsad Comision Har Taraf
double z = (x * y); //Hesab Kardan Comision Forosh
double z2 = (z * 0.09); //Hesab Kardan Arzesh Afzode
ComisionForosh.Text = "کمیسیون بنگاه مبلغ " + (z + z2).ToString("n0") + " تومان از هر طرف معامله می باشد.";
}
if (x > 500000000)
{
double xc = 500000000; //500Milion Avalye
double xc1 = (x - 500000000); //Kam Kardan 500Milion az Pol Forosh
double xc2 = (xc * 0.005); //Hesab Kardan 500Milion Avalye
double xc3 = (xc1 * 0.0025); //Hesab Kardan BaghiMande Pol Forosh
double xc4 = (xc2 + xc3); //Jam Kardan Comision 500Milion Avalye Ba BaghiMande Comision
double xc5 = (xc4 * 0.09); //Hesab Kardan Arzesh Afzode
ComisionForosh.Text = "کمیسیون بنگاه مبلغ " + (xc4 + xc5).ToString("n0") + " تومان از هر طرف معامله می باشد.";
}
}
private void TextboxForosh_TextChanged(object sender, EventArgs e)
{
MohasebeForosh.Enabled = true;
if (TextboxForosh.Text != string.Empty)
{
TextboxForosh.Text = string.Format("{0:N0}", double.Parse(TextboxForosh.Text.Replace(",", "")));
TextboxForosh.Select(TextboxForosh.TextLength, 0);
}
}
private void ComisionForosh_TextChanged(object sender, EventArgs e)
{
}
private void TextboxEjare1_TextChanged(object sender, EventArgs e)
{
MohasebeEjare.Enabled = true;
if (TextboxEjare1.Text != string.Empty)
{
TextboxEjare1.Text = string.Format("{0:N0}", double.Parse(TextboxEjare1.Text.Replace(",", "")));
TextboxEjare1.Select(TextboxEjare1.TextLength, 0);
}
}
private void TextboxEjare2_TextChanged(object sender, EventArgs e)
{
MohasebeEjare.Enabled = true;
if (TextboxEjare2.Text != string.Empty)
{
TextboxEjare2.Text = string.Format("{0:N0}", double.Parse(TextboxEjare2.Text.Replace(",", "")));
TextboxEjare2.Select(TextboxEjare2.TextLength, 0);
}
}
private void TextboxForosh_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(char.IsControl(e.KeyChar) || char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
}
private void TextboxEjare1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(char.IsControl(e.KeyChar) || char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
}
private void TextboxEjare2_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(char.IsControl(e.KeyChar) || char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
}
private void MohasebeEjare_Click(object sender, EventArgs e)
{
if (TextboxEjare1.Text == "")
{
TextboxEjare1.Text = "0";
}
if (TextboxEjare2.Text == "")
{
TextboxEjare2.Text = "0";
}
double x1 = double.Parse(TextboxEjare1.Text); //Daryaft Pish
double x2 = double.Parse(TextboxEjare2.Text); //Daryaft Ejare
double x3 = (x1 / 100 * 3); // Tabdil Pish be Ejare
double z = (x2 + x3); //Jam Kardan Pish o Ejare (Tabdil Shodan Hame be Ejare)
double z2 = (z / 4); //Hesab Kardan Comision Ejare
double z3 = (z2 * 0.09); //Hesab Kardan Arzesh Afzode
ComisionEjare.Text = "کمیسیون بنگاه مبلغ " + (z2 + z3).ToString("n0") + " تومان از هر طرف معامله می باشد.";
}
}
}