private void simpleButton1_Click(object sender, EventArgs e)
        {
            var dt = (DataView) gridView1.DataSource;
            dt.RowFilter = "Requested >0";
            if (dt == null) return;
            var po = new PO();
            po.AddNew();
            var serverDateTime = DateTimeHelper.ServerDateTime;
            po.PODate = serverDateTime;
            po.DateOfEntry = serverDateTime;
            po.PurchaseType = POType.INTERNAL;
            po.PaymentTypeID = PaymentType.Constants.STV;
            po.TermOfPayement = TermOfPayment.List[6].ID;
            po.PurchaseOrderStatusID = 9; //PurchaseOrderStatus ==> Processed
            po.SavedbyUserID = CurrentContext.LoggedInUser.ID;
            po.Save();
            var purchaseOrderDetail = new PurchaseOrderDetail();
            foreach (DataRowView dr in dt)
            {
                var itemUnit = new ItemUnitBase();
                itemUnit.LoadByPrimaryKey(Convert.ToInt32(dr["UnitID"]));

                purchaseOrderDetail.AddNew();
                purchaseOrderDetail.ItemID = Convert.ToInt32(dr["ItemID"]);
                purchaseOrderDetail.UnitOfIssueID = itemUnit.UnitOfIssueID;
                purchaseOrderDetail.Quantity = Convert.ToInt32(dr["Requested"]);
                purchaseOrderDetail.PurchaseOrderID = po.ID;
                purchaseOrderDetail.Rowguid = Guid.NewGuid();
                purchaseOrderDetail.ApprovedQuantity = 0;

            }
            purchaseOrderDetail.Save();
            lookUpEdit1_EditValueChanged(null, null);
        }
        private void RemoveItem(DataRow dr)
        {
            var rows = dr.Table.Columns.Contains("ID") ? _dtselectedItemsTable.Select(String.Format("ItemID = {0} and UnitID = {1}", dr["ID"], dr["UnitID"])) : new[] { dr };

            foreach (var rw in rows)
            {

                if (rw != null && rw["PurchaseOrderDetailID"] != DBNull.Value)
                {
                    if (XtraMessageBox.Show(@"Are you sure you want to delete the detail from the database?",
                        @"Confirmation", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        var purchaseorderdetail = new PurchaseOrderDetail();
                        purchaseorderdetail.LoadByPrimaryKey(Convert.ToInt32((rw["PurchaseOrderDetailID"])));
                        purchaseorderdetail.MarkAsDeleted();
                        purchaseorderdetail.Save();
                        _dtselectedItemsTable.Rows.Remove(rw);
                    }
                    continue;
                }
                _dtselectedItemsTable.Rows.Remove(rw);
            }
        }