Пример #1
0
        /// <summary>
        /// 批量插入用户角色记录
        /// </summary>
        /// <param name="ht2"></param>
        /// <returns></returns>
        public override int AddMore(Hashtable ht2)
        {
            MUsersRole MUserRol = new MUsersRole();
            Hashtable  ht       = new Hashtable();
            Hashtable  htstr    = new Hashtable();

            if (ht2.Count > 0)
            {
                for (int i = 0; i < ht2.Count; i++)
                {
                    ht.Clear();
                    MUserRol = (MUsersRole)ht2[i];
                    ht.Add("ROLE_ID", MUserRol.ROLE_ID);
                    ht.Add("ROLE_NAME", MUserRol.ROLE_NAME);
                    ht.Add("EXAM_CLASS", MUserRol.EXAM_CLASS);
                    ht.Add("EXAM_SUB_CLASS", MUserRol.EXAM_SUB_CLASS);
                    ht.Add("FUN_MODEL", MUserRol.FUN_MODEL);
                    htstr.Add(i, StringConstructor.InsertSql(TableName, ht).ToString());
                }
                return(ExecuteNonSql(htstr));
            }
            else
            {
                return(0);
            }
        }
Пример #2
0
        /// <summary>
        /// 查询是否存在指定角色记录
        /// </summary>
        /// <param name="iusers_role"></param>
        /// <returns></returns>
        public override bool Exists(IModel iusers_role)
        {
            MUsersRole users_role = (MUsersRole)iusers_role;

            strSql = "select * from " + TableName + " where ROLE_ID='" + users_role.ROLE_ID + "'";
            return(recordIsExist(strSql));
        }
Пример #3
0
        /// <summary>
        /// 更新指定角色记录
        /// </summary>
        /// <param name="iusers_role"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        public override int Update(IModel iusers_role, string where)
        {
            MUsersRole users_role = (MUsersRole)iusers_role;
            Hashtable  ht         = new Hashtable();

            ht.Add("FUN_MODEL", users_role.FUN_MODEL);
            return(ExecuteSql(StringConstructor.UpdateSql(TableName, ht, where).ToString()));
        }
Пример #4
0
        /// <summary>
        /// 插入一条用户角色记录
        /// </summary>
        /// <param name="iusers_role"></param>
        /// <returns></returns>
        public override int Add(IModel iusers_role)
        {
            MUsersRole users_role = (MUsersRole)iusers_role;
            Hashtable  ht         = new Hashtable();

            ht.Add("ROLE_ID", users_role.ROLE_ID);
            ht.Add("ROLE_NAME", users_role.ROLE_NAME);
            ht.Add("EXAM_CLASS", users_role.EXAM_CLASS);
            ht.Add("EXAM_SUB_CLASS", users_role.EXAM_SUB_CLASS);
            ht.Add("FUN_MODEL", users_role.FUN_MODEL);
            return(ExecuteSql(StringConstructor.InsertSql(TableName, ht).ToString()));
        }
Пример #5
0
        /// <summary>
        /// 获取指定ID的角色记录
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public override IModel GetModel(string roleId)
        {
            strSql = "select * from " + TableName + "  where ROLE_ID='" + roleId + "'";
            DataTable dt = GetDataTable(strSql);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            MUsersRole users_role = new MUsersRole();

            users_role.ROLE_ID        = Convert.ToInt32(dt.Rows[0]["ROLE_ID"].ToString());
            users_role.ROLE_NAME      = dt.Rows[0]["ROLE_NAME"].ToString();
            users_role.EXAM_CLASS     = dt.Rows[0]["EXAM_CLASS"].ToString();
            users_role.EXAM_SUB_CLASS = dt.Rows[0]["EXAM_SUB_CLASS"].ToString();
            users_role.FUN_MODEL      = dt.Rows[0]["FUN_MODEL"].ToString();
            return(users_role);
        }
