예제 #1
0
        /// <summary>
        /// This method uses to update a DataSet of SysRight
        /// </summary>
        /// <param name="pdstData"></param>
        public void UpdateRight(DataSet pdstData)
        {
            const string METHOD_NAME = THIS + ".UpdateDataSet()";

            try
            {
                var dsSysRight = new Sys_RightDS();
                dsSysRight.UpdateDataSet(pdstData);
            }
            catch (SqlException ex)
            {
                if (ex.Errors.Count > 1)
                {
                    if (ex.Number == ErrorCode.SQLDUPLICATE_KEYCODE)
                    {
                        throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);
                    }
                    throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
                }
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Update Dataset of table Sys_Role after deleting related rights
        /// </summary>
        /// <param name="dstData"></param>
        /// <Author>Duong NA, Oct-10-2005 </Author>

        public void UpdateDataSetAndDelete(DataSet dstData, string pstrDeletedRoleIDs)
        {
            const char CHR_SEPARATOR = ',';
            //const int DEFAULT_PERMISSION = 1;
            string strAddedRole = string.Empty;

            //Begin edit by duongna 10-10-2005 to add default menus to new role and delete all menus assigned to role
            //mark added role

            foreach (DataRow drRole in dstData.Tables[0].Rows)
            {
                if (drRole.RowState == DataRowState.Added)
                {
                    strAddedRole += "'" + drRole[Sys_RoleTable.NAME_FLD].ToString().Replace("'", "''") + "' ,";
                }
            }

            if (strAddedRole.EndsWith(CHR_SEPARATOR.ToString()))
            {
                strAddedRole = strAddedRole.Substring(0, strAddedRole.Length - 1);
            }

            //Delete all menu entries assigned to this role

            Sys_RightDS objRightDS = new Sys_RightDS();

            if (pstrDeletedRoleIDs.Length > 0)
            {
                pstrDeletedRoleIDs = pstrDeletedRoleIDs.Replace(';', ',');
                objRightDS.DeleteRightsOfRole(pstrDeletedRoleIDs);
            }

            //End edit by duongna 10-10-2005

            //Init the DS object
            Sys_RoleDS objSysRoleDs = new Sys_RoleDS();

            objSysRoleDs.UpdateDataSet(dstData);

            //
            if (strAddedRole.Length > 0)
            {
                Sys_VisibilityGroup_RoleDS dsVisibility = new Sys_VisibilityGroup_RoleDS();
                dsVisibility.InsertDefaultVisibility(strAddedRole);
                objRightDS.InsertDefaultMenu(strAddedRole);
            }
            //Begin edit by duongna 10-10-2005

            #region             // HACK: DEL SonHT 2005-12-09

            //Add default menus for added role
//			foreach (string strIndex in strAddedRole.Split(CHR_SEPARATOR))
//			{
//				try
//				{
//					nIndex = Convert.ToInt32(strIndex);
//				}
//				catch
//				{
//					continue;
//				}
//				if (dstData.Tables[0].Rows[nIndex].RowState == DataRowState.Unchanged)
//				{
//					//Get all default menu entry
//					Sys_Menu_EntryDS objSysMenuDS = new Sys_Menu_EntryDS();
//					Sys_RightDS objSysRight = new Sys_RightDS();
//					ArrayList arrDefaultMenus = objSysMenuDS.GetAllDefaultMenus();
//					//Do add default rights here
//					foreach (int nMenuID in arrDefaultMenus)
//					{
//						Sys_RightVO voRight = new Sys_RightVO();
//						voRight.Menu_EntryID = nMenuID;
//						voRight.Permission = DEFAULT_PERMISSION;
//						try
//						{
//							voRight.RoleID = Convert.ToInt32(dstData.Tables[0].Rows[nIndex][Sys_RoleTable.ROLEID_FLD]);
//						}
//						catch
//						{
//							continue;
//						}
//						objSysRight.Add(voRight);
//					}
//				}
//			}
            //End edit by duongna
            #endregion             // END: DEL SonHT 2005-12-09
        }