Exemplo n.º 1
0
        private void BtnAddCalculate_Click(object sender, EventArgs e)
        {
            try
            {
                //Initial Estimate
                string ProgramBudget, EstimatedBudget0, EstimatedBudget2, EstimatedBudget1;
                string Contingency_Percent;

                //ProgramBudget
                if (TxtAddProgramBudget.Text == "")
                {
                    ProgramBudget = 0.ToString();
                }
                else
                {
                    ProgramBudget = TxtAddProgramBudget.Text;
                }

                //EstimatedBudget0
                if (TxtAddEstiBud0.Text == "")
                {
                    EstimatedBudget0 = 0.ToString();
                }
                else
                {
                    EstimatedBudget0 = TxtAddEstiBud0.Text;
                }

                //EstimatedBudget2
                if (TxtAddEstiBud2.Text == "")
                {
                    EstimatedBudget2 = 0.ToString();
                }
                else
                {
                    EstimatedBudget2 = TxtAddEstiBud2.Text;
                }

                //contingency percent
                if (TxtContingencyPercent.Text == "")
                {
                    Contingency_Percent = 3.ToString();
                }
                else
                {
                    Contingency_Percent = TxtContingencyPercent.Text;
                }

                double Contingency   = Convert.ToDouble(ProgramBudget) * Convert.ToDouble(Contingency_Percent) / 100;
                double NetPayable0   = Convert.ToDouble(ProgramBudget) - Contingency;
                double Contribution0 = Convert.ToDouble(EstimatedBudget0) - NetPayable0;

                //Frist running bill
                double NetPayable1, Contribution1;
                //EstimatedBudget2
                if (TxtAddEstiBud1.Text == "")
                {
                    EstimatedBudget1 = 0.ToString();
                }
                else
                {
                    EstimatedBudget1 = TxtAddEstiBud1.Text;
                }

                //Netpayable1

                /*if (TxtAddNetPay1.Text == "")
                 * {
                 *  NetPayable1 = 0;
                 * }
                 * else
                 * {
                 *  NetPayable1 = Convert.ToDouble(TxtAddNetPay1.Text);
                 * }*/

                double EvaluationFactor = NetPayable0 / Convert.ToDouble(EstimatedBudget0);
                TxtEvalulationFactor.Text = EvaluationFactor.ToString();
                NetPayable1   = Convert.ToDouble(EstimatedBudget1) * NetPayable0 / Convert.ToDouble(EstimatedBudget0);
                Contribution1 = Convert.ToDouble(EstimatedBudget1) - NetPayable1;
                double Running_InitialRatio = NetPayable1 / NetPayable0;
                TxtAddNetPay1.Text           = NetPayable1.ToString("0.00");
                TxtAddContribution1.Text     = Contribution1.ToString("0.00");
                TxtRunning_InitialRatio.Text = Running_InitialRatio.ToString("0.00");

                //Final Bill
                double NetPayable2, Contribution2, TotalNetPay, TotalContribution;

                /*if (Convert.ToDouble(EstimatedBudget2) * 0.9 > NetPayable0)
                 * {
                 *  NetPayable2 = NetPayable0;
                 * }
                 * else
                 * {
                 *  NetPayable2 = Convert.ToDouble(EstimatedBudget2) * 0.9;
                 * }*/

                //TxtTotalNetPayable.Text = NetPayable2.ToString();
                //Contribution2 = Convert.ToDouble(EstimatedBudget2) - NetPayable2 - Contribution1;

                TotalNetPay = Convert.ToDouble(EstimatedBudget2) * NetPayable0 / Convert.ToDouble(EstimatedBudget0);
                if (TotalNetPay <= NetPayable0)
                {
                    TotalNetPay = Convert.ToDouble(EstimatedBudget2) * NetPayable0 / Convert.ToDouble(EstimatedBudget0);
                }
                else
                {
                    TotalNetPay = NetPayable0;
                }

                TxtTotalNetPayable.Text   = TotalNetPay.ToString("0.00");
                TotalContribution         = Convert.ToDouble(EstimatedBudget2) - Convert.ToDouble(TotalNetPay);
                TxtTotalContribution.Text = TotalContribution.ToString("0.00");

                //Total Netpay

                /*if (TxtTotalNetPayable.Text == "")
                 * {
                 *  TotalNetPay = 0;
                 * }
                 * else
                 * {
                 *  TotalNetPay = Convert.ToDouble(TxtTotalNetPayable.Text);
                 * }
                 * //TotalNetPay = Convert.ToDouble(TxtTotalNetPayable.Text);
                 * //TotalContribution = Convert.ToDouble(TxtTotalContribution.Text);
                 * // TotalContribution
                 * if (TxtTotalContribution.Text == "")
                 * {
                 *  TotalContribution = 0;
                 * }
                 * else
                 * {
                 *  TotalContribution = Convert.ToDouble(TxtTotalContribution.Text);
                 * }*/

                NetPayable2   = TotalNetPay - NetPayable1;
                Contribution2 = TotalContribution - Contribution1;
                if (TotalNetPay <= NetPayable0)
                {
                    LblCheck.Text      = "Log: " + "OK";
                    LblCheck.ForeColor = Color.Green;
                }
                else
                {
                    LblCheck.Text      = "Log: " + "Review";
                    LblCheck.ForeColor = Color.Red;
                }

                //evaluation factor check
                if (EvaluationFactor <= 0.9)
                {
                    LblCheckEvalFacto.Text      = "Log: " + "OK";
                    LblCheckEvalFacto.ForeColor = Color.Green;
                }
                else
                {
                    LblCheckEvalFacto.Text      = "Log: " + "Review";
                    LblCheckEvalFacto.ForeColor = Color.Red;
                }

                //Running Initial ratio check
                if (Running_InitialRatio < 1)
                {
                    lblcheckRunningRatio.Text      = "Log: " + "OK";
                    lblcheckRunningRatio.ForeColor = Color.Green;
                }
                else
                {
                    lblcheckRunningRatio.Text      = "Log: " + "Review";
                    lblcheckRunningRatio.ForeColor = Color.Red;
                }
                //TxtTotalContribution.Text = (Contribution2 + Contribution1).ToString();

                //NetPayable2 = NetPayable2 - NetPayable1;
                //TxtAddNetPay2.Text = NetPayable2.ToString();


                TxtAddContingency.Text   = Contingency.ToString("0.00");
                TxtAddNetPay0.Text       = NetPayable0.ToString("0.00");
                TxtAddContribution0.Text = Contribution0.ToString("0.00");
                TxtAddContribution2.Text = Contribution2.ToString("0.00");
                TxtAddNetPay2.Text       = NetPayable2.ToString("0.00");
            }
            catch
            {
            }
        }