private void GenerateIncome_btn_Click(object sender, EventArgs e) { if (Revenue_Combobox.Items.Count == 0) { MessageBox.Show("There is no revenues", "Revenues Box", MessageBoxButtons.OK, MessageBoxIcon.Information); Revenue_Combobox.Focus(); } else if (Expense_Combobox.Items.Count == 0) { MessageBox.Show("There is no Expenses", "Expenses Box", MessageBoxButtons.OK, MessageBoxIcon.Information); Expense_Combobox.Focus(); } else { double Total_expenses = 0, Total_revenue = 0, Income; //Calculate the sum of the revenues for (int i = 0; i < Revenue_Combobox.Items.Count; i++) { Total_revenue += double.Parse(Revenue_Combobox.Items[i].ToString()); } //Calculate the sum of expenses for (int i = 0; i < Expense_Combobox.Items.Count; i++) { Total_expenses += double.Parse(Expense_Combobox.Items[i].ToString()); } Income_label.Visible = true; Icome_TRev_label.Visible = true; Icome_TExp_label.Visible = true; T_REvenue_Label.Visible = true; Total_Expenses.Visible = true; Total_Result_label.Visible = true; Income = Total_revenue - Total_expenses; T_REvenue_Label.Text = Total_revenue + " $"; Total_Expenses.Text = Total_expenses + " $"; if (Total_revenue > Total_expenses) { Total_Result_label.Text = "Net Income = " + Income + " $"; } else if (Total_expenses > Total_revenue) { Total_Result_label.Text = "Net loss = " + Income + " $"; } else if (Total_expenses == Total_revenue) { Total_Result_label.Text = "The values are same"; } } }
private void ClearRevenue_btn_Click(object sender, EventArgs e) { if (Revenue_Combobox.Items.Count == 0) { MessageBox.Show("There is no values in box", "Revenue Box", MessageBoxButtons.OK, MessageBoxIcon.Information); Revenue_Combobox.Focus(); } else { Revenue_Combobox.Items.Clear(); Revenue_Count = 0; Count_ItemRevenue_Notif.Text = Revenue_Count.ToString(); } }