private void loadAllItemsToView() { try { addStockTransfer.grid_itemFinder.IsEnabled = false; addStockTransfer.button_saveTransfer.IsEnabled = false; addStockTransfer.button_addItem.IsEnabled = false; addStockTransfer.dataGrid.IsEnabled = false; StockTransfer stockTransfer = getStockTransferById(addStockTransfer.SelectedStockTransferID); if (stockTransfer != null) { addStockTransfer.comboBox_from_selectStock.SelectedValue = stockTransfer.FromLocationId; addStockTransfer.comboBox_to_selectStock.SelectedValue = stockTransfer.ToLocationId; addStockTransfer.datePicker_date_selectStock.SelectedDate = stockTransfer.Date; addStockTransfer.textBox_carrierName_selectStock.Text = stockTransfer.Carrier; addStockTransfer.textBox_details_selectStock.Text = stockTransfer.Details; StockTransferItem sti = new StockTransferItem(); sti.StockTransferId = stockTransfer.Id; List <StockTransferItem> list = getTransferItem(sti); foreach (StockTransferItem stockTransferItem in list) { Item item = itemManagerImpl.getItemById(stockTransferItem.ItemId); addStockTransfer.DataTable.Rows.Add(stockTransferItem.Id, item.Name + " (" + companyManagerImpl.getCompanyNameById(item.CompanyId) + ")", stockTransferItem.Quantity); } } } catch (Exception) { } }
internal void loadPricesForItemId() { try { sellingPriceManager.DataTableUnitPrice.Rows.Clear(); sellingPriceManager.DataTablePackPrice.Rows.Clear(); Item item = itemManagerImpl.getItemById(sellingPriceManager.textBox_selectedItemId.IntValue); sellingPriceManager.SelectedItemId = item.Id; sellingPriceManager.label_selectedItem.Content = companyManagerImpl.getCompanyNameById(item.CompanyId) + ", " + item.Name + " " + categoryManagerImpl.getCategoryNameById(item.CategoryId); List <SellingPrice> list = getSellingPriceByItemId(sellingPriceManager.textBox_selectedItemId.IntValue); DataRow dataRow = null; foreach (SellingPrice sellingPrice in list) { if (sellingPrice.Mode == "u") { dataRow = sellingPriceManager.DataTableUnitPrice.NewRow(); sellingPriceManager.DataTableUnitPrice.Rows.Add(dataRow); } else { dataRow = sellingPriceManager.DataTablePackPrice.NewRow(); sellingPriceManager.DataTablePackPrice.Rows.Add(dataRow); } dataRow[0] = sellingPrice.Id; dataRow[1] = sellingPrice.Price.ToString("#,##0.00"); } } catch (Exception) { } }
internal void selectItemById() { try { addCompanyReturn.SelectedItem = itemManagerImpl.getItemById(addCompanyReturn.textBox_itemId.IntValue); addCompanyReturn.label_itemName.Content = addCompanyReturn.SelectedItem.Name; addCompanyReturn.textBox_price.DoubleValue = buyingInvoiceManagerImpl.getLatestBuyingPriceByItemId(addCompanyReturn.SelectedItem.Id, "u"); //addCompanyReturn.textBox_price.DoubleValue = sellingPriceManagerImpl.getSellingPriceByItemAndMode(addCompanyReturn.SelectedItem.Id, "u")[0].Price; addCompanyReturn.textBox_quantity.Focus(); } catch (Exception) { } }
internal void loadDiscountsForItemId() { try { discountManager.DataTableUnitDiscount.Rows.Clear(); discountManager.DataTablePackDiscount.Rows.Clear(); Item item = itemManagerImpl.getItemById(discountManager.textBox_selectedItemId.IntValue); discountManager.label_selectedItem.Content = companyManagerImpl.getCompanyNameById(item.CompanyId) + ", " + item.Name + " " + categoryManagerImpl.getCategoryNameById(item.CategoryId); List <Discount> list = getDiscountsByItemId(discountManager.textBox_selectedItemId.IntValue); DataRow dataRow = null; foreach (Discount discount in list) { if (discount.Mode == "u") { dataRow = discountManager.DataTableUnitDiscount.NewRow(); discountManager.DataTableUnitDiscount.Rows.Add(dataRow); } else { dataRow = discountManager.DataTablePackDiscount.NewRow(); discountManager.DataTablePackDiscount.Rows.Add(dataRow); } dataRow[0] = discount.Id; dataRow[1] = discount.Quantity.ToString("#,##0.00"); dataRow[2] = discount.Value.ToString(); } if (item.Sip == 0) { discountManager.groupBox_packDiscounts.IsEnabled = false; } else { discountManager.groupBox_packDiscounts.IsEnabled = true; } } catch (Exception) { } }
private double calculateValue(int theItemId, double theStockQuantity) { double returnValue = 0; try { Item item = itemManagerImpl.getItemById(theItemId); BuyingItem buyingItem_request = new BuyingItem(); buyingItem_request.ItemId = theItemId; buyingItem_request.OrderBy = "modified_date DESC"; buyingItem_request.LimitStart = 0; buyingItem_request.LimitEnd = 10; List <BuyingItem> list_buyingItem = buyingInvoiceManagerImpl.getItem(buyingItem_request); double itemsLeftForCalculating = theStockQuantity; double lastBuyingPrice = 0; String m = item.DefaultBuyingMode; double lastBPrice = 1; double quantity = 0; foreach (BuyingItem buyingItem_a in list_buyingItem) { lastBuyingPrice = buyingItem_a.BuyingPriceActual; m = buyingItem_a.BuyingMode; lastBPrice = buyingItem_a.BuyingPriceActual; quantity = buyingItem_a.BuyingMode == "p" ? (buyingItem_a.Quantity + buyingItem_a.FreeQuantity) * item.QuantityPerPack : (buyingItem_a.Quantity + buyingItem_a.FreeQuantity); if (itemsLeftForCalculating > 0) { if (itemsLeftForCalculating < (quantity)) { if (buyingItem_a.BuyingMode == "u") { returnValue += itemsLeftForCalculating * buyingItem_a.BuyingPriceActual; } else { returnValue += itemsLeftForCalculating * (buyingItem_a.BuyingPriceActual / item.QuantityPerPack); } itemsLeftForCalculating = 0; } else { returnValue += (buyingItem_a.Quantity + buyingItem_a.FreeQuantity) * buyingItem_a.BuyingPriceActual; itemsLeftForCalculating -= (quantity); } } } if (itemsLeftForCalculating > 0) { if (m == "u") { returnValue += lastBuyingPrice * itemsLeftForCalculating; } else { returnValue += itemsLeftForCalculating * (lastBuyingPrice / item.QuantityPerPack); //returnValue += lastBuyingPrice * itemsLeftForCalculating; //returnValue += (lastBuyingPrice * lastBPrice) * itemsLeftForCalculating; } } } catch (Exception) { } return(returnValue); }