Guest User

Untitled

a guest
Feb 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.14 KB | None | 0 0
  1.         public Form1()
  2.  
  3.         {
  4.             InitializeComponent();
  5.         }
  6.  
  7.         System.Data.SqlClient.SqlConnection con;
  8.         System.Data.SqlClient.SqlDataAdapter da;
  9.         DataSet ds1;
  10.         DataSet ds2;
  11.  
  12.         private void Form1_Load(object sender, EventArgs e)
  13.         {
  14.  
  15.         }
  16.  
  17.         private void button1_Click(object sender, EventArgs e)
  18.         {
  19.  
  20.             con = new System.Data.SqlClient.SqlConnection();
  21.             ds1 = new DataSet();
  22.    //         ds2 = new DataSet();
  23.             con.ConnectionString ="Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\tabela_awg.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
  24.  
  25.             double variavel_indutor;
  26.             double variavel_corrente;
  27.             double variavel_fluxo;
  28.             double variavel_densidade;
  29.             double variavel_razao;
  30.             double resposta;
  31.             double espiras;
  32.             double Ae=0;
  33.             double entreferro;
  34.             string nucleo="none";
  35.             double area_fio;
  36.  
  37.             variavel_indutor = double.Parse(texto_indutor.Text);
  38.             variavel_corrente = double.Parse(texto_ipico.Text);
  39.             variavel_fluxo = double.Parse(texto_fluxo.Text);
  40.             variavel_densidade = double.Parse(texto_densidade.Text);
  41.             variavel_razao = double.Parse(texto_razao.Text);
  42.  
  43.             resposta = (variavel_indutor * variavel_corrente * variavel_corrente * 10 * 10 * 10 * 10) / (variavel_razao * variavel_fluxo * variavel_densidade);
  44.  
  45.             if (resposta <= 0.08)
  46.             {
  47.                 Ae = 0.312;
  48.                 nucleo = "E-20";
  49.             }
  50.             else if (resposta <= 0.48)
  51.             {
  52.                 Ae = 0.6;
  53.                 nucleo = "E-30/7";
  54.             }
  55.  
  56.             else if (resposta <= 1.02)
  57.             {
  58.                 Ae = 1.2;
  59.                 nucleo = "E-30/14";
  60.             }
  61.  
  62.             else if (resposta <= 2.84)
  63.             {
  64.                 Ae = 1.81;
  65.                 nucleo = "E-42/15";
  66.             }
  67.             else if (resposta <= 3.77)
  68.             {
  69.                 Ae = 2.4;
  70.                 nucleo = "E-42/20";
  71.             }
  72.             else if (resposta > 3.77)
  73.             {
  74.                 Ae = 3.54;
  75.                 nucleo = "E-55";
  76.             }
  77.  
  78.             espiras = (variavel_indutor * variavel_corrente * 10 * 10 * 10 * 10) / (variavel_fluxo * Ae);
  79.             entreferro = ((espiras*espiras*4*3.1415*Ae)/(variavel_indutor*10*10*10*10*10*10*10*10*10));
  80.  
  81.             area_fio = (variavel_corrente / variavel_densidade);
  82.  
  83.             double area_selected=0;
  84.  
  85.             string leitura = "SELECT ABS(Area-" +area_fio +") as Dist FROM AWG ORDER BY Dist";
  86.             da = new System.Data.SqlClient.SqlDataAdapter(leitura, con);
  87.  
  88.             con.Open();
  89.  
  90.             da.Fill(ds1, "Area");
  91.  
  92.             con.Close();
  93.             con.Dispose();
  94.            
  95.             //double variavel_linha;
  96.            // string nome_do_fio;
  97.  
  98.             //int linha_quero = 0;
  99.  
  100.             //foreach (DataRow dr in ds1.Tables[0].Rows)
  101.             //{
  102.             //    int i;
  103.             //    for (i = 1; i <= ds1.Tables[0].Columns.Count; i++)
  104.             //    {
  105.             //        variavel_linha = Convert.ToDouble(dr[i -1]);
  106.             //        if (variavel_linha >= area_fio)
  107.             //        {
  108.             //            area_selected = variavel_linha;
  109.             //            linha_quero = i;
  110.             //        }
  111.             //    }
  112.             //}
  113.  
  114.             double espiras_round = Math.Round(espiras) + 1;
  115.             double resposta_round = Math.Round(resposta, 3, MidpointRounding.ToEven);
  116.             double entreferro_round = Math.Round(entreferro, 3, MidpointRounding.ToEven);
  117.            
  118.             MessageBox.Show("AwAe = " + resposta_round.ToString() + " cm^4\nNúcleo = "
  119.                 + nucleo + "\nEspiras = "
  120.                 + espiras_round.ToString() + " espiras\nEntreferro = "
  121.                 + entreferro_round.ToString() + " cm" +
  122.                 "\nArea fio = " + area_fio +
  123.                 "\nArea normalizada = " + ds1, "Vai enrolar fio!");
Add Comment
Please, Sign In to add comment