Ejemplo n.º 1
0
        private void transferBtn_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (pcClickUrlTxt.Text == string.Empty)
                    return;
                //if (!pcClickUrlTxt.Text.Trim().Contains("34009286"))
                //{
                //    MessageBox.Show("链接没带上咱们的淘宝客ID,34009286");
                //    return;
                //}
                string pcClickUrl = pcClickUrlTxt.Text;
                Uri uri = new Uri(pcClickUrl);
                string queryString = uri.Query;
                NameValueCollection collection = GetQueryString(queryString, Encoding.UTF8, false);
                m_currentNumId = Convert.ToInt64(collection.Get("id"));
                string mobileClickUrl = null;
                if (m_currentNumId == 0)
                    return;
                //if (pcClickUrl.StartsWith("http://item.taobao.com"))
                //{
                //    mobileClickUrl = pcClickUrl.Replace("http://item.taobao.com", "http://a.m.taobao.com");
                //    string findStr = "tem.htm?";
                //    int length = findStr.Length;
                //    int index = pcClickUrl.IndexOf(findStr);
                //    mobileClickUrl = mobileClickUrl.Replace(findStr, collection.Get("id") + ".htm?");
                //    mobileClickUrl = mobileClickUrl.Replace("id=" + collection.Get("id") + "&", "");
                //}
                //else if (pcClickUrl.StartsWith("http://detail.tmall.com"))
                //{
                //    mobileClickUrl = pcClickUrl.Replace("http://detail.tmall.com", "http://a.m.tmall.com");
                //    string findStr = "tem.htm?";
                //    int length = findStr.Length;
                //    int index = pcClickUrl.IndexOf(findStr);
                //    mobileClickUrl = mobileClickUrl.Replace(findStr, collection.Get("id") + ".htm?");
                //    mobileClickUrl = mobileClickUrl.Replace("id=" + collection.Get("id") + "&", "");
                //}
                //else
                //    return;
                //ItemGetRequest itemResquest = new ItemGetRequest();
                //itemResquest.NumIid = m_currentNumId;
                //itemResquest.Fields = "num_iid,title,pic_url,price";
                //ItemGetResponse itemResponse=MShareDataManager.gInstance.mClient.Execute<ItemGetResponse>(itemResquest);
                TaobaokeItemsDetailGetRequest req = new TaobaokeItemsDetailGetRequest();
                req.Fields = "click_url,num_iid,title,pic_url,price";
                req.NumIids = m_currentNumId.ToString();
                req.IsMobile = true;
                TaobaokeItemsDetailGetResponse itemResponse = MShareDataManager.gInstance.mClient.Execute<TaobaokeItemsDetailGetResponse>(req);
                string url = itemResponse.ReqUrl;
                if (itemResponse.TaobaokeItemDetails == null || itemResponse.TaobaokeItemDetails.Count == 0)
                {
                    MessageBox.Show("不是淘宝客商品");
                    return;
                }
                TaobaokeItemDetail item = itemResponse.TaobaokeItemDetails.FirstOrDefault();
                m_currentProduct = new MProduct();
                m_currentProduct.mNumId = m_currentNumId;
                m_currentProduct.mTitle = item.Item.Title;
                m_currentProduct.mImageUrl = item.Item.PicUrl;
                m_currentProduct.mOldPrice = Convert.ToSingle(item.Item.Price);
                mobileClickUrl = item.ClickUrl;
                this.oldPriceTxt.Text = this.newPriceTxt.Text = m_currentProduct.mOldPrice.ToString();
                this.numIdTxt.Text = m_currentNumId.ToString();
                this.titleTxt.Text = m_currentProduct.mTitle;
                m_currentProduct.mMobileClickUrl = this.mobileClickUrlTxt.Text = mobileClickUrl;
                this.pictureBox1.Image = downloadImg(m_currentProduct.mImageUrl + "_100x100.jpg");

                TaobaokeItemsDetailGetRequest req1 = new TaobaokeItemsDetailGetRequest();
                req.Fields = "click_url";
                req.NumIids = m_currentNumId.ToString();
                req.IsMobile = false;
                TaobaokeItemsDetailGetResponse itemResponse1 = MShareDataManager.gInstance.mClient.Execute<TaobaokeItemsDetailGetResponse>(req);
                string url1 = itemResponse1.ReqUrl;
                if (itemResponse1.TaobaokeItemDetails == null || itemResponse1.TaobaokeItemDetails.Count == 0)
                {
                    MessageBox.Show("不是淘宝客商品");
                    return;
                }
                TaobaokeItemDetail item1 = itemResponse1.TaobaokeItemDetails.FirstOrDefault();
                m_currentProduct.mPcClickUrl = pcClickUrl = pcClickUrlTxt.Text = item1.ClickUrl;

            }
            catch (Exception e1)
            {
                MessageBox.Show("错误:" + e1.Message.ToString());
            }
        }
Ejemplo n.º 2
0
        private void saveProductBtn_Click(object sender, EventArgs e)
        {
            if (!m_isEdit)
            {
                if (m_currentProduct == null)
                    return;
            }
            else
            {
                if (m_selectProduct == null)
                    return;
            }
            string url = MShareDataManager.gInstance.mServerUrl + "AddProduct";
            url += "?isEdit=" + m_isEdit;
            Encoding myEncoding = Encoding.GetEncoding("utf-8");
            HttpWebRequest myRequest =
            (HttpWebRequest)WebRequest.Create(url);

            string postData = "numId=" + numIdTxt.Text.Trim();
            postData += "&title=" + titleTxt.Text.Trim();
            postData += "&imageUrl=" + (m_isEdit ? m_selectProduct.mImageUrl : m_currentProduct.mImageUrl);
            postData += "&pcClickUrl=" + Util.encode(pcClickUrlTxt.Text.Trim());
            postData += "&mobileClickUrl=" + Util.encode(mobileClickUrlTxt.Text.Trim());
            postData += "&newPrice=" + newPriceTxt.Text.Trim();
            postData += "&oldPrice=" + oldPriceTxt.Text.Trim();
            postData += "&imageRate=" + imageRateTxt.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:
                    // m_pageIndex = 0;
                    //addCategoryProduct(59);
                    //addBrandProduct(34);
                    //addAblumProduct(38);
                    request();
                    break;
                case 2:
                    MessageBox.Show("商品已经存在,无需添加");
                    break;
                case 3:
                    MessageBox.Show("未知错误");
                    break;
            }
            if (products != null && products.Count > 0)
                m_selectProduct = products[0];
        }
Ejemplo n.º 3
0
        void refreshBtn()
        {
            if (m_isEdit)
            {
                saveProductBtn.Text = "保存";
                exitEditBtn.Visible = true;
                transferBtn.Enabled = false;
            }
            else
            {
                saveProductBtn.Text = "添加入库";
                exitEditBtn.Visible = false;
                transferBtn.Enabled = true;
                this.titleTxt.Text = "";
                m_selectProduct = null;
                this.newPriceTxt.Text = "";
                this.oldPriceTxt.Text = "";
                this.imageRateTxt.Text = "";
                this.pcClickUrlTxt.Text = "";
                this.mobileClickUrlTxt.Text = "";
                this.numIdTxt.Text = "";
                pictureBox1.Image = null;

            }
        }
Ejemplo n.º 4
0
        private void resetProductDataBtn_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in productGridView.Rows)
            {
                MProduct product = products[row.Index];
                m_selectProduct = product;
                Uri uri = new Uri(m_selectProduct.mPcClickUrl);
                string queryString = uri.Query;
                NameValueCollection collection = GetQueryString(queryString, Encoding.UTF8, false);
                long numId = Convert.ToInt64(collection.Get("id"));
                string mobileClickUrl = null;
                if (numId == 0)
                    continue;

                TaobaokeItemsDetailGetRequest req = new TaobaokeItemsDetailGetRequest();
                req.Fields = "click_url,num_iid,title,pic_url,price";
                req.NumIids = numId.ToString();
                req.IsMobile = true;
                TaobaokeItemsDetailGetResponse itemResponse = MShareDataManager.gInstance.mClient.Execute<TaobaokeItemsDetailGetResponse>(req);
                // string url2 = itemResponse.ReqUrl;
                if (itemResponse.TaobaokeItemDetails == null || itemResponse.TaobaokeItemDetails.Count == 0)
                {
                    continue;
                }
                TaobaokeItemDetail item = itemResponse.TaobaokeItemDetails.FirstOrDefault();
                MProduct tempProduct = new MProduct();
                tempProduct.mNumId = numId;
                tempProduct.mTitle = item.Item.Title;
                tempProduct.mImageUrl = item.Item.PicUrl;
                tempProduct.mOldPrice = Convert.ToSingle(item.Item.Price);
                mobileClickUrl = item.ClickUrl;
                this.oldPriceTxt.Text = tempProduct.mOldPrice.ToString();
                this.newPriceTxt.Text = m_selectProduct.mNewPrice.ToString();
                this.numIdTxt.Text = numId.ToString();
                this.titleTxt.Text = tempProduct.mTitle;
                tempProduct.mMobileClickUrl = this.mobileClickUrlTxt.Text = mobileClickUrl;
                this.pictureBox1.Image = downloadImg(tempProduct.mImageUrl + "_100x100.jpg");

                TaobaokeItemsDetailGetRequest req1 = new TaobaokeItemsDetailGetRequest();
                req.Fields = "click_url";
                req.NumIids = numId.ToString();
                req.IsMobile = false;
                TaobaokeItemsDetailGetResponse itemResponse1 = MShareDataManager.gInstance.mClient.Execute<TaobaokeItemsDetailGetResponse>(req);
                // string url1 = itemResponse1.ReqUrl;
                if (itemResponse1.TaobaokeItemDetails == null || itemResponse1.TaobaokeItemDetails.Count == 0)
                {
                    continue;
                }
                TaobaokeItemDetail item1 = itemResponse1.TaobaokeItemDetails.FirstOrDefault();
                tempProduct.mPcClickUrl = pcClickUrlTxt.Text = item1.ClickUrl;

                string url = MShareDataManager.gInstance.mServerUrl + "AddProduct";
                url += "?isEdit=true";
                Encoding myEncoding = Encoding.GetEncoding("utf-8");
                HttpWebRequest myRequest =
                (HttpWebRequest)WebRequest.Create(url);

                string postData = "numId=" + numIdTxt.Text.Trim();
                postData += "&title=" + titleTxt.Text.Trim();
                postData += "&imageUrl=" + m_selectProduct.mImageUrl;
                postData += "&pcClickUrl=" + Util.encode(pcClickUrlTxt.Text.Trim());
                postData += "&mobileClickUrl=" + Util.encode(mobileClickUrlTxt.Text.Trim());
                postData += "&newPrice=" + newPriceTxt.Text.Trim();
                postData += "&oldPrice=" + oldPriceTxt.Text.Trim();
                postData += "&imageRate=" + imageRateTxt.Text.Trim();
                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();
                newStream.Close();
                stream.Close();
            }
            request();
            MessageBox.Show("重置完成");
        }
Ejemplo n.º 5
0
        private void productGridView_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (products == null)
                return;
            string columnName = productGridView.Columns[e.ColumnIndex].Name;
            MProduct product = products[e.RowIndex];
            m_selectProduct = product;
            if (product == null)
                return;
            if (columnName == "imageUrl")
            {
                this.pictureBox1.Image = downloadImg(product.mImageUrl + "_100x100.jpg");
            }
            else if (columnName == "detail")
            {

                this.pcClickUrlTxt.Text = product.mPcClickUrl;
                this.mobileClickUrlTxt.Text = product.mMobileClickUrl;
                this.numIdTxt.Text = product.mNumId.ToString();
                this.newPriceTxt.Text = product.mNewPrice.ToString();
                this.oldPriceTxt.Text = product.mOldPrice.ToString();
                this.pictureBox1.Image = downloadImg(product.mImageUrl + "_100x100.jpg");
                this.imageRateTxt.Text = product.mImageRate.ToString();
                this.titleTxt.Text = Util.decode(product.mTitle);

                m_isEdit = true;
                refreshBtn();
            }
            else if (columnName == "delete")
            {
                HttpWebRequest myRequest =
                       (HttpWebRequest)WebRequest.Create(MShareDataManager.gInstance.mServerUrl + "DeleteProduct?numId=" + product.mNumId);
                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))
                {
                    requestProductList();
                }
            }
            else if (columnName == "reset")
            {
                Uri uri = new Uri(m_selectProduct.mPcClickUrl);
                string queryString = uri.Query;
                NameValueCollection collection = GetQueryString(queryString, Encoding.UTF8, false);
                long numId = Convert.ToInt64(collection.Get("id"));
                string mobileClickUrl = null;
                if (numId == 0)
                    return;

                TaobaokeItemsDetailGetRequest req = new TaobaokeItemsDetailGetRequest();
                req.Fields = "click_url,num_iid,title,pic_url,price";
                req.NumIids = numId.ToString();
                req.IsMobile = true;
                TaobaokeItemsDetailGetResponse itemResponse = MShareDataManager.gInstance.mClient.Execute<TaobaokeItemsDetailGetResponse>(req);
                string url = itemResponse.ReqUrl;
                if (itemResponse.TaobaokeItemDetails == null || itemResponse.TaobaokeItemDetails.Count == 0)
                {
                    MessageBox.Show("不是淘宝客商品");
                    return;
                }
                TaobaokeItemDetail item = itemResponse.TaobaokeItemDetails.FirstOrDefault();
                MProduct tempProduct = new MProduct();
                tempProduct.mNumId = numId;
                tempProduct.mTitle = item.Item.Title;
                tempProduct.mImageUrl = item.Item.PicUrl;
                tempProduct.mOldPrice = Convert.ToSingle(item.Item.Price);
                mobileClickUrl = item.ClickUrl;
                this.oldPriceTxt.Text = tempProduct.mOldPrice.ToString();
                this.newPriceTxt.Text = m_selectProduct.mNewPrice.ToString();
                this.numIdTxt.Text = numId.ToString();
                this.titleTxt.Text = tempProduct.mTitle;
                tempProduct.mMobileClickUrl = this.mobileClickUrlTxt.Text = mobileClickUrl;
                this.pictureBox1.Image = downloadImg(tempProduct.mImageUrl + "_100x100.jpg");

                TaobaokeItemsDetailGetRequest req1 = new TaobaokeItemsDetailGetRequest();
                req.Fields = "click_url";
                req.NumIids = numId.ToString();
                req.IsMobile = false;
                TaobaokeItemsDetailGetResponse itemResponse1 = MShareDataManager.gInstance.mClient.Execute<TaobaokeItemsDetailGetResponse>(req);
                string url1 = itemResponse1.ReqUrl;
                if (itemResponse1.TaobaokeItemDetails == null || itemResponse1.TaobaokeItemDetails.Count == 0)
                {
                    MessageBox.Show("不是淘宝客商品");
                    return;
                }
                TaobaokeItemDetail item1 = itemResponse1.TaobaokeItemDetails.FirstOrDefault();
                tempProduct.mPcClickUrl = pcClickUrlTxt.Text = item1.ClickUrl;
                button1_Click(null, null);
            }
        }