using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NiApiLib;

namespace FUTDELORDER
{
    class Program
    {
        static void Main(string[] args)
        {
            Connection c = new Connection();
            c.connect();
            Console.ReadLine();
            c.disconnect();
        }
    }
    class Connection
    {
        NiApiLib.SrvrSession Session = new NiApiLib.SrvrSessionClass();
        NiApiLib.Transaction Trans = new NiApiLib.TransactionClass();
        NiApiLib.DataRow Row = new NiApiLib.DataRowClass();
        public void connect()
        {
            Session.HostAddr = "10.230.230.226";
            Session.HostPort = 2900;
            Session.Name = "1";
            Session.Password = "1";
            //Session.Journal = "Fest";
            Session.CatalogName = "catalog.xml";
            
            
            //Session.CryptoStart();


            Session.OnLogin+=new _ISrvrSessionEvents_OnLoginEventHandler(Session_OnLogin);
            Session.Connect();
        }
        public void disconnect()
        {
            Session.Disconnect();
        }
        public void Session_OnLogin(int LoginResult)
        {
            if (LoginResult == 0)
            {
                Console.WriteLine("[System] Соединение установлено");
                Trans.Open(Session, "FUTDELORDER", ETableType.tabAdrr);
                Console.WriteLine("[System] Транзакция открыта");
                Row.Structure = Trans.Structure;   
                object ORDER_NUMBER="I_ORDER_NUMBER";
                Row.set_Item(ref ORDER_NUMBER, "183346580");   // № записи I_RID
                object ACCOUNT="I_ACCOUNT";
                Row.set_Item(ref ACCOUNT, "AC1"); // Счет
                Trans.Execute(Row);
                Console.WriteLine("[System] Снятие заявки");
            }
            else
            {
                Console.WriteLine("[System] Ошибка подключения");
            }
        }
    }
}