Пример #6
0
        /// <summary>
        /// 批量更新角色记录
        /// </summary>
        /// <param name="ht2"></param>
        /// <returns></returns>
        public override int UpdateMore(Hashtable ht2)
        {
            MUsersRole MUserRol = new MUsersRole();
            Hashtable  ht       = new Hashtable();
            Hashtable  htStr    = new Hashtable();

            if (ht2.Count > 0)
            {
                for (int i = 0; i < ht2.Count; i++)
                {
                    ht.Clear();
                    MUserRol = (MUsersRole)ht2[i];
                    ht.Add("ROLE_NAME", MUserRol.ROLE_NAME);
                    ht.Add("EXAM_CLASS", MUserRol.EXAM_CLASS);
                    ht.Add("EXAM_SUB_CLASS", MUserRol.EXAM_SUB_CLASS);
                    htStr.Add(i, StringConstructor.UpdateSql(TableName, ht, " where ROLE_ID=" + MUserRol.ROLE_ID));
                }

                return(ExecuteNonSql(htStr));
            }
            return(0);
        }
Пример #7
0
        private void EditData()//批量修改
        {
            Hashtable htEdit = new Hashtable();
            int       r      = 0;

            if (htRow.Count > 0)
            {
                for (int k = 0; k < htRow.Count; k++)
                {
                    r = Convert.ToInt32(htRow[k].ToString());
                    MUsersRole MUserRol = new MUsersRole();
                    MUserRol.ROLE_ID = Convert.ToInt32(dgv_GroupManage.Rows[r].Cells["ROLE_ID"].Value.ToString());
                    if (!string.IsNullOrEmpty(dgv_GroupManage.Rows[r].Cells["ROLE_NAME"].FormattedValue.ToString()))
                    {
                        MUserRol.ROLE_NAME = dgv_GroupManage.Rows[r].Cells["ROLE_NAME"].Value.ToString();
                    }
                    if (!string.IsNullOrEmpty(dgv_GroupManage.Rows[r].Cells["EXAM_CLASS"].FormattedValue.ToString()))
                    {
                        MUserRol.EXAM_CLASS = dgv_GroupManage.Rows[r].Cells["EXAM_CLASS"].Value.ToString();
                    }
                    if (!string.IsNullOrEmpty(dgv_GroupManage.Rows[r].Cells["EXAM_SUB_CLASS"].FormattedValue.ToString()))
                    {
                        MUserRol.EXAM_SUB_CLASS = dgv_GroupManage.Rows[r].Cells["EXAM_SUB_CLASS"].Value.ToString();
                    }
                    htEdit.Add(k, MUserRol);
                }
                if (BUserRol.UpdateMore(htEdit) >= 0)
                {
                    MessageBoxEx.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBoxEx.Show("修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            htRow.Clear();
            i = 0;
        }
Пример #8
0
        private void SaveData()//批量保存
        {
            Hashtable ht = new Hashtable();

            if (dgv_GroupManage.Rows.Count > rowcount - 1)                                                                 //说明有新增行
            {
                for (int i = rowcount, j = 0; i <= dgv_GroupManage.Rows.Count && j < dgv_GroupManage.Rows.Count; i++, j++) //从第rowcount个开始保存
                {
                    MUsersRole MUserRol = new MUsersRole();
                    MUserRol.ROLE_ID = Convert.ToInt32(dgv_GroupManage.Rows[i - 1].Cells["ROLE_ID"].Value.ToString());
                    if (!string.IsNullOrEmpty(dgv_GroupManage.Rows[i - 1].Cells["ROLE_NAME"].FormattedValue.ToString()))
                    {
                        MUserRol.ROLE_NAME = dgv_GroupManage.Rows[i - 1].Cells["ROLE_NAME"].Value.ToString();
                    }
                    if (!string.IsNullOrEmpty(dgv_GroupManage.Rows[i - 1].Cells["EXAM_CLASS"].FormattedValue.ToString()))
                    {
                        MUserRol.EXAM_CLASS = dgv_GroupManage.Rows[i - 1].Cells["EXAM_CLASS"].Value.ToString();
                    }
                    if (!string.IsNullOrEmpty(dgv_GroupManage.Rows[i - 1].Cells["EXAM_SUB_CLASS"].FormattedValue.ToString()))
                    {
                        MUserRol.EXAM_SUB_CLASS = dgv_GroupManage.Rows[i - 1].Cells["EXAM_SUB_CLASS"].Value.ToString();
                    }
                    MUserRol.FUN_MODEL = ",";
                    ht.Add(j, MUserRol);
                }
            }
            if (ht.Count > 0)
            {
                if (BUserRol.AddMore(ht) > 0)
                {
                    MessageBoxEx.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBoxEx.Show("添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }