示例#1
0
        public ActionResult Delete(string area_Razoninactivo)
        {
            //declaramos la variable de coneccion solo para recuperar los datos necesarios.
            //posteriormente es destruida.
            string result = "";
            var    cAreas =
                new cAreas
            {
                area_Id            = (int)Session["area_Id"],
                area_Razoninactivo = area_Razoninactivo
            };
            var Usuario = (tbUsuario)Session["Usuario"];

            try
            {
                using (db = new ERP_GMEDINAEntities())
                {
                    var list = db.UDP_RRHH_tbAreas_Delete(cAreas.area_Id, cAreas.area_Razoninactivo,
                                                          (int)Session["UserLogin"],
                                                          Function.DatetimeNow());
                    foreach (UDP_RRHH_tbAreas_Delete_Result item in list)
                    {
                        result = item.MensajeError;
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
                result = "-2";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        private void GuardarArea()
        {
            cAreas area = new cAreas();

            if (!string.IsNullOrEmpty(Clave))
            {  //Actualizar
                area.Actualizar(new AREA
                {
                    ID_AREA   = SelectedItem.ID_AREA,
                    DESCR     = Descripcion,
                    ID_CENTRO = SelectedTipo.ID_CENTRO
                });
            }
            else
            {   //Agregar
                area.Insertar(new AREA
                {
                    ID_AREA   = 0,
                    DESCR     = Descripcion,
                    ID_CENTRO = SelectedTipo.ID_CENTRO
                });
            }
            //Limpiamos las variables
            Clave       = string.Empty;
            Descripcion = string.Empty;
            Tipo        = 0;
            //Mostrar Listado
            this.GetAreas();
        }
        private void GetAreas()
        {
            cAreas area = new cAreas();

            ListItems.Clear();
            ListItems = new ObservableCollection <AREA>(area.ObtenerTodos(Busqueda, SelectedTipo.ID_CENTRO));
            if (ListItems.Count > 0)
            {
                EmptyVisible = false;
            }
            else
            {
                EmptyVisible = true;
            }
        }
 private bool EliminarArea()
 {
     if (SelectedItem != null)
     {
         cAreas area = new cAreas();
         if (!area.Eliminar(SelectedItem.ID_AREA))
         {
             return(false);
         }
         Clave       = string.Empty;
         Descripcion = string.Empty;
         Tipo        = 0;
         this.GetAreas();
     }
     return(true);
 }
        //
        //  Page class constructor
        //
        public cPersonas_add(AspNetMaker9_ControlVehicular APage)
        {
            m_ParentPage = APage;
            m_Page = this;
            m_PageID = "add";
            m_PageObjName = "Personas_add";
            m_PageObjTypeName = "cPersonas_add";

            // Initialize language object
            if (Language == null)
                Language = new cLanguage(this);

            // Initialize table object
            if (Personas == null)
                Personas = new cPersonas(this);
            if (Areas == null)
                Areas = new cAreas(this);
            if (Usuarios == null)
                Usuarios = new cUsuarios(this);
            if (VehiculosAutorizados_grid == null)
                VehiculosAutorizados_grid = new cVehiculosAutorizados_grid(ParentPage);
            if (VehiculosAutorizados == null)
                VehiculosAutorizados = new cVehiculosAutorizados(this);

            // Table
            m_TableName = "Personas";
            m_Table = Personas;
            CurrentTable = Personas;

            //CurrentTableType = Personas.GetType();
            // Initialize URLs
            // Connect to database

            if (Conn == null)
                Conn = new cConnection();
        }
        //
        //  Page class constructor
        //
        public cAreas_view(AspNetMaker9_ControlVehicular APage)
        {
            m_ParentPage = APage;
            m_Page = this;
            m_PageID = "view";
            m_PageObjName = "Areas_view";
            m_PageObjTypeName = "cAreas_view";

            // Initialize language object
            if (Language == null)
                Language = new cLanguage(this);

            // Initialize table object
            if (Areas == null)
                Areas = new cAreas(this);
            if (Usuarios == null)
                Usuarios = new cUsuarios(this);

            // Table
            m_TableName = "Areas";
            m_Table = Areas;
            CurrentTable = Areas;

            //CurrentTableType = Areas.GetType();
            // Initialize URLs

            string KeyUrl = "";
            if (ew_NotEmpty(ew_Get("IdArea"))) {
                RecKey["IdArea"] = ew_Get("IdArea");
                KeyUrl += "&IdArea=" + ew_UrlEncode(RecKey["IdArea"]);
            }
            ExportPrintUrl = PageUrl + "export=print" + KeyUrl;
            ExportHtmlUrl = PageUrl + "export=html" + KeyUrl;
            ExportExcelUrl = PageUrl + "export=excel" + KeyUrl;
            ExportWordUrl = PageUrl + "export=word" + KeyUrl;
            ExportXmlUrl = PageUrl + "export=xml" + KeyUrl;
            ExportCsvUrl = PageUrl + "export=csv" + KeyUrl;
            ExportPdfUrl = PageUrl + "export=pdf" + KeyUrl;

            // Connect to database
            if (Conn == null)
                Conn = new cConnection();

            // Export options
            ExportOptions = new cListOptions();
            ExportOptions.Tag = "span";
            ExportOptions.Separator = "&nbsp;&nbsp;";
        }
        //
        //  Page class constructor
        //
        public cAreas_list(AspNetMaker9_ControlVehicular APage)
        {
            m_ParentPage = APage;
            m_Page = this;
            m_PageID = "list";
            m_PageObjName = "Areas_list";
            m_PageObjTypeName = "cAreas_list";

            // Initialize language object
            if (Language == null)
                Language = new cLanguage(this);

            // Initialize table object
            if (Areas == null)
                Areas = new cAreas(this);
            if (Personas == null)
                Personas = new cPersonas(this);
            if (Usuarios == null)
                Usuarios = new cUsuarios(this);

            // Table
            m_TableName = "Areas";
            m_Table = Areas;
            CurrentTable = Areas;

            //CurrentTableType = Areas.GetType();
            // Initialize URLs

            ExportPrintUrl = PageUrl + "export=print";
            ExportExcelUrl = PageUrl + "export=excel";
            ExportWordUrl = PageUrl + "export=word";
            ExportHtmlUrl = PageUrl + "export=html";
            ExportXmlUrl = PageUrl + "export=xml";
            ExportCsvUrl = PageUrl + "export=csv";
            ExportPdfUrl = PageUrl + "export=pdf";
            AddUrl = "Areasadd.aspx?" + EW_TABLE_SHOW_DETAIL + "=";
            InlineAddUrl = PageUrl + "a=add";
            GridAddUrl = PageUrl + "a=gridadd";
            GridEditUrl = PageUrl + "a=gridedit";
            MultiDeleteUrl = "Areasdelete.aspx";
            MultiUpdateUrl = "Areasupdate.aspx";

            // Connect to database
            if (Conn == null)
                Conn = new cConnection();

            // Initialize list options
            ListOptions = new cListOptions();

            // Export options
            ExportOptions = new cListOptions();
            ExportOptions.Tag = "span";
            ExportOptions.Separator = "&nbsp;&nbsp;";
        }
        //
        //  Page class constructor
        //
        public cPersonas_grid(AspNetMaker9_ControlVehicular APage)
        {
            m_ParentPage = APage;
            m_Page = this;
            m_PageID = "grid";
            m_PageObjName = "Personas_grid";
            m_PageObjTypeName = "cPersonas_grid";

            // Initialize language object
            if (Language == null)
                Language = new cLanguage(this);

            // Initialize table object
            if (Personas == null)
                Personas = new cPersonas(this);
            if (Areas == null)
                Areas = new cAreas(this);
            if (Usuarios == null)
                Usuarios = new cUsuarios(this);

            // Table
            m_TableName = "Personas";
            m_Table = Personas;
            MasterTable = CurrentTable;

            //MasterTableType = CurrentTableType;
            CurrentTable = Personas;

            //CurrentTableType = Personas.GetType();
            Personas.LoadDetailParms();
            if (ew_NotEmpty(ew_Get("confirmpage")))
                ConfirmPage = ew_ConvertToBool(ew_Get("confirmpage"));
            if (Personas.CurrentMasterTable == "Areas") {
                Personas.IdArea.FldIsDetailKey = true;
                if (ew_NotEmpty(ew_Get("IdArea"))) {
                    Personas.IdArea.CurrentValue = ew_Get("IdArea");
                    Personas.IdArea.SessionValue = Personas.IdArea.CurrentValue;
                }
            }

            // Initialize URLs
            // Connect to database

            if (Conn == null)
                Conn = new cConnection();

            // Initialize list options
            ListOptions = new cListOptions();
        }
示例#9
0
        public ActionResult Edit(cAreas cAreas, cDepartamentos[] Departamentos, cDepartamentos[] inactivar)
        {
            //declaramos la variable de coneccion solo para recuperar los datos necesarios.
            //posteriormente es destruida.
            string result = "";

            cAreas.area_Id = (int)Session["area_Id"];
            var Usuario = (tbUsuario)Session["Usuario"];

            //en esta area ingresamos el registro con el procedimiento almacenado
            try
            {
                db = new ERP_GMEDINAEntities();
                using (var transaction = db.Database.BeginTransaction())
                {
                    var list = db.UDP_RRHH_tbAreas_Update(
                        cAreas.area_Id,
                        cAreas.suc_Id,
                        cAreas.area_Descripcion,
                        (int)Session["UserLogin"],
                        Function.DatetimeNow());
                    foreach (UDP_RRHH_tbAreas_Update_Result item in list)
                    {
                        if (item.MensajeError == "-1")
                        {
                            return(Json(new { codigo = "-1" }, JsonRequestBehavior.AllowGet));
                        }
                        cAreas.area_Id = int.Parse(item.MensajeError);
                    }
                    inactivar     = inactivar == null ? new cDepartamentos[] { } : inactivar;
                    Departamentos = Departamentos == null ? new cDepartamentos[] { } : Departamentos;
                    foreach (cDepartamentos item in inactivar)
                    {
                        var depto = db.UDP_RRHH_tbDepartamentos_Delete(
                            item.depto_Id,
                            item.depto_RazonInactivo,
                            (int)Session["UserLogin"],
                            Function.DatetimeNow());
                        foreach (UDP_RRHH_tbDepartamentos_Delete_Result dep in depto)
                        {
                            dep.ToString();
                        }
                    }
                    foreach (cDepartamentos item in Departamentos)
                    {
                        if (item.Accion == "i")
                        {
                            var deptocargo = db.UDP_RRHH_tbCargos_Insert(
                                item.car_Descripcion,
                                item.car_SalarioMinimo,
                                item.car_SalarioMaximo,
                                (int)Session["UserLogin"],
                                Function.DatetimeNow()
                                );
                            foreach (UDP_RRHH_tbCargos_Insert_Result i in deptocargo)
                            {
                                var resultadod = i.MensajeError + "  ";
                                if (resultadod.Substring(0, 2) == "-1")
                                {
                                    return(Json(new { codigo = "-3", Accion = "i" }, JsonRequestBehavior.AllowGet));
                                }
                                item.car_Id = int.Parse(i.MensajeError);
                            }
                            var depto = db.UDP_RRHH_tbDepartamentos_Insert(
                                cAreas.area_Id,
                                item.depto_Descripcion,
                                item.car_Id,
                                (int)Session["UserLogin"],
                                Function.DatetimeNow());
                            string mensajeDB = "";
                            foreach (UDP_RRHH_tbDepartamentos_Insert_Result i in depto)
                            {
                                mensajeDB = i.MensajeError.ToString();
                            }
                            if (mensajeDB == "-1")
                            {
                                return(Json(new { codigo = "-4", Accion = "i" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else if (item.Accion == "e")
                        {
                            var depto = db.UDP_RRHH_tbDepartamentos_Update(
                                item.depto_Id,
                                cAreas.area_Id,
                                item.depto_Descripcion,
                                (int)Session["UserLogin"],
                                Function.DatetimeNow());
                            string mensajeDB = "";
                            foreach (UDP_RRHH_tbDepartamentos_Update_Result i in depto)
                            {
                                mensajeDB = i.MensajeError.ToString();
                            }
                            if (mensajeDB == "-1")
                            {
                                return(Json(new { codigo = "-4", Accion = "e" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else if (item.Accion == "a")
                        {
                            var depto = db.UDP_RRHH_tbDepartamentos_Restore(item.depto_Id,
                                                                            (int)Session["UserLogin"],
                                                                            Function.DatetimeNow());
                            foreach (UDP_RRHH_tbDepartamentos_Restore_Result dep in depto)
                            {
                                dep.ToString();
                            }
                        }
                    }
                    transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
                return(Json(new { codigo = "-2" }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { codigo = result }, JsonRequestBehavior.AllowGet));
        }
        //
        //  Page class constructor
        //
        public cAreas_delete(AspNetMaker9_ControlVehicular APage)
        {
            m_ParentPage = APage;
            m_Page = this;
            m_PageID = "delete";
            m_PageObjName = "Areas_delete";
            m_PageObjTypeName = "cAreas_delete";

            // Initialize language object
            if (Language == null)
                Language = new cLanguage(this);

            // Initialize table object
            if (Areas == null)
                Areas = new cAreas(this);
            if (Usuarios == null)
                Usuarios = new cUsuarios(this);

            // Table
            m_TableName = "Areas";
            m_Table = Areas;
            CurrentTable = Areas;

            //CurrentTableType = Areas.GetType();
            // Initialize URLs
            // Connect to database

            if (Conn == null)
                Conn = new cConnection();
        }