0

我想使用 c# 从销售订单文档 Lines 部分中删除一些特定行。

4

3 回答 3

1

您需要首先使用 DocEntry 获取要更改的文档。

然后您必须设置需要删除的行号。见下文

Documents oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
int docEntry = 109;
int lineNum = 2;

// Load your sales orders
if (oDoc.GetByKey(docEntry))
{
    // Go through your line items
    for (int i = 0; i < oDoc.Lines.Count; i++)
    {
        oDoc.Lines.SetCurrentLine(i);
        if (oDoc.Lines.LineNum == lineNum) //Find your line number that you want delete.
        {
            oDoc.Lines.Delete(); //Delete
            break;
        }
    }

    // Update your sales order
    if (oDoc.Update() != 0)
        MessageBox.Show(oCompany.GetLastErrorDescription());
}
于 2019-11-28T12:58:56.913 回答
1
private void Delete_Single_Line_Row(string docentry, int lNum)
        {
            SAPbobsCOM.Documents oSalesOrd = null;
            oSalesOrd = (SAPbobsCOM.Documents)SBOC_SAP.G_DI_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
            int docEntry = Convert.ToInt32(docentry);
            int lineNum = lNum;

            // Load your sales orders
            if (oSalesOrd.GetByKey(docEntry))
            {
                // Go through your line items
                for (int i = 0; i < oSalesOrd.Lines.Count; i++)
                {
                    oSalesOrd.Lines.SetCurrentLine(i);
                    if (oSalesOrd.Lines.LineNum == lineNum) //Find your line number that you want delete.
                    {
                        oSalesOrd.Lines.Delete(); //Delete
                        break;
                    }
                }
                // Update your sales order
                int result = oSalesOrd.Update();

            }
        }    enter code here
于 2019-11-28T13:49:27.853 回答
0
Documents oDoc = Utils.oCompany.GetBusinessObject(BoObjectTypes.oOrders);
oDoc.GetByKey(123);
oDoc.Lines.SetCurrentLine(0);
oDoc.Lines.Delete();
int lret = oDoc.Update();
if (lret != 0)
{
    //HANDLE ERROR
}

我认为这很简单。

于 2019-11-28T11:41:23.690 回答