예제 #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (Request["id"] != null)
            {
                CurrentGroup = Group.Get(Convert.ToInt32(Request["id"]));
            }

            if (CurrentGroup == null)
            {
                CurrentGroup = new Group(GroupType.None, "");
            }

            switch (CurrentGroup.Type)
            {
                case GroupType.System:
                    PageTitle = "ϵͳ�û���";
                    CurrentAdminRights = SysAdminRights.ConvertFromString(CurrentGroup.Rights) as SysAdminRights;
                    break;
                case GroupType.Supplier:
                    PageTitle = "��Ӧ���û���";
                    CurrentSupplierRights = SupplierRights.ConvertFromString(CurrentGroup.Rights) as SupplierRights;
                    break;
                default:
                    PageTitle = "�û���";
                    break;
            }

            if (IsPost)
            {
                switch (AjaxAction)
                {
                    case "SysGroupPage.saverights":
                        SaveGroupRights();
                        break;
                    case "SysGroupPage.save":
                        SaveGroup();
                        break;
                }
            }
        }
예제 #2
0
        private static ArrayList List(int type)
        {
            /*
             SysGroupList
            @type smallint=0
             */

            /*[Id], GroupType, GroupName, Rights*/
            ArrayList list = new ArrayList();

            SqlParameter[] prams ={
                Database.MakeInParam("@type",SqlDbType.SmallInt,type)
            };

            SqlDataReader reader = null;
            Group g;
            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "SysGroupList", prams);
                while (reader.Read())
                {
                    g = new Group();
                    g.id = reader.GetInt32(0);
                    g.type = (GroupType)(reader.GetInt16(1));
                    g.name = reader.GetString(2);
                    g.rights = reader.GetString(3);
                    list.Add(g);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return list;
        }
예제 #3
0
        public static Group Get(int grpId)
        {
            /*
             SysGroupGet
               @id int
             */

            /*GroupType, GroupName, Rights*/

            Group gp = null;
            SqlParameter[] prams ={
                Database.MakeInParam("@id",SqlDbType.Int,grpId)
            };

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "SysGroupGet", prams);
                if (reader.Read())
                {
                    gp = new Group();
                    gp.id = grpId;
                    gp.type = (GroupType)(reader.GetInt16(0));
                    gp.name = reader.GetString(1);
                    gp.rights = reader.GetString(2);
                }
                reader.Close();
            }
            catch(Exception e)
            {
                throw e;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return gp;
        }
예제 #4
0
 private void SaveGroup()
 {
     Response.Clear();
     if (Request.Form["groupType"] != null &&
         Request.Form["groupName"] != null &&
         Request.Form["groupId"] != null)
     {
         try
         {
             int gpId = Convert.ToInt32(Request.Form["groupId"]);
             GroupType gpType=(GroupType)(Convert.ToInt16(Request.Form["groupType"]));
             string gpName = Request.Form["groupName"].Trim();
             Group gp;
             if (gpId > 0)
             {
                 gp = Group.Get(gpId);
                 gp.Name = gpName;
             }
             else
             {
                 gp = new Group(gpType, gpName);
                 switch (gpType)
                 {
                     case GroupType.System:
                         gp.Rights = SysAdminRights.Default.ConvertToString();
                         break;
                     case GroupType.Supplier:
                         gp.Rights =SupplierRights.Default.ConvertToString();
                         break;
                 }
             }
             if (gp.Save(gpId))
             {
                 Response.Write(gpId);
             }
         }
         catch
         {
             //
         }
     }
     Response.End();
 }