Stock Transfer API V2

From AutoCount Resource Center
Revision as of 03:46, 29 June 2018 by DanielY (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Technical Specification

References of AutoCount Accounting version 2.0

AutoCount.Accounting.dll
AutoCount.Accounting.UI.dll
AutoCount.dll
AutoCount.MainEntry.dll
AutoCount.UI.dll
AutoCount.Stock.dll
AutoCount.Manufacturing.dll

API Usage

New

public void New(AutoCount.Authentication.UserSession userSession)
{
    AutoCount.Stock.StockTransfer.StockTransferCommand cmd =
        AutoCount.Stock.StockTransfer.StockTransferCommand.Create(userSession, userSession.DBSetting);
    AutoCount.Stock.StockTransfer.StockTransfer doc = cmd.AddNew();
    AutoCount.Stock.StockTransfer.StockTransferDetail dtl = null;

    //doc.DocNo = "<<New>>";
    doc.DocDate = DateTime.Today.Date;
    doc.Description = "Test Generated.";
    doc.FromLocation = "HQ";
    doc.ToLocation = "PJ";

    //Set to auto populate the item information from Item Maintenance
    //such as Item Description
    doc.EnableAutoLoadItemDetail = true;

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00001";
    dtl.UOM = "KG";
    dtl.Qty = 1;

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00002";
    dtl.UOM = "PCS";
    dtl.Qty = 2;

    try
    {
        doc.Save();
        //log success
        AutoCount.AppMessage.ShowMessage($"Stock Transfer {doc.DocNo} is created.");
    }
    catch (AutoCount.AppException ex)
    {
        //log error
        AutoCount.AppMessage.ShowMessage("Fail to create new Stock Transfer.\n" + ex.Message);
    }
}

Edit

public void Edit(AutoCount.Authentication.UserSession userSession)
{
    AutoCount.Stock.StockTransfer.StockTransferCommand cmd =
        AutoCount.Stock.StockTransfer.StockTransferCommand.Create(userSession, userSession.DBSetting);
    AutoCount.Stock.StockTransfer.StockTransfer doc = cmd.Edit("XFER-00001");
    AutoCount.Stock.StockTransfer.StockTransferDetail dtl = null;

    if (doc == null)
    {
        //Log document not found.
        return;
    }

    doc.DocDate = DateTime.Today.Date;
    doc.Description = "Test Generated.";
    doc.FromLocation = "HQ";
    doc.ToLocation = "PJ";

    doc.ClearDetails();

    //Set to auto populate the item information from Item Maintenance
    //such as Item Description
    doc.EnableAutoLoadItemDetail = true;

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00001";
    dtl.UOM = "KG";
    dtl.Qty = 1;

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00002";
    dtl.UOM = "PCS";
    dtl.Qty = 2;

    try
    {
        doc.Save();
        //log success
        AutoCount.AppMessage.ShowMessage($"Stock Transfer '{doc.DocNo}' is updated.");
    }
    catch (AutoCount.AppException ex)
    {
        //log error
        AutoCount.AppMessage.ShowMessage($"Fail to update Stock Transfer '{doc.DocNo}'.\n" + ex.Message);
    }
}

Cancel

public void Cancel(AutoCount.Authentication.UserSession userSession)
{
    string docNo = "XFER-00001";
    AutoCount.Stock.StockTransfer.StockTransferCommand cmd =
        AutoCount.Stock.StockTransfer.StockTransferCommand.Create(userSession, userSession.DBSetting);

    try
    {
        cmd.CancelDocument(docNo);
        //log success
        AutoCount.AppMessage.ShowMessage($"Stock Transfer '{docNo}' is cancelled.");
    }
    catch (AutoCount.AppException ex)
    {
        //log error
        AutoCount.AppMessage.ShowMessage($"Fail to cancel Stock Transfer '{docNo}'.\n" + ex.Message);
    }
}

Uncancel

public void UnCancel(AutoCount.Authentication.UserSession userSession)
{
    string docNo = "XFER-00001";
    AutoCount.Stock.StockTransfer.StockTransferCommand cmd =
        AutoCount.Stock.StockTransfer.StockTransferCommand.Create(userSession, userSession.DBSetting);

    try
    {
        cmd.UncancelDocument(docNo);
        //log success
        AutoCount.AppMessage.ShowMessage($"Stock Transfer '{docNo}' is uncancelled.");
    }
    catch (AutoCount.AppException ex)
    {
        //log error
        AutoCount.AppMessage.ShowMessage($"Fail to uncancel Stock Transfer '{docNo}'.\n" + ex.Message);
    }
}

Delete

public void Delete(AutoCount.Authentication.UserSession userSession)
{
    string docNo = "XFER-00001";
    AutoCount.Stock.StockTransfer.StockTransferCommand cmd =
        AutoCount.Stock.StockTransfer.StockTransferCommand.Create(userSession, userSession.DBSetting);

    try
    {
        cmd.Delete(docNo);
        //log success
        AutoCount.AppMessage.ShowMessage($"Stock Transfer '{docNo}' is deleted.");
    }
    catch (AutoCount.AppException ex)
    {
        //log error
        AutoCount.AppMessage.ShowMessage($"Fail to delete Stock Transfer '{docNo}'.\n" + ex.Message);
    }
}


See Also

Go to menu

IconAC81.png Go to top
ProgrammerGo.jpg Resources For AutoCount Software Developers