Esempio n. 1
0
        private void Cargar()
        {
            //select de cabeceras albaranes de venta (no facturados) por detallista
            string gIdent = this.GetType().FullName + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " ";

            GloblaVar.gUTIL.ATraza(gIdent + " Entrada a  " + gIdent);

            //string strQ = "SELECT * FROM VENALB_CABE WHERE (DetCod=" + textBox_DetCod.Text + ") AND (VenNfp IS NULL) AND (AnyoFra IS NULL) AND (SerieFra IS NULL) AND (Anulado<>1) order by VenFec, VenAlb";
            string strQ = "SELECT * FROM VENALB_CABE ";

            strQ += " WHERE ";
            strQ += " (DetCod=" + textBox_DetCod.Text + ") ";
            strQ += " AND (VenNfp IS NULL) ";
            strQ += " AND (AnyoFra IS NULL)";
            strQ += " AND (SerieFra IS NULL)";
            strQ += " AND (Anulado<>1) ";
            if (GloblaVar.gCERCLE_105 == true)
            {
                strQ += " AND (VenTve NOT IN (3,51,43)) ";
            }
            else
            {
                strQ += " AND (VenTve NOT IN (51,43)) ";
            }                                                                                                                                  //DIALPESCA no QUIERE Factura de CONTADOS DE OREMAPE
            strQ += " ORDER by VenFec, VenAlb";

            this.Cursor = Cursors.WaitCursor;

            //limpiamos ambos grids por el binding
            dataSource1.Clear();
            dataSource2.Clear();

            try
            {
                SqlDataReader myReader  = null;
                SqlCommand    myCommand = new SqlCommand(strQ, GloblaVar.gConRem);
                myReader = myCommand.ExecuteReader();
                while (myReader.Read())
                {
                    clase_albaran alba = new clase_albaran();

                    alba.Albaran  = myReader["VenAlb"].ToString();
                    alba.Año      = myReader["Anyo"].ToString();
                    alba.Facturar = false;
                    alba.Fecha    = myReader["VenFec"].ToString(); if (alba.Fecha.Length > 10)
                    {
                        alba.Fecha = alba.Fecha.Substring(0, 10);
                    }
                    alba.TV      = myReader["VenTve"].ToString();
                    alba.Total   = Funciones.Formatea(myReader["VenTot"].ToString());
                    alba.BI      = myReader["VenBru"].ToString();
                    alba.IVA     = myReader["VenIva"].ToString();
                    alba.Recargo = myReader["VenRec"].ToString();

                    dataSource1.Add(alba);
                }
                myReader.Close();

                //como usamos binding esta línea no es necesaria:
                //dataGridView_Albaranes.DataSource = Albaranes;

                if (dataGridView_Albaranes.Rows.Count > 0)
                {
                    dataGridView_Albaranes.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dataGridView_Albaranes.Columns[6].Visible      = false;
                    dataGridView_Albaranes.Columns[7].Visible      = false;
                    dataGridView_Albaranes.Columns[8].Visible      = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                GloblaVar.gUTIL.ATraza(gIdent + ex.ToString());
            }

            this.Cursor = Cursors.Default;
        }
Esempio n. 2
0
        private void Cargar(string CampoOrden = "VenAlb")
        {
            albaranes = new ArrayList();

            //string strQ = "SELECT * FROM VENALB_CABE WHERE (DetCod=" + textBox_DetCod.Text + ") AND (VenNfp IS NULL) AND (AnyoFra IS NULL) AND (SerieFra IS NULL) AND (Anulado<>1) order by VenFec, VenAlb";
            string strQ = @"SELECT vc.VenAlb, vc.Anyo, vc.VenFec, vc.DetCod, d.DetNom, d.SubCta, vc.VenTve, Vc.IdCobro, vc.FechaCobro, vc.VenTot, vc.PerCentIva FROM VENALB_CABE as vc ";

            strQ += " INNER JOIN DETALLISTAS as d on d.DetCod = vc.DetCod ";
            strQ += " WHERE ";
            //strQ += "(vc.VenFec='" + dtpFecha.Text + "')";
            //strQ += " AND ";
            strQ += "(vc.Anulado<>1) ";
            strQ += " AND ";
            strQ += " (vc.VenTve NOT IN (1,51,43)) ";
            strQ += " AND ";
            strQ += "vc.FechaCobro='" + dtpFecha.Text + "'";
            if (radioButton2.Checked)
            {
                CampoOrden = "DetCod";
            }
            switch (CampoOrden)
            {
            case "DetCod":
                strQ += " ORDER by vc.DetCod";
                break;

            case "VenAlb":
                strQ += " ORDER by vc.VenAlb";
                break;

            default:
                strQ += " ORDER by vc.VenFec, vc.VenAlb";
                break;
            }


            this.Cursor = Cursors.WaitCursor;

            try
            {
                double Total_Lista = 0;

                SqlDataReader myReader  = null;
                SqlCommand    myCommand = new SqlCommand(strQ, CnO);
                myReader = myCommand.ExecuteReader();
                while (myReader.Read())
                {
                    clase_albaran alba = new clase_albaran();


                    alba.Albaran = myReader["VenAlb"].ToString();
                    alba.Fecha   = myReader["VenFec"].ToString(); if (alba.Fecha.Length > 10)
                    {
                        alba.Fecha = alba.Fecha.Substring(0, 10);
                    }
                    alba.Año              = myReader["Anyo"].ToString();
                    alba.CodDetallista    = myReader["DetCod"].ToString();
                    alba.NomDetallista    = myReader["DetNom"].ToString();
                    alba.SubCtaDetallista = myReader["SubCta"].ToString();
                    alba.TV       = myReader["VenTve"].ToString();
                    alba.NumCobro = myReader["IdCobro"].ToString();
                    alba.FecCobro = myReader["FechaCobro"].ToString(); if (alba.FecCobro.Length > 10)
                    {
                        alba.FecCobro = alba.FecCobro.Substring(0, 10);
                    }

                    alba.Total         = Funciones.Formatea(myReader["VenTot"].ToString());
                    Total_Lista       += Convert.ToDouble(alba.Total);
                    alba.PorcentajeIva = Funciones.Formatea(myReader["PerCentIva"].ToString());

                    albaranes.Add(alba);
                }
                myReader.Close();

                dataGridView_Albaranes.AutoGenerateColumns = false;
                dataGridView_Albaranes.DataSource          = albaranes;
                label1.Text = Total_Lista.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            this.Cursor = Cursors.Default;
        }
        private void Cargar()
        {
            //select de cabeceras albaranes de venta (no facturados) por detallista

            string strQ = "SELECT * FROM VENALB_CABE WHERE (DetCod=" + textBox_DetCod.Text + ") AND ((VenNfp = " + textBox_Factura.Text + " AND AnyoFra = " + factura.Anyo + " AND SerieFra = '" + factura.Serie + "') OR (VenNfp IS NULL AND AnyoFra IS NULL AND SerieFra IS NULL)) AND (Anulado<>1) order by VenFec, VenAlb";

            this.Cursor = Cursors.WaitCursor;

            //limpiamos ambos grids por el binding
            dataSource1.Clear();
            dataSource2.Clear();

            try
            {
                SqlDataReader myReader  = null;
                SqlCommand    myCommand = new SqlCommand(strQ, CnO);
                myReader = myCommand.ExecuteReader();
                while (myReader.Read())
                {
                    clase_albaran alba = new clase_albaran();

                    alba.Albaran  = myReader["VenAlb"].ToString();
                    alba.Año      = myReader["Anyo"].ToString();
                    alba.Facturar = false; if (myReader["VenNfp"].ToString() == textBox_Factura.Text)
                    {
                        alba.Facturar = true;
                    }
                    alba.Fecha = myReader["VenFec"].ToString(); if (alba.Fecha.Length > 10)
                    {
                        alba.Fecha = alba.Fecha.Substring(0, 10);
                    }
                    alba.TV      = myReader["VenTve"].ToString();
                    alba.Total   = Funciones.Formatea(myReader["VenTot"].ToString());
                    alba.BI      = myReader["VenBru"].ToString();
                    alba.IVA     = myReader["VenIva"].ToString();
                    alba.Recargo = myReader["VenRec"].ToString();

                    dataSource1.Add(alba);
                }
                myReader.Close();

                if (dataGridView_Albaranes.Rows.Count > 0)
                {
                    dataGridView_Albaranes.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dataGridView_Albaranes.Columns[6].Visible      = false;
                    dataGridView_Albaranes.Columns[7].Visible      = false;
                    dataGridView_Albaranes.Columns[8].Visible      = false;
                    dataGridView_Albaranes.Columns[9].Visible      = false;
                    dataGridView_Albaranes.Columns[10].Visible     = false;
                    dataGridView_Albaranes.Columns[11].Visible     = false;
                    dataGridView_Albaranes.Columns[12].Visible     = false;
                    dataGridView_Albaranes.Columns[13].Visible     = false;
                    dataGridView_Albaranes.Columns[14].Visible     = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            this.Cursor = Cursors.Default;
        }