Exemplo n.º 1
0
        public GastosUserControl(string id = null)
        {
            InitializeComponent();

            currentID               = -1;
            currentGastosDao        = new GastosDAO(MainWindow.currentPath);
            tipoComboBox.DataSource = Enum.GetValues(typeof(GastosType));

            maquinarioDao              = new MaquinarioDAO(MainWindow.currentPath);
            unidadeAnimalDao           = new UnidadeAnimalDAO(MainWindow.currentPath);
            combustiveisDao            = new CombustiveisDAO(MainWindow.currentPath);
            pastagemDao                = new PastagemDAO(MainWindow.currentPath);
            gastosDao                  = new GastosDAO(MainWindow.currentPath);
            tipoComboBox.SelectedIndex = -1;

            if (id != null)
            {
                currentID                  = int.Parse(id);
                currentGastos              = currentGastosDao.selectById(currentID);
                nomeTextBox.Text           = currentGastos.nome;
                tipoComboBox.SelectedIndex = (int)currentGastos.idCategoria;
                refreshList();
                if (tipoComboBox.SelectedIndex > 0)
                {
                    referenteComboBox.SelectedIndex = currentGastos.idRef - 1;
                }
                else
                {
                    referenteComboBox.SelectedIndex = -1;
                }
                valorTextBox.Text = currentGastos.valor.ToString();
            }
        }
 private void initDaos()
 {
     if (currentPath == null)
     {
         return;
     }
     maquinarioDao    = new MaquinarioDAO(currentPath);
     combustiveisDao  = new CombustiveisDAO(currentPath);
     pastagemDao      = new PastagemDAO(currentPath);
     tipoPastagemDao  = new TipoPastagemDAO(currentPath);
     gastosDao        = new GastosDAO(currentPath);
     unidadeAnimalDao = new UnidadeAnimalDAO(currentPath);
 }