Пример #1
0
        private void Recarrega()
        {
            if (tbCodigo.Text.Length <= 0)
            {
                return;
            }

            if (editando)
            {
                if (MessageBox.Show("Tem certeza que deseja perder os dados alterados?",
                                    "Aviso de alteração",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }

            var controls = (ControlCollection)this.Controls;

            validacao.despintarCampos(controls);

            if (item != null)
            {
                item = itemDAO.BuscaByID(item.ItemID);
                PreencheCampos(item);
                if (editando)
                {
                    Editando(false);
                }
            }
            else
            {
                ignoraCheckEvent = true;
                LimpaCampos(true);
                ignoraCheckEvent = false;
            }
        }
Пример #2
0
        private void DgvItensorcamento_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvItensorcamento.Rows.Count > 0)
            {
                decimal c;

                if (decimal.TryParse(dgvItensorcamento.SelectedRows[0].Cells[6].Value.ToString(), out c))
                {
                    itemOrcamento      = new OrcamentoItem();
                    itemOrcamento.Item = itemDAO.BuscaByID((int)dgvItensorcamento.CurrentRow.Cells[0].Value);

                    quantidade    = c;
                    valorunitario = decimal.Parse(dgvItensorcamento.SelectedRows[0].Cells[5].Value.ToString());
                    totalitem     = quantidade * valorunitario;
                    dgvItensorcamento.SelectedRows[0].Cells[7].Value = totalitem;

                    itemOrcamento.Quantidade = quantidade;
                    itemOrcamento.ValorTotal = totalitem;

                    itemRemover = listaitensorcamento.Find(i => i.Item.ItemID == itemOrcamento.Item.ItemID);

                    listaitensorcamento.Remove(itemRemover);
                    if (itemRemover != null)
                    {
                        total -= itemRemover.ValorTotal;
                    }

                    if (c > 0)
                    {
                        listaitensorcamento.Add(itemOrcamento);
                        if (itemOrcamento != null)
                        {
                            total += itemOrcamento.ValorTotal;
                        }
                    }
                }
                else
                {
                    quantidade = 0;
                    dgvItensorcamento.SelectedRows[0].Cells[6].Value = 0.00;
                    dgvItensorcamento.SelectedRows[0].Cells[7].Value = 0.00;
                }
                dbTotal.Valor = total;
            }
        }
Пример #3
0
 private void TbCodigoItem_Leave(object sender, System.EventArgs e)
 {
     if (!int.TryParse(tbCodigoItem.Text, out int codigo))
     {
         tbCodigoItem.Clear();
     }
     if (tbCodigoItem.Text.Length > 0)
     {
         item = itemDAO.BuscaByID(int.Parse(tbCodigoItem.Text));
         PreencheCamposItem(item);
     }
     else
     {
         item = null;
         tbDescricaoItem.Clear();
     }
     this.Codigo_Leave?.Invoke(this, e);
 }