Exemplo n.º 1
0
        public ActionResult Remove(int id)
        {
            FlashOK("El Reporte fue eliminado");

            try
            {
                context.Connection.Open();
                using (var tr = context.Connection.BeginTransaction())
                {
                    var item = context.TBL_REPORTE.Where(c => c.ID == id).SingleOrDefault();
                    TBL_REPORTE_PARAM[] toDelete = new TBL_REPORTE_PARAM[item.TBL_REPORTE_PARAM.Count()];
                    item.TBL_REPORTE_PARAM.CopyTo(toDelete, 0);
                    foreach (TBL_REPORTE_PARAM param in toDelete)
                    {
                        context.DeleteObject(param);
                    }
                    context.DeleteObject(item);

                    context.SaveChanges(System.Data.Objects.SaveOptions.None);

                    tr.Commit();
                }
            }
            catch (Exception ex)
            {
                FlashError("No se pudo eliminar el reporte, intente nuevamente:" + ex.Message);
            }

            return(View("List"));
        }
Exemplo n.º 2
0
        private void AddParams(decimal reporte_id)
        {
            string[] param_keys    = this.Request.Params.AllKeys;
            int      index         = 1;
            string   key_nombre    = String.Format("TBL_REPORTE_PARAM-NOMBRE_{0}", index.ToString());
            string   key_tipo_dato = String.Format("TBL_REPORTE_PARAM-TIPO_DATO_{0}", index.ToString());
            bool     hay_params    = param_keys.Contains(key_nombre);

            while (hay_params)
            {
                TBL_REPORTE_PARAM param = new TBL_REPORTE_PARAM();
                param.INDICE     = index;
                param.NOMBRE     = this.Request.Params.Get(key_nombre);
                param.TIPO_DATO  = Convert.ToInt32(this.Request.Params.Get(key_tipo_dato));
                param.REPORTE_ID = reporte_id;//reporte.ID;

                context.TBL_REPORTE_PARAM.AddObject(param);
                //reporte.TBL_REPORTE_PARAM.Add(param);

                index++;
                key_nombre    = String.Format("TBL_REPORTE_PARAM-NOMBRE_{0}", index.ToString());
                key_tipo_dato = String.Format("TBL_REPORTE_PARAM-TIPO_DATO_{0}", index.ToString());
                hay_params    = param_keys.Contains(key_nombre);
            }
        }
Exemplo n.º 3
0
        static public SelectList CreateDataTypeCombo(TBL_REPORTE_PARAM param)
        {
            List <object> newList = new List <object>();

            foreach (ReporteParamDataType dataType in Enum.GetValues(typeof(ReporteParamDataType)))
            {
                newList.Add(new
                {
                    id     = Convert.ToInt32(dataType),
                    nombre = Convert.ToString(dataType)
                });
            }

            return(new SelectList(newList, "id", "nombre", Convert.ToInt32(param.TIPO_DATO)));
        }
Exemplo n.º 4
0
        private TBL_REPORTE getNewReporte(TBL_REPORTE reporte)
        {
            TBL_REPORTE _reporte = new TBL_REPORTE();

            if (reporte != null)
            {
                _reporte = reporte;
            }

            _reporte.TBL_REPORTE_PARAM = new System.Data.Objects.DataClasses.EntityCollection <TBL_REPORTE_PARAM>();
            TBL_REPORTE_PARAM param = new TBL_REPORTE_PARAM();

            param.INDICE    = 1;
            param.NOMBRE    = "nombre";
            param.TIPO_DATO = Convert.ToInt32(ReporteParamDataType.ENTERO);

            _reporte.TBL_REPORTE_PARAM.Add(param);
            return(_reporte);
        }