public TrayCalc(Structures.Tray_Params tray_Params_input) { InitializeComponent(); dataGridView1.Rows.Add("Gray"); dataGridView1.Rows.Add("Redyeing"); dataGridView1.Rows.Add("Total"); dataGridView1.Rows[1].DefaultCellStyle.BackColor = Color.Wheat; dataGridView1.Rows[1].DefaultCellStyle.SelectionBackColor = Color.Wheat; this.tray_Params = tray_Params_input; if (tray_Params.net_wt == -1F) //values are not set { } else { float r = 0F; Console.WriteLine("Ratio r=" + r.ToString()); tray_Params.n_rd = (tray_Params.rd_percentage * tray_Params.net_wt) / 100F; tray_Params.g_rd = tray_Params.n_rd + r * tray_Params.tray_tare + tray_Params.s_rd * tray_Params.spring_wt; tray_Params.g_g = tray_Params.gross_wt - tray_Params.g_rd; tray_Params.s_g = tray_Params.no_of_springs - tray_Params.s_rd; tray_Params.n_g = tray_Params.net_wt - tray_Params.n_rd; this.load_values(); } }
private void add_edit_rd_paramsButton_Click(object sender, EventArgs e) { try { float.Parse(springWeightTB.Text); } catch { c.ErrorBox("Please Select Spring Type"); return; } this.springCB.Enabled = false; Structures.Tray_Params tray_Params = new Structures.Tray_Params(0); if (String.IsNullOrEmpty(this.grossWeightTB.Text) == false) { tray_Params.gross_wt = float.Parse(this.grossWeightTB.Text); } tray_Params.net_wt = this.dynamicLabelChange(); if (String.IsNullOrEmpty(this.traytareTB.Text) == false) { tray_Params.tray_tare = float.Parse(this.traytareTB.Text); } if (String.IsNullOrEmpty(this.springWeightTB.Text) == false) { tray_Params.spring_wt = float.Parse(this.springWeightTB.Text); } if (String.IsNullOrEmpty(this.numberOfSpringsTB.Text) == false) { tray_Params.no_of_springs = int.Parse(this.numberOfSpringsTB.Text); } if (String.IsNullOrEmpty(this.redyeingPerTB.Text) == false) { tray_Params.rd_percentage = float.Parse(this.redyeingPerTB.Text); } if (String.IsNullOrEmpty(this.redyeingSpringsTB.Text) == false) { tray_Params.s_rd = int.Parse(this.redyeingSpringsTB.Text); } TrayCalc f = new TrayCalc(tray_Params); f.ShowDialog(); tray_Params = f.tray_Params; this.grossWeightTB.Text = tray_Params.gross_wt.ToString(); this.numberOfSpringsTB.Text = tray_Params.no_of_springs.ToString(); this.traytareTB.Text = tray_Params.tray_tare.ToString(); this.dynamicLabelChange(); this.redyeingPerTB.Text = tray_Params.rd_percentage.ToString(); this.redyeingSpringsTB.Text = tray_Params.s_rd.ToString(); }