Пример #1
0
 protected virtual void doCopyRecord()
 {
     RecRefType.Code         = Reference.Property("Code").ToString();
     RecRefType.Description  = Reference.Property("Description").ToString();
     RecRefType.IsDeleteMark = Reference.Method("DeleteMark").ToBool();
     RecRefType.IsGroup      = Reference.Method("IsGroup").ToBool();
 }
Пример #2
0
        public OLEConnection(string PathToDatabase, V77Servers ServerType, bool Exclusive, string User, string Password)
        {
            FPathToDatabase = PathToDatabase;
            FUser           = User;
            FPassword       = Password;
            FExclusive      = Exclusive;
            if (!Directory.Exists(PathToDatabase) && (PathToDatabase != ""))
            {
                throw new OLE1C77Exception("Сбой соединения !!! Каталог - " + PathToDatabase + "  не существует !!!");
            }
            V77OLE        = Type.GetTypeFromProgID(Enum.Format(typeof(V77Servers), ServerType, "G") + ".Application");
            Handle        = Activator.CreateInstance(V77OLE);
            GlobalContext = new OLE(this, Handle);
            OLE RMTrade = Global.Method("RMTrade");

            string ParamStr = "/D" + PathToDatabase;

            if (Exclusive)
            {
                ParamStr = ParamStr + " /M";
            }
            if (User != "")
            {
                ParamStr = ParamStr + " /N" + User;
            }
            if (Password != "")
            {
                ParamStr = ParamStr + " /P" + Password;
            }

            if (!(bool)Global.Method("Initialize", RMTrade, ParamStr, "").ToObject())
            {
                GlobalContext = null;
                Handle        = null;
                V77OLE        = null;
                throw new OLE1C77Exception("Сбой соединения !!! Вероятней всего программа запущена монопольно или требует переиндексации !!!");
            }

            ntics_CommonAllConfig conf = new ntics_CommonAllConfig();

            FirmReference = Global.CreateObject("Справочник.Фирмы");
            FirmReference.Method("ВыбратьЭлементы");
            while (FirmReference.Method("ПолучитьЭлемент").ToBool())
            {
                if (FirmReference.Method("DeleteMark").ToBool())
                {
                    continue;
                }
                if (FirmReference.Property("ЕДРПОУ").ToString().Trim() == conf.ЕДРПОУ)
                {
                    FirmReference = FirmReference.Method("CurrentItem");
                    return;
                }
            }

            string s = Global.EvalExpr("SystemCaption()").ToString();

            FirmReference = null;
            GlobalContext = null;
            Handle        = null;
            V77OLE        = null;
            throw new OLE1C77Exception("Программа не зарегистрирована для даной базы: " + s);
        }