示例#1
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            ArrayList YCS = new ArrayList();

            foreach (ListItem li in lbVisible.Items)
            {
                if (li.Selected)
                {
                    YCS.Add(int.Parse(li.Value));
                }
            }

            ArrayList CSY = new ArrayList();

            foreach (ListItem li in lbCU.Items)
            {
                if (li.Selected)
                {
                    CSY.Add(int.Parse(li.Value));
                }
            }

            byte[] GroupLogo = null;
            if (fLogo.PostedFile != null && fLogo.PostedFile.ContentLength > 0)
            {
                GroupLogo = new byte[fLogo.PostedFile.ContentLength];
                fLogo.PostedFile.InputStream.Read(GroupLogo, 0, fLogo.PostedFile.ContentLength);
            }
            else if (GroupID == 0)
            {
                FileInfo   fi = new FileInfo(Server.MapPath(GlobalResourceManager.Strings["IMGroupLogoUrl"]));
                FileStream fs = fi.OpenRead();
                GroupLogo = new byte[fi.Length];
                int nBytesRead = fs.Read(GroupLogo, 0, (int)fi.Length);
            }

            int outid = 1;

            if (GroupID > 0)
            {
                IMGroup.Update(GroupID, tbGroupTitle.Text, tbColor.Text, GroupLogo, YCS, CSY);
                outid = GroupID;
            }
            else if (CloneGroupID > 0)
            {
                outid = IMGroup.Clone(CloneGroupID, tbGroupTitle.Text, tbColor.Text, GroupLogo, YCS, CSY);
            }
            else
            {
                outid = IMGroup.Create(tbGroupTitle.Text, tbColor.Text, GroupLogo, YCS, CSY);
            }

            if (outid != -1)
            {
                Response.Redirect("../Directory/Directory.aspx?Tab=1&IMGroupID=0");
            }
        }