private Hash SettleSwapToExternal(string destinationPlatform, Hash sourceHash, Func <Address, IToken, BigInteger, Hash> generator)
        {
            var oracleReader = Nexus.CreateOracleReader();
            var swap         = oracleReader.ReadTransaction(DomainSettings.PlatformName, DomainSettings.RootChainName, sourceHash);

            var transfers = swap.Transfers.Where(x => x.destinationAddress.IsInterop).ToArray();

            // TODO not support yet
            if (transfers.Length != 1)
            {
                logger.Warning($"Not implemented: Swap support for multiple transfers in a single transaction");
                return(Hash.Null);
            }

            var transfer = transfers[0];

            var token = Nexus.GetTokenInfo(Nexus.RootStorage, transfer.Symbol);

            var destHash = generator(transfer.destinationAddress, token, transfer.Value);

            if (destHash != Hash.Null)
            {
                var pendingList = new StorageList(PendingTag, this.Storage);
                var settle      = new PendingSettle()
                {
                    sourceHash = sourceHash, destinationHash = destHash, settleHash = Hash.Null, time = DateTime.UtcNow, status = SwapStatus.Settle
                };
                pendingList.Add <PendingSettle>(settle);
            }

            return(destHash);
        }
Exemple #2
0
 public string this[StorageList tableName]
 {
     get
     {
         return(this.StorageNames.TryGetValue(tableName.ToString(), out var tblName) ? tblName : "");
     }
 }
Exemple #3
0
        public bool DeployContractScript(StorageContext storage, Address contractOwner, string name, Address contractAddress, byte[] script, ContractInterface abi)
        {
            var scriptKey = GetContractKey(contractAddress, "script");

            if (storage.Has(scriptKey))
            {
                return(false);
            }

            storage.Put(scriptKey, script);

            var ownerBytes = contractOwner.ToByteArray();
            var ownerKey   = GetContractKey(contractAddress, "owner");

            storage.Put(ownerKey, ownerBytes);

            var abiBytes = abi.ToByteArray();
            var abiKey   = GetContractKey(contractAddress, "abi");

            storage.Put(abiKey, abiBytes);

            var nameBytes = Encoding.ASCII.GetBytes(name);
            var nameKey   = GetContractKey(contractAddress, "name");

            storage.Put(nameKey, nameBytes);

            var contractList = new StorageList(GetContractListKey(), storage);

            contractList.Add <Address>(contractAddress);

            return(true);
        }
        private bool UpdatePendingSettle(StorageList list, int index)
        {
            var swap       = list.Get <PendingSettle>(index);
            var prevStatus = swap.status;

            switch (swap.status)
            {
            case SwapStatus.Settle:
            {
                var diff = Timestamp.Now - swap.time;
                if (diff >= 60)
                {
                    swap.settleHash = SettleTransaction(DomainSettings.PlatformName, DomainSettings.RootChainName, swap.sourceHash);
                    if (swap.settleHash != Hash.Null)
                    {
                        swap.status = SwapStatus.Confirm;
                    }
                }
                break;
            }

            case SwapStatus.Confirm:
            {
                var result = this.NexusAPI.GetTransaction(swap.settleHash.ToString());
                if (result is TransactionResult)
                {
                    var tx = (TransactionResult)result;
                    swap.status = SwapStatus.Finished;
                }
                else
                if (result is ErrorResult)
                {
                    var error = ((ErrorResult)result).error;
                    if (error != "pending")
                    {
                        swap.settleHash = Hash.Null;
                        swap.time       = Timestamp.Now;
                        swap.status     = SwapStatus.Settle;
                    }
                }
                break;
            }

            default: return(false);
            }

            if (swap.status == SwapStatus.Finished)
            {
                var settlements = new StorageMap(SettlementTag, this.Storage);
                settlements.Set <Hash, Hash>(swap.sourceHash, swap.destinationHash);
                return(true);
            }

            if (swap.status != prevStatus)
            {
                list.Replace <PendingSettle>(index, swap);
            }

            return(false);
        }
Exemple #5
0
        public IContract[] GetContracts()
        {
            var contractList = new StorageList(GetContractListKey(), this.Storage);
            var addresses    = contractList.All <Address>();

            return(addresses.Select(x => Nexus.GetContractByAddress(x)).ToArray());
        }
        private Track(int key, CsvReader csvReader)
        {
            Key          = key;
            FileName     = csvReader.ReadString();
            FullFileName = csvReader.ReadString();
            var locationKey = csvReader.ReadInt();

            Location           = DC.Data._Locations.GetItem(locationKey) ?? Location.NoLocation;
            Title              = csvReader.ReadStringNull();
            TitleLowerCase     = Title?.ToLowerInvariant();
            Duration           = csvReader.ReadTimeNull();
            Album              = csvReader.ReadStringNull();
            AlbumLowerCase     = Album?.ToLowerInvariant();
            AlbumTrack         = csvReader.ReadIntNull();
            Artists            = csvReader.ReadStringNull();
            ArtistsLowerCase   = Artists?.ToLowerInvariant();
            Composers          = csvReader.ReadStringNull();
            ComposersLowerCase = Composers?.ToLowerInvariant();
            Publisher          = csvReader.ReadStringNull();
            PublisherLowerCase = Publisher?.ToLowerInvariant();
            Year         = csvReader.ReadIntNull();
            Genres       = csvReader.ReadStringNull();
            Weight       = csvReader.ReadIntNull();
            Volume       = csvReader.ReadIntNull();
            SkipStart    = csvReader.ReadIntNull();
            SkipEnd      = csvReader.ReadIntNull();
            TitleArtists = csvReader.ReadString();
            DC.Data._TracksByTitleArtists.Add(TitleArtists, this);
            playlistTracks = new StorageList <PlaylistTrack>();
            if (Location != Location.NoLocation)
            {
                Location.AddToTracks(this);
            }
            onCsvConstruct();
        }
        public void TestStorageListWithNestedMap()
        {
            var context = new MemoryStorageContext();

            var map = new StorageMap("map".AsByteArray(), context);

            Assert.IsTrue(map.Count() == 0);

            map.Set(1, "hello");
            map.Set(3, "world");
            var count = map.Count();

            Assert.IsTrue(count == 2);

            var list = new StorageList("list".AsByteArray(), context);

            Assert.IsTrue(list.Count() == 0);

            list.Add(map);

            count = list.Count();
            Assert.IsTrue(count == 1);

            var another = list.Get <StorageMap>(0);

            count = another.Count();
            Assert.IsTrue(count == 2);
        }
Exemple #8
0
        public IContract[] GetContracts(StorageContext storage)
        {
            var contractList = new StorageList(GetContractListKey(), storage);
            var addresses    = contractList.All <Address>();

            return(addresses.Select(x => this.GetContractByAddress(storage, x)).ToArray());
        }
        /// <summary>
        /// Set Dictionary Iterator to first Key-Value pair and return its Key.
        /// </summary>
        /// <param name="DictID">Supplies the id of the Dictionary to access.
        /// </param>
        /// <param name="Key">Output is the first Key in the SortedDictionary.
        /// </param>
        /// <returns>True if Dictionary DictID exists and contains elements,
        /// otherwise false.</returns>
        private bool DictionaryIterateFirst(string DictID, out string Key)
        {
            SortedDictionary <string, string> Dict;
            IDictionaryEnumerator             ide;

            Key = "";

            if (StorageList.TryGetValue(DictID, out Dict) == false)
            {
                return(false);
            }

            ide = Dict.GetEnumerator();

            // Confirm there exists an element within this dictionary,
            // if not simply return false
            if (ide.MoveNext() == false)
            {
                return(false);
            }

            Key = (string)ide.Key;

            // Store iterator for future use
            StorageIteratorList[DictID] = ide;

            return(true);
        }
Exemple #10
0
        public bool Remove(StorageContext storage, Address address, BigInteger tokenID)
        {
            if (tokenID <= 0)
            {
                return(false);
            }

            if (GetOwner(storage, tokenID) != address)
            {
                return(false);
            }

            var listKey  = GetKeyForList(address);
            var ownerKey = GetKeyForOwner(tokenID);

            lock (storage)
            {
                var list = new StorageList(listKey, storage);
                list.Remove(tokenID);

                storage.Delete(ownerKey);
            }

            return(true);
        }
