public PurchaseOrder(List<string[]> field)
 {
     int linecount = field.Count;
     _poDetails = new List<PO_DetailItem>();
     PO_ID = Int32.Parse(field[0][0]);
     PO_Date = DateTime.Now; // Parse(field[0][1]);
     EmployeeID = Int32.Parse(field[0][2]);
     PO_Status = Int32.Parse(field[0][3]);
     SupplierID = Int32.Parse(field[0][4]);
     DeliveryDate = DateTime.Now;  // Parse(field[0][5]);
     Comment = field[0][6];
     for (int i = 1; i < linecount; i++)
     {
         PO_DetailItem detailItem = new PO_DetailItem(field[i]);
         _poDetails.Add(detailItem);
     }
 }
 public PurchaseOrder(List<string> records)
 {
     int linecount = records.Count;
     _poDetails = new List<PO_DetailItem>();
     string[] field = records[0].Split(',');
     PO_ID = Int32.Parse(field[0]);
     PO_Date = DateTime.Now;  // Parse(field[1]);
     EmployeeID = Int32.Parse(field[2]);
     PO_Status = Int32.Parse(field[3]);
     SupplierID = Int32.Parse(field[4]);
     DeliveryDate = DateTime.Now;  // Parse(field[5]);
     Comment = field[6];
     for (int i = 1; i < linecount; i++)
     {
         string[] detailStrings = records[i].Split(',');
         PO_DetailItem detailItem = new PO_DetailItem(detailStrings );
         _poDetails.Add(detailItem);
     }
 }
        private void button_Add_Click(object sender, EventArgs e)
        {
            //Add Prodcut to purchase order
            PO_DetailItem _item = new PO_DetailItem();
            _item.Name = textBox_PO_ID2.Text;
            _item.PO_ID = po_ID; // lastPO_Number + 1;
            _item.ProductID = Int32.Parse(textBox_ProductID.Text);
            _item.Quantity = Int32.Parse(textBox_Quantity.Text);
            _item.Price = Double.Parse(textBox_Price.Text);
            int Onhand = Int32.Parse(textBox_OnHand.Text);
            if (_item.Quantity == 0)
            {
                MessageBox.Show("Please enter quanity > 0");
                return;
            }

            else if (_item.Quantity > Onhand)
            {
                MessageBox.Show("Please enter quanity less than on hand");
                return;
            }

            else
            {
                //_item.Comment = "Product No:" + _item.ProductID;// +"(" + +")";

                var duplicate = _details.FirstOrDefault(x => x.ProductID == _item.ProductID);

                if (duplicate == null)
                {
                    _details.Add(_item);
                    dataGridResults.Rows.Add();
                    int lastrow = dataGridResults.Rows.Count - 2;
                    dataGridResults.Rows[lastrow].Cells[1].Value = textBox_PO_ID2.Text;
                    dataGridResults.Rows[lastrow].Cells[0].Value = textBox_ProductID.Text;
                    dataGridResults.Rows[lastrow].Cells[2].Value = textBox_Quantity.Text;
                    dataGridResults.Rows[lastrow].Cells[3].Value = textBox_Price.Text;
                    if (textBox_Comment.Text == "")
                    {
                        textBox_Comment.Text = "Product No:" + textBox_ProductID.Text + "(" + textBox_PO_ID2.Text + ")";
                    }
                    else
                    {
                        textBox_Comment.Text += ",Product No:" + textBox_ProductID.Text + "(" + textBox_PO_ID2.Text + ")";
                    }
                }
                else
                {
                    MessageBox.Show("Product is already added");
                }
            }
        }