예제 #1
0
        private void bunifuThinButton24_Click(object sender, EventArgs e)
        {
            if (txtUser.Text.Trim() != "" && !hint)
            {
                if (txtPassword.Text.Trim() != "" && !hint2)
                {
                    System.Configuration.Configuration c = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
                    User us;
                    try
                    {
                        if (UserCurrent.getCurrentUser() != null)
                        {
                            usController = new UserController();
                        }

                        us = usController.Logar(txtUser.Text, txtPassword.Text);
                        if (us != null)
                        {
                            SystemInfoCurrent.initialize();

                            UserCurrent.initialize(us);
                            if (us.FlagFirstLogin)
                            {
                                new FrmUserFirstLogin(us, this).Show();
                            }
                            else
                            {
                                new Main(this).Show();
                            }
                            txtUser.Focus();
                            txtUser.Select(0, 0);
                            Hide();
                            txtPassword.Clear();
                            txtUser.Clear();
                        }
                        else
                        {
                            MessageBox.Show("usuario ou senha incorrestos,\n TRY AGAIN");
                            txtPassword.Clear();
                            txtUser.Clear();
                            txtUser.Focus();
                        }
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show(error.Message);
                        us = null;
                    }
                }
                else
                {
                    MessageBox.Show("Insira a senha");
                    txtPassword.Focus();
                }
            }
            else
            {
                MessageBox.Show("Insira o usuario");
            }
        }
예제 #2
0
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            // string hora = DateTime.Now.Hour <= 9 ? "0" + DateTime.Now.Hour. : DateTime.Now.Hour;
            Turno t = new Turno()
            {
                Data     = DateTime.Now,
                Estado   = "Aberto",
                Hora     = DateTime.Now.ToShortTimeString(),
                Caixa    = decimal.Parse(textEdit1.Text),
                Abertura = decimal.Parse(textEdit1.Text),
                Tpa      = 0,
                UserId   = UserCurrent.getCurrentUser().Id,
                UserName = UserCurrent.getCurrentUser().Nome,
                DataF    = DateTime.Now,
                HoraF    = DateTime.Now.ToShortTimeString(),
            };
            TurnoController _turnoController = new TurnoController();

            _turnoController.insert(t);   TurnoCurrent.initialize(t);
            frmC.setButtonFalse();
            frmC.fillData();
            FrmReportView frm = new FrmReportView();

            frm.PrintOpenBox(TurnoCurrent.getTurnoCurrent());

            Close();
            // Hide();
        }
예제 #3
0
        public FrmPosRestaurant(Main main)
        {
            InitializeComponent();

            lblUser.Text = UserCurrent.getCurrentUser().Nome;
            this.main    = main;
            idUser       = UserCurrent.getCurrentUser().Id;
            if (UserCurrent.getCurrentUser().FlagAdmin)
            {
                isAdminActive = true;
            }
            toGridControlProducts();

            getSerie();
            string hora = DateTime.Now.Hour.ToString();
            string min  = DateTime.Now.Minute.ToString();

            if (int.Parse(min) < 10)
            {
                min = "0" + min;
            }
            if (int.Parse(hora) < 10)
            {
                hora = "0" + hora;
            }
            lblHora.Text = hora + ":" + min;
        }
예제 #4
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (position >= 0)
            {
                if (UserCurrent.getCurrentUser().FlagAdmin == true)
                {
                    idProd = MethodsTable.getCellValueRowSelectedIdInt(gridViewProducts);
                    new FrmProducts(this, idProd).ShowDialog();
                }
                else
                {
                    if (UserCurrent.getPermission().Stock)
                    {
                        idProd = MethodsTable.getCellValueRowSelectedIdInt(gridViewProducts);
                        if (position >= 0)
                        {
                            idProd = MethodsTable.getCellValueRowSelectedIdInt(gridViewProducts);
                            new FrmProducts(this, idProd).ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("Selecione o produto");
                        }
                    }
                }
            }

            position = -1;
            ///
        }
