コード例 #1
0
        void MoverDatos(BO.Models.Roles MyComp)
        {
            //else if(ctr.Tag == MyComp.COM_DESCRIPCION)
            foreach (Control ctr in tabPage2.Controls)
            {
                if (ctr.Tag == null)
                {
                    continue;
                }


                switch (ctr.Tag.ToString())
                {
                case "ROLE_ID":
                    ctr.Text = MyComp.ROL_ID.ToString();
                    break;

                case "NOMBRE":
                    ctr.Text = MyComp.NOMBRE.ToString();
                    break;

                case "DESCRIPCION":
                    ctr.Text = MyComp.DESCRIPCION.ToString();
                    break;

                case "ACTIVO":
                    ((CheckBox)ctr).Checked = MyComp.ACTIVO;
                    break;
                }
            }
        }
コード例 #2
0
        bool ExisteRol(BO.Models.Roles oItem)
        {
            var QryUsrRol = unitOfWork.UsuariosRolesRepository.Get(filter: s => s.ROL_ID == oItem.ROL_ID && s.USR_SUC_ID == iIsucUsrId);

            if (QryUsrRol.Count() == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
        bool SalvarDatos()
        {
            int  iId      = -1;
            bool bRetorno = false;

            //CompaniasRecord oCom = new CompaniasRecord();


            BO.Models.Roles oCom;


            if (usrbntMant1.bAdiciona == false)
            {
                iId  = Convert.ToInt32(this.textGRUPO_TIPO_ID.Text);
                oCom = unitOfWork.RolesRepository.GetByID(iId);
            }
            else
            {
                oCom = new BO.Models.Roles();
            }


            oCom.NOMBRE      = this.txtNombre.Text.ToString();
            oCom.MOD_ID      = _iModuloId;
            oCom.ACTIVO      = chkActivo.Checked;
            oCom.DESCRIPCION = txtDESCR.Text;


            try
            {
                if (usrbntMant1.bAdiciona == false)
                {
                    unitOfWork.RolesRepository.Update(oCom);
                }
                else
                {
                    unitOfWork.RolesRepository.Insert(oCom);
                }

                unitOfWork.Save();
                bRetorno           = true;
                usrbntMant1.bExito = true;
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    string s = "";

                    /*
                     * Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                     *  eve.Entry.Entity.GetType().Name, eve.Entry.State);
                     */


                    foreach (var ve in eve.ValidationErrors)
                    {
                        s += ve.ErrorMessage + "\n";

                        /*Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                         *  ve.PropertyName, ve.ErrorMessage);*/
                    }
                    MessageBox.Show("Existen los siguientes errores:" + s, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //throw;
            }
            catch (DataException ex)
            {
                throw ex;
            }


            return(bRetorno);
        }