using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using System.Runtime.InteropServices;

namespace AccountingControls
{
    [Guid("3931F309-AAC3-484c-B050-8E5D5227E8F4")]
    interface IMyDotNetInterface
    {
        void ShowCOMDialog();
    }

    [ClassInterface(ClassInterfaceType.None)]
    [Guid("EDC19A52-9F42-490f-AC2B-1E22E415F2DC")]
    [ProgId("AccountingControls.BalanceSheet")]
    public partial class BalanceSheet : UserControl, IMyDotNetInterface
    {
        // IBusinessControl Interface allows Application to include IndexButton in the SidePanel automatically.
        private string _IndexButton = "Balance Sheet";
        public string IndexButton { get { return _IndexButton; } }


        public BalanceSheet()
        {
            InitializeComponent();
        }


        public void ShowCOMDialog()
        {
            MessageBox.Show("I am a" + "  Managed DotNET C# COM Object Dialog");
        }


        private void CalculateButton_Click(object sender, EventArgs e)
        {
            Calculate();
        }

        private void Calculate()
        {
            double cash = 0;
            double credit = 0;
            double cog = 0;
            double labor = 0;
            double rent = 0;
            double advert = 0;

            try
            {
                cash = double.Parse(CashTextBox.Text);
            }
            catch {/* Leave set to 0*/}
            try
            {
                credit = double.Parse(CreditTextBox.Text);
            }
            catch {/* Leave set to 0*/}
            try
            {
                cog = double.Parse(CostOfGoodsTextBox.Text);
                labor = double.Parse(LaborTextBox.Text);
            }
            catch {/* Leave set to 0*/}
            try
            {
                rent = double.Parse(RentTextBox.Text);
            }
            catch {/* Leave set to 0*/}
            try
            {
                advert = double.Parse(AdvertizingTextBox.Text);
            }
            catch {/* Leave set to 0*/}


            // Sum total
            double sum = cash + credit - cog - labor - rent - advert;

            // Assign value to TotalTextBox
            TotalTextBox.Text = sum.ToString();
        }
    }
}