private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {

                Invest anInvest = new Invest();
                anInvest.Id = Convert.ToInt16(idTextBox.Text);
                anInvest.Book = Convert.ToDouble(bookTextBox.Text);
                anInvest.Paper = Convert.ToDouble(paperTextBox.Text);
                anInvest.Ink = Convert.ToDouble(inkTextBOx.Text);
                anInvest.Equipment = Convert.ToDouble(equipmentTextBox.Text);
                anInvest.Others = Convert.ToDouble(othersTextBox.Text);
                anInvest.Date = dateTimePicker1.Text;
                lastAdded = Convert.ToInt16(idTextBox.Text);

                InvestmentGateway gateway = new InvestmentGateway();
               string status = gateway.SaveTotalInvestment(anInvest);
                MessageBox.Show(status,"Status",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    LastAddedInvestlNo();
                DBManager manager = new DBManager();
                SqlConnection connection = manager.Connection();
                string updateQuery = "UPDATE FInvestmentCost set FBook='" + bookTextBox.Text + "',FPaper='" + paperTextBox.Text + "',FInk='" + inkTextBOx.Text + "',FEquipment='" + equipmentTextBox.Text + "',FOthers='" + othersTextBox.Text + "',FInvestment_Date='" + dateTimePicker1.Text + "' WHERE FId='" + 1 + "'";
                SqlCommand updateCmd = new SqlCommand(updateQuery, connection);
                connection.Open();
                int x = updateCmd.ExecuteNonQuery();
                connection.Close();
                string query = "INSert INTo InvestmentCost values('" + bookTextBox.Text + "','" + paperTextBox.Text + "','" + inkTextBOx.Text + "','" + equipmentTextBox.Text + "','" + othersTextBox.Text + "','" + dateTimePicker1.Text + "')";
                SqlCommand command3=new SqlCommand(query,connection);
                connection.Open();
                int y = command3.ExecuteNonQuery();
                last = LastAddedInvestlNo();
                idTextBox.Text = last.ToString();  

                connection.Close();
                ClearAlltextBox();
            }
            catch (FormatException)
            {
                
                MessageBox.Show("Please fill every field properly.","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
           
        }