public static NfeDetalheDTO GravaNfceVendaDetalhe(NfeDetalheDTO pNfceVendaDetalhe) { try { using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession()) { NHibernateDAL <NfeDetalheDTO> DAL = new NHibernateDAL <NfeDetalheDTO>(Session); DAL.SaveOrUpdate(pNfceVendaDetalhe); Session.Flush(); } return(pNfceVendaDetalhe); } catch (Exception ex) { throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : "")); } }
public void PesquisarProduto() { try { SearchWindowApp searchWindow = new SearchWindowApp(typeof(ProdutoDTO), typeof(NFe.Model.ServicoNFe)); searchWindow.definirColunas(new string[] { "Gtin", "Nome", "ValorVenda" }); if (searchWindow.ShowDialog() == true) { ProdutoSelected = (ProdutoDTO)searchWindow.itemSelecionado; DetalheNFe = new NfeDetalheDTO(); notifyPropertyChanged("ProdutoSelected"); notifyPropertyChanged("DetalheNFe"); } } catch (Exception ex) { throw ex; } }
public static int CancelaItemVenda(int pItem) { try { int Resultado = -1; using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession()) { NHibernateDAL <NfeDetalheDTO> DALDetalhe = new NHibernateDAL <NfeDetalheDTO>(Session); NfeDetalheDTO Detalhe = DALDetalhe.SelectObjeto <NfeDetalheDTO>( new NfeDetalheDTO { NumeroItem = pItem, IdNfeCabecalho = Sessao.Instance.VendaAtual.Id } ); if (Detalhe != null) { // Se o item existe na base, exclui o imposto e o item NfeDetalheImpostoIcmsDTO Icms = new NfeDetalheImpostoIcmsDTO(); Icms.IdNfeDetalhe = Detalhe.Id; NHibernateDAL <NfeDetalheImpostoIcmsDTO> DALIcms = new NHibernateDAL <NfeDetalheImpostoIcmsDTO>(Session); DALIcms.Delete(Icms); DALDetalhe.Delete(Detalhe); Session.Flush(); Resultado = 0; } } return(Resultado); } catch (Exception ex) { throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : "")); } }