예제 #5
0
 private void bunifuThinButton23_Click(object sender, EventArgs e)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin == true)
     {
         if (position >= 0)
         {
             _storeController.deleteForId(_storeController.List()[position].Id);
             fillData();
         }
         else
         {
             MessageBox.Show("Selecione o armazem");
         }
     }
     else
     {
         if (UserCurrent.getPermission().Stock)
         {
             if (position >= 0)
             {
                 _storeController.deleteForId(_storeController.List()[position].Id);
                 fillData();
             }
             else
             {
                 MessageBox.Show("Selecione o armazem");
             }
         }
     }
     position = -1;
 }
예제 #6
0
 private void simpleButton2_Click(object sender, EventArgs e)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin)
     {
         main.Show();
         Close();
     }
     else
     {
         Close();
     }
 }
예제 #7
0
        public void initDate(Turno t)
        {
            lblValor.Text    = t.Caixa.ToString();;
            lblUser.Text     = UserCurrent.getCurrentUser().Nome;
            lblDataHora.Text = t.Data.ToString();
            string rootPath = Application.StartupPath;

            Company company = SystemInfoCurrent.getCurrentCompany();

            xrlblCompany.Text = company.Empresa;
            xrlblNif.Text     = "NIF: " + company.Nif;
            xrlblTel.Text     = "Telefone: " + company.Tel;
        }
예제 #8
0
 private void barButtonItem42_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin == true)
     {
         if (new SerieController().ListALL().Count > 0)
         {
             if (TurnoCurrent.getTurnoCurrent() == null)
             {
                 MessageBox.Show("Abra o Caixa Primeiro");
             }
             else
             {
                 FrmPosRestaurant frmPos = new FrmPosRestaurant(this);
                 frmPos.Show();
                 Hide();
             }
         }
         else
         {
             MessageBox.Show("Cadastre uma serie no sistema");
         }
     }
     else
     {
         if (UserCurrent.getPermission().Venda)
         {
             if (new SerieController().ListALL().Count > 0)
             {
                 if (new TableController().ListALL().Count > 0)
                 {
                     FrmPosRestaurant frmPos = new FrmPosRestaurant(this);
                     frmPos.Show();
                     Hide();
                 }
                 else
                 {
                     MessageBox.Show("Cadastre pelo menos uma(1) mesa");
                 }
             }
             else
             {
                 MessageBox.Show("Cadastre uma serie no sistema");
             }
         }
         else
         {
             MessageBox.Show("Não tem permissão para completar essa operação");
         }
     }
 }
예제 #9
0
        public PDV()
        {
            InitializeComponent();
            idUser = UserCurrent.getCurrentUser().Id;
            getSerie();
            _codigoFaturaAtual = 1;

            if (!Directory.Exists(pathImgs))
            {
                Directory.CreateDirectory(pathImgs);
            }
            allowPermissionFolder(pathImgs);
            CalcCodigoFaturaAtual();
        }
예제 #10
0
 private void btnNewCategory_Click(object sender, EventArgs e)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin == true)
     {
         new FrmCategorySave(this).ShowDialog();
     }
     else
     {
         if (UserCurrent.getPermission().Stock)
         {
             new FrmCategorySave(this).ShowDialog();
         }
         else
         {
             MessageBox.Show("Não tem permissão para completar essa operação");
         }
     }
 }
예제 #11
0
 private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin == true)
     {
         new FrmOutProduct().ShowDialog();
     }
     else
     {
         if (UserCurrent.getPermission().Stock)
         {
             new FrmOutProduct().ShowDialog();
         }
         else
         {
             MessageBox.Show("Não tem permissão para completar essa operação");
         }
     }
 }
예제 #12
0
 private void bunifuThinButton21_Click(object sender, EventArgs e)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin == true)
     {
         FrmStoreSave frm = new FrmStoreSave(this);
         frm.ShowDialog();
     }
     else
     {
         if (UserCurrent.getPermission().Stock)
         {
             FrmStoreSave frm = new FrmStoreSave(this);
             frm.ShowDialog();
         }
         else
         {
             MessageBox.Show("Não tem permissão para completar essa operação");
         }
     }
 }
예제 #13
0
 public void openInvoiceForm(string type, FrmInvoice frm)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin == true)
     {
         if (isFormInactive(frm))
         {
             activeForm(frm = new FrmInvoice(type));
         }
     }
     else
     {
         if (UserCurrent.getPermission().Venda)
         {
             if (isFormInactive(frm))
             {
                 activeForm(frm = new FrmInvoice(type));
             }
         }
         else
         {
             MessageBox.Show("Não tem permissão para completar essa operação");
         }
     }
 }
