protected void btnVisualizar_Click(object sender, EventArgs e)
 {
     try
     {
         string sUser = UsuarioWeb.GetNomeUsuarioConectado(Session);
         Session["DadosConsultaRepresentante"] = null;
         UsuarioWeb objUsuario        = Session["ObjetoUsuario"] as UsuarioWeb;
         string     sCodRepresentante = string.Empty;
         if (ckbVendedor.Checked)
         {
             sCodRepresentante = cbxVendedor.SelectedValue;
         }
         if (txtDataInicial.Text != "" && txtDataFinal.Text != "")
         {
             dsVendas ds = GetVendasByRepresentantes(Convert.ToDateTime(txtDataInicial.Text), Convert.ToDateTime(txtDataFinal.Text), objUsuario, sCodRepresentante);
             Session["VendasRepresLista"] = ds;
             string sDtInicial = txtDataInicial.Text.Replace("/", ".");
             string sDtFinal   = txtDataFinal.Text.Replace("/", ".");
             Response.Redirect("~/ViewVendasPorRepresentanteListagem.aspx?DT_INI=" + sDtInicial + "&DT_FIM=" + sDtFinal);
         }
         else
         {
             MessageHLP.ShowPopUpMsg("As datas estão incorretas.", this);
         }
     }
     catch (Exception ex)
     {
         MessageHLP.ShowPopUpMsg(ex.Message, this.Page);
     }
 }
Esempio n. 2
0
        public override global::System.Data.DataSet Clone()
        {
            dsVendas cln = ((dsVendas)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Esempio n. 3
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            dsVendas ds = new dsVendas();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
    protected dsVendas GetVendasByRepresentantes(DateTime dtIni, DateTime dtFim, UsuarioWeb objUsuario, string sCodRepresentante = "")
    {
        dsVendas ds          = new dsVendas();
        string   sdtIni      = dtIni.ToShortDateString().Replace("/", ".");
        string   sdtFim      = dtFim.ToShortDateString().Replace("/", ".");
        string   stpdocs     = objUsuario.oTabelas.hlpDbFuncoes.qrySeekValue("EMPRESA", "DS_TPDOCWEB", "CD_EMPRESA = '" + objUsuario.oTabelas.sEmpresa + "'");
        string   sTpdocFinal = "";

        foreach (string item in stpdocs.Split(';'))
        {
            string[] tpdoc = item.Split(',');
            if (tpdoc.Length > 1)
            {
                sTpdocFinal += "'" + tpdoc[1].ToString().Trim() + "',";
            }
        }
        sTpdocFinal = sTpdocFinal.Remove(sTpdocFinal.Length - 1, 1);
        StringBuilder sQuery = new StringBuilder();

        sQuery.Append("select v.cd_vend, coalesce(sum(p.vl_totalped),0) TOTAL,v.nm_vend NM_VEND ");
        sQuery.Append("from pedido p inner join clifor c on p.cd_cliente = c.cd_clifor inner join vendedor v on v.cd_vend = c.cd_vend1 ");
        sQuery.Append("where coalesce(v.st_acessa_web,'N') = 'S'  and p.dt_pedido  between '{0}' and '{1}' and ");
        sQuery.Append("p.cd_tipodoc in ({2}) ");
        if (sCodRepresentante != "")
        {
            sQuery.Append("and v.cd_vend = '" + sCodRepresentante + "' ");
        }
        sQuery.Append("group by v.cd_vend,v.nm_vend order by v.cd_vend ");
        string sQueryFinal = string.Format(sQuery.ToString(), sdtIni, sdtFim, sTpdocFinal);

        StringBuilder sQueryTotDia = new StringBuilder();

        sQueryTotDia.Append("select coalesce(sum(p.vl_totalped),0)  from pedido p inner join clifor c on p.cd_cliente = c.cd_clifor inner join vendedor v on ");
        sQueryTotDia.Append("v.cd_vend = c.cd_vend1 where p.cd_vend1 = '{0}' and p.dt_pedido = '{1}' and p.cd_tipodoc in ('{2}')");


        dsVendas.VendasRow rowVendas = ds.Vendas.NewVendasRow();
        foreach (DataRow item in objUsuario.oTabelas.hlpDbFuncoes.qrySeekRet(sQueryFinal).Rows)
        {
            rowVendas.CD_VEND   = item["CD_VEND"].ToString();
            rowVendas.TOTAL     = item["TOTAL"].ToString();
            rowVendas.NM_VEND   = item["NM_VEND"].ToString();
            rowVendas.TOTAL_DIA = objUsuario.oTabelas.hlpDbFuncoes.qrySeekValue("PEDIDO", "coalesce(sum(vl_totalped),0)",
                                                                                string.Format("cd_vend1 = '{0}' and dt_pedido = '{1}' and cd_tipodoc in ({2})",
                                                                                              rowVendas.CD_VEND,
                                                                                              DateTime.Today.ToShortDateString().Replace("/", "."),
                                                                                              sTpdocFinal));
            ds.Vendas.AddVendasRow(rowVendas);
            rowVendas = ds.Vendas.NewVendasRow();
        }
        return(ds);
    }
    protected dsVendas GetVendasByRepresentantes(DateTime dtIni, DateTime dtFim, UsuarioWeb objUsuario, string sCodRepresentante = "")
    {
        dsVendas ds = new dsVendas();
        string sdtIni = dtIni.ToShortDateString().Replace("/", ".");
        string sdtFim = dtFim.ToShortDateString().Replace("/", ".");
        string stpdocs = objUsuario.oTabelas.hlpDbFuncoes.qrySeekValue("EMPRESA", "DS_TPDOCWEB", "CD_EMPRESA = '" + objUsuario.oTabelas.sEmpresa + "'");
        string sTpdocFinal = "";
        foreach (string item in stpdocs.Split(';'))
        {
            string[] tpdoc = item.Split(',');
            if (tpdoc.Length > 1)
            {
                sTpdocFinal += "'" + tpdoc[1].ToString().Trim() + "',";
            }
        }
        sTpdocFinal = sTpdocFinal.Remove(sTpdocFinal.Length - 1, 1);
        StringBuilder sQuery = new StringBuilder();
        sQuery.Append("select v.cd_vend, coalesce(sum(p.vl_totalped),0) TOTAL,v.nm_vend NM_VEND ");
        sQuery.Append("from pedido p inner join clifor c on p.cd_cliente = c.cd_clifor inner join vendedor v on v.cd_vend = c.cd_vend1 ");
        sQuery.Append("where coalesce(v.st_acessa_web,'N') = 'S'  and p.dt_pedido  between '{0}' and '{1}' and ");
        sQuery.Append("p.cd_tipodoc in ({2}) ");
        if (sCodRepresentante != "")
        {
            sQuery.Append("and v.cd_vend = '" + sCodRepresentante + "' ");
        }
        sQuery.Append("group by v.cd_vend,v.nm_vend order by v.cd_vend ");
        string sQueryFinal = string.Format(sQuery.ToString(), sdtIni, sdtFim, sTpdocFinal);

        StringBuilder sQueryTotDia = new StringBuilder();
        sQueryTotDia.Append("select coalesce(sum(p.vl_totalped),0)  from pedido p inner join clifor c on p.cd_cliente = c.cd_clifor inner join vendedor v on ");
        sQueryTotDia.Append("v.cd_vend = c.cd_vend1 where p.cd_vend1 = '{0}' and p.dt_pedido = '{1}' and p.cd_tipodoc in ('{2}')");

        dsVendas.VendasRow rowVendas = ds.Vendas.NewVendasRow();
        foreach (DataRow item in objUsuario.oTabelas.hlpDbFuncoes.qrySeekRet(sQueryFinal).Rows)
        {
            rowVendas.CD_VEND = item["CD_VEND"].ToString();
            rowVendas.TOTAL = item["TOTAL"].ToString();
            rowVendas.NM_VEND = item["NM_VEND"].ToString();
            rowVendas.TOTAL_DIA = objUsuario.oTabelas.hlpDbFuncoes.qrySeekValue("PEDIDO", "coalesce(sum(vl_totalped),0)",
                                                                                string.Format("cd_vend1 = '{0}' and dt_pedido = '{1}' and cd_tipodoc in ({2})",
                                                                                rowVendas.CD_VEND,
                                                                                DateTime.Today.ToShortDateString().Replace("/", "."),
                                                                                sTpdocFinal));
            ds.Vendas.AddVendasRow(rowVendas);
            rowVendas = ds.Vendas.NewVendasRow();
        }
        return ds;
    }
    protected void btnVisualizar_Click(object sender, EventArgs e)
    {
        string sUser = UsuarioWeb.GetNomeUsuarioConectado(Session);

        if (sUser != "")
        {
            Session["DadosConsultaRepresentante"] = null;
            UsuarioWeb objUsuario        = Session["ObjetoUsuario"] as UsuarioWeb;
            string     sCodRepresentante = objUsuario.oTabelas.CdVendedorAtual;
            if (txtDataInicial.Text != "" && txtDataFinal.Text != "")
            {
                dsVendas ds = GetVendasByRepresentantes(Convert.ToDateTime(txtDataInicial.Text), Convert.ToDateTime(txtDataFinal.Text), objUsuario, sCodRepresentante);
                Session["VendasRepresLista"] = ds;
                string sDtInicial = txtDataInicial.Text.Replace("/", ".");
                string sDtFinal   = txtDataFinal.Text.Replace("/", ".");
                Response.Redirect("~/ViewVendasPorRepresentanteListagem.aspx?DT_INI=" + sDtInicial + "&DT_FIM=" + sDtFinal);
            }
            else
            {
                MessageHLP.ShowPopUpMsg("As datas estão incorretas.", this);
            }
        }
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string sUser = UsuarioWeb.GetNomeUsuarioConectado(Session);
            if (Request["DT_INI"] == null || Request["DT_FIM"] == null)
            {
                Response.Redirect("~/Home.aspx");
            }
            string sDataInicial = Request["DT_INI"].ToString();
            string sDataFinal   = Request["DT_FIM"].ToString();

            dsVendas dsImpressao = (dsVendas)Session["VendasRepresLista"];
            rpt.Load(Server.MapPath("rptVendasRepres.rpt"));
            rpt.SetDataSource(dsImpressao);
            CrystalReportViewer1.ReportSource = rpt;
            string sfiltro = string.Format("Período de {0} à {1}", sDataInicial, sDataFinal);
            if (rpt.DataDefinition.FormulaFields["Filtro"] != null)
            {
                rpt.DataDefinition.FormulaFields["Filtro"].Text = "\"" + sfiltro + "\"";
            }
            GerarPDF();
        }
    }