Ejemplo n.º 1
0
        private void SubmitRecord_Click(object sender, EventArgs e)
        {
            if (MilkManNameTextbox.Text == "" || VolumeTextbox.Text == "" || FatTextbox.Text == "" || LRTextbox.Text == "" || RateTextbox.Text == "" || AmountTextbox.Text == "")
            {
                MessageBox.Show("Plesae fill the missing fields before submission.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                CalculateButton_Click(sender, e);
                return;
            }
            else
            {
                // the validation to check the values within range
                if (!(double.Parse(FatTextbox.Text) >= 0 && double.Parse(FatTextbox.Text) <= 8))
                {
                    MessageBox.Show(" FAT should be within Range (0 - 8).", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FatTextbox.Focus();
                    FatTextbox.Text             = "";
                    FatTextbox.LineFocusedColor = Color.Red;
                }
                else if (!(double.Parse(LRTextbox.Text) >= 10 && double.Parse(LRTextbox.Text) <= 30))
                {
                    MessageBox.Show(" LR (Lactometer Reading) should be within Range (10 - 30).", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LRTextbox.Focus();
                    LRTextbox.Text             = "";
                    LRTextbox.LineFocusedColor = Color.Red;
                }
                else
                {
                    MessageBox.Show("Successfull", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    ClearTextBoxes();
                }
            }
        }
Ejemplo n.º 2
0
        private void CalculateButton_Click(object sender, EventArgs e)
        {
            if (MilkManNameTextbox.Text == "")
            {
                MessageBox.Show("Name missing.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MilkManNameTextbox.Focus();
                MilkManNameTextbox.LineFocusedColor = Color.Red;
                return;
            }
            else if (VolumeTextbox.Text == "")
            {
                MessageBox.Show("Volume is Missing.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                VolumeTextbox.Focus();
                VolumeTextbox.LineFocusedColor = Color.Red;
                return;
            }
            else if (FatTextbox.Text == "")
            {
                MessageBox.Show("FAT is Missing.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                FatTextbox.Focus();
                FatTextbox.LineFocusedColor = Color.Red;
                return;
            }
            else if (LRTextbox.Text == "")
            {
                MessageBox.Show("LR is Missing.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LRTextbox.Focus();
                LRTextbox.LineFocusedColor = Color.Red;
                return;
            }
            else if (RateTextbox.Text == "")
            {
                MessageBox.Show("Amount is Missing.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                RateTextbox.Focus();
                RateTextbox.LineFocusedColor = Color.Red;
                return;
            }

            else
            {
                this.LRTextbox.LineFocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(6)))), ((int)(((byte)(34)))), ((int)(((byte)(55)))));
                amount = ((double.Parse(TSTextbox.Text)) * (double.Parse(RateTextbox.Text)));

                AmountTextbox.Text = amount.ToString();
                if (LRTextbox.Text == "" || VolumeTextbox.Text == "" || FatTextbox.Text == "" || AmountTextbox.Text == "")
                {
                    SNFTextbox.Text = "0";
                    TSTextbox.Text  = "0";
                    return;
                }


                else
                {
                    volume = double.Parse(VolumeTextbox.Text);
                    fat    = double.Parse(FatTextbox.Text);
                    lr     = double.Parse(LRTextbox.Text);

                    // now calculate the SNF from formula given below
                    //SNF = (.25 * LR) + (.22 * FAT) +(.72)
                    snf             = ((.25 * lr) + (.22 * fat) + (.72));
                    SNFTextbox.Text = snf.ToString();

                    // now calculate the 13TS from formula given below

                    ts13           = (((snf + fat) * (volume)) / (13));
                    TSTextbox.Text = ts13.ToString();
                }
            }
        }