public string addNewPO(DateTime orderdate, string supcode, int orderby, DateTime reqdate)
        {
            PurchaseOrder po = new PurchaseOrder();

            po.PONumber = createPO_ID();
            po.Order_Date = orderdate;
            po.Supplier_Code = supcode;
            po.Department_Code = "UNISTR";   //change later
            po.Ordered_By = orderby;
            po.Request_Date = reqdate;
            po.StoredRecord_Status = "NO"; //at first status will be "NO" Will be changed to "YES" only when it is updated.
            edm.PurchaseOrders.AddObject(po);
            this.edm.SaveChanges();

            string pon = po.PONumber;

            return pon;
        }
        protected void ddlPONumber_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlPONumber.SelectedIndex != 0)
            {

                string ponum = ddlPONumber.SelectedValue;
                pendingPO = pobll.GetPurchaseOrderByPONum(ponum);

                EmployeeBLL emp = new EmployeeBLL();
                int orderById =(Int32)pendingPO.Ordered_By;
                //string supcode = ;

                SupplierBLL supbll = new SupplierBLL();
                Supplier sup = supbll.GetSupplierByCode(pendingPO.Supplier_Code);

                txtSupplierName.Text = sup.Supplier_Name;

                txtOrderBy.Text = emp.GetEmployeeNameById(orderById);
                txtOrderDate.Text = pendingPO.Order_Date.ToShortDateString();

                txtSupplierName.ReadOnly = true;
                txtOrderBy.ReadOnly = true;
                txtOrderDate.ReadOnly = true;

                List<PurchaseOrderDetail> pendingPOD = new List<PurchaseOrderDetail>();

                pendingPOD = podetailbll.GetPendingPODetails(ponum);

                gvPODetailList.Visible = true;

            }
        }
        public PurchaseOrder GetPurchaseOrderByPONum(string pon)
        {
            var q = (from r in edm.PurchaseOrders where r.PONumber == pon select r);
            PurchaseOrder po = new PurchaseOrder();
            po = q.First<PurchaseOrder>();

            return po;
        }
 /// <summary>
 /// Create a new PurchaseOrder object.
 /// </summary>
 /// <param name="pONumber">Initial value of the PONumber property.</param>
 /// <param name="supplier_Code">Initial value of the Supplier_Code property.</param>
 /// <param name="department_Code">Initial value of the Department_Code property.</param>
 /// <param name="order_Date">Initial value of the Order_Date property.</param>
 public static PurchaseOrder CreatePurchaseOrder(global::System.String pONumber, global::System.String supplier_Code, global::System.String department_Code, global::System.DateTime order_Date)
 {
     PurchaseOrder purchaseOrder = new PurchaseOrder();
     purchaseOrder.PONumber = pONumber;
     purchaseOrder.Supplier_Code = supplier_Code;
     purchaseOrder.Department_Code = department_Code;
     purchaseOrder.Order_Date = order_Date;
     return purchaseOrder;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the PurchaseOrders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPurchaseOrders(PurchaseOrder purchaseOrder)
 {
     base.AddObject("PurchaseOrders", purchaseOrder);
 }