Пример #1
0
        public void Delete(Goody entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }


                using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted,
                    Timeout = new TimeSpan(2, 0, 0)
                }))
                {
                    Business.GetGoodyConvertCountingUnitBusiness().Delete(Business.GetGoodyConvertCountingUnitBusiness().GetByGoodyId(entity.ID));
                    Business.GetGoodyPriceListBusiness().Delete(Business.GetGoodyPriceListBusiness().GetByGoodyId(entity.ID).ToList());
                    this.Table.Remove(entity);
                    this.SubmitChanges();


                    scope.Complete();
                }
            }
            catch
            {
                throw;
            }
        }
Пример #2
0
        public decimal SetPrice(Guid?unitId, Goody goody, Com company)
        {
            try
            {
                if (!unitId.HasValue)
                {
                    return(0);
                }

                if (goody == null || company == null || !company.CPersonType.HasValue)
                {
                    return(0);
                }

                var priceList   = Business.GetPriceListBusiness().GetByCommodityIdCompanyPriceTypeId(company.CPriceType.Value, goody.ID);
                var coefficient = Business.GetGoodyConvertCountingUnitBusiness().FindCoefficient(goody.ID, goody.CBaseCountingUnit.ToGUID(), unitId.Value);
                if (priceList != null && priceList.PLPrice.HasValue)
                {
                    return(priceList.PLPrice.ToDecimal() * coefficient);
                }
                return(0);
            }
            catch
            {
                throw;
            }
        }
Пример #3
0
 public void Insert(Goody entity)
 {
     try
     {
         if (entity.ID == Guid.Empty)
         {
             entity.ID = Guid.NewGuid();
         }
         this.Table.Add(entity);
         this.SubmitChanges();
     }
     catch
     {
         throw;
     }
 }
Пример #4
0
 public void Save(Goody entity)
 {
     try
     {
         if (entity.ID == Guid.Empty)
         {
             entity.ID = Guid.NewGuid();
             this.Insert(entity);
         }
         else
         {
             this.SubmitChanges();
         }
     }
     catch
     {
         throw;
     }
 }
Пример #5
0
        void LoadPointValues()
        {
            //can't be too sure of what the current directory is
            Assembly ass = Assembly.GetExecutingAssembly();

            string dllDir = Path.GetDirectoryName(ass.Location);

            string filePath = Path.Combine(dllDir, "ItemPointValues.txt");

            eDebugSpew?.Invoke("Loading Config file for the queen's point values: " + filePath, null);

            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            if (fs == null)
            {
                return;
            }

            StreamReader sr = new StreamReader(fs);

            if (sr == null)
            {
                return;
            }

            while (!sr.EndOfStream)
            {
                string line = sr.ReadLine();

                string  [] toks = line.Split(' ', '\t');

//				eDebugSpew?.Invoke("Got " + toks.Length + " tokenses for line " + line, null);

                if (toks.Length < 3)
                {
                    //bad line
                    eDebugSpew?.Invoke("Bad line in point config file at position: " + sr.BaseStream.Position, null);
                    continue;
                }

                //skip whitespace
                int idx = 0;
                while (idx < toks.Length)
                {
                    if (toks[idx] == "" || toks[idx] == " " || toks[idx] == "\t")
                    {
                        idx++;
                        continue;
                    }
                    break;
                }

                if (toks[idx].StartsWith("//"))
                {
                    continue;
                }

                Goody good = new Goody();

                if (!int.TryParse(toks[idx], out good.mID))
                {
                    eDebugSpew?.Invoke("Bad token looking for item id in point config file at position: " + sr.BaseStream.Position, null);
                    continue;
                }

                idx++;

                while (idx < toks.Length)
                {
                    if (toks[idx] == "" || toks[idx] == " " || toks[idx] == "\t")
                    {
                        idx++;
                        continue;
                    }
                    break;
                }

                //this one should be in quotes
                if (toks[idx][0] != '\"')
                {
                    eDebugSpew?.Invoke("Expecting \" looking for item name, got " + toks[idx] + " in point config file at position: " + sr.BaseStream.Position, null);
                    continue;
                }

                //one word?
                if (toks[idx].EndsWith("\""))
                {
                    good.mName = toks[idx].Substring(1, toks[idx].Length - 2);
                    idx++;
                }
                else
                {
                    //tokens ahead will have the end quote
                    good.mName  = toks[idx].Substring(1, toks[idx].Length - 1);
                    good.mName += " ";                          //spaces are chopped out

                    idx++;
                    //tack on tokens till the trailing " is hit
                    while (idx < toks.Length)
                    {
                        if (toks[idx].EndsWith("\""))
                        {
                            //found the trailing quote
                            good.mName += toks[idx].Substring(0, toks[idx].Length - 1);
                            idx++;
                            break;
                        }

                        good.mName += toks[idx];
                        idx++;
                    }
                }

                while (idx < toks.Length)
                {
                    if (toks[idx] == "" || toks[idx] == " " || toks[idx] == "\t")
                    {
                        idx++;
                        continue;
                    }
                    break;
                }

                if (!int.TryParse(toks[idx], out good.mValue))
                {
                    eDebugSpew?.Invoke("Bad token looking for value in point config file at position: " + sr.BaseStream.Position, null);
                    continue;
                }

                mWantedItemsValue.Add(good.mID, good);
            }

            sr.Close();
            fs.Close();

            //print goodies desired if there's a problem
//			foreach(KeyValuePair<int, Goody> goods in mWantedItemsValue)
//			{
//				eDebugSpew?.Invoke("Goody: " + goods.Value.mID + ", " + goods.Value.mName + ", " + goods.Value.mValue);
//			}
        }