예제 #1
0
        public void AddScrap(long historyId, ScrapItem item)
        {
            ReturnedHistory parentHistory = _context.ReturnedHistories.FirstOrDefault(h => h.Id == historyId);

            parentHistory.ScrapItems.Add(item);
            SaveChanges("AddScrap");
        }
예제 #2
0
        public void DeleteScrapItem(long itemId)
        {
            ScrapItem itemToRemove = _context.ScrapItems.FirstOrDefault(i => i.Id == itemId);

            _context.ScrapItems.Remove(itemToRemove);
            SaveChanges("DeleteScrapItem");
        }
예제 #3
0
        private ScrapItem GetScrapItemInListView()
        {
            long      itemId = Convert.ToInt32(scrapListView.SelectedItems[0].SubItems[0].Text);
            ScrapItem item   = _scrapItems.FirstOrDefault(d => d.Item.Id == itemId);

            return(item);
        }
예제 #4
0
 private void ScrapItem()
 {
     if (_selectedItemForScrap != null)
     {
         if (IsItemAlreadyIncluded(scrapListView, _selectedItemForScrap.Id))
         {
             MessageBox.Show("Item already in the scrap list!",
                             "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else if (txtScrapQty.Text == "0" || string.IsNullOrWhiteSpace(txtScrapQty.Text))
         {
             MessageBox.Show("Please provide Quantity!",
                             "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else if (IsInputIsGreaterThanCurrentQty(txtScrapQty, lblScrapQty))
         {
             MessageBox.Show("In should not be greated than DR stocks!",
                             "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             ScrapItem item = MakeScrapItem();
             AddToScrapAndMakeHistory(item);
             AddToListView(true, null, item);
             SetDefaultUIForScrap();
             _selectedItemForScrap = null;
         }
     }
     else
     {
         MessageBox.Show("Please select item!",
                         "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
 public void SetupSC(GameManager gm, Player player, ScrapItem inItem)
 {
     this.gm     = gm;
     this.player = player;
     item        = inItem;
     itemName    = inItem.name;
     sr.sprite   = item.GetSprite();
 }
예제 #6
0
        private ScrapItem MakeScrapItem()
        {
            ScrapItem i = new ScrapItem();

            i.Item = _selectedItemForScrap;
            i.Qty  = Convert.ToDouble(txtScrapQty.Text);

            return(i);
        }
예제 #7
0
        private void AddToScrapAndMakeHistory(ScrapItem scrap)
        {
            ScrapItem sI = new ScrapItem();

            sI.Item            = scrap.Item;
            sI.ReturnedHistory = _history;
            sI.Qty             = Convert.ToDouble(scrap.Qty);
            sI.DateAdded       = DateTime.Now;

            ScrapInOutParam p = new ScrapInOutParam();

            p.Scrap   = sI;
            p.InOrOut = InOrOut.In;

            _inOutService.InOutScrapItems(p);
        }
        private void AggregateData()
        {
            foreach (IItem item in PawnItems)
            {
                bool isGold = false;
                if (item is ScrapItem)
                {
                    ScrapItem scrap = item as ScrapItem;
                    if (_listGoldTypes.Contains(scrap.TypeOfMetal))
                    {
                        isGold = true;
                    }
                    // Have we added this type of ScrapItem to _aggData yet?
                    var results = from a in _aggData
                                  where a.IsGold == isGold &&
                                  a.TypeOfMetal == scrap.TypeOfMetal &&
                                  a.ApproximateKarats == (scrap.ApproximateKarats + "K")
                                  select a;

                    AggScrapItemInfo info;
                    if (results.Any())
                    {
                        // Increment existing _aggData Cost and Weight values.
                        info         = results.First();
                        info.Cost   += scrap.ItemAmount;
                        info.Weight += Convert.ToDecimal(scrap.ApproximateWeight);
                    }
                    else
                    {
                        // Add ScrapItem to _aggData since not added yet.
                        info                   = new AggScrapItemInfo();
                        info.IsGold            = isGold;
                        info.TypeOfMetal       = scrap.TypeOfMetal;
                        info.ApproximateKarats = scrap.ApproximateKarats + "K";
                        info.Weight            = Convert.ToDecimal(scrap.ApproximateWeight);
                        info.Cost              = scrap.ItemAmount;
                        _aggData.Add(info);
                    }
                } //end if (item is ScrapItem)
            }     //end foreach (PawnItems)
        }
예제 #9
0
        private void AddToListView(bool isScrap, ReturnedItem goodItem, ScrapItem scrapItem)
        {
            string[] arr = new string[3];

            if (isScrap)
            {
                arr[0] = Convert.ToString(scrapItem.Item.Id);
                arr[1] = scrapItem.Item.Name;
                arr[2] = Convert.ToString(scrapItem.Qty);
                ListViewItem lit = new ListViewItem(arr);
                scrapListView.Items.Add(lit);
            }
            else
            {
                arr[0] = Convert.ToString(goodItem.Item.Id);
                arr[1] = goodItem.Item.Name;
                arr[2] = Convert.ToString(goodItem.Qty);
                ListViewItem lit = new ListViewItem(arr);
                goodListView.Items.Add(lit);
            }
        }
예제 #10
0
        public static List <IItem> GetJsupItemsByStore(DesktopSession dSession, string pStoreNumber, string pTransferType, out string errorMessage)
        {
            // Declare OUT parameters.
            DataTable table     = new DataTable();
            DataTable tableDesc = new DataTable();
            string    errorCode;
            string    errorText;

            errorMessage = string.Empty;

            List <IItem> items = new List <IItem>();

            bool retVal =
                TransfersDBProcedures.ExecuteGetJsupMerchandise(
                    pStoreNumber, pTransferType,
                    out table, out tableDesc, out errorCode, out errorText);

            if (retVal == false || table == null || string.IsNullOrEmpty(errorText) == false)
            {
                errorMessage = errorCode + ": " + errorText;
                FileLogger.Instance.logMessage(LogLevel.ERROR, null, errorMessage);
                return(items);
            }

            IItem item = new Item(); //re-instantiated and re-used in each loop iteration

            foreach (DataRow r in table.Rows)
            {
                if (pTransferType.Equals("SCRAP", StringComparison.CurrentCultureIgnoreCase))
                {
                    item = new ScrapItem();
                }
                else if (pTransferType.Equals("REFURB", StringComparison.CurrentCultureIgnoreCase))
                {
                    //item = new Item();
                    item = new ScrapItem();
                }
                else if (pTransferType.Equals("EXCESS", StringComparison.CurrentCultureIgnoreCase))
                {
                    // item = new Item();
                    item = new ScrapItem();
                }
                //else handled by TransfersDBProcedures's call above returning false with errorCode and errorText having been set

                int    icndocFromRow      = Utilities.GetIntegerValue(r["ICN_DOC"], -1);
                string storeNumberFromRow = Utilities.GetStringValue(r["STORENUMBER"], "");

                item.RefurbNumber      = Utilities.GetIntegerValue(r["RFB_NO"]);
                item.Icn               = Utilities.GetStringValue(r["ICN"]);
                item.TicketDescription = Utilities.GetStringValue(r["MD_DESC"]);
                item.ItemAmount        = Utilities.GetDecimalValue(r["PFI_AMOUNT"]);

                item.ItemStatus          = (ProductStatus)Enum.Parse(typeof(ProductStatus), Utilities.GetStringValue(r["STATUS_CD"], ""));
                item.mDocType            = Utilities.GetStringValue(r["ICN_DOC_TYPE"]);
                item.mStore              = Utilities.GetIntegerValue(r["ICN_STORE"]);
                item.CategoryCode        = Utilities.GetIntegerValue(r["CAT_CODE"], 0);
                item.CategoryDescription = Utilities.GetStringValue(r["CAT_DESC"], "");
                item.mItemOrder          = Utilities.GetIntegerValue(r["ICN_ITEM"]);
                item.CaccLevel           = Utilities.GetIntegerValue(r["CACC_LEV"], -1);

                item.Attributes = new List <ItemAttribute>();

                //Used to get the attributes of the item.
                //This will be helpful later, such as determining the type of metal for scraps.
                for (int iMask = 1; iMask <= 15; iMask++)
                {
                    ItemAttribute itemAttribute = new ItemAttribute();

                    if (Utilities.GetIntegerValue(r["MASK" + iMask.ToString()], 0) > 0)
                    {
                        itemAttribute.MaskOrder = iMask;

                        Answer answer = new Answer();
                        answer.AnswerCode = Utilities.GetIntegerValue(r["MASK" + iMask.ToString()], 0);
                        answer.AnswerText = Utilities.GetStringValue(r["MASK_DESC" + iMask.ToString()], "");

                        // Pull from Other Description List Table
                        if (tableDesc != null && answer.AnswerCode == 999)
                        {
                            string sOtherDscFilter = "STORENUMBER = '" + storeNumberFromRow + "'";
                            sOtherDscFilter += " and ICN_STORE = " + item.mStore.ToString();
                            sOtherDscFilter += " and ICN_YEAR = " + item.mYear.ToString();
                            sOtherDscFilter += " and ICN_DOC = '" + icndocFromRow + "' ";
                            sOtherDscFilter += " and ICN_DOC_TYPE = " + item.mDocType;
                            sOtherDscFilter += " and ICN_ITEM = " + item.mItemOrder;
                            sOtherDscFilter += " and ICN_SUB_ITEM = 0";
                            sOtherDscFilter += " and MASK_SEQ = " + iMask.ToString();

                            DataRow[] dataOtherDScRows = tableDesc.Select(sOtherDscFilter);
                            if (dataOtherDScRows.Length > 0)
                            {
                                answer.AnswerCode = 999;
                                answer.AnswerText = Utilities.GetStringValue(dataOtherDScRows[0]["OD_DESC"], "");
                            }
                            else
                            {
                                answer.AnswerCode = 0;
                                answer.AnswerText = "";
                            }
                        }
                        itemAttribute.Answer = answer;
                    }
                    if (itemAttribute.Answer.AnswerCode == 999 || itemAttribute.Answer.AnswerCode > 0)
                    {
                        item.Attributes.Add(itemAttribute);
                    }
                }

                //Set item attributes
                int iCategoryMask = dSession.CategoryXML.GetCategoryMask(item.CategoryCode);
                DescribedMerchandise dmPawnItem = new DescribedMerchandise(iCategoryMask);

                Item pawnItem = (Item)item;
                Item.PawnItemMerge(ref pawnItem, dmPawnItem.SelectedPawnItem, true);

                //Should copy the description, etc. over to the item.
                PropertyInfo[] fromFields = typeof(Item).GetProperties();
                PropertyInfo[] toFields   = //typeof(ScrapItem).GetProperties();
                                            item.GetType().GetProperties();
                PropertyHandler.SetProperties(fromFields, toFields, pawnItem, item);

                //Does not merge well.
                item.Quantity = Utilities.GetIntegerValue(r["QUANTITY"]);

                if (item is ScrapItem)
                {
                    //Wait to add scrap items until after merge.
                    ((ScrapItem)item).StoreNumber  = storeNumberFromRow;
                    ((ScrapItem)item).TicketNumber = icndocFromRow;
                }

                items.Add(item);
            }

            return(items);
        }