Exemple #1
0
        public static bool Insert(BillItem billItem)
        {
            if (!ValidatorSaleMessage(billItem.Sale))
            {
                return(false);
            }

            DataTable dt = new DataTable();

            try
            {
                using (DAO.PgsqlConnection = new NpgsqlConnection(DAO.ConnString))
                {
                    //Abra a conexão com o PgSQL
                    DAO.PgsqlConnection.Open();

                    string inserirVendaCMD = string.Format("select * from inserir_venda('{0}','{1}','{2}','{3}')",
                                                           billItem.Sale.Customer.CPF, billItem.Sale.Date,
                                                           billItem.Sale.TotalMoney.ToString("N", CultureInfo.CreateSpecificCulture("en-US")),
                                                           billItem.Sale.TotalCard.ToString("N", CultureInfo.CreateSpecificCulture("en-US")));

                    using (NpgsqlDataAdapter Adpt = new NpgsqlDataAdapter(inserirVendaCMD, DAO.PgsqlConnection))
                    {
                        Adpt.Fill(dt);
                    }

                    if (dt.Rows.Count > 0)
                    {
                        billItem.Sale.ID = dt.Rows[0]["inserir_venda"].ToString(); // Captura ID da venda
                        for (int i = 0; i < billItem.Sale.SaleItem_.Count; i++)
                        {
                            billItem.Sale.SaleItem_[i].VendaID = billItem.Sale.ID;
                        }

                        SalelItemDAO.MultiInsertAuto(billItem.Sale.SaleItem_);

                        string inserirItemContaCMD = string.Format("select * from inserir_item_conta('{0}','{1}','{2}')",
                                                                   billItem.Sale.ID, billItem.Sale.Customer.CPF,
                                                                   billItem.Total.ToString("N", CultureInfo.CreateSpecificCulture("en-US")));

                        return(GenericDAO.genericBool(inserirItemContaCMD));
                    }
                }
            }
            catch (NpgsqlException ex)
            {
                MessageBox.Show("Erro: " + ex.Message + ".\nPor Favor contate o suporte.", "Erro de Banco de Dados",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message + ".\nPor Favor contate o suporte.", "Erro de Sofware",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            finally
            {
                DAO.PgsqlConnection.Close();
            }

            return(false);
        }
Exemple #2
0
        public static bool Delete(string id)
        {
            string cmd = string.Format("select * from excluir_venda('{0}')", id);

            return(GenericDAO.genericBool(cmd));
        }
Exemple #3
0
        public static DataTable Select(DateTime start, DateTime end)
        {
            string cmd = string.Format("select * from selecionar_todas_vendas_periodo('{0}','{1}')", start, end);

            return(GenericDAO.Select(cmd));
        }
Exemple #4
0
        public static DataTable Select()
        {
            string cmd = string.Format("select * from selecionar_todas_vendas()");

            return(GenericDAO.Select(cmd));
        }