Ejemplo n.º 1
0
        private void appGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string columnName = appGridView.Columns[e.ColumnIndex].Name;
            MAppData app = appList[e.RowIndex];
            m_selectApp = app;
            if (m_selectApp == null)
                return;

            if (columnName == "detail")
            {
                this.idTxt.Text = app.mId.ToString();
                this.platformBox.Text = app.mPlatform;
                this.categoryBox.Text =Util.decode(app.mCategoryName);
                this.leftUpIconUrlTxt.Text = app.mLeftUpIconUrl;
                this.rightUpIconUrlTxt.Text = app.mRightUpIconUrl;
                this.leftDownIconUrlTxt.Text = app.mLeftDownIconUrl;
                this.rightDownIconUrlTxt.Text = app.mRightDownIconUrl;
                this.leftUpRedirectUrlTxt.Text = app.mLeftUpRedirectUrl;
                this.rightUpRedirectUrlTxt.Text = app.mRightUpRedirectUrl;
                this.leftDownRedirectUrlTxt.Text = app.mLeftDownRedirectUrl;
                this.rightDownRedirectUrlTxt.Text = app.mRightDownRedirectUrl;
                this.bannerIsShowChe.Checked = app.mBannerIsShow;
                this.taobaokeIsShowChe.Checked = app.mTaobaokeIsShow;
                this.adIsShowChe.Checked = app.mAdIsShow;
                m_isEdit = true;
                refreshBtn();
            }
            else if (columnName == "delete")
            {
                HttpWebRequest myRequest =
                       (HttpWebRequest)WebRequest.Create(MShareDataManager.gInstance.mServerUrl + "DeleteAppData?id=" + app.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();

                    requestAppList();

            }
        }
Ejemplo n.º 2
0
        private void btnAddAppData_Click(object sender, EventArgs e)
        {
            if (m_isEdit)
            {
                if (m_selectApp == null)
                    return;
            }

            string url = MShareDataManager.gInstance.mServerUrl + "AddAppData";
            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 += "&platform=" + platformBox.SelectedItem;
            postData += "&categoryName=" +Util.encode(categoryBox.SelectedItem.ToString());
            postData += "&leftUpIconUrl=" +leftUpIconUrlTxt.Text.Trim();
            postData += "&rightUpIconUrl=" + rightUpIconUrlTxt.Text.Trim();
            postData += "&leftDownIconUrl=" + leftDownIconUrlTxt.Text.Trim();
            postData += "&rightDownIconUrl=" + rightDownIconUrlTxt.Text.Trim();
            postData += "&leftUpRedirectUrl=" + leftUpRedirectUrlTxt.Text.Trim();
            postData += "&rightUpRedirectUrl=" + rightUpRedirectUrlTxt.Text.Trim();
            postData += "&leftDownRedirectUrl=" + leftDownRedirectUrlTxt.Text.Trim();
            postData += "&rightDownRedirectUrl=" + rightDownRedirectUrlTxt.Text.Trim();
            postData += "&bannerIsShow=" + bannerIsShowChe.Checked;
            postData += "&taobaokeIsShow=" +taobaokeIsShowChe.Checked;
            postData += "&adIsShow=" +adIsShowChe.Checked;
            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:
                    requestAppList();
                    break;
                case 2:
                    MessageBox.Show("App已经存在,无需添加");
                    break;
                case 3:
                    MessageBox.Show("未知错误");
                    break;
            }
            if (appList != null && appList.Count > 0)
                m_selectApp = appList[0];
        }