Ejemplo n.º 1
0
        // Removed by KK on 2015/12/26.
        // Obsoleted.
        //private void StockAction(string productId, int count, string fromto, string op, string comment)
        //{
        //    string cmd = string.Empty;
        //    switch (_stockLocation)
        //    {
        //        case OrderLib.ShippingOrigins.Shanghai:
        //            cmd = "stock";
        //            break;
        //        case OrderLib.ShippingOrigins.Ningbo:
        //            cmd = "stocknb";
        //            break;
        //    }

        //    DateTime dt = DateTime.Now;
        //    string url = string.Format(Common.URL_DATA_CENTER, cmd);
        //    url += string.Format("&productids={0}&counts={1}&dest={2}&op={3}&comment={4}&date={5}", productId, count.ToString(), fromto, Settings.Operator, comment, dt.ToString("yyyy-MM-dd HH:mm:ss"));
        //    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
        //    request.Method = "GET";
        //    request.ContentType = "text/xml";
        //    WebResponse response = request.GetResponse();
        //    StreamReader reader = new StreamReader(response.GetResponseStream());
        //    string result = reader.ReadToEnd();
        //    reader.Close();
        //    //Trace.WriteLine(result);

        //    if (result.StartsWith("Succeeded"))
        //    {
        //        StockHistoryRecord r = new StockHistoryRecord(Settings.Operator, dt, productId, count, fromto, comment);
        //        StockHistoryRecordListViewItem lvi = new StockHistoryRecordListViewItem(r);
        //        lvwHistory.Items.Insert(0, lvi);
        //        lvwHistory.SelectedItems.Clear();
        //        lvi.Selected = true;
        //        lvi.EnsureVisible();
        //        lvwHistory.Focus();
        //    }

        //    MessageBox.Show(
        //        this,
        //        "Result from server: \n" + result,
        //        this.Text,
        //        MessageBoxButtons.OK, MessageBoxIcon.Information);
        //}
        private void StockAction(bool stockout, List <SoldProductInfo> stockProductInfos, string fromto, string comment)
        {
            Application.DoEvents();
            Cursor.Current = Cursors.WaitCursor;

            string result = StockActionAdvForm.StockAction(stockout, stockProductInfos, fromto, comment, _stockLocation);

            if (result.StartsWith("Succeeded"))
            {
                lvwHistory.SelectedItems.Clear();
                foreach (SoldProductInfo spi in stockProductInfos)
                {
                    StockHistoryRecord             r   = new StockHistoryRecord(Settings.Operator, DateTime.Now, spi.Id, (stockout ? -1 : 1) * spi.Count, fromto, comment);
                    StockHistoryRecordListViewItem lvi = new StockHistoryRecordListViewItem(r);
                    lvwHistory.Items.Insert(0, lvi);
                    lvi.Selected = true;
                    lvi.EnsureVisible();
                }
                lvwHistory.Focus();
            }

            MessageBox.Show(
                this,
                "Result from server: \n" + result,
                this.Text,
                MessageBoxButtons.OK, MessageBoxIcon.Information);

            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 2
0
        void RefreshHistoryList(List <StockHistoryRecord> history)
        {
            Cursor.Current = Cursors.WaitCursor;

            lvwHistory.Items.Clear();

            if (null == history || history.Count <= 0)
            {
                return;
            }

            foreach (StockHistoryRecord r in history)
            {
                if (r.Count < 0 && _cboStockTypes.SelectedIndex == 0)
                {
                    continue;
                }
                if (r.Count > 0 && _cboStockTypes.SelectedIndex == 1)
                {
                    continue;
                }
                if (null != _cboProducts && _cboProducts.Items.Count > 1)
                {
                    ProductInfo filterProduct = (ProductInfo)_cboProducts.SelectedItem;
                    if (!r.ProductId.Equals(filterProduct.Id) && !filterProduct.Id.Equals("0"))
                    {
                        continue;
                    }
                }
                if (!string.IsNullOrEmpty(txtKeyword.Text.Trim()) && !r.Match(txtKeyword.Text.Trim()))
                {
                    continue;
                }

                StockHistoryRecordListViewItem lvi = new StockHistoryRecordListViewItem(r);
                lvwHistory.Items.Add(lvi);
            }

            Cursor.Current = Cursors.Default;
        }