public void showResl() { if (CheckInput.checkInputAll()) { Fract reslFr = cIP.getOperation(hsa, hsB, hsC, hsD, selectOp, messErr); hsE.Text = Convert.ToString(reslFr.Element); hsF.Text = Convert.ToString(reslFr.Sample); } }
public Fract getOperation(TextBox a, TextBox b, TextBox c, TextBox d, ComboBox selectOp, Label mesEr) //ham nay dung de rut gon phan so khi da tinh toan xong { FractProces fractProces = new FractProces(); Fract fract = new Fract(); switch (selectOp.Text) { case "+": fract.Element = Convert.ToDouble(a.Text) * Convert.ToDouble(d.Text) + Convert.ToDouble(b.Text) * Convert.ToDouble(c.Text); fract.Sample = Convert.ToDouble(b.Text) * Convert.ToDouble(d.Text); fractProces.compactFract(fract); return(fract = fractProces.compactFract(fract)); case "-": fract.Element = Convert.ToDouble(a.Text) * Convert.ToDouble(d.Text) - Convert.ToDouble(b.Text) * Convert.ToDouble(c.Text); fract.Sample = Convert.ToDouble(b.Text) * Convert.ToDouble(d.Text); return(fract = fractProces.compactFract(fract)); case "x": fract.Element = Convert.ToDouble(a.Text) * Convert.ToDouble(c.Text); fract.Sample = Convert.ToDouble(b.Text) * Convert.ToDouble(d.Text); return(fract = fractProces.compactFract(fract)); case ":": if (c.Text != "0") { fract.Element = Convert.ToDouble(a.Text) / Convert.ToDouble(c.Text); fract.Sample = Convert.ToDouble(b.Text) / Convert.ToDouble(d.Text); mesEr.Text = ""; return(fract = fractProces.compactFract(fract)); } else { mesEr.Text = "Không thể thực hiện phép chia vì c =0"; } break; } return(fract); }