public void SavePoDetail()
        {
            if (!ValidateOrderDetails())
            {
                return;
            }

            var itemData = (DataView)gridSelectedItemsView.DataSource;

            foreach (DataRowView row in itemData)
            {
                if (row["PurchaseOrderDetailID"] == DBNull.Value)
                {
                    _poDetail.AddNew();
                }
                else
                {
                    _poDetail.LoadByPrimaryKey(Convert.ToInt32(row["PurchaseOrderDetailID"]));
                }
                var itemUnit = new ItemUnitBase();
                var unitID   = Convert.ToInt32(row["UnitID"]);
                itemUnit.LoadByPrimaryKey(unitID);

                _poDetail.PurchaseOrderID  = _poid;
                _poDetail.ItemID           = Convert.ToInt32(row["ItemID"]);
                _poDetail.Quantity         = Convert.ToDecimal(row["Quantity"]);
                _poDetail.Remark           = string.Empty;
                _poDetail.UnitOfIssueID    = itemUnit.UnitOfIssueID;
                _poDetail.Rowguid          = Guid.NewGuid();
                _poDetail.ApprovedQuantity = 0;
                _poDetail.Amount           = Convert.ToDecimal(row["Amount"]);
                if (row["PreferredManufacturerID"] != DBNull.Value)
                {
                    _poDetail.PreferredManufacturerID = Convert.ToInt32(row["PreferredManufacturerID"]);
                }
                _poDetail.Save();
            }
            MessageBox.Show("Order detail saved!", "Confirmation", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
            Close();
        }
Esempio n. 2
0
        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);
        }