public void LoadPurchaseReq(string prno)
 {
     DsPurchase.PURCHASEREQUESTDataTable ds;
     dsPurchase1.PURCHASEREQUEST.Rows.Clear();
     _prno = prno;
     var dm = new PrDataManager();
            ds =   dm.GetPurchaseRequest(prno);
          var d = ds.Select("ISSUED = 0 ");// var d = from r in ds where r.ISSUED == 0 && r.UPLOAD == false select r;
          dsPurchase1.Merge(d);
 }
        void SaveRequest()
        {
            if(XtraMessageBox.Show("Do you want to save the request","POS",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
            {
                if(dsPurchase1.PURCHASEREQUEST.Rows.Count==0)
                {
                    XtraMessageBox.Show("Nothing to save", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                foreach(DataRow dr in dsPurchase1.PURCHASEREQUEST.Rows)
                {
                    string qty = dr["QTY"].ToString();
                    if(string.IsNullOrEmpty(dr["QTY"].ToString()))
                    {
                        dr.SetColumnError("QTY","Please check Qty");    
                    }
                    else if(int.Parse(dr["QTY"].ToString())==0)
                    {
                        dr.SetColumnError("QTY", "Please check Qty");    
                    }
                    else
                    {
                        dr.SetColumnError("QTY",null);  
                    }
                }
                if(dsPurchase1.PURCHASEREQUEST.HasErrors)
                {
                    XtraMessageBox.Show("Purchase request not saved due to errors", "POS", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    return;
                }
                var dm = new PrDataManager {Purchaserequest = dsPurchase1.PURCHASEREQUEST};
                var changes = (DsPurchase.PURCHASEREQUESTDataTable)dsPurchase1.PURCHASEREQUEST.GetChanges();
                var retval =   dm.DoSave();
                if(retval=="1")
                {
                    XtraMessageBox.Show("Purchase request created", "POS", MessageBoxButtons.OK,MessageBoxIcon.Information);
                    var addedRows = from row in dsPurchase1.PURINVDETAIL
                                    where row.RowState == DataRowState.Added
                                    select row;
                    foreach (var row in addedRows.ToArray())
                    {
                        row.Delete();
                    }
                    
                    if (changes != null) dsPurchase1.Merge(changes);
                    dsPurchase1.AcceptChanges();
                    dsPurchase1.Clear();
                    dsPurchase1.PURCHASEREQUEST.Merge(dm.GetPurchaseRequest(prno));
                }


            }
        }