コード例 #1
0
        public List<clsPeriodoContable> generarP(String buscar)
        {
            EPeriodoContable gene = new EPeriodoContable();
            NPeriodo addPeriodo = new NPeriodo();
            //NModeloAsiento addModeloAsiento = new NModeloAsiento();
            int mes = 0;

            int WIDempresa = 0;
            int WIdPeriodo = 0;
            int WIdAFiscal = 0;
            DateTime wFechaInicio = DateTime.Now;
            DateTime wFechaFin = DateTime.Now;
            int WIdEstado = 0;
            int WIdUsuario = 0;
            DateTime wFechaModificacion = DateTime.Now;

            try
            {
                for (int i = 1; i < 13; i++)
                {
                    // Genero los meses del año que no existe
                    TECAEntitiesCont ent = new TECAEntitiesCont();
                    WIDempresa = 1;
                    WIdPeriodo = i;
                    WIdAFiscal = Convert.ToInt32(buscar);
                    string fechaI = buscar + '-' + i.ToString() + '-' + 1;
                    if(i==2){
                    string fechaF = buscar + '-' + i.ToString() + '-' + 28;
                    wFechaFin = Convert.ToDateTime(fechaF);
                    }
                    if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
                    {
                        string fechaF = buscar + '-' + i.ToString() + '-' + 31;
                        wFechaFin = Convert.ToDateTime(fechaF);
                    }
                    if (i == 4 || i == 6 || i == 9 || i == 11 )
                    {
                        string fechaF = buscar + '-' + i.ToString() + '-' + 30;
                        wFechaFin = Convert.ToDateTime(fechaF);
                    }
                    wFechaInicio = Convert.ToDateTime(fechaI);
                    WIdEstado = 1;
                    WIdUsuario = 1;
                    wFechaModificacion = DateTime.Now;
                    //DateTime.Now
                    NPeriodo dat = new NPeriodo();
                    dat.periodocontable_Insertar(WIDempresa, WIdPeriodo, WIdAFiscal, wFechaInicio, wFechaFin, WIdEstado, WIdUsuario, wFechaModificacion);

                    ///this.txtSecuencia.Text = this.addModeloAsiento.Insertar(this.e).ToString();
                    ///this.addModeloAsiento.Insertar(this.e).ToString();.
                    //MessageBox.Show("Registro insertado correctamente", "Correcto!!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    /// pongo en falso que al precionar grabar otra vez no se
                }

                return ListarP(Convert.ToInt32(buscar));
            }
            catch (Exception ex)
            {

                throw new Exception("Error al Listar rrrr\n " + ex.Message);
            }
        }
コード例 #2
0
        public List <clsPeriodoContable> generarP(String buscar)
        {
            EPeriodoContable gene       = new EPeriodoContable();
            NPeriodo         addPeriodo = new NPeriodo();
            //NModeloAsiento addModeloAsiento = new NModeloAsiento();
            int mes = 0;

            int      WIDempresa         = 0;
            int      WIdPeriodo         = 0;
            int      WIdAFiscal         = 0;
            DateTime wFechaInicio       = DateTime.Now;
            DateTime wFechaFin          = DateTime.Now;
            int      WIdEstado          = 0;
            int      WIdUsuario         = 0;
            DateTime wFechaModificacion = DateTime.Now;

            try
            {
                for (int i = 1; i < 13; i++)
                {
                    // Genero los meses del año que no existe
                    TECAEntitiesCont ent = new TECAEntitiesCont();
                    WIDempresa = 1;
                    WIdPeriodo = i;
                    WIdAFiscal = Convert.ToInt32(buscar);
                    string fechaI = buscar + '-' + i.ToString() + '-' + 1;
                    if (i == 2)
                    {
                        string fechaF = buscar + '-' + i.ToString() + '-' + 28;
                        wFechaFin = Convert.ToDateTime(fechaF);
                    }
                    if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
                    {
                        string fechaF = buscar + '-' + i.ToString() + '-' + 31;
                        wFechaFin = Convert.ToDateTime(fechaF);
                    }
                    if (i == 4 || i == 6 || i == 9 || i == 11)
                    {
                        string fechaF = buscar + '-' + i.ToString() + '-' + 30;
                        wFechaFin = Convert.ToDateTime(fechaF);
                    }
                    wFechaInicio       = Convert.ToDateTime(fechaI);
                    WIdEstado          = 1;
                    WIdUsuario         = 1;
                    wFechaModificacion = DateTime.Now;
                    //DateTime.Now
                    NPeriodo dat = new NPeriodo();
                    dat.periodocontable_Insertar(WIDempresa, WIdPeriodo, WIdAFiscal, wFechaInicio, wFechaFin, WIdEstado, WIdUsuario, wFechaModificacion);



                    ///this.txtSecuencia.Text = this.addModeloAsiento.Insertar(this.e).ToString();
                    ///this.addModeloAsiento.Insertar(this.e).ToString();.
                    //MessageBox.Show("Registro insertado correctamente", "Correcto!!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    /// pongo en falso que al precionar grabar otra vez no se
                }

                return(ListarP(Convert.ToInt32(buscar)));
            }
            catch (Exception ex)
            {
                throw new Exception("Error al Listar rrrr\n " + ex.Message);
            }
        }
コード例 #3
0
        public List<clsPeriodoContable> generarP(String @buscar)
        {
            EPeriodoContable gene = new EPeriodoContable();
            NPeriodo addPeriodo = new NPeriodo();
            //NModeloAsiento addModeloAsiento = new NModeloAsiento();

            try
            {
                using (this.dt = new TECAEntitiesCont())
                {
                    List<clsPeriodoContable> generarlista = new List<clsPeriodoContable>();
                    var per = from c in this.dt.PeriodoContable
                              where c.IdPeriodoContable.ToString().Contains(buscar) && c.IdEmpresa == 1
                              select c;
                    int mes = 0;

                    int WIDempresa = 0;
                    int WIdPeriodo = 0;
                    int WIdAFiscal = 0;
                    DateTime wFechaInicio = DateTime.Now ;
                    DateTime wFechaFin = DateTime.Now ;
                    int WIdEstado = 0;
                    int WIdUsuario = 0;
                    DateTime wFechaModificacion = DateTime.Now ;

                    foreach (var item in per)
                    {
                        clsPeriodoContable ctipo = new clsPeriodoContable();
                        //las variables puden ser nulas u no soportan el tipo de dato int por eso se realiza el convert
                        //ctipo.IdEmpresa = Convert.ToInt32(item.IdEmpresa);
                        ctipo.IdPeriodoContable = Convert.ToInt32(item.IdPeriodoContable);
                        ctipo.IdAFiscal = Convert.ToInt32(item.IdAFiscal);
                        ctipo.FechaInicio = item.FechaInicio;
                        ctipo.FechaFin = item.FechaFin;
                        ctipo.IdEstado = item.IdEstado;
                        generarlista.Add(ctipo);
                        mes = 1;
                    }

                    if (mes == 0)
                    {
                        // Genero los meses del año
                        for (int i = 1; i < 13; i++)
                        {
                            // Genero los meses del año que no existe

                            WIDempresa = 1;
                            WIdPeriodo = Convert.ToInt32(buscar);
                            WIdAFiscal = i;
                            string fechaI = WIdPeriodo.ToString()+'-'+i.ToString()+'-'+1;
                            string fechaF = WIdPeriodo.ToString() + '-' + i.ToString() + '-' + 28;
                            wFechaInicio = Convert.ToDateTime(fechaI);
                            wFechaFin = Convert.ToDateTime(fechaF);
                            WIdEstado = 1;
                            WIdUsuario = 1;
                            wFechaModificacion = DateTime.Now;
                            //DateTime.Now
                                NPeriodo dat = new NPeriodo();
                                dat.periodocontable_Insertar(WIDempresa, WIdPeriodo, WIdAFiscal, wFechaInicio, wFechaFin , WIdEstado , WIdUsuario, wFechaModificacion);
                                ///this.txtSecuencia.Text = this.addModeloAsiento.Insertar(this.e).ToString();
                                ///this.addModeloAsiento.Insertar(this.e).ToString();.
                                //MessageBox.Show("Registro insertado correctamente", "Correcto!!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                /// pongo en falso que al precionar grabar otra vez no se
                        }
                    }
                    else
                    {
                        throw new Exception("Existe informacion en el año ");
                    }

                    //return per.ToList();
                    return generarlista;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al Listar\n " + ex.Message);
            }
        }