예제 #14
0
        public FrmPosPdv(Main main)
        {
            InitializeComponent();
            this.main = main;
            new FrmPosPrinter().ShowDialog();
            if (UserCurrent.getCurrentUser().FlagAdmin)
            {
                isAdminActive = true;
            }
            toGridControlProducts();
            gridCategory.DataSource = _categoryController.ListALLAsNoTracking();
            getSerie();
            string hora = DateTime.Now.Hour.ToString();
            string min  = DateTime.Now.Minute.ToString();

            if (int.Parse(min) < 10)
            {
                min = "0" + min;
            }
            if (int.Parse(hora) < 10)
            {
                hora = "0" + hora;
            }
            lblHora.Text = hora + ":" + min;

            /* PictureEdit pic = new PictureEdit();
             * pic.Image = Image.FromFile(@"C:\Users\FernandoWonder\Pictures\detalhe_empresa.png");
             * repositoryItemPictureEdit1.HtmlImages = pic.Image;
             * //pic.EditValue = Image.FromFile("");
             * RepositoryItemPictureEdit edit = new RepositoryItemPictureEdit();
             * edit.HtmlImages = pic;
             *
             * edit.HtmlImages = Image.FromFile(@"C:\Users\FernandoWonder\Pictures\detalhe_empresa.png");
             */
            //cardView1.Columns["Id"].Visible = false;
        }
예제 #15
0
 private void btnNDC_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin == true)
     {
         if (isFormInactive(frmInvoiceCredite))
         {
             activeForm(frmInvoiceCredite = new FrmInvoicesForCreditNote());
         }
     }
     else
     {
         if (UserCurrent.getPermission().Stock)
         {
             if (isFormInactive(frmInvoiceCredite))
             {
                 activeForm(frmInvoiceCredite = new FrmInvoicesForCreditNote());
             }
         }
         else
         {
             MessageBox.Show("Não tem permissão para completar essa operação");
         }
     }
 }
예제 #16
0
 private void btnPOS_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (UserCurrent.getCurrentUser().FlagAdmin == true)
     {
         if (new SerieController().ListALL().Count > 0)
         {
             FrmPosPdv frmPost = new FrmPosPdv(this);
             frmPost.Show();
             Hide();
         }
         else
         {
             MessageBox.Show("Cadastre uma serie no sistema");
         }
     }
     else
     {
         if (UserCurrent.getPermission().Stock)
         {
             if (new SerieController().ListALL().Count > 0)
             {
                 FrmPosPdv frmPost = new FrmPosPdv(this);
                 frmPost.Show();
                 Hide();
             }
             else
             {
                 MessageBox.Show("Cadastre uma serie no sistema");
             }
         }
         else
         {
             MessageBox.Show("Não tem permissão para completar essa operação");
         }
     }
 }
예제 #17
0
        /* public bool verificaData()
         * {
         *   Invoice ivlast = _invoiceController.ListALLAsNoTracking().LastOrDefault();
         *   if(ivlast != null)
         *   {
         *       if(ivlast.DataCadastro > DateTime.Now)
         *       {
         *           MessageBox.Show("Verifique se a data do Sistema está correta..!");
         *           return false;
         *       }
         *   }
         *   return true;
         * }*/



        public void salvar()
        {
            //Series serie = _serieController.ListALLAsNoTracking()[cmbSerie.SelectedIndex];
            try
            {
                CalcCodigoFaturaAtual();
                obs = txtDescricao.Text;
                string   invoiceNo = getInvoiceTypeTipo() + " " + _serieController.ListALLAsNoTracking()[cmbSerie.SelectedIndex].Serie + "/" + _codigoFaturaAtual;
                DateTime dataAtual = DateTime.Now;

                //string GrossTotal = (TotalIva + totalIncidencia).ToString("F").Replace(',', '.');
                string GrossTotal = (totGeral).ToString("F3").Replace(',', '.');
                //   string dadosHash2 = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm") + ";" + invoiceNo + ";" + (TotalIva + totalIncidencia).ToString("N2").Replace(",", ".") + ";";
                string dadosHash = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm:ss") + ";" + invoiceNo + ";" + GrossTotal + ";";
                dadosHash += lastInvoice != null ? lastInvoice.Hash : "";
                //dadosHash = lastInvoice != null ? dadosHash + lastInvoice.Hash : dadosHash;

                string Hash = Methods.gerarHash(dadosHash, invoiceNo);

                Invoice invoice = new Invoice()
                {
                    InvoiceDate      = dataAtual.ToString("yyyy-MM-dd"),
                    Codigo           = _codigoFaturaAtual,
                    ClienteId        = ClienteID,
                    SeriesId         = idSerie,
                    InvoiceNo        = invoiceNo,
                    TipoDocumentoId  = idTipoDocumento,
                    Desconto         = totDescontoProducts,
                    Observacao       = obs,
                    TotalImposto     = TotalIva,
                    TotalIncidencia  = totalIncidencia,
                    TotalLiquidar    = cmbInvoiceType.Text == "FT" ? totalIncidencia + TotalIva : 0,
                    UserId           = UserCurrent.getCurrentUser().Id,
                    Troco            = troco,
                    ValorPago        = valorPago,
                    FormaPagamentoId = cmbInvoiceType.Text == "FT" ? "CD" : cmbInvoiceType.Text == "PP" || cmbInvoiceType.Text == "FP" ? null : _paymentWays.ListALLAsNoTracking()[cmbPaymentMechanism.SelectedIndex].Id,
                    DataCadastro     = dataAtual,
                    Hash             = Hash,
                    DataVencimento   = dtVencimento.Enabled ? dtVencimento.Value : DateTime.Now,
                };
                _invoiceController.insert(invoice);

                invoice = _invoiceController.getForInvoiceNo(invoiceNo);
                int idFatura = invoice != null ? invoice.Id : 0;

                if (idFatura == 0)
                {
                    MessageBox.Show("Fatura Nula");
                }
                _invoiceController.Dispose();
                _invoiceController = new InvoiceController();

                /*string dadosHash = invoice.InvoiceDate + ";" + invoice.DataCadastro.ToString("yyyy-MM-ddTHH:mm:ss") + ";" + invoice.InvoiceNo + ";" + invoice.TotalGeral.ToString("N2").Replace(",", ".") + ";";
                 * string dadosHash2 = invoice.InvoiceDate + ";" + invoice.DataCadastro.ToString("yyyy-MM-ddTHH:mm") + ";" + invoice.InvoiceNo + ";" + invoice.TotalGeral.ToString("N2").Replace(",", ".") + ";";
                 * dadosHash = lastInvoice != null ? dadosHash2 + lastInvoice.Hash : dadosHash;
                 * invoice.Hash = Methods.gerarHash(dadosHash);*/


                CurrentAccountSystem currentAccountSystem = _currentAcountSystemController.ListALL()[cmbConta.SelectedIndex];
                currentAccountSystem.Saldo += invoice.TotalGeral;
                _currentAcountSystemController.update(currentAccountSystem);



                foreach (var item in __listaSelected)
                {
                    Stock stock = _stock.getStockArmazemProduct(item.ProdutoId, item.Stock.ArmazemId);
                    stock.Quantidade -= item.Quantidade;
                    _stock.update(stock);

                    string  movitoISE = null;
                    Product product   = _products.getOne(item.ProdutoId);
                    if (product.MotivoISEId != null)
                    {
                        movitoISE = product.MotivoISE.MencaoFatura;
                    }


                    ProductSales productSale = new ProductSales()
                    {
                        Preco             = item.Preco,
                        FaturaId          = idFatura,
                        ProductId         = item.ProdutoId,
                        Desconto          = item.Desconto,
                        Descricao_Produto = product.Descricao,
                        Quantidade        = item.Quantidade,
                        StockId           = item.StockId,
                        Taxa          = product.CodigoTaxa.Taxa,
                        Unidade       = product.UnidadeBase.Simbolo,
                        MotivoISEId   = product.MotivoISEId,
                        MotivoIsencao = movitoISE,
                    };

                    _sales.insert(productSale);
                }

                __listaSelected.Clear();
                gdvControlProducts.DataSource = __listaSelected;
                gdvControlProducts.RefreshDataSource();
                CalcCodigoFaturaAtual();
                print(idFatura);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
예제 #18
0
        public void salvar()
        {
            CalcCodigoFaturaAtual();

            DateTime dataAtual = DateTime.Now;

            string GrossTotal = (totGeral).ToString().Replace(',', '.');
            //   string dadosHash2 = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm") + ";" + invoiceNo + ";" + (TotalIva + totalIncidencia).ToString("N2").Replace(",", ".") + ";";
            string dadosHash = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm:ss") + ";" + invoiceNo + ";" + GrossTotal + ";";

            dadosHash += lastInvoice != null ? lastInvoice.Hash : "";

            string Hash = Methods.gerarHash(dadosHash, invoiceNo);


            _invoiceNota = new Invoice()
            {
                ClienteId        = _invoiceCorrigir.ClienteId, // Trocar depois, pois o motivo da nota pode erro no cliente
                Codigo           = _codigoFaturaAtual,
                Desconto         = totDescontoProducts,
                InvoiceDate      = dataAtual.ToString("yyyy-MM-dd"),
                InvoiceNo        = invoiceNo,
                TipoDocumentoId  = idTipoDocumento,
                RazaoNota        = cmbMotivoNota.Text,
                SeriesId         = idSerie,
                TipoOperacaoId   = (cmbTipoOperacaoNota.SelectedIndex + 1),
                TotalImposto     = TotalIva,
                TotalIncidencia  = totalIncidencia,
                UserId           = UserCurrent.getCurrentUser().Id,
                Hash             = Hash,
                Referencia       = _invoiceCorrigir.InvoiceNo,
                FormaPagamentoId = _invoiceCorrigir.FormaPagamentoId,
            };

            int r = _invoiceController.insert(_invoiceNota);

            _invoiceNota = _invoiceController.getForInvoiceNo(invoiceNo);


            int idFatura = _invoiceNota != null ? _invoiceNota.Id : 0;

            if (idFatura == 0)
            {
                MessageBox.Show("Fatura Nula");
            }
            //_invoiceController.Dispose();
            //_invoiceController = new InvoiceController();

            foreach (var item in __productSales)
            {
                Stock stock = _stock.getStockArmazemProduct(item.ProductId, item.Stock.ArmazemId);
                stock.Quantidade += item.Quantidade;
                _stock.update(stock);

                ProductSales productSale = new ProductSales()
                {
                    Desconto          = item.Desconto,
                    FaturaId          = idFatura,
                    MotivoIsencao     = item.MotivoIsencao,
                    Descricao_Produto = item.Product.Descricao,
                    ProductId         = item.ProductId,
                    Quantidade        = item.Quantidade,
                    StockId           = item.StockId,
                    Taxa        = item.Taxa,
                    Unidade     = item.Unidade,
                    Preco       = item.Preco,
                    Observacao  = item.Observacao,
                    MotivoISEId = item.MotivoISEId,
                };
                _sales.insert(productSale);
            }

            //__listaSelected.Clear();
            //   gdvControlProducts.DataSource = __listaSelected;
            gdvControlProducts.RefreshDataSource();
            CalcCodigoFaturaAtual();
            print(idFatura);
        }
예제 #19
0
 private void Main_Load(object sender, EventArgs e)
 {
     lblUserCurrent.Text = UserCurrent.getCurrentUser().Usuario;
 }
예제 #20
0
        private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (UserCurrent.getCurrentUser().FlagAdmin == true)
            {
                StorageController  _storageController  = new StorageController();
                ProviderController _providerController = new ProviderController();

                if (_providerController.ListALLAsNoTracking().Count > 0)
                {
                    if (_storageController.List().Count > 0)
                    {
                        if (isFormInactive(frmEntry))
                        {
                            frmEntry           = new FrmEntryProducts();
                            frmEntry.MdiParent = this;
                            frmEntry.Show();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Nenhum armazem encontrado \nInsira um armazem primeiro");
                        new FrmStoreSave().ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Nenhum Fornecedor encontrado \nInsira um Fornecedor primeiro");
                    new FrmFornecedorSave(true).ShowDialog();
                }
            }
            else
            {
                if (UserCurrent.getPermission().Stock)
                {
                    StorageController  _storageController  = new StorageController();
                    ProviderController _providerController = new ProviderController();

                    if (_providerController.ListALLAsNoTracking().Count > 0)
                    {
                        if (_storageController.List().Count > 0)
                        {
                            if (isFormInactive(frmEntry))
                            {
                                frmEntry           = new FrmEntryProducts();
                                frmEntry.MdiParent = this;
                                frmEntry.Show();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Nenhum armazem encontrado \nInsira um armazem primeiro");
                            new FrmStoreSave().ShowDialog();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Nenhum Fornecedor encontrado \nInsira um Fornecedor primeiro");
                        new FrmFornecedorSave(true).ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Não tem permissão para completar essa operação");
                }
            }
        }
예제 #21
0
        private void btnSaveRecibo_Click(object sender, EventArgs e)
        {
            if (!Methods.verificaData())
            {
                MessageBox.Show("Verifique se a data do Sistema está correta..!");
            }
            else if (_faturasSelecionadas.Count > 0)
            {
                CalcCodigoFaturaAtual();
                obs = txtDescricao.Text;
                string   invoiceNo = getInvoiceTypeTipo() + " " + _serieController.ListALLAsNoTracking()[cmbSerie.SelectedIndex].Serie + "/" + _codigoFaturaAtual;
                DateTime dataAtual = DateTime.Now;

                //string GrossTotal = (TotalIva + totalIncidencia).ToString("F").Replace(',', '.');
                string GrossTotal = (totGeral).ToString("F3").Replace(',', '.');
                //   string dadosHash2 = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm") + ";" + invoiceNo + ";" + (TotalIva + totalIncidencia).ToString("N2").Replace(",", ".") + ";";
                string dadosHash = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm:ss") + ";" + invoiceNo + ";" + GrossTotal + ";";
                dadosHash += lastInvoice != null ? lastInvoice.Hash : "";
                //dadosHash = lastInvoice != null ? dadosHash + lastInvoice.Hash : dadosHash;

                string Hash = Methods.gerarHash(dadosHash, invoiceNo);

                Invoice documento = new Invoice()
                {
                    InvoiceDate      = dataAtual.ToString("yyyy-MM-dd"),
                    Codigo           = _codigoFaturaAtual,
                    ClienteId        = ClienteID,
                    SeriesId         = idSerie,
                    InvoiceNo        = invoiceNo,
                    TipoDocumentoId  = idTipoDocumento,
                    Observacao       = obs,
                    UserId           = UserCurrent.getCurrentUser().Id,
                    FormaPagamentoId = _paymentWays.ListALLAsNoTracking()[cmbFormaPagamentoRecibo.SelectedIndex].Id,
                    DataCadastro     = dataAtual,
                    Hash             = Hash,
                };
                _invoiceController.insert(documento);

                documento = _invoiceController.getForInvoiceNo(invoiceNo);
                int idFatura = documento != null ? documento.Id : 0;

                if (idFatura == 0)
                {
                    MessageBox.Show("Fatura Nula");
                }
                else
                {
                    _invoiceController.Dispose();
                    _invoiceController = new InvoiceController();
                }


                ReciboController _rcController = new ReciboController();

                int reciboId = 0; // Vai receber o id do recibo apos ser cadastrado


                Recibo recibo = new Recibo()
                {
                    DataUltimoEstadoPagamento = DateTime.Now,
                    DocumentoId = documento.Id,
                    UserUltimoEstadoDocumentoId = UserCurrent.getCurrentUser().Id,
                    TotalRecibo = decimal.Parse(lblTotalRecibo.Text),
                };
                _rcController.insert(recibo);
                recibo = _rcController.getForDocumentId(idFatura);

                reciboId = recibo != null ? recibo.Id : 0;

                if (reciboId == 0)
                {
                    MessageBox.Show("Recibo Nulo");
                }
                else
                {
                    salvarPagamentos(reciboId);
                    print(idFatura);
                    clearRecibo();
                }
            }
            else
            {
                MessageBox.Show("Nenhuma Fatura Selecionada");
            }
        }