private void btnAlterar_Click(object sender, EventArgs e)
        {
            DALConexao           cx       = new DALConexao(DadosDaConexao.StringDeConexao);
            BLLOrdemServico      bll      = new BLLOrdemServico(cx);
            BLLOrdemServicoItens bllitens = new BLLOrdemServicoItens(cx);
            frmCadastroOS        f        = new frmCadastroOS(AcaoTela.Alterar);

            f.btFinalizar.Enabled = true;
            if (dgvDados.SelectedRows.Count == 0)
            {
                MessageBox.Show("Nenhum registro selecionado!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                this.cod = Convert.ToInt32(dgvDados.CurrentRow.Cells[0].Value);
                ModelOrdemServico modelo = bll.CarregaModelOrdemServico(cod);
                f.txtCodigo.Text      = modelo.IdOS.ToString();
                f.txtDataInicial.Text = modelo.DataInicial;
                f.txtDataFinal.Text   = modelo.DataFinal;
                f.txtSituacao.Text    = modelo.Situacao;
                f.txtObservacao.Text  = modelo.Observacao;
                f.txtCodCliente.Text  = modelo.IdCliente.ToString();
                f.txtCodCliente_Leave(sender, e);

                //servicos itens
                DataTable tabela = bllitens.Localizar(modelo.IdOS);
                for (int i = 0; i < tabela.Rows.Count; i++)
                {
                    string   idser   = tabela.Rows[i]["idser"].ToString();
                    string   nomeser = tabela.Rows[i]["nomeser"].ToString();
                    string   det     = tabela.Rows[i]["detalhes"].ToString();
                    String[] it      = new String[] { idser, nomeser, det };
                    f.dgvItens.Rows.Add(it);
                }

                //NAO DEIXA A OS SER EDITADA MAIS
                if ((f.txtSituacao.Text == "FINALIZADO") || (f.txtSituacao.Text == "CANCELADO"))
                {
                    f.gbDadosOS.Enabled        = false;
                    f.gbLancarServicos.Enabled = false;
                    f.txtObservacao.Enabled    = false;
                    f.btFinalizar.Enabled      = false;
                    f.btnGravar.Enabled        = false;
                    f.btnSair.Enabled          = false;
                }

                f.ShowDialog();
                f.Dispose();
                if (cbSituacao.SelectedIndex == 0)
                {
                    dgvDados.DataSource = bll.LocalizarTodos(txtPesquisar.Text);
                    dgvDados.ClearSelection();
                }
                else if (cbSituacao.SelectedIndex == 1)
                {
                    dgvDados.DataSource = bll.LocalizarAbertos(txtPesquisar.Text);
                    dgvDados.ClearSelection();
                }
                else if (cbSituacao.SelectedIndex == 2)
                {
                    dgvDados.DataSource = bll.LocalizarFinalizados(txtPesquisar.Text);
                    dgvDados.ClearSelection();
                }
                else if (cbSituacao.SelectedIndex == 3)
                {
                    dgvDados.DataSource = bll.LocalizarCancelados(txtPesquisar.Text);
                    dgvDados.ClearSelection();
                }
                dgvDados.ClearSelection();
            }
        }
Exemple #2
0
 public BLLCategoria(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #3
0
 public BLLVoto(DALConexao cx)
 {
     DALobj = new DALVoto(cx);
 }
 public BLLPerson(DALConexao cx)
 {
     this.connection = cx;
 }
Exemple #5
0
 public BLLProduto(DALConexao cx)
 {
     this.conexao = cx;
 }
 public BLLTipoPessoa(DALConexao dalConexao)
 {
     this.Conexao = dalConexao;
 }
 public BLLEleitor(DALConexao cx)
 {
     dalEleitor = new DALEleitor(cx);
 }
Exemple #8
0
 public BLLSubCategoria(DALConexao cx) //Contrutor
 {
     this.conexao = cx;
 }
Exemple #9
0
 public BLLDepartamento(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #10
0
        public void TratarFila(string connectionString)
        {
            StringBuilder strSQL = new StringBuilder();

            strSQL.Append("select id ");
            strSQL.Append(", entrada ");
            strSQL.Append(", prioridade ");
            strSQL.Append(",status_atendimento ");
            strSQL.Append(", cliente ");
            strSQL.Append("from tb_atendimento ");
            strSQL.Append("where status_atendimento = 1 ");
            strSQL.Append("order by prioridade, entrada ");

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(strSQL.ToString(), connection);

                List <Fila> ListaDaFila    = new List <Fila>();
                List <Fila> listaAtendente = new List <Fila>();

                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    ListaDaFila.Add(new Fila()
                    {
                        id_atendente       = Convert.ToInt32(reader["id"]),
                        entrada            = Convert.ToDateTime(reader["entrada"]),
                        prioridade         = Convert.ToInt32(reader["prioridade"]),
                        status_atendimento = Convert.ToInt32(reader["status_atendimento"]),
                        cliente            = reader["cliente"].ToString()
                    });

                    listaAtendente = AtendenteDisponivel();

                    if (listaAtendente.Count() != 0)
                    {
                        foreach (var item in listaAtendente)
                        {
                            // atualizarFila(item.id_atendente, Convert.ToInt32(reader["id"].ToString()), connectionString);

                            id_atendente = item.id_atendente;
                            id           = Convert.ToInt32(reader["id"].ToString());

                            DALConexao   cx      = new DALConexao(Conexao.StringDeConexao);
                            DALCategoria bll     = new DALCategoria(cx);
                            Fila         objFila = new Fila(id, id_atendente);
                            bll.Alterar(objFila);
                        }
                    }

                    else
                    {
                        Console.WriteLine("sem atendente no momento!");
                        //continue;
                        break;
                    }
                }

                reader.Close();
                //  Console.ReadLine();
            }
        }
Exemple #11
0
 public BLLFabricante(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #12
0
 public BLLCompra(DALConexao cx)
 {
     conexao = cx;
 }
        private void Consulta()
        {
            busca = "select i.concluido, i.inventario, i.data_criacao_inv, COUNT(i.inventario) as quant_inventario, " +
                    "u.iniciais_usuario from inventario i inner join usuario u on i.id_usuario = u.id_usuario " +
                    "where i.id_unidade = " + cbUnidade.SelectedValue;

            //Leitura dos filtros

            string prefix       = "";
            int    quantFiltros = 1;

            if (txtDataDe.Text.Trim() != "/  /" && txtDataA.Text == txtDataDe.Text)
            {
                if (quantFiltros > 0)
                {
                    prefix = " and ";
                }

                busca = busca + " i.data_criacao_inv = '" + Convert.ToDateTime(txtDataDe.Text).ToString("d") + "'";
                quantFiltros++;
            }

            if (txtDataDe.Text.Trim() != "/  /" && txtDataA.Text != txtDataDe.Text)
            {
                if (quantFiltros > 0)
                {
                    prefix = " and ";
                }

                busca = busca + prefix + " i.data_criacao_inv >= '" + Convert.ToDateTime(txtDataDe.Text).ToString("d") + "' and " +
                        "i.data_criacao_inv <= '" + Convert.ToDateTime(txtDataA.Text).ToString("d") + "'";

                quantFiltros++;
            }

            if (txtNumero.Text.Trim() != "")
            {
                if (quantFiltros > 0)
                {
                    prefix = " and ";
                }

                busca = busca + prefix + "i.inventario = " + txtNumero.Text;
                quantFiltros++;
            }

            if (cbAbertos.Checked == true)
            {
                if (quantFiltros > 0)
                {
                    prefix = " and ";
                }

                busca = busca + prefix + " i.concluido = 'A'";
            }


            busca = busca + " group by i.inventario, i.concluido, i.data_criacao_inv, u.iniciais_usuario;";

            DALConexao    cx     = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLInventario bll    = new BLLInventario(cx);
            DataTable     tabela = bll.Localizar(busca);

            dgvInventario.Rows.Clear();

            bool Aberto;

            for (int i = 0; i < tabela.Rows.Count; i++)
            {
                try
                {
                    if (quantFiltros > 0)
                    {
                        prefix = " and ";
                    }

                    if (tabela.Rows[i]["concluido"].ToString() == "A")
                    {
                        Aberto = true;
                    }
                    else
                    {
                        Aberto = false;
                    }

                    string nrInv   = Convert.ToInt32(tabela.Rows[i]["inventario"]).ToString("00000000");
                    string data    = Convert.ToDateTime(tabela.Rows[i]["data_criacao_inv"]).ToString("d");
                    string quant   = tabela.Rows[i]["quant_inventario"].ToString();
                    string usuario = tabela.Rows[i]["iniciais_usuario"].ToString();

                    String[] P = new string[] { Aberto.ToString(), nrInv, data, quant, usuario };
                    this.dgvInventario.Rows.Add(P);
                }
                catch
                {
                }
            }

            #endregion
        }
Exemple #14
0
 public BLLEndereco(DALConexao dalConexao)
 {
     this.Conexao = dalConexao;
 }
Exemple #15
0
 public BLLVAR(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #16
0
 public BLLUnidadeMedida(DALConexao con)
 {
     this.CONEXAO = con;
 }
 public BLLCompra(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #18
0
 public BLLRelatorioPedido(DALConexao cx)
 {
     this.conexao = cx;
 }
 public BLLCaixaStatus(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #20
0
        private void CarregarIngredientesPorCodigo(string cod)
        {
            dgvDados.Rows.Clear();

            //Linha por linha busca ingrediente com custo
            DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLPratos  bll = new BLLPratos(cx);
            DataTable  tabelaIngredientes = bll.ListarIngredientes(cod);

            BLLAeB    bllaeb = new BLLAeB(cx);
            DataTable tabelaAeb;

            Augoritmos a = new Augoritmos();

            double TotalFicha = 0;

            if (tabelaIngredientes.Rows.Count > 0)
            {
                for (int i = 0; i < tabelaIngredientes.Rows.Count; i++)
                {
                    //cod_item, quant_ingrediente

                    tabelaAeb = bllaeb.LocalizarPorCod(tabelaIngredientes.Rows[i][0].ToString());

                    string codIngrediente, nomeingrediente, um;
                    double quant, custoUnit, custoTotal, fc;

                    codIngrediente  = tabelaIngredientes.Rows[i][0].ToString();
                    nomeingrediente = tabelaAeb.Rows[0][0].ToString();
                    um = tabelaAeb.Rows[0][1].ToString();
                    if (string.IsNullOrEmpty(tabelaAeb.Rows[0][2].ToString()))
                    {
                        fc = 0;
                    }
                    else
                    {
                        fc = Convert.ToDouble(tabelaAeb.Rows[0][2]);
                    }

                    quant = Convert.ToDouble(tabelaIngredientes.Rows[i][1]);

                    custoUnit  = a.CustoIngrediente(codIngrediente, unidade);
                    custoTotal = custoUnit * quant;


                    String[] V = new string[] { codIngrediente, nomeingrediente, um, fc.ToString("#,0.0000"), quant.ToString("#,0.0000"), custoUnit.ToString("#,0.00"), custoTotal.ToString("#,0.00") };
                    dgvDados.Rows.Add(V);

                    TotalFicha += custoTotal;
                }

                lbTotal.Text = TotalFicha.ToString("#,0.00");

                if (Convert.ToDouble(lbPeso.Text) > 0)
                {
                    lbTotalKg.Text = (TotalFicha / Convert.ToDouble(lbPeso.Text)).ToString("#,0.00");
                }
                else
                {
                    lbTotalKg.Text = "0,00";
                }

                lbcustoPorcao.Text = (TotalFicha / Convert.ToDouble(lbRendimento.Text)).ToString("#,0.00");
            }
        }
Exemple #21
0
 public BBLUnidadeMedida(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #22
0
        private void CarregaFicha(string cod)
        {
            DALConexao cx     = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLPratos  bllp   = new BLLPratos(cx);
            DataTable  tabela = bllp.LocalizarPorCod(cod);

            DTOCaminhos dto = new DTOCaminhos();

            string nomePrato, codigo, desc, preparo;
            double rendimento, peso;
            int    setor, cat, subcat;

            // Preenche dados da Ficha
            codigo     = cod;
            nomePrato  = tabela.Rows[0][1].ToString();
            desc       = tabela.Rows[0][8].ToString();
            preparo    = tabela.Rows[0][6].ToString();
            rendimento = Convert.ToDouble(tabela.Rows[0][5]);
            peso       = Convert.ToDouble(tabela.Rows[0][7]);
            setor      = Convert.ToInt32(tabela.Rows[0][2]);
            cat        = Convert.ToInt32(tabela.Rows[0][3]);
            subcat     = Convert.ToInt32(tabela.Rows[0][4]);

            lbTitulo.Text = $"{nomePrato} ({cod})";


            if (string.IsNullOrEmpty(preparo))
            {
                lbPreparo.Text = "";
            }
            else
            {
                lbPreparo.Text = preparo;
            }

            if (string.IsNullOrEmpty(peso.ToString()))
            {
                lbPeso.Text = "0,0000";
            }
            else
            {
                lbPeso.Text = peso.ToString("#,0.0000");
            }

            lbRendimento.Text = rendimento.ToString("#,0.00");

            //Carrega setor, categoria e subcategoria

            BLLBuffet bllsetor    = new BLLBuffet(cx);
            DataTable tabelasetor = bllsetor.localizarPorId(setor);

            lbSetor.Text = tabelasetor.Rows[0][0].ToString();

            BLLCategoria bllcat    = new BLLCategoria(cx);
            DataTable    tabelacat = bllcat.localizarPorId(cat);

            if (tabelacat.Rows.Count > 0)
            {
                lbCategoria.Text = tabelacat.Rows[0][0].ToString();
            }
            else
            {
                lbCategoria.Text = "";
            }

            BLLSubCategoria bllscat    = new BLLSubCategoria(cx);
            DataTable       tabelascat = bllscat.localizarPorId(subcat);

            if (tabelascat.Rows.Count > 0)
            {
                lbSubcategoria.Text = tabelascat.Rows[0][0].ToString();
            }
            else
            {
                lbSubcategoria.Text = "";
            }

            //Verifica se existe foto

            if (File.Exists(dto.FT + cod + ".jpg"))
            {
                pbImagem.Visible = true;
                pbimagem1.Load(dto.FT + cod + ".jpg");
            }
            else
            {
                pbImagem.Visible = false;
            }
        }
Exemple #23
0
 public BLLTipoEquipamento(DALConexao dalConexao)
 {
     this.Conexao = dalConexao;
 }
 public BLLOrdemServicoItens(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #25
0
 public BLLCliente(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #26
0
 public BLLProduto(DALConexao cx)
 {
     conexao = cx;
 }
Exemple #27
0
        public void ClassificaPed(int tpDiv)
        {
            try
            {
                if (txtNome.Text != null && tpDiv == 1)
                {
                    DALConexao   cx            = new DALConexao(DadosDaConexao.StringDeConexao);
                    BLLPCPEDC    bllpcpcold    = new BLLPCPEDC(cx);
                    ModeloPCPEDC modelopcpcold = bllpcpcold.CarregaPCPEDC(Convert.ToInt64(txtCodigo.Text));
                    if (modelopcpcold.numcar == 0)
                    {
                        BLLCARREG      bllcar   = new BLLCARREG(cx);
                        ModeloPCCARREG modelcar = bllcar.CarregaNewNumCar();
                        modelcar.vltotal    = Convert.ToDouble(modelopcpcold.vltotal);
                        modelcar.codfuncmon = modelopcpcold.codemitente;
                        bllcar.Incluir(modelcar);
                        modelopcpcold.numcar = modelcar.numcar;
                        bllcar.MontaCarreg(modelopcpcold);
                        bllcar.MontaCarregI(modelopcpcold);
                        numcar = modelcar.numcar;
                    }

                    numcar = Convert.ToInt32(modelopcpcold.numcar);


                    ModeloPCPEDC modelopcpcnew = bllpcpcold.CarregaPCPEDC(Convert.ToInt64(txtCodigo.Text));

                    decimal?vltotalrest = Convert.ToDecimal(modelopcpcnew.vlatend);
                    modelopcpcold.numpedold = Convert.ToInt64(txtCodigo.Text);

                    int     qualificado   = 0;
                    int     ped           = 0;
                    int     paraped       = 0;
                    decimal?totalgeralped = 0;
                    string  qtit          = txtQtdItens.Text;
                    qualificado = (vltotalrest < 500) ? 0 : 1;
                    if (qualificado == 1)
                    {
                        if (dgvItens.RowCount > 0)
                        {
                            ModeloPCPEDI mitens = new ModeloPCPEDI();
                            BLLPCPEDI    bitens = new BLLPCPEDI(cx);

                            for (int i = 0; i < dgvItens.RowCount; i++)
                            {
                                mitens.numped      = Convert.ToInt64(txtCodigo.Text);
                                mitens.codprod     = Convert.ToInt32(dgvItens.Rows[i].Cells[0].Value);
                                mitens.codauxiliar = Convert.ToInt64((dgvItens.Rows[i].Cells[1].Value.ToString()));
                                mitens.qt          = Convert.ToDecimal(dgvItens.Rows[i].Cells[2].Value);
                                mitens.qtunitemb   = Convert.ToDecimal(dgvItens.Rows[i].Cells[3].Value);
                                mitens.pvenda      = Convert.ToDecimal(dgvItens.Rows[i].Cells[4].Value);
                                bitens.IncluirDUP(mitens);
                            }
                        }

                        do
                        {
                            ped = ped + 1;

                            BLLPCVENDACONSUM    bllpcvc    = new BLLPCVENDACONSUM(cx);
                            ModeloPCVENDACONSUM modelopcvc = bllpcvc.CarregaPCVENDACONSUM(Convert.ToInt64(txtCodigo.Text));

                            BLLPCPEDC    bllpcpc    = new BLLPCPEDC(cx);
                            ModeloPCPEDC modelopcpc = bllpcpc.CarregaPCPEDC(Convert.ToInt64(txtCodigo.Text));

                            modelopcpc.numpedold = Convert.ToInt64(txtCodigo.Text);

                            BLLVAR    bllvar    = new BLLVAR(cx);
                            ModeloVAR modelovar = bllvar.CarregaNewNumPed(Convert.ToInt64(modelopcpc.codusur));
                            bllvar.AlterarNW(modelovar);

                            modelopcpc.numped    = modelovar.newnumped;
                            modelopcvc.numped    = modelovar.newnumped;
                            modelopcpc.condvenda = 1;
                            //modelopcpc.codcli = 1;
                            modelopcpc.origemped = "T";

                            if (ped == 1)
                            {
                                pedidos[0] = modelopcpc.numped;
                            }
                            pedidos[1] = modelopcpc.numped;

                            int     it           = 0;
                            decimal vltotal      = 0;
                            decimal vltabela     = 0;
                            decimal vlcustoreal  = 0;
                            decimal vlcustofin   = 0;
                            decimal vlatend      = 0;
                            decimal?vlcustorep   = 0;
                            decimal?vlcustocont  = 0;
                            decimal?qtrest       = 0;
                            decimal VlrTotalVend = 0;

                            int contped = 0;
                            int itens   = 0;

                            do
                            {
                                BLLPCPEDI    bllpcpi    = new BLLPCPEDI(cx);
                                ModeloPCPEDI modelopcpi = bllpcpi.CarregaPCPEDI(Convert.ToInt64(txtCodigo.Text));
                                dgvItens.DataSource  = bllpcpi.Localizar(Convert.ToInt64(txtCodigo.Text));
                                modelopcpi.oldnumped = Convert.ToInt64(txtCodigo.Text);
                                modelopcpi.numped    = modelovar.newnumped;
                                //modelopcpi.codcli = 1;
                                modelopcpi.qtunitemb = 1;
                                modelopcpi.numseqori = modelopcpi.numseq;


                                if (modelopcpi.codprod != 0)
                                {
                                    bllpcpi.IncluirQT(modelopcpi);
                                }

                                modelopcpi.codauxiliar = modelopcpi.codauxiliarunit;
                                modelopcpi.qtunitcx    = modelopcpi.qtunitcxunit;
                                modelopcpi.qtunitemb   = Convert.ToDecimal(modelopcpi.qtunitcxunit);

                                decimal QtRestprod   = 0;
                                decimal QtAnt        = 0;
                                decimal VlrProd      = 0;
                                decimal QtProd       = 0;
                                decimal pvltabela    = 0;
                                decimal pvlcustoreal = 0;
                                decimal pvlcustofin  = 0;
                                decimal pvlatend     = 0;
                                decimal?pvlcustorep  = 0;
                                decimal?pvlcustocont = 0;

                                QtAnt = modelopcpi.qt;
                                modelopcpc.numitens = Convert.ToInt16(itens + 1);

                                for (decimal ii = 0; ii < QtAnt; ii++)
                                {
                                    if (modelopcpi.fracao == "N")
                                    {
                                        QtProd     = QtProd + 1;
                                        QtRestprod = QtAnt - QtProd;

                                        pvlcustoreal = pvlcustoreal + (modelopcpi.vlcustoreal);
                                        pvlcustofin  = pvlcustofin + (modelopcpi.vlcustofin);
                                        pvlcustorep  = (pvlcustorep + (modelopcpi.vlcustorep));
                                        pvlcustocont = pvlcustocont + (modelopcpi.vlcustocont);

                                        // Tratamento para politica de preços conforme tributação
                                        if (modelopcpi.sittribut == "90")
                                        {
                                            VlrProd      = VlrProd + Convert.ToDecimal(modelopcpi.pvenda);
                                            pvltabela    = pvlatend + Convert.ToDecimal(modelopcpi.pvenda);
                                            pvlatend     = pvlatend + Convert.ToDecimal(modelopcpi.pvenda);
                                            VlrTotalVend = VlrTotalVend + Convert.ToDecimal(modelopcpi.pvenda);
                                        }
                                        else
                                        {
                                            VlrProd      = VlrProd + Convert.ToDecimal(modelopcpi.pvenda);
                                            pvltabela    = pvlatend + Convert.ToDecimal(modelopcpi.pvenda);
                                            pvlatend     = pvlatend + Convert.ToDecimal(modelopcpi.pvenda);
                                            VlrTotalVend = VlrTotalVend + Convert.ToDecimal(modelopcpi.pvenda);
                                        }


                                        if (VlrTotalVend > 499)
                                        {
                                            QtProd     = QtProd - 1;
                                            QtRestprod = QtRestprod + 1;

                                            pvlcustoreal = pvlcustoreal - (modelopcpi.vlcustoreal);
                                            pvlcustofin  = pvlcustofin - (modelopcpi.vlcustofin);
                                            pvlcustorep  = pvlcustorep - (modelopcpi.vlcustorep);
                                            pvlcustocont = pvlcustocont - (modelopcpi.vlcustocont);


                                            // Tratamento para politica de preços conforme tributação
                                            if (modelopcpi.sittribut == "90")
                                            {
                                                VlrProd      = VlrProd - Convert.ToDecimal(modelopcpi.pvenda);
                                                pvlatend     = pvlatend - Convert.ToDecimal(modelopcpi.pvenda);
                                                pvltabela    = pvlatend - Convert.ToDecimal(modelopcpi.pvenda);
                                                VlrTotalVend = VlrTotalVend - Convert.ToDecimal(modelopcpi.pvenda);
                                            }
                                            if (modelopcpi.sittribut == "60")
                                            {
                                                VlrProd      = VlrProd - Convert.ToDecimal(modelopcpi.pvenda);
                                                pvlatend     = pvlatend - Convert.ToDecimal(modelopcpi.pvenda);
                                                pvltabela    = pvlatend - Convert.ToDecimal(modelopcpi.pvenda);
                                                VlrTotalVend = VlrTotalVend - Convert.ToDecimal(modelopcpi.pvenda);
                                            }
                                            else
                                            {
                                                VlrProd      = VlrProd - Convert.ToDecimal(modelopcpi.pvenda);
                                                pvlatend     = pvlatend - Convert.ToDecimal(modelopcpi.pvenda);
                                                pvltabela    = pvlatend - Convert.ToDecimal(modelopcpi.pvenda);
                                                VlrTotalVend = VlrTotalVend - Convert.ToDecimal(modelopcpi.pvenda);
                                            }


                                            contped = 1;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        QtProd     = QtProd + 0.10m;
                                        QtRestprod = QtAnt - QtProd;

                                        pvlcustoreal = pvlcustoreal + (modelopcpi.vlcustoreal / 10);
                                        pvlcustofin  = pvlcustofin + (modelopcpi.vlcustofin / 10);
                                        pvlcustorep  = pvlcustorep + (modelopcpi.vlcustorep / 10);
                                        pvlcustocont = pvlcustocont + (modelopcpi.vlcustocont / 10);



                                        // Tratamento para politica de preços conforme tributação
                                        VlrProd      = VlrProd + Convert.ToDecimal(modelopcpi.pvenda / 10);
                                        VlrTotalVend = VlrTotalVend + Convert.ToDecimal(modelopcpi.pvenda / 10);
                                        pvltabela    = pvlatend + Convert.ToDecimal(modelopcpi.pvenda / 10);
                                        pvlatend     = pvlatend + Convert.ToDecimal(modelopcpi.pvenda / 10);

                                        if (VlrTotalVend > 490)
                                        {
                                            contped = 1;
                                            break;
                                        }
                                        ii = ii - 0.90m;
                                    }
                                }

                                modelopcpi.numseq = it + 1;
                                modelopcpi.qt     = QtProd;

                                if (modelopcpi.codprod != 0 && modelopcpi.qt > 0)
                                {
                                    bllpcpi.Incluir(modelopcpi);
                                }

                                if (modelopcpi.qt == 0)
                                {
                                    bllpcpi.AlterarQTDEL(modelopcpi);
                                }

                                it++;
                                itens++;


                                vlcustoreal = vlcustoreal + pvlcustoreal;
                                vlcustofin  = vlcustofin + pvlcustofin;
                                vlcustorep  = vlcustorep + pvlcustorep;
                                vlcustocont = vlcustocont + pvlcustocont;


                                vltotal  = vltotal + VlrProd;
                                vltabela = vlatend + pvlatend; //vltabela + pvltabela;
                                vlatend  = vlatend + pvlatend;

                                //
                                modelopcpi.qtrest = QtAnt - QtProd;
                                qtrest            = modelopcpi.qtrest;

                                if (modelopcpi.codprod != 0)
                                {
                                    bllpcpi.AlterarQT(modelopcpi);
                                }
                                dgvItens.DataSource = bllpcpi.Localizar(Convert.ToInt64(txtCodigo.Text));
                                if (dgvItens.RowCount == 0)
                                {
                                    contped = 1;
                                    paraped = 1;
                                }
                            } while (vltotal < 500 && dgvItens.RowCount > 0 && contped == 0);

                            vltotalrest = vltotalrest - vltotal;

                            modelopcpc.vltotal     = Math.Round(vltotal, 2);
                            modelopcpc.vltabela    = Math.Round(vlatend, 2); // Math.Round(vltabela, 2);
                            modelopcpc.vlatend     = Math.Round(vlatend, 2);
                            modelopcpc.vlcustocont = Convert.ToDouble(vlcustocont);
                            modelopcpc.vlcustorep  = Convert.ToDouble(vlcustorep);
                            modelopcpc.vlcustofin  = Convert.ToDouble(vlcustofin);
                            modelopcpc.vlcustoreal = Convert.ToDouble(vlcustoreal);
                            modelopcpc.numpedtv1   = modelopcpcold.numpedold;
                            if (modelopcpc.vltotal != 0)
                            {
                                bllpcpc.Incluir(modelopcpc);

                                bllpcvc.Incluir(modelopcvc);

                                totalgeralped = totalgeralped + modelopcpc.vltotal;
                                string texto = "Pedido Cód: " + modelopcpc.numped.ToString() + " - Valor R$: " + Math.Round(Convert.ToDecimal(modelopcpc.vltotal), 2).ToString() + ";" + "\n";
                                rtbPedGerados.Text = rtbPedGerados.Text + "\n" + texto;
                            }
                        } while (vltotalrest > 1 && paraped == 0);

                        rtbPedGerados.Text = rtbPedGerados.Text + "\n" + "\n" + " Num. Carregamento:" + modelopcpcold.numcar + "\n" + " Pedidos/Itens: " + ped.ToString() + "/" + qtit + " Valor Total R$ " + Math.Round(Convert.ToDecimal(totalgeralped), 2).ToString();
                        clsArquivo LCLS_ArquivoTxt = new clsArquivo();
                        LCLS_ArquivoTxt.FU_Gravar(rtbPedGerados.Text);

                        //if (rtbPedGerados.Text != null)
                        //{
                        //    spoolrec("PEDIDOS.TXT");
                        //}



                        BLLPCPEDC    bllpcpold    = new BLLPCPEDC(cx);
                        ModeloPCPEDC modelopcpold = bllpcpold.CarregaPCPEDC(Convert.ToInt64(txtCodigo.Text));
                        modelopcpold.vltotal = 0;
                        modelopcpold.numped  = Convert.ToInt64(txtCodigo.Text);
                        //bllpcpcold.AlterarCarSEL(modelopcpcold);
                        bllpcpold.AlterarVT(modelopcpold);
                        bllpcpold.AlterarVTI(modelopcpold);
                        txtVlrTotal.Text = "0";
                        btnGerar.Visible = false;
                        //btnImprimir.Visible = false;
                        txtTotalGer.Focus();
                        AtualizaDGVPED(Convert.ToInt32(modelopcpcold.numcar));
                        //LimpaTela();
                    }
                    if (qualificado == 0)
                    {
                        DALConexao   cx1       = new DALConexao(DadosDaConexao.StringDeConexao);
                        BLLPCPEDC    bllTab    = new BLLPCPEDC(cx1);
                        ModeloPCPEDC modeloTab = bllTab.CarregaPCPEDC(Convert.ToInt64(txtCodigo.Text));

                        bllpcpcold.AlterarPedPtabelaC(modeloTab);
                        bllpcpcold.AlterarPedPtabelaIT(modeloTab);

                        pedidos[0] = Convert.ToInt64(txtCodigo.Text);
                        pedidos[1] = Convert.ToInt64(txtCodigo.Text);
                        if (modelopcpcold.origemped != "B")
                        {
                        }
                        rtbPedGerados.Text = rtbPedGerados.Text + "\n" + "\n" + " Num. Carregamento:" + modelopcpcold.numcar + "\n" + " Pedidos/Itens: 1 /" + modelopcpcold.numitens + " Valor Total R$ " + Math.Round(Convert.ToDecimal(modelopcpcold.vlcustocont), 2).ToString();
                        AtualizaDGVPED(Convert.ToInt32(modelopcpcold.numcar));
                        txtTotalGer.Focus();
                        btnGerar.Visible = false;
                    }
                }
                if (txtNome.Text == null)
                {
                    MessageBox.Show("Pedido não pode ser dividio.", "Atenção!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #28
0
        private void Loga()
        {
            this.BloqueioTela(Convert.ToInt32(0));
            frmLogin log = new frmLogin();

            log.ShowDialog();
            log.Dispose();


            int idusuario = 0;
            int idunidade = 0;
            int nvusuario = 0;

            try
            {
                idusuario = Convert.ToInt32(log.IdUsuarioLogado);
            }
            catch { }

            try
            {
                idunidade = Convert.ToInt32(log.UnidadeUsuarioLogado);
            }
            catch { }

            try
            {
                nvusuario = Convert.ToInt32(log.NvUsuarioLogado);
            }
            catch { }

            if (idusuario.ToString() != "")
            {
                #region Se Login Adm
                if (log.IdUsuarioLogado == -1)
                {
                    txtId.Text          = idusuario.ToString();
                    txtUsuario.Text     = "Administrador";
                    txtLogin.Text       = "Admin";
                    txtSenha.Text       = "";
                    txtIniciais.Text    = "Adm";
                    txtUnidade.Text     = "99";
                    txtPermissao.Text   = "4";
                    txtEmail.Text       = "";
                    txtNomeUnidade.Text = "Admin";

                    this.PreencheCampos();
                }

                #endregion

                #region Se login normal

                else
                {
                    txtId.Text          = idusuario.ToString();
                    txtUsuario.Text     = log.NomeUsuarioLogado.ToString();
                    txtLogin.Text       = log.LoginUsuarioLogado.ToString();
                    txtSenha.Text       = log.SenhaUsuarioLogado.ToString();
                    txtIniciais.Text    = log.IniciaisUsuarioLogado.ToString();
                    txtUnidade.Text     = idunidade.ToString();
                    txtPermissao.Text   = nvusuario.ToString();
                    txtEmail.Text       = log.EmailUsuarioLogado.ToString();
                    txtNomeUnidade.Text = log.NomeUnidade.ToString();

                    this.PreencheCampos();

                    //Se login automático salva ip
                    DTOLog     dtolog = new DTOLog();
                    DALConexao cx     = new DALConexao(DadosDaConexao.StringDaConexao);
                    BLLLog     blllog = new BLLLog(cx);

                    if (log.LembrarSenha != "")
                    {
                        try
                        {
                            try
                            {
                                blllog.Excluir(Convert.ToInt32(txtId.Text), log.LembrarSenha);
                            }
                            catch
                            {}
                            finally
                            {
                                dtolog.IdUsuario = Convert.ToInt32(txtId.Text);
                                dtolog.CodLog    = log.LembrarSenha;
                                blllog.Incluir(dtolog);
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Erro ao salvar suas credenciais.");
                        }
                    }
                }
                #endregion

                log = null;
            }
        }
 public BLLTipoPagamento(DALConexao cx)
 {
     this.conexao = cx;
 }
Exemple #30
0
 public DLLUndMedida(DALConexao cx)
 {
     this.conexao = cx;
 }