Example #1
0
        public Boolean GrabarDB_Periodos(List <Aca_Periodo_Info> Lst, ref string mensaje)
        {
            try
            {
                using (Entities_Academico Context = new Entities_Academico())
                {
                    foreach (var Item in Lst)
                    {
                        var que = from C in Context.Aca_periodo
                                  where C.IdPeriodo == Item.IdPeriodo
                                  select C;
                        if (que.Count() == 0)
                        {
                            Aca_periodo Periodo = new Aca_periodo();
                            Periodo.IdInstitucion = Item.IdInstitucion;
                            Periodo.IdPeriodo     = Item.IdPeriodo;
                            Periodo.IdAnioLectivo = Item.IdAnioLectivo;
                            Periodo.pe_anio       = Item.pe_anio;
                            Periodo.pe_mes        = Item.pe_mes;
                            Periodo.pe_FechaIni   = Item.pe_FechaIni;
                            Periodo.pe_FechaFin   = Item.pe_FechaFin;
                            Periodo.pe_estado     = Item.pe_estado;
                            Periodo.est_apertura  = Item.est_apertura;

                            Context.Aca_periodo.Add(Periodo);
                            Context.SaveChanges();
                        }
                        else
                        {
                            mensaje = "Error en el ingreso; Periodo Existente";
                            return(false);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string array = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", array, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
Example #2
0
        public Boolean GrabarDB(Aca_Periodo_Info Info, ref string msg)
        {
            try
            {
                using (Entities_Academico context = new Entities_Academico())
                {
                    var que = from C in context.Aca_periodo
                              where C.IdPeriodo == Info.IdPeriodo
                              select C;
                    if (que.Count() == 0)
                    {
                        var address = new Aca_periodo();
                        //Info.IdPeriodo = getId(Info.IdInstitucion, Info.pe_anio, Info.pe_mes);
                        address.IdInstitucion = Info.IdInstitucion;
                        address.IdPeriodo     = Info.IdPeriodo;
                        address.IdAnioLectivo = Info.IdAnioLectivo;
                        address.pe_FechaIni   = Convert.ToDateTime(Info.pe_FechaIni);
                        address.pe_FechaFin   = Convert.ToDateTime(Info.pe_FechaFin);
                        address.pe_anio       = Convert.ToInt32(Info.pe_anio);
                        address.pe_mes        = Convert.ToByte(Info.pe_mes);
                        address.pe_estado     = Info.pe_estado;

                        context.Aca_periodo.Add(address);

                        context.SaveChanges();
                    }
                    else
                    {
                        msg = "Error en el ingreso; Periodo  Existente";
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string array = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", array, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }