// 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; }
public StockHistoryRecordListViewItem(StockHistoryRecord record) { _record = record; this.Text = User.GetDisplayName(_record.Op); this.SubItems.Add(_record.DateTime.ToString("yyyy-MM-dd HH:mm:ss")); this.SubItems.Add(ProductInfo.GetProductInfo(_record.ProductId).Name); this.SubItems.Add(_record.Count.ToString()); this.SubItems.Add(_record.FromTo); this.SubItems.Add(_record.Comment); if (_record.Count < 0) { this.ForeColor = Color.FromArgb(0xff, 0xff, 0x40, 0x40); } else if (_record.Count > 0) { this.ForeColor = Color.DarkGreen; } }
private List <StockHistoryRecord> GetStockHistory(string xml) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList nlStockout = doc.SelectNodes(".//action"); List <StockHistoryRecord> history = new List <StockHistoryRecord>(); foreach (XmlNode nodeStockout in nlStockout) { string op = nodeStockout.Attributes.GetNamedItem("operator").Value; DateTime date = DateTime.Parse(nodeStockout.Attributes.GetNamedItem("date").Value); string productId = nodeStockout.Attributes.GetNamedItem("product").Value; int count = int.Parse(nodeStockout.Attributes.GetNamedItem("amount").Value); string fromto = nodeStockout.Attributes.GetNamedItem("from_to").Value; string comment = nodeStockout.Attributes.GetNamedItem("comment").Value; StockHistoryRecord record = new StockHistoryRecord(op, date, productId, count, fromto, comment); history.Add(record); } return(history); }
private void tsbtnDeleteRecord_Click(object sender, EventArgs e) { if (lvwHistory.SelectedItems.Count <= 0) { MessageBox.Show(this, "Select a record first.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } DialogResult dr = MessageBox.Show( this, "删除出库记录操作不可逆转, 如误删除, 被删除数据不可恢复!\n是否确定要删除选中的出入库记录?", this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); if (DialogResult.Yes != dr) { return; } Cursor.Current = Cursors.WaitCursor; string cmd = string.Empty; switch (_stockLocation) { case OrderLib.ShippingOrigins.Shanghai: cmd = "delstockrec"; break; case OrderLib.ShippingOrigins.Ningbo: cmd = "delstockrecnb"; break; } StockHistoryRecord r = ((StockHistoryRecordListViewItem)lvwHistory.SelectedItems[0]).Record; string url = string.Format(Common.URL_DATA_CENTER, cmd); url += string.Format("&date={0}&product={1}&amount={2}", r.DateTime.ToString("yyyy-MM-dd HH:mm:ss"), r.ProductId, r.Count); 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")) { lvwHistory.Items.Remove(lvwHistory.SelectedItems[0]); } MessageBox.Show( this, "Result from server: \n" + result, this.Text, MessageBoxButtons.OK, result.StartsWith("Succeeded") ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation); Cursor.Current = Cursors.Default; }