private void frmFPVManual_Load(object sender, EventArgs e)
        {
            string gIdent = this.GetType().FullName + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " ";

            GloblaVar.gUTIL.CartelTraza("ENTRADA a " + this.GetType().FullName);

            //se ejecuta al cargar el formulario

            if (CnO != null)
            {
                clase_UTILESdb cla = new clase_UTILESdb();
                if (GloblaVar.gMayCod != "13")
                {
                    cla.SP1();
                }

                //array de detallistas
                Lista_detallistas = new ArrayList();
                string strQ = "SELECT * FROM DETALLISTAS order by DetCod";

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

                        detal.DetCod   = myReader["DetCod"].ToString();
                        detal.DetNom   = myReader["DetNom"].ToString();
                        detal.DetCpf   = "";
                        detal.DetEMail = myReader["DetEMail"].ToString();
                        detal.detvia   = myReader["detvia"].ToString();
                        detal.DetCop   = myReader["DetCop"].ToString();
                        detal.detmun   = myReader["DetMun"].ToString();
                        detal.DetNif   = myReader["DetNif"].ToString();

                        Lista_detallistas.Add(detal);
                    }
                    myReader.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    GloblaVar.gUTIL.ATraza(gIdent + ex.ToString());
                }
            }

            //cargar datos factura nueva
            textBox_Anyo.Text = DateTime.Today.Year.ToString();
            //textBox_Factura.Text = Nuevo_Factura();
            comboBox_Serie.Text = "AA";

            //limpiamos los datagrid y hacemos binding
            dataSource1.Clear();
            bs1.DataSource = dataSource1;
            dataGridView_Albaranes.DataSource = bs1;

            dataSource2.Clear();
            bs2.DataSource = dataSource2;
            dataGridView_Facturado.DataSource = bs2;

            textBox_DetCod.Focus();
        }
Exemple #2
0
        private void frmFPVAbono_Load(object sender, EventArgs e)
        {
            GloblaVar.gUTIL.CartelTraza("ENTRADA a " + this.GetType().FullName);
            string gIdent = this.GetType().FullName + " " + System.Reflection.MethodBase.GetCurrentMethod().Name;

            //se ejecuta al cargar el formulario

            if (CnO != null)
            {
                clase_UTILESdb cla = new clase_UTILESdb();
                //cla.SP1();

                //array de detallistas
                Lista_detallistas = new ArrayList();
                string strQ = "SELECT * FROM DETALLISTAS order by DetCod";

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

                        detal.DetCod   = myReader["DetCod"].ToString();
                        detal.DetNom   = myReader["DetNom"].ToString();
                        detal.DetCpf   = "";
                        detal.DetEMail = myReader["DetEMail"].ToString();
                        detal.detvia   = myReader["detvia"].ToString();
                        detal.DetCop   = myReader["DetCop"].ToString();
                        detal.detmun   = myReader["DetMun"].ToString();
                        detal.DetNif   = myReader["DetNif"].ToString();

                        Lista_detallistas.Add(detal);
                    }
                    myReader.Close();
                }
                catch (Exception ex)
                {
                    GloblaVar.gUTIL.ATraza(gIdent + ex.ToString());
                    MessageBox.Show(ex.ToString());
                }

                //dTipo_iva = 0;

                string selectTipoIva = "SELECT TOP(1)IVA, Recargo FROM [dbo].[TIPOS_IVA] ORDER BY Fecha desc";

                using (SqlCommand cmd = new SqlCommand(selectTipoIva, CnO))
                {
                    try
                    {
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            dTipo_iva     = decimal.Parse(reader["IVA"].ToString());
                            dTipo_recargo = decimal.Parse(reader["Recargo"].ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Al consultar el tipo de iva se ha producido el siguiente error: \n\n " + ex.Message);
                    }
                }
            }

            //cargar datos factura nueva
            textBox_Anyo.Text = DateTime.Today.Year.ToString();
            //textBox_Factura.Text = Nuevo_Factura();
            comboBox_Serie.Text = "AB";

            textBox_DetCod.Focus();
        }//private void frmFPVAbono_Load(object sender, EventArgs e)