Ejemplo n.º 1
0
    public void addTypeFactory(string typeName, string smallTypeName)
    {
        string      smallTypeId = Request.QueryString["smallTypeId"].ToString();
        string      operate     = Request.QueryString["operate"].ToString();
        string      typeId      = smallTypeId.Substring(0, 3);
        bool        typeFlag    = false;
        TypeFactory myFactory   = new TypeFactory();

        if (Session["Factory"] == null)
        {
            Session["Factory"] = new TypeFactory();
        }
        else
        {
            myFactory = (TypeFactory)Session["Factory"];
        }
        for (int i = 0; i < myFactory.myTypeFactory.Count; i++)
        {
            if (operate == "delete")
            {
                if (smallTypeId == myFactory.myTypeFactory[i].SmallTypeId)
                {
                    myFactory.myTypeFactory.Remove(myFactory.myTypeFactory[i]);
                    typeFlag = true;
                }
            }
            else
            {
                if (typeId == myFactory.myTypeFactory[i].TypeId)
                {
                    if (smallTypeId == myFactory.myTypeFactory[i].SmallTypeId)
                    {
                        typeFlag = true;
                    }
                    else
                    {
                        myFactory.myTypeFactory[i].SmallTypeId   = smallTypeId;
                        myFactory.myTypeFactory[i].SmallTypeName = smallTypeName;
                        typeFlag = true;
                    }
                }
            }
        }
        if (typeFlag == false)
        {
            Type myType = new Type(typeId, typeName, smallTypeId, smallTypeName);
            myFactory.AddItem(myType);
            Session["Factory"] = myFactory;
        }
    }