void refreshBtn()
 {
     if (m_isEdit)
     {
         btnAddNews.Text = "保存";
         exitEditBtn.Visible = true;
     }
     else
     {
         btnAddNews.Text = "添加";
         exitEditBtn.Visible = false;
         this.titleTxt.Text = "";
         m_selectNews = null;
         this.descriptionTxt.Text = "";
         this.urlTxt.Text = "";
         this.ext1Txt.Text = "";
         this.ext2Txt.Text = "";
         this.ext3Txt.Text = "";
     }
 }
        private void btnAddNews_Click(object sender, EventArgs e)
        {
            if (m_isEdit)
            {
                if (m_selectNews == null)
                    return;
            }

            string url = MShareDataManager.gInstance.mServerUrl + "AddNews";
            url += "?isEdit=" + m_isEdit;
            Encoding myEncoding = Encoding.GetEncoding("utf-8");
            HttpWebRequest myRequest =
            (HttpWebRequest)WebRequest.Create(url);
            string postData = string.Empty;
            if(m_isEdit)
            postData += "&id=" + idTxt.Text.Trim();
            postData += "&title=" + titleTxt.Text.Trim();
            postData += "&description=" + Util.encode(descriptionTxt.Text.Trim());
            postData += "&redirectUrl=" + Util.encode(urlTxt.Text.Trim());
            postData += "&titleImageUrl=" + newsPicUrlTxt.Text.Trim();
            postData += "&isWebPage=" + isWebPageChe.Checked;
            postData += "&ext1=" + ext1Txt.Text.Trim();
            postData += "&ext2=" + ext2Txt.Text.Trim();
            postData += "&ext3=" + ext3Txt.Text.Trim();
            postData += "&categoryId=" +MShareDataManager.gInstance.mCategoryID;
            byte[] data = myEncoding.GetBytes(postData);

            myRequest.Method = "POST";
            myRequest.ContentType = "application/x-www-form-urlencoded";
            myRequest.ContentLength = data.Length;
            Stream newStream = myRequest.GetRequestStream();

            // Send the data.
            newStream.Write(data, 0, data.Length);
            newStream.Close();
            WebResponse response = myRequest.GetResponse();
            Stream stream = response.GetResponseStream();
            StreamReader readStream = new StreamReader(stream);
            char[] readByte = new char[response.ContentLength];
            readStream.Read(readByte, 0, (int)response.ContentLength);
            String result = new String(readByte);
            newStream.Close();
            stream.Close();
            switch (Convert.ToInt32(result))
            {
                case 1:
                    this.descriptionTxt.Text = this.idTxt.Text = string.Empty;
                    this.newsPicUrlTxt.Text = this.titleTxt.Text = string.Empty;
                    this.ext1Txt.Text = this.ext2Txt.Text = this.ext3Txt.Text = string.Empty;
                    requestNewsList();
                    break;
                case 2:
                    MessageBox.Show("网页已经存在,无需添加");
                    break;
                case 3:
                    MessageBox.Show("未知错误");
                    break;
            }
            if (newsList != null && newsList.Count > 0)
                m_selectNews = newsList[0];
        }
        private void newsGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string columnName = newsGridView.Columns[e.ColumnIndex].Name;
            MNews news = newsList[e.RowIndex];
            m_selectNews = news;
            if (m_selectNews == null)
                return;

               if (columnName == "detail")
            {
                this.descriptionTxt.Text = Util.decode(news.mDescription);
                this.idTxt.Text = news.mID.ToString();
                this.urlTxt.Text = news.mRedirectUrl;
                this.ext2Txt.Text = news.mExt2;
                this.ext3Txt.Text = news.mExt3;
                this.ext1Txt.Text = news.mExt1;
                this.newsPicUrlTxt.Text = news.mTitleImageUrl;
                this.titleTxt.Text = Util.decode(news.mTitle);
                Image img = downloadImg(news.mTitleImageUrl); ;
                int width = img.Width;
                int height = img.Height;
                double rate = (double)height / (double)width;
                this.newsImgPic.Width = 120;
                this.newsImgPic.SizeMode = PictureBoxSizeMode.Zoom;
                this.newsImgPic.Height = Convert.ToInt32(120 * rate);
                this.newsImgPic.Image = img;
                m_isEdit = true;
                refreshBtn();
            }
            else if (columnName == "delete")
            {
                HttpWebRequest myRequest =
                       (HttpWebRequest)WebRequest.Create(MShareDataManager.gInstance.mServerUrl + "DeleteNews?id=" + news.mID);
                myRequest.Method = "GET";
                myRequest.ContentType = "application/x-www-form-urlencoded";
                WebResponse response = myRequest.GetResponse();
                Stream stream = response.GetResponseStream();
                StreamReader readStream = new StreamReader(stream);
                char[] readByte = new char[response.ContentLength];
                readStream.Read(readByte, 0, (int)response.ContentLength);
                String result = new String(readByte);
                response.Close();
                stream.Close();
                if (Convert.ToBoolean(result))
                {
                    requestNewsList();
                }
            }
        }