예제 #1
0
        public void ImprimirRelPed()
        {
            try
            {
                //Instancio o FormConsulta
                FrmConPDV x = (FrmConPDV)_pdv;

                if (x.rdbped.Checked)
                {
                    //Instancio o Relatorio
                    RptConPDV objRptConPDV = new RptConPDV();

                    //Instancio o Dataset
                    COMERCIALDataSet oDataset = new COMERCIALDataSet();

                    Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase();
                    //Crio a Conexão
                    SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["Comercial.Properties.Settings.COMERCIALConnectionString"].ConnectionString);

                    //Abro a conexão
                    sqlcon.Open();

                    //Recebo a String SQL feita na tela de consulta
                    string StringConnection = x.pesquisar();


                    SqlDataAdapter dtAdapter = new SqlDataAdapter(StringConnection, sqlcon);

                    //Localizo o datatable criado no dataset
                    dtAdapter.Fill(oDataset, "RelPedido");

                    objRptConPDV.SetDataSource(oDataset);

                    //Passo parametro para relatorio no caso somente o de pedido tem parametro
                    ParameterFieldDefinitions crParameterFieldDefinitions;
                    ParameterFieldDefinition  crParameterFieldDefinition;
                    ParameterValues           crParameterValues        = new ParameterValues();
                    ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();

                    crParameterDiscreteValue.Value = "PDV";
                    crParameterFieldDefinitions    = objRptConPDV.DataDefinition.ParameterFields;
                    crParameterFieldDefinition     = crParameterFieldDefinitions["Tipo"];
                    crParameterValues = crParameterFieldDefinition.CurrentValues;

                    crParameterValues.Clear();
                    crParameterValues.Add(crParameterDiscreteValue);
                    crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                    //atribiu o resultado ao CristalReportView
                    crstlRprtVwrRel.DisplayGroupTree = false;
                    crstlRprtVwrRel.ReportSource     = objRptConPDV;
                }
                else
                {
                    //Instancio o Relatorio
                    RptConPDV objRptConPDV = new RptConPDV();

                    //Instancio o Dataset
                    COMERCIALDataSet oDataset = new COMERCIALDataSet();

                    Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase();
                    //Crio a Conexão
                    SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["Comercial.Properties.Settings.COMERCIALConnectionString"].ConnectionString);

                    //Abro a conexão
                    sqlcon.Open();

                    //Recebo a String SQL feita na tela de consulta
                    string StringConnection = x.pesquisar();

                    SqlDataAdapter dtAdapter = new SqlDataAdapter(StringConnection, sqlcon);

                    //Localiso o datateble criado no dataset
                    dtAdapter.Fill(oDataset, "RelPedido");

                    objRptConPDV.SetDataSource(oDataset);

                    //Passo parametro para relatorio no caso somente o de pedido tem parametro
                    ParameterFieldDefinitions crParameterFieldDefinitions;
                    ParameterFieldDefinition  crParameterFieldDefinition;
                    ParameterValues           crParameterValues        = new ParameterValues();
                    ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();

                    crParameterDiscreteValue.Value = "prd";
                    crParameterFieldDefinitions    = objRptConPDV.DataDefinition.ParameterFields;
                    crParameterFieldDefinition     = crParameterFieldDefinitions["Tipo"];
                    crParameterValues = crParameterFieldDefinition.CurrentValues;

                    crParameterValues.Clear();
                    crParameterValues.Add(crParameterDiscreteValue);
                    crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                    //atribiu o resultado ao CristalReportView
                    crstlRprtVwrRel.DisplayGroupTree = false;
                    crstlRprtVwrRel.ReportSource     = objRptConPDV;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        private void pedidoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int x = 0, y = 0;

            // Localiza o formulario
            foreach (Form form in this.MdiChildren)
            {
                if (form is FrmConPDV)
                {
                    form.WindowState = FormWindowState.Maximized;
                    form.Activate();
                    x++;
                }
                y++;

            }

            // Para criar o formulario 
            if (x == 0 && y == 0)
            {
                FrmConPDV filho = new FrmConPDV(this);
                filho.Show();

                tlStrpConsulta.Visible = true;
                bindingNavigator1.Visible = false;

                // Util.Interface.ResetControls(filho);
                //Util.Interface.ChangeControlStatus(filho, false);

                filho.WindowState = FormWindowState.Maximized;
            }
        }