예제 #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (lsvOpciones.Items.Count > 0)
     {
         for (int i = 0; i < lsvOpciones.Items.Count; i++)
         {
             if (lsvOpciones.Items[i].Selected)
             {
                 if (MessageBox.Show($"Esta seguro que desea eliminar la opcion {lsvOpciones.Items[i].SubItems[1].Text.Trim()}",
                                     "Microsoft Dynamics GP", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                 {
                     con = new SqlDbConnect();
                     con.SqlQuery($"DEVELOPMENT.dbo.DYREP10100SD '{Dynamics.Globals.IntercompanyId.Value}','{cboSerie.Text.Trim()}','{cboReporte.Text.Trim()}','{lsvOpciones.Items[i].SubItems[1].Text.Trim()}'");
                     con.NonQueryEx();
                 }
                 lsvOpciones.Items[i].Remove();
                 CargarOpciones();
                 return;
             }
         }
     }
     else
     {
         MessageBox.Show("Debe de seleccionar la opcion que desea eliminar", "Microsoft Dynamics GP", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #2
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();
                }
            }
        }
예제 #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();
 }
        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);
            }
        }
 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();
     }
 }
예제 #6
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);
            }
        }