Exemple #11
0
        private StorageList GetChildrenListOfChain(string chainName)
        {
            var key  = Encoding.UTF8.GetBytes(ChainChildrenBlockKey + chainName);
            var list = new StorageList(key, new KeyStoreStorage(_vars.Adapter));

            return(list);
        }
Exemple #12
0
        // should only be called from inside lock block
        private Hash GetSettleHash(string sourcePlatform, Hash sourceHash)
        {
            var settlements = new StorageMap(SettlementTag, this.Storage);

            if (settlements.ContainsKey <Hash>(sourceHash))
            {
                return(settlements.Get <Hash, Hash>(sourceHash));
            }

            var pendingList = new StorageList(PendingTag, this.Storage);
            var count       = pendingList.Count();

            for (int i = 0; i < count; i++)
            {
                var settlement = pendingList.Get <PendingFee>(i);
                if (settlement.sourceHash == sourceHash)
                {
                    return(settlement.destinationHash);
                }
            }

            var hash = (Hash)Nexus.RootChain.InvokeContract(Nexus.RootStorage, "interop", nameof(InteropContract.GetSettlement), sourcePlatform, sourceHash).ToObject();

            if (hash != Hash.Null && !settlements.ContainsKey <Hash>(sourceHash))
            {
                // This modification should be locked when GetSettleHash() is called from SettleSwap(),
                // so we lock it in SettleSwap().
                settlements.Set <Hash, Hash>(sourceHash, hash);
            }
            return(hash);
        }
        public Hash GetSettleHash(string sourcePlatform, Hash sourceHash)
        {
            var settlements = new StorageMap(SettlementTag, this.Storage);

            if (settlements.ContainsKey <Hash>(sourceHash))
            {
                return(settlements.Get <Hash, Hash>(sourceHash));
            }

            var pendingList = new StorageList(PendingTag, this.Storage);
            var count       = pendingList.Count();

            for (int i = 0; i < count; i++)
            {
                var settlement = pendingList.Get <PendingSettle>(i);
                if (settlement.sourceHash == sourceHash)
                {
                    return(settlement.destinationHash);
                }
            }

            var hash = (Hash)Nexus.RootChain.InvokeContract(Nexus.RootStorage, "interop", nameof(InteropContract.GetSettlement), sourcePlatform, sourceHash).ToObject();

            if (hash != Hash.Null && !settlements.ContainsKey <Hash>(sourceHash))
            {
                settlements.Set <Hash, Hash>(sourceHash, hash);
            }
            return(hash);
        }
 private Playlist(int key, CsvReader csvReader)
 {
     Key       = key;
     Name      = csvReader.ReadString();
     NameLower = Name.ToLowerInvariant();
     DC.Data._PlaylistsByNameLower.Add(NameLower, this);
     playlistTracks = new StorageList <PlaylistTrack>();
     onCsvConstruct();
 }
 /// <summary>
 /// 删除按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_Delete_Click(object sender, EventArgs e)
 {
     StorageList storage = new StorageList();
     string idlist = this.dgProduct.SelectedIDList;
     string sql = "delete from StorageList where StorageNo in ('" + idlist.Replace(",", "','") + "')";
     storage.DatabaseAccess.ExecuteNonQuery(sql);
     Response.Write("<script language=javascript>alert('删除成功!')</script>");
     BindData();
 }
Exemple #16
0
    private void BindStorage()
    {
        StorageList storage = new StorageList();
        string      sql     = "select StorageNo from StorageList";

        this.ddl_StoNo.DataSource = storage.DatabaseAccess.ExecuteDataset(sql);
        this.ddl_StoNo.DataBind();
        this.ddl_StoNo.Items.Insert(0, new ListItem("----------", "-1"));
    }
Exemple #17
0
 public         BigInteger[] Get(StorageContext storage, Address address)
 {
     lock (storage)
     {
         var listKey = GetKeyForList(address);
         var list    = new StorageList(listKey, storage);
         return(list.All <BigInteger>());
     }
 }
        public Track(
            string fileName,
            string fullFileName,
            Location location,
            string?title,
            TimeSpan?duration,
            string?album,
            int?albumTrack,
            string?artists,
            string?composers,
            string?publisher,
            int?year,
            string?genres,
            int?weight,
            int?volume,
            int?skipStart,
            int?skipEnd,
            string titleArtists,
            bool isStoring = true)
        {
            Key                = StorageExtensions.NoKey;
            FileName           = fileName;
            FullFileName       = fullFileName;
            Location           = location;
            Title              = title;
            TitleLowerCase     = Title?.ToLowerInvariant();
            Duration           = duration.Round(Rounding.Seconds);
            Album              = album;
            AlbumLowerCase     = Album?.ToLowerInvariant();
            AlbumTrack         = albumTrack;
            Artists            = artists;
            ArtistsLowerCase   = Artists?.ToLowerInvariant();
            Composers          = composers;
            ComposersLowerCase = Composers?.ToLowerInvariant();
            Publisher          = publisher;
            PublisherLowerCase = Publisher?.ToLowerInvariant();
            Year               = year;
            Genres             = genres;
            Weight             = weight;
            Volume             = volume;
            SkipStart          = skipStart;
            SkipEnd            = skipEnd;
            TitleArtists       = titleArtists;
            playlistTracks     = new StorageList <PlaylistTrack>();
            Location.AddToTracks(this);
            onConstruct();
            if (DC.Data.IsTransaction)
            {
                DC.Data.AddTransaction(new TransactionItem(1, TransactionActivityEnum.New, Key, this));
            }

            if (isStoring)
            {
                Store();
            }
        }
Exemple #19
0
 //From upstream to downstream list: Warehouse->Supermarket->BinMagazine
 public Storage(string nameIn, FLOWObject parentIn, int capacityIn, Node nodeIn) : base(nameIn, parentIn, capacityIn)
 {
     if (nodeIn != null)
     {
         this.Node     = nodeIn;
         this.NodeName = nodeIn.Name;
     }
     upstreamSuppliers   = new StorageList();
     downstreamCustomers = new StorageList();
 }
Exemple #20
0
        /// <summary>
        /// Adds a storage to the manager
        /// </summary>
        /// <param name="storage"></param>
        static public void AddStorage(StorageBase storage)
        {
            if (storage == null)
            {
                return;
            }

            storage.Process();
            StorageList.Add(storage);
        }
 private Location(int key, CsvReader csvReader)
 {
     Key       = key;
     Path      = csvReader.ReadString();
     PathLower = Path.ToLowerInvariant();
     DC.Data._LocationsByPathLower.Add(PathLower, this);
     Name   = csvReader.ReadString();
     tracks = new StorageList <Track>();
     onCsvConstruct();
 }
    /// <summary>
    /// 删除按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_Delete_Click(object sender, EventArgs e)
    {
        StorageList storage = new StorageList();
        string      idlist  = this.dgProduct.SelectedIDList;
        string      sql     = "delete from StorageList where StorageNo in ('" + idlist.Replace(",", "','") + "')";

        storage.DatabaseAccess.ExecuteNonQuery(sql);
        Response.Write("<script language=javascript>alert('删除成功!')</script>");
        BindData();
    }
        private void assert(StorageList <TestChild> storageList, string expectedStored, string expectedAll)
        {
            sb.Clear();
            foreach (var item in storageList.GetStoredItems())
            {
                sb.AppendLine(item.ToString());
            }
            if (expectedStored.Length == 0)
            {
                Assert.AreEqual(0, sb.Length);
            }
            else
            {
                expectedStored = expectedStored.Replace(Environment.NewLine + "          ", Environment.NewLine);
                Assert.AreEqual(expectedStored + Environment.NewLine, sb.ToString());
            }

            sb.Clear();
            foreach (var item in storageList)
            {
                sb.AppendLine(item.ToString());
            }
            if (expectedAll.Length == 0)
            {
                Assert.AreEqual(0, sb.Length);
            }
            else
            {
                expectedAll = expectedAll.Replace(Environment.NewLine + "          ", Environment.NewLine);
                Assert.AreEqual(expectedAll + Environment.NewLine, sb.ToString());
            }

            //var parent = storageList.Parent;
            //sb.Clear();
            //foreach (var item in parent.Children) {
            //  sb.AppendLine(item.ToString());
            //}
            //if (expectedForEach.Length==0) {
            //  Assert.AreEqual(0, sb.Length);
            //} else {
            //  expectedForEach = expectedForEach.Replace(Environment.NewLine + "          ", Environment.NewLine);
            //  Assert.AreEqual(expectedForEach + Environment.NewLine, sb.ToString());
            //}
            //sb.Clear();
            //foreach (var item in parent.Children.GetAll()) {
            //  sb.AppendLine(item.ToString());
            //}
            //if (expectedGetAll.Length==0) {
            //  Assert.AreEqual(0, sb.Length);
            //} else {
            //  expectedGetAll = expectedGetAll.Replace(Environment.NewLine + "          ", Environment.NewLine);
            //  Assert.AreEqual(expectedGetAll + Environment.NewLine, sb.ToString());
            //}
        }
        /// <summary>
        /// Delete value from dictionary by key.
        /// </summary>
        /// <param name="DictID">Supplies the id of the Dictionary to access.
        /// </param>
        /// <param name="Key">Key to search for and delete from the dictionary.
        /// </param>
        private void DictionaryDeleteKey(string DictID, string Key)
        {
            SortedDictionary <string, string> Dict;

            if (StorageList.TryGetValue(DictID, out Dict) == false)
            {
                return;
            }

            Dict.Remove(Key);
            StorageIteratorList.Remove(Key);
        }
Exemple #25
0
        static void Main(String[] args)
        {
            bool primitive = typeof(C2Vector).IsPrimitive;

            using (var fs = File.OpenRead(@"D:\World of Warcraft 3.3.5\dbc\AreaTrigger.dbc"))
            {
                var collection = new StorageList <AreaTriggerEntry>(StorageOptions.Default, fs);
                Console.WriteLine(collection[0].MapID);
            }

            Console.ReadKey();
        }
        public void DeleteStorageList(StorageList storageList)
        {
            if (storageList == null)
            {
                throw new ArgumentNullException(nameof(storageList));
            }

            foreach (var storageProduct in storageList.StorageProducts)
            {
                _context.StorageProducts.Remove(storageProduct);
            }
            _context.StorageLists.Remove(storageList);
        }
        /// <summary>
        /// Set Dictionary DictID's Key to a String Value.
        /// </summary>
        /// <param name="DictID">Supplies the id of the Dictionary to access.
        /// If this Dictionary does not exist, create it. </param>
        /// <param name="Key">Supplies the Key for lookup of the target dictionary.
        /// If no such Key exists, create a new Key/Value pair. </param>
        /// <param name="Value">Supplies the Value to associate to the Key in the
        /// target dictionary. </param>
        private void DictionarySetString(string DictID, string Key, string Value)
        {
            SortedDictionary <string, string> Dict;

            // Create if does not exist
            if (StorageList.TryGetValue(DictID, out Dict) == false)
            {
                Dict = new SortedDictionary <string, string>();
                StorageList[DictID] = Dict;
            }

            Dict[Key] = Value;
            StorageIteratorList.Remove(DictID);
        }
    public DataSet GetStorageListDataSource()
    {
        StorageList storage = new StorageList();
        System.Text.StringBuilder sql = new System.Text.StringBuilder();
        sql.Append(@"SELECT StorageNo,StorageDescription,GenerationTime FROM StorageList where 1=1 ");

        if (this.txt_StoNo.Text != string.Empty)
        {
            sql.Append(string.Format(" and StorageNo='{0}'", storage.DatabaseAccess.ConvertToDBString(this.txt_StoNo.Text)));
        }
        sql.Append(string.Format(" and convert(char(10),GenerationTime,102)>= '{0}' and convert(char(10),GenerationTime,102)<='{1}' ", this.StartDate.ToString("yyyy.MM.dd"), this.EndDate.ToString("yyyy.MM.dd")));
        sql.Append(" order by GenerationTime desc");
        return storage.GetDateSet(sql.ToString());
    }
        public void TestStorageList()
        {
            _ = new DC(null);

            var parent      = new TestParent("Parent", isStoring: false);
            var storageList = new StorageList <TestChild>();

            assert(storageList, "", "");

            var child0 = new TestChild("Child0", parent, isStoring: false);

            storageList.Add(child0);
            assert(storageList,
                   @"",
                   @"Key: noKey, Text: Child0, Parent: noKey, Parent;");

            var child1 = new TestChild("Child1", parent, isStoring: false);

            storageList.Add(child1);
            assert(storageList,
                   @"",
                   @"Key: noKey, Text: Child0, Parent: noKey, Parent;
          Key: noKey, Text: Child1, Parent: noKey, Parent;");

            parent.Store();
            assert(storageList,
                   @"",
                   @"Key: noKey, Text: Child0, Parent: 0, Parent;
          Key: noKey, Text: Child1, Parent: 0, Parent;");

            child0.Store();
            assert(storageList,
                   @"Key: 0, Text: Child0, Parent: 0, Parent;",
                   @"Key: 0, Text: Child0, Parent: 0, Parent;
          Key: noKey, Text: Child1, Parent: 0, Parent;");

            child1.Store();
            assert(storageList,
                   @"Key: 0, Text: Child0, Parent: 0, Parent;
          Key: 1, Text: Child1, Parent: 0, Parent;",
                   @"Key: 0, Text: Child0, Parent: 0, Parent;
          Key: 1, Text: Child1, Parent: 0, Parent;");

            child0.Release();
            assert(storageList,
                   @"Key: 1, Text: Child1, Parent: 0, Parent;",
                   @"Key: noKey, Text: Child0, Parent: 0, Parent;
          Key: 1, Text: Child1, Parent: 0, Parent;");
        }
Exemple #30
0
        private Hash SettleSwapToExternal(Hash sourceHash, string destPlatform)
        {
            var swap      = OracleReader.ReadTransaction(DomainSettings.PlatformName, DomainSettings.RootChainName, sourceHash);
            var transfers = swap.Transfers.Where(x => x.destinationAddress.IsInterop).ToArray();

            // TODO not support yet
            if (transfers.Length != 1)
            {
                Logger.Warning($"Not implemented: Swap support for multiple transfers in a single transaction");
                return(Hash.Null);
            }

            var transfer = transfers[0];

            var token = Nexus.GetTokenInfo(Nexus.RootStorage, transfer.Symbol);

            lock (StateModificationLock)
            {
                var destHash = GetSettleHash(DomainSettings.PlatformName, sourceHash);
                Logger.Debug("settleHash in settleswap: " + destHash);

                if (destHash != Hash.Null)
                {
                    return(destHash);
                }

                if (!_swappers.ContainsKey(destPlatform))
                {
                    return(Hash.Null); // just in case, should never happen
                }

                var chainSwapper = _swappers[destPlatform];

                destHash = chainSwapper.SettleSwap(sourceHash, transfer.destinationAddress, token, transfer.Value);

                // if the asset transfer was sucessfull, we prepare a fee settlement on the mainnet
                if (destHash != Hash.Null)
                {
                    var pendingList = new StorageList(PendingTag, this.Storage);
                    var settle      = new PendingFee()
                    {
                        sourceHash = sourceHash, destinationHash = destHash, settleHash = Hash.Null, time = DateTime.UtcNow, status = SwapStatus.Settle
                    };
                    pendingList.Add <PendingFee>(settle);
                }

                return(destHash);
            }
        }
    public DataSet GetStorageListDataSource()
    {
        StorageList storage = new StorageList();

        System.Text.StringBuilder sql = new System.Text.StringBuilder();
        sql.Append(@"SELECT StorageNo,StorageDescription,GenerationTime FROM StorageList where 1=1 ");

        if (this.txt_StoNo.Text != string.Empty)
        {
            sql.Append(string.Format(" and StorageNo='{0}'", storage.DatabaseAccess.ConvertToDBString(this.txt_StoNo.Text)));
        }
        sql.Append(string.Format(" and convert(char(10),GenerationTime,102)>= '{0}' and convert(char(10),GenerationTime,102)<='{1}' ", this.StartDate.ToString("yyyy.MM.dd"), this.EndDate.ToString("yyyy.MM.dd")));
        sql.Append(" order by GenerationTime desc");
        return(storage.GetDateSet(sql.ToString()));
    }
Exemple #32
0
 /// <summary>
 /// 绑定值
 /// </summary>
 /// <param name="storageID"></param>
 private void BindDetails(string storageID)
 {
     if (!string.IsNullOrEmpty(storageID))
     {
         StorageList storage = new StorageList();
         DataTable   dt      = storage.GetEntityByID(storageID) as DataTable;
         if (dt != null && dt.Rows.Count > 0)
         {
             this.txt_SNo.Text         = storageID;
             this.txt_SNo.ReadOnly     = true;
             this.txt_Date.Text        = dt.Rows[0]["GenerationTime"] == null ? "" : Convert.ToDateTime(dt.Rows[0]["GenerationTime"].ToString()).ToShortDateString();
             this.txt_Description.Text = dt.Rows[0]["StorageDescription"] == null ? "" : dt.Rows[0]["StorageDescription"].ToString();
         }
     }
 }
    /// <summary>
    /// 绑定值
    /// </summary>
    /// <param name="storageID"></param>
    private void BindDetails(string storageID)
    {
        if (!string.IsNullOrEmpty(storageID))
        {
            StorageList storage = new StorageList();
            DataTable dt = storage.GetEntityByID(storageID) as DataTable;
            if (dt != null && dt.Rows.Count > 0)
            {
                this.txt_SNo.Text = storageID;
                this.txt_SNo.ReadOnly = true;
                this.txt_Date.Text = dt.Rows[0]["GenerationTime"] == null ? "" : Convert.ToDateTime(dt.Rows[0]["GenerationTime"].ToString()).ToShortDateString();
                this.txt_Description.Text = dt.Rows[0]["StorageDescription"] == null ? "" : dt.Rows[0]["StorageDescription"].ToString();

            }

        }
    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        StorageList storage = new StorageList();
        string sID=this.txt_SNo.Text==null?"":this.txt_SNo.Text.ToString();
        string description=this.txt_Description.Text==null?"":this.txt_Description.Text.ToString();
        string sql;
        if (string.IsNullOrEmpty(sid))//新增
        {
            sql=string.Format(@"insert into StorageList( StorageNo,StorageDescription,GenerationTime) values('{0}','{1}',getdate())",sID,description);
            storage.DatabaseAccess.ExecuteNonQuery(sql);
            Response.Write("<script>alert('入库单生成成功!');opener.location = opener.location;</script>");
        }
        else//修改
        {
         sql=string.Format(@"update StorageList set StorageDescription='{1}',GenerationTime=getdate() where StorageNo='{0}'",sID,description);
            storage.DatabaseAccess.ExecuteNonQuery(sql);
            Response.Write("<script>alert('入库单修改成功!');opener.location = opener.location;</script>");

        }
    }
 private void BindStorage()
 {
     StorageList storage = new StorageList();
     string sql = "select StorageNo from StorageList";
     this.ddl_StoNo.DataSource = storage.DatabaseAccess.ExecuteDataset(sql);
     this.ddl_StoNo.DataBind();
     this.ddl_StoNo.Items.Insert(0, new ListItem("----------", "-1"));
 }
Exemple #36
0
 void Start()
 {
     attributesScript = GameObject.Find("Player").GetComponent<PlayerAttributes> ();
     storageList = GameObject.Find ("StorageInventoryWeaponScroll").GetComponent<StorageList> ();
     sound = GameObject.Find ("Player").GetComponent<Sounds>();
 }