Beispiel #1
0
    protected void gridConsultaClientes_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Pendencias")
        {
            UsuarioWeb objUsuario = (UsuarioWeb)Session["ObjetoUsuario"];

            CliforDAO objCliente = ClienteDAOWeb.GetInstanciaClienteDAOWeb(Session,
                                                                           objUsuario);
            int index = Convert.ToInt32(e.CommandArgument);

            DataTable   dtClientes    = (DataTable)Session["DadosConsultaClientes"];
            GridViewRow RegistroAtual = gridConsultaClientes.Rows[index];
            DataRow     Registro      = dtClientes.Rows[RegistroAtual.DataItemIndex];
            Session["CD_ALTER"] = Registro["CD_ALTER"];
            string sCdClifor = objUsuario.oTabelas.hlpDbFuncoes.qrySeekValue("CLIFOR", "CD_CLIFOR", "CD_ALTER = '" + Registro["CD_ALTER"] + "'");

            DataTable dtRet = objUsuario.oTabelas.hlpDbFuncoes.qrySeekRet(string.Format("select count(NR_DOC)TOTAL from doc_ctr where coalesce(st_baixa,'') <> 'B' and cd_empresa = '{0}' and cd_cliente = '{1}' and dt_venci < current_date", objUsuario.oTabelas.sEmpresa, sCdClifor));

            int QtdePendencias = Convert.ToInt32(dtRet.Rows[0]["TOTAL"]);
            if (QtdePendencias > 0)
            {
                GridDuplicatas.DataSource = GetDuplicatasAbertas();
                GridDuplicatas.DataBind();
            }
            else
            {
                lblCliente.Text           = "";
                GridDuplicatas.DataSource = null;
                GridDuplicatas.DataBind();

                MessageHLP.ShowPopUpMsg("Não existem pendências para esse cliente!", this.Page);
            }
        }
    }
Beispiel #2
0
    private void ProcessarDataBind(CliforDAO objCliente)
    {
        if (!Page.IsPostBack)
        {
            if (objCliente.RegistroAtual != null)
            {
                DataRow registroClifor = objCliente.RegistroAtual;
                lblCdClifor.Text = registroClifor["CD_ALTER"].ToString();

                CarregarValoresCamposLista();
                cbxCidades.LimparValores(Session);
                cbxCidades.SelectedValue = null;
                cbxCidades.DataSource    = null;
                cbxCidades.DataBind();
                objCliente.PreencherComponentesComValoresBanco(this);

                CarregaCidades();
                cbxCidades.SetValor(registroClifor["NM_CIDNOR"].ToString());
                cbxCidades.DataBind();

                cbxStPessoaJ_SelectedIndexChanged(null, null);

                if (txtNumero.GetValor().ToString().Equals(""))
                {
                    txtNumero.SetValor("S/N");
                }
                //  lblAdvertencia.Visible = false;
            }
            else
            {
                //  painelDetalhe.Visible = false;
                //lblAdvertencia.Visible = true;
            }
        }
    }
Beispiel #3
0
    private bool EfetuarExclusao(DataRow RegistroAExcluir)
    {
        bool       bExcluiu   = false;
        UsuarioWeb objUsuario = (UsuarioWeb)Session["ObjetoUsuario"];
        string     sCdClifor  = RegistroAExcluir["CD_ALTER"].ToString();
        CliforDAO  objCliente = ClienteDAOWeb.GetInstanciaClienteDAOWeb(Session,
                                                                        objUsuario);

        try
        {
            DataTable dtPedidoExclusao =
                objCliente.Select("(CD_ALTER = '" + sCdClifor + "')");
            objCliente.RegistroAtual = dtPedidoExclusao.Rows[0];
            bExcluiu = objCliente.ProcessarExclusao();
            if (bExcluiu)
            {
                SetMensagemExclusao("O cliente " + sCdClifor +
                                    " foi excluído com sucesso!!!", false);
            }
            else
            {
                SetMensagemExclusao(objCliente.GetErros(), true);
            }
        }
        catch
        {
            SetMensagemExclusao("Ocorreu um erro durante a exclusão " +
                                "do cliente de código " + sCdClifor + " !!!", true);
        }
        finally
        {
            objCliente.RegistroAtual = null;
        }
        return(bExcluiu);
    }
Beispiel #4
0
    private bool ExecutaPosvalidaCad(CliforDAO objCliente, bool bIncluindo)
    {
        bool   bRetorno  = objCliente.ProcessarPosvalidaCad();
        string sCdClifor = objCliente.GetValorPrimario("CD_CLIFOR");

        if (bRetorno)
        {
            if (!bIncluindo)
            {
                MessageHLP.ShowPopUpMsg(string.Format("Dados do Cliente {0}, foram alterados com sucesso! {1}Código: {2}", txtNmGuerra.GetValor(), Environment.NewLine, Session["CD_ALTER"].ToString()), this.Page);
            }
            else
            {
                UsuarioWeb objUsuario = (UsuarioWeb)Session["ObjetoUsuario"];
                Session["CD_ALTER"] = objUsuario.oTabelas.hlpDbFuncoes.qrySeekValue("CLIFOR", "FIRST 1 CD_CLIFOR", string.Format("nm_clifor = '{0}' AND nm_guerra = '{1}'", this.txtNmClifor.GetValor(), this.txtNmGuerra.GetValor()));


                MessageHLP.ShowPopUpMsg(string.Format("Cliente {0} salvo com sucesso! {1}Código: {2}", txtNmGuerra.GetValor(), Environment.NewLine, Session["CD_ALTER"].ToString()), this.Page);
            }
            objCliente.ClearComponentes(this);
            Response.Redirect("~/PesquisarClientes.aspx?CD_ALTER=" + Session["CD_ALTER"].ToString());
        }
        else
        {
            MessageHLP.ShowPopUpMsg(objCliente.GetErros(), this.Page);
        }
        return(bRetorno);
    }
Beispiel #5
0
 protected void btnConfirmar_Click(object sender, EventArgs e)
 {
     if (btnConfirmar.Text == "Confirmar")
     {
         if (!ValoresValidosCliente())
         {
             return;
         }
         CliforDAO objCliente =
             (CliforDAO)Session["ObjetoClienteDetalhado"];
         if (objCliente != null)
         {
             if (objCliente.Status == StatusRegistro.IncluindoRegistro)
             {
                 GravarClienteIncluido(objCliente);
             }
             else
             {
                 objCliente.SetValoresRegistroAtual(this);
                 ExecutaPosvalidaCad(objCliente, false);
             }
         }
     }
     if (btnConfirmar.Text == "Incluir Pedido")
     {
         Session["CD_CLIFOR"]            = lblCdClifor.Text.Trim();
         Session["NM_CLIFOR"]            = txtNmGuerra.Text.Trim();
         Session["IncluirClientePedido"] = false;
         Response.Redirect("~/Pedido.aspx");
     }
 }
Beispiel #6
0
    private void GravarClienteIncluido(CliforDAO objCliente)
    {
        objCliente.SetValoresRegistroAtual(this);
        bool bContinua = ExecutaPosvalidaCad(objCliente, true);

        if (bContinua)
        {
            objCliente.RegistroAtual = null;
            btnConfirmar.Text        = "Confirmar";
        }
    }
Beispiel #7
0
    private void PesquisarDados()
    {
        UsuarioWeb objUsuario = (UsuarioWeb)Session["ObjetoUsuario"];
        DataTable  dtClientes = null;

        txtCodCli.Text = txtCodCli.Text.PadLeft(7, '0');
        StringBuilder str = new StringBuilder();

        str.Append("SELECT CD_CLIFOR, CD_ALTER, NM_GUERRA, NM_CLIFOR, DS_ENDNOR, NR_ENDNOR, NM_BAIRRONOR, NM_CIDNOR, CD_UFNOR, ST_PESSOAJ, CD_CGC, cd_insest, CD_CPF, CD_RG, CD_CEPNOR, CD_FONENOR,CD_FONECOM, CD_FAXNOR   ");
        str.Append("FROM CLIFOR ");
        str.Append("WHERE ");
        str.Append("((CLIFOR.ST_INATIVO <> 'S') OR (CLIFOR.ST_INATIVO IS NULL)) AND (CLIFOR.CD_VEND1 = '" + objUsuario.CodigoVendedor.ToString() + "') AND (NM_GUERRA IS NOT NULL) ");
        str.Append("AND (CD_CLIFOR ='" + txtCodCli.Text + "')");
        dtClientes = objUsuario.oTabelas.hlpDbFuncoes.qrySeekRet(
            str.ToString());
        DataColumn[] ChavePrimaria = new DataColumn[] { dtClientes.Columns["CD_CLIFOR"] };
        dtClientes.PrimaryKey            = ChavePrimaria;
        Session["DadosConsultaClientes"] = dtClientes;


        if (dtClientes.Rows.Count == 0)
        {
            MessageHLP.ShowPopUpMsg("Não existem registros para o filtro selecionado", this.Page);
            if (Session["CD_CLIFOR"] != null)
            {
                txtCodCli.Text = Session["CD_CLIFOR"].ToString();
            }
            else
            {
                txtCodCli.Text = "";
            }
        }
        else
        {
            BaseDAO.CancelarOperacaoObjetoDAO((BaseDAO)Session["ObjetoClienteDetalhado"]);

            Session["CD_CLIFOR"]            = txtCodCli.Text;
            Session["NM_CLIFOR"]            = dtClientes.Rows[0]["NM_CLIFOR"].ToString();
            Session["IncluirClientePedido"] = false;
            CliforDAO objCliente = ClienteDAOWeb.GetInstanciaClienteDAOWeb(Session,
                                                                           objUsuario);
            objCliente.RegistroAtual = dtClientes.Rows[0];
            CarregaDados();

            Session["lsCodigoInseridos"] = new List <string>();
        }
    }
Beispiel #8
0
    private bool ExecutaPosvalidaCad(CliforDAO objCliente, bool bIncluindo)
    {
        bool   bRetorno  = objCliente.ProcessarPosvalidaCad();
        string sCdClifor = objCliente.GetValorPrimario("CD_CLIFOR");

        if (bRetorno)
        {
            if (!bIncluindo)
            {
                MessageHLP.ShowPopUpMsg(string.Format("Dados do Cliente {0}, foram alterados com sucesso! {1}Código: {2}", txtNmGuerra.GetValor(), Environment.NewLine, Session["CD_ALTER"].ToString()), this.Page);
            }
            else
            {
                MessageHLP.ShowPopUpMsg(string.Format("Cliente {0} salvo com sucesso! {1}Código: {2}", txtNmGuerra.GetValor(), Environment.NewLine, Session["CD_ALTER"].ToString()), this.Page);
            }
            objCliente.ClearComponentes(this);
            Response.Redirect("~/PesquisarClientes.aspx?CD_ALTER=" + Session["CD_ALTER"].ToString());
        }
        else
        {
            MessageHLP.ShowPopUpMsg(objCliente.GetErros(), this.Page);
        }
        return(bRetorno);
    }
Beispiel #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sUser = UsuarioWeb.GetNomeUsuarioConectado(Session);

        if (sUser == "")
        {
            Response.Redirect("~/Login.aspx");
        }
        object IncluiCliente = Request["inclui"];

        if (Convert.ToBoolean(IncluiCliente))
        {
            Session["IncluirClientePedido"] = false;
        }

        bool IncluiClientePedido = (bool)Session["IncluirClientePedido"];
        bool PesquisaPedido      = false;

        if (Session["PesquisaPendencia"] != null)
        {
            PesquisaPedido = (bool)Session["PesquisaPendencia"];
        }


        if (IncluiClientePedido)
        {
            btnConfirmar.Text = "Incluir Pedido";
            SomenteLeitura(false);
        }
        else if (PesquisaPedido)
        {
            btnConfirmar.Text = "Verificar Pendencia";
            SomenteLeitura(false);
        }
        else
        {
            btnConfirmar.Text = "Confirmar";
            SomenteLeitura(true);
        }
        UsuarioWeb objUsuario = (UsuarioWeb)Session["ObjetoUsuario"];
        CliforDAO  objCliente = ClienteDAOWeb.GetInstanciaClienteDAOWeb(Session,
                                                                        objUsuario);


        bool bSolicitouInclusao = ((IncluiCliente != null) &&
                                   (Convert.ToBoolean(IncluiCliente)));

        if (bSolicitouInclusao)
        {
            //A lógica está assim, a fim de que ao se clicar novamente em
            //inclusão o sistema limpe todos os campos e inicie um novo
            //cadastro.
            if (objCliente.Status != StatusRegistro.Nenhum)
            {
                objCliente.CancelarOperacao();
            }
            Response.Redirect("~/CadastroCliente.aspx?incluindo=true");
            return;
        }

        IncluiCliente = Request["incluindo"];
        bool bIncluindo = ((IncluiCliente != null) && (Convert.ToBoolean(IncluiCliente)));

        if ((bIncluindo) && (objCliente.Status != StatusRegistro.IncluindoRegistro))
        {
            if (objCliente.Status == StatusRegistro.AlterandoRegistro)
            {
                objCliente.CancelarOperacao();
            }
            objCliente.ProcessarPrevalidaCad();
            //  lblAdvertencia.Text = String.Empty;
            btnConfirmar.Text = "Cadastrar";
            CarregarValoresCamposLista();
            //  objCliente.PreencherComponentesComValoresBanco(this);
            cbxStPessoaJ_SelectedIndexChanged(null, null);
            txtCdBanco.Text = WebConfigurationManager.AppSettings["CdContaBancariaDefault"];
        }
        else if (!bIncluindo)
        {
            bool bClienteValido;
            try
            {
                if (objCliente.Status == StatusRegistro.IncluindoRegistro)
                {
                    objCliente.CancelarOperacao();
                }
                string  sCdClifor         = Request["CD_ALTER"].ToString();
                DataRow UltimoCliente     = objCliente.RegistroAtual;
                bool    bPesquisarCliente = (UltimoCliente == null);
                if (!bPesquisarCliente)
                {
                    string sUltimoClientePesquisado = UltimoCliente["CD_ALTER"].ToString();
                    bPesquisarCliente = (!sUltimoClientePesquisado.Equals(sCdClifor));
                }
                if (bPesquisarCliente)
                {
                    DataTable dtClifor = objCliente.Select(
                        "(CD_ALTER = '" + sCdClifor.ToString() + "') AND " +
                        "(CD_VEND1 = '" + objUsuario.CodigoVendedor + "') AND " +
                        "((ST_INATIVO <> 'S') OR (ST_INATIVO IS NULL)) ");
                    objCliente.RegistroAtual = dtClifor.Rows[0];
                }
                bClienteValido = (objCliente.RegistroAtual != null);
                if ((bClienteValido) && (objCliente.Status != StatusRegistro.AlterandoRegistro))
                {
                    objCliente.ProcessarPrevalidaAlt();
                }
            }
            catch
            {
                bClienteValido = false;
            }
            if (!bClienteValido)
            {
                Response.Redirect("~/PesquisarClientes.aspx");
                return;
            }
            ProcessarDataBind(objCliente);
            if (objCliente.Status == StatusRegistro.IncluindoRegistro)
            {
                btnConfirmar.OnClientClick = "return confirm('Deseja salvar as informações ?');";
            }
        }
    }