Esempio n. 1
0
        private void CargarOpciones()
        {
            con = new SqlDbConnect();
            lsvImprimir.Items.Clear();
            lsvOpciones.Items.Clear();
            aReportId   = "";
            aReportName = "";
            aReportSql  = "";
            if (!string.IsNullOrEmpty(cboReporte.Text))
            {
                con.SqlQuery($"DEVELOPMENT.dbo.DYREP10100S1 '{Dynamics.Globals.IntercompanyId.Value}','{cboSerie.Text.Trim()}','{cboReporte.Text.Trim()}'");
                var table = con.QueryEx();
                foreach (DataRow item in table.Rows)
                {
                    var listDatos = new ListViewItem();
                    listDatos.SubItems.Add(item[0].ToString().ToUpper().Trim());
                    lsvOpciones.Items.Add(listDatos);
                }

                con.SqlQuery($"DEVELOPMENT.dbo.DYREP10000S3 '{Dynamics.Globals.IntercompanyId.Value}','{cboSerie.Text.Trim()}','{cboReporte.Text.Trim()}'");
                table = con.QueryEx();
                if (table.Rows.Count > 0)
                {
                    aReportId   = table.Rows[0][0].ToString().Trim();
                    aReportName = table.Rows[0][1].ToString().Trim();
                    aReportSql  = table.Rows[0][2].ToString().Trim();
                }
            }
        }
        private void StartReport()
        {
            if (string.IsNullOrEmpty(ReportPathx))
            {
                MessageBox.Show("La ubicacion de los reportes no ha sido configurada", "Microsoft Dynamics GP", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
            else
            {
                if (ReportPathx.Trim().Substring(ReportPathx.Trim().Length - 1, 1) != @"\")
                {
                    ReportPathx += @"\";
                }
            }

            ReportDocument document = new ReportDocument();

            try
            {
                var con = new SqlDbConnect();

                ReportHeader = "SELECT '" + CompanyNamex.Trim() + "' CompName, '" + ReportNamex.Trim() + "' Titulo, '" + Parameter1x.Trim() + "' Parametro1, '" + Parameter2x.Trim() + "' Parametro2, '" + Parameter3x.Trim() + "' Parametro3, '" + Parameter4x.Trim() + "' Parametro4, '" + Parameter5x.Trim() + "' Parametro5, '" + Parameter6x.Trim() + "' Parametro6, '" + UserIdx.Trim() + "' Usuario, 1 Marca";
                con.SqlQuery(ReportHeader);
                var cabecera = con.QueryEx();
                con.SqlQuery(ReportSQLx);
                var detalle = con.QueryEx();

                if (detalle.Rows.Count == 0)
                {
                    MessageBox.Show("No existen registros con los parametros suministrados para generar este reporte", "Microsoft Dynamics GP", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                }
                else
                {
                    document.Load($"{ReportPathx}{ReportIdx}.rpt");
                    document.Database.Tables[0].SetDataSource(cabecera);
                    document.Database.Tables[1].SetDataSource(detalle);
                    Viewer.ReportSource = document;
                    Viewer.Show();
                    Viewer.Cursor = Cursors.Arrow;
                    WindowState   = FormWindowState.Maximized;
                    Viewer.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Microsoft Dynamics GP", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
 private void DYREP10100_Load(object sender, EventArgs e)
 {
     con = new SqlDbConnect();
     con.SqlQuery($"DEVELOPMENT.dbo.DYREPPATHS1");
     aReportPath = con.QueryEx().Rows[0][0].ToString();
     CargarSeries();
 }
Esempio n. 4
0
        private void CargarReportes()
        {
            cboReporte.Items.Clear();
            con.SqlQuery($"DEVELOPMENT.dbo.DYREP10000S4 '{Dynamics.Globals.IntercompanyId.Value}', '{Dynamics.Globals.UserId.Value}', '{cboSerie.Text.Trim()}'");
            var table = con.QueryEx();

            foreach (DataRow item in table.Rows)
            {
                cboReporte.Items.Add(item[0].ToString().Trim().ToUpper());
            }
            if (cboReporte.Items.Count > 0)
            {
                cboReporte.SelectedIndex = 0;
                if (!string.IsNullOrEmpty(cboReporte.Text))
                {
                    CargarOpciones();
                }
            }
        }
        private void CargarIntervalos()
        {
            cboIntervalo.Items.Clear();
            lsvOpciones.Items.Clear();
            if (!string.IsNullOrEmpty(aReportName))
            {
                con.SqlQuery($"DEVELOPMENT.dbo.DYREP10001S4 '{Dynamics.Globals.IntercompanyId.Value}','{aSerie.Trim()}','{aReportName}'");
                var table = con.QueryEx();
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow item in table.Rows)
                    {
                        cboIntervalo.Items.Add(item[0].ToString());
                    }
                    if (cboIntervalo.Items.Count > 0)
                    {
                        cboIntervalo.SelectedIndex = 0;
                    }
                }

                if (!string.IsNullOrEmpty(cboOpcion.Text.Trim()))
                {
                    con.SqlQuery($"DEVELOPMENT.dbo.DYREP10101S1 '{Dynamics.Globals.IntercompanyId.Value}','{aSerie.Trim()}','{aReportName}','{cboOpcion.Text.Trim()}'");
                    table = con.QueryEx();
                    foreach (DataRow item in table.Rows)
                    {
                        listDatos = new ListViewItem();
                        listDatos.SubItems.Add(item[0].ToString().Trim());
                        listDatos.SubItems.Add(item[1].ToString().Trim());
                        listDatos.SubItems.Add(item[2].ToString().Trim());
                        listDatos.SubItems.Add(item[3].ToString().Trim());
                        listDatos.SubItems.Add(item[4].ToString().Trim());
                        listDatos.SubItems.Add(item[5].ToString().Trim());
                        listDatos.SubItems.Add(item[6].ToString().Trim());
                        lsvOpciones.Items.Add(listDatos);
                    }
                }
            }
        }
 private void CargarOpciones()
 {
     cboOpcion.Items.Clear();
     cboIntervalo.Items.Clear();
     lsvOpciones.Items.Clear();
     con = new SqlDbConnect();
     if (!string.IsNullOrEmpty(aReportName))
     {
         con.SqlQuery($"DEVELOPMENT.dbo.DYREP10100S1 '{Dynamics.Globals.IntercompanyId.Value}','{aSerie.Trim()}','{aReportName}'");
         var table = con.QueryEx();
         if (table.Rows.Count > 0)
         {
             foreach (DataRow item in table.Rows)
             {
                 cboOpcion.Items.Add(item[0].ToString());
             }
             cboOpcion.SelectedIndex = 0;
         }
         CargarIntervalos();
     }
 }
Esempio n. 7
0
        private void CargarSeries()
        {
            con = new SqlDbConnect();
            cboSerie.SelectedIndex = 0;
            con.SqlQuery($"DEVELOPMENT.dbo.DYREP00800S1 '{Dynamics.Globals.IntercompanyId.Value}','{Dynamics.Globals.UserId.Value}'");
            var table = con.QueryEx();

            if (table.Rows.Count > 0)
            {
                cboSerie.Items.Clear();
                foreach (DataRow item in table.Rows)
                {
                    cboSerie.Items.Add(item[0].ToString());
                }

                if (cboSerie.Items.Count > 0)
                {
                    cboSerie.SelectedIndex = 0;
                    CargarReportes();
                }
            }
        }
        private void cboIntervalo_SelectedIndexChanged(object sender, EventArgs e)
        {
            aIntervaloActivo = false;
            con = new SqlDbConnect();
            if (!string.IsNullOrEmpty(cboIntervalo.Text.Trim()))
            {
                con.SqlQuery($"DEVELOPMENT.dbo.DYREP10001S5 '{Dynamics.Globals.IntercompanyId.Value}','{aSerie.Trim()}','{aReportName}','{cboIntervalo.Text.Trim()}'");
                var table = con.QueryEx();
                if (table.Rows.Count > 0)
                {
                    aIntervaloActivo     = true;
                    aFieldType           = Convert.ToInt32(table.Rows[0][0]);
                    aSqlFind             = Convert.ToString(table.Rows[0][1]);
                    aSqlParameters       = Convert.ToString(table.Rows[0][2]);
                    aSqlBalIni           = Convert.ToString(table.Rows[0][3]);
                    txtDesde.Visible     = false;
                    txtHasta.Visible     = false;
                    btnLookDesde.Visible = false;
                    btnLookHasta.Visible = false;
                    cboDesde.Visible     = false;
                    cboHasta.Visible     = false;
                    dtpDesde.Visible     = false;
                    dtpHasta.Visible     = false;
                    Refresh();
                    switch (aFieldType)
                    {
                    case 0:
                        txtDesde.Visible = true;
                        txtHasta.Visible = true;
                        break;

                    case 1:
                        txtDesde.Visible = true;
                        txtHasta.Visible = true;
                        if (!string.IsNullOrEmpty(aSqlFind))
                        {
                            btnLookDesde.Visible = true;
                            btnLookHasta.Visible = true;
                        }
                        break;

                    case 2:
                        cboDesde.Visible       = true;
                        cboHasta.Visible       = true;
                        dtpDesde.Visible       = true;
                        dtpHasta.Visible       = true;
                        cboDesde.SelectedIndex = 0;
                        cboHasta.SelectedIndex = 0;
                        break;
                    }
                    switch (Convert.ToInt32(table.Rows[0][4]))
                    {
                    case 1:
                        txtHasta.Visible     = false;
                        btnLookHasta.Visible = false;
                        dtpHasta.Visible     = false;
                        cboHasta.Visible     = false;
                        break;

                    case 2:
                        txtDesde.Visible     = false;
                        btnLookDesde.Visible = false;
                        dtpDesde.Visible     = false;
                        cboDesde.Visible     = false;
                        break;
                    }
                }
            }

            Refresh();
            Application.DoEvents();
        }
        private void Lookup_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                //this.dgvLookup.DefaultCellStyle.Font = new Font("Tahoma", 8);
                this.Text = xTitle;

                con = new SqlDbConnect();
                con.SqlQuery(xQuery);

                //-- Llenando objecto BindingSource --
                xBindingSource = new BindingSource {
                    DataSource = con.QueryEx()
                };
                dgvLookup.DataSource = xBindingSource;
                //-- Llenando Grilla

                //-- Asignando tamaño y formato de columnas --
                for (int Conteo = 1; Conteo <= dgvLookup.Columns.Count; Conteo++)
                {
                    switch (Conteo)
                    {
                    case 1:
                        //-- Definiendo ancho para columna 1 --
                        if (xWithCol1 == 0)
                        {
                            dgvLookup.Columns[0].Width = 150;
                        }
                        else
                        {
                            dgvLookup.Columns[0].Width = xWithCol1;
                        }
                        Lbl_Lookup.Text = Lbl_Lookup.Tag + dgvLookup.Columns[0].HeaderText.ToString().Trim();

                        break;

                    case 2:
                        //-- Definiendo ancho para columna 2 --
                        if (xWithCol2 == 0)
                        {
                            dgvLookup.Columns[1].Width = dgvLookup.Width - (dgvLookup.Columns[0].Width + 5);
                        }
                        else if (xWithCol2 > 0)
                        {
                            dgvLookup.Columns[1].Width = xWithCol2;
                        }
                        break;

                    case 3:     // ERROR: Case labels with binary operators are unsupported : Equality

                        //-- Definiendo ancho para columna 3 --
                        if (xWithCol3 == 0)
                        {
                            dgvLookup.Columns[Conteo - 1].Width = dgvLookup.Columns[0].Width;
                        }
                        else if (xWithCol3 > 0)
                        {
                            dgvLookup.Columns[Conteo - 1].Width = xWithCol3;
                        }
                        break;

                    default:     // ERROR: Case labels with binary operators are unsupported : GreaterThan

                        //-- Definiendo ancho para columna 3 --
                        dgvLookup.Columns[Conteo - 1].Width = dgvLookup.Columns[0].Width;
                        break;
                    }
                }
                Txt_Lookup.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Microsoft Dynamics GP", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            int xRowCount = dgvLookup.RowCount;

            try
            {
                //-- Asignando ancho fijo a celdas y deshabilitando campo --
                for (int yRowCount = 0; yRowCount <= xRowCount - 1; yRowCount++)
                {
                    dgvLookup.Rows[yRowCount].Height = 30;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Microsoft Dynamics GP", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //-- Verificando si existe texto para buscar --
            if (xSearchText.Trim().Length > 0)
            {
                Txt_Lookup.Text = xSearchText;
                Txt_Lookup_TextChanged(sender, e);
            }
        }