using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ACCPAC_OE_Screen
{
public partial class TestForm : Form
{
private ACCPAC.Advantage.Session accpacSession;
private ACCPAC.Advantage.DBLink mDBLinkPHARW;
private ACCPAC.Advantage.View OEORD1header;
private ACCPAC.Advantage.ViewFields OEORD1headerFields;
private ACCPAC.Advantage.View OEORD1detail1;
private ACCPAC.Advantage.ViewFields OEORD1detail1Fields;
private ACCPAC.Advantage.View OEORD1detail2;
private ACCPAC.Advantage.ViewFields OEORD1detail2Fields;
private ACCPAC.Advantage.View OEORD1detail3;
private ACCPAC.Advantage.ViewFields OEORD1detail3Fields;
private ACCPAC.Advantage.View OEORD1detail4;
private ACCPAC.Advantage.ViewFields OEORD1detail4Fields;
private ACCPAC.Advantage.View OEORD1detail5;
private ACCPAC.Advantage.ViewFields OEORD1detail5Fields;
private ACCPAC.Advantage.View OEORD1detail6;
private ACCPAC.Advantage.ViewFields OEORD1detail6Fields;
private ACCPAC.Advantage.View OEORD1detail7;
private ACCPAC.Advantage.ViewFields OEORD1detail7Fields;
private ACCPAC.Advantage.View OEORD1detail8;
private ACCPAC.Advantage.ViewFields OEORD1detail8Fields;
private ACCPAC.Advantage.View OEORD1detail9;
private ACCPAC.Advantage.ViewFields OEORD1detail9Fields;
private ACCPAC.Advantage.View OEORD1detail11;
private ACCPAC.Advantage.ViewFields OEORD1detail11Fields;
private ACCPAC.Advantage.View OEORD1detail10;
private ACCPAC.Advantage.ViewFields OEORD1detail10Fields;
private ACCPAC.Advantage.View OEORD1detail12;
private ACCPAC.Advantage.ViewFields OEORD1detail12Fields;
private ACCPAC.Advantage.Errors errors;
private Int16 editingLine = 32; // LIne number to be edited
public TestForm()
{
InitializeComponent();
try
{
accpacSession = new ACCPAC.Advantage.Session();
accpacSession.Init("", "XX", "XX1000", "56A");
accpacSession.Open("ADMIN", "", "IBXPHA", DateTime.Now, 0);
mDBLinkPHARW = accpacSession.OpenDBLink(ACCPAC.Advantage.DBLinkType.Company, ACCPAC.Advantage.DBLinkFlags.ReadWrite);
}
catch (Exception e)
{
MessageBox.Show(e.InnerException.Message, "ACCPAC connection error", MessageBoxButtons.OK);
}
OEORD1header = mDBLinkPHARW.OpenView("OE0520");
OEORD1detail1 = mDBLinkPHARW.OpenView("OE0500");
OEORD1detail2 = mDBLinkPHARW.OpenView("OE0740");
OEORD1detail3 = mDBLinkPHARW.OpenView("OE0180");
OEORD1detail4 = mDBLinkPHARW.OpenView("OE0526");
OEORD1detail5 = mDBLinkPHARW.OpenView("OE0522");
OEORD1detail6 = mDBLinkPHARW.OpenView("OE0508");
OEORD1detail7 = mDBLinkPHARW.OpenView("OE0507");
OEORD1detail8 = mDBLinkPHARW.OpenView("OE0501");
OEORD1detail9 = mDBLinkPHARW.OpenView("OE0502");
OEORD1detail10 = mDBLinkPHARW.OpenView("OE0504");
OEORD1detail11 = mDBLinkPHARW.OpenView("OE0506");
OEORD1detail12 = mDBLinkPHARW.OpenView("OE0503");
OEORD1header.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1, null, OEORD1detail3, OEORD1detail2, OEORD1detail4, OEORD1detail5 });
OEORD1headerFields = OEORD1header.Fields;
OEORD1detail1.Compose(new ACCPAC.Advantage.View[] { OEORD1header, OEORD1detail8, OEORD1detail12, OEORD1detail9, OEORD1detail6, OEORD1detail7 });
OEORD1detail1Fields = OEORD1detail1.Fields;
OEORD1detail2.Compose(new ACCPAC.Advantage.View[] { OEORD1header });
OEORD1detail2Fields = OEORD1detail2.Fields;
OEORD1detail3.Compose(new ACCPAC.Advantage.View[] { OEORD1header, OEORD1detail1 });
OEORD1detail3Fields = OEORD1detail3.Fields;
OEORD1detail4.Compose(new ACCPAC.Advantage.View[] { OEORD1header });
OEORD1detail4Fields = OEORD1detail4.Fields;
OEORD1detail5.Compose(new ACCPAC.Advantage.View[] { OEORD1header });
OEORD1detail5Fields = OEORD1detail5.Fields;
OEORD1detail6.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1 });
OEORD1detail6Fields = OEORD1detail6.Fields;
OEORD1detail7.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1 });
OEORD1detail7Fields = OEORD1detail7.Fields;
OEORD1detail8.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1 });
OEORD1detail8Fields = OEORD1detail8.Fields;
OEORD1detail9.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1, OEORD1detail10, OEORD1detail11 });
OEORD1detail9Fields = OEORD1detail9.Fields;
OEORD1detail10.Compose(new ACCPAC.Advantage.View[] { OEORD1detail9 });
OEORD1detail10Fields = OEORD1detail10.Fields;
OEORD1detail11.Compose(new ACCPAC.Advantage.View[] { OEORD1detail9 });
OEORD1detail11Fields = OEORD1detail11.Fields;
OEORD1detail12.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1 });
OEORD1detail12Fields = OEORD1detail12.Fields;
OEORD1headerFields.FieldByName("DRIVENBYUI").SetValue("0", false);
OEORD1header.Cancel();
OEORD1header.Init();
OEORD1detail2.Browse("", true);
OEORD1headerFields.FieldByName("ORDNUMBER").SetValue("QT000507", false);
OEORD1header.Order = 1;
OEORD1header.Read(false);
OEORD1header.Order = 0;
OEORD1detail1.RecordClear();
while (Convert.ToInt32(OEORD1detail1Fields.FieldByName("LINENUM").Value) != editingLine)
{
OEORD1detail1.GoNext();
}
OEORD1detail1.Fields.FieldByName("QTYORDERED").SetValue(10, true); //Change Quantity
bool nothing = OEORD1header.Exists;
OEORD1detail1.Update();
OEORD1detail1Fields.FieldByName("LINENUM").SetValue(editingLine, false);
OEORD1detail1.Read(false);
OEORD1headerFields.FieldByName("OECOMMAND").SetValue(4, true);
OEORD1header.Process();
OEORD1header.Update();
OEORD1header.Read(false);
OEORD1detail1.RecordClear();
while (Convert.ToInt32(OEORD1detail1Fields.FieldByName("LINENUM").Value) != editingLine)
{
OEORD1detail1.GoNext();
}
}
}
}