예제 #1
0
            private static void LoadItemInfo(ProcessMaskSegmentsServiceRequest serviceRequest, Barcode barcode, int position, BarcodeMaskSegment segment)
            {
                if (barcode.ItemBarcode != null && !string.IsNullOrWhiteSpace(barcode.ItemBarcode.ItemId))
                {
                    // Skip item barcode lookup if it is already set.
                    return;
                }

                string barcodeText = serviceRequest.Barcode.BarcodeId.Substring(0, position + segment.Length);

                barcodeText += '%';

                GetProductBarcodeDataRequest dataRequest = new GetProductBarcodeDataRequest(barcodeText);
                ItemBarcode itemBarcode = serviceRequest.RequestContext.Runtime.Execute <GetProductBarcodeDataResponse>(dataRequest, serviceRequest.RequestContext).Barcode;

                if (itemBarcode == null)
                {
                    barcodeText  = barcodeText.Substring(0, barcodeText.Length - 1);
                    barcodeText += Convert.ToString(CalculateCheckDigit(barcodeText), CultureInfo.CurrentCulture);

                    dataRequest = new GetProductBarcodeDataRequest(barcodeText);
                    itemBarcode = serviceRequest.RequestContext.Runtime.Execute <GetProductBarcodeDataResponse>(dataRequest, serviceRequest.RequestContext).Barcode;
                }

                if (itemBarcode != null)
                {
                    barcode.ItemBarcode   = itemBarcode;
                    barcode.Mask.MaskType = BarcodeMaskType.Item;
                }
            }
예제 #2
0
 public static ItemBarcode GetItemBarcodeByID(int id)
 {
     ItemBarcode itemBarcode = new ItemBarcode();
     SqlItemBarcodeProvider sqlItemBarcodeProvider = new SqlItemBarcodeProvider();
     itemBarcode = sqlItemBarcodeProvider.GetItemBarcodeByID(id);
     return itemBarcode;
 }
예제 #3
0
    private void showItemBarcodeData()
    {
        ItemBarcode itemBarcode = new ItemBarcode();
        itemBarcode = ItemBarcodeManager.GetItemBarcodeByID(Int32.Parse(Request.QueryString["itemBarcodeID"]));

        lblSubCategory.Text = itemBarcode.IteamDetails;
        txtNoOfItem.Text = itemBarcode.NoOfItem.ToString();
        txtBarcodeText.Text = itemBarcode.BarcodeText;
    }
예제 #4
0
            /// <summary>
            /// Executes the workflow for a get price check for a product.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The response.</returns>
            protected override PriceCheckResponse Process(PriceCheckRequest request)
            {
                ThrowIf.Null(request, "request");

                ItemBarcode itemBarcode = null;

                if (string.IsNullOrEmpty(request.Barcode) && string.IsNullOrEmpty(request.ItemId))
                {
                    throw new DataValidationException(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_ItemIdBarcodeMissing, "Either an item identifier or barcode is required.");
                }

                if (string.IsNullOrEmpty(request.ItemId))
                {
                    GetProductBarcodeDataRequest dataRequest = new GetProductBarcodeDataRequest(request.Barcode);
                    itemBarcode = this.Context.Runtime.Execute <GetProductBarcodeDataResponse>(dataRequest, this.Context).Barcode;
                }

                SalesTransaction salesTransaction = new SalesTransaction()
                {
                    Id         = Guid.NewGuid().ToString(),
                    CustomerId = request.CustomerAccountNumber,
                };

                SalesLine salesLine = new SalesLine()
                {
                    ItemId = request.ItemId,
                    InventoryDimensionId    = request.InventoryDimensionId ?? itemBarcode.InventoryDimensionId,
                    SalesOrderUnitOfMeasure = request.UnitOfMeasureSymbol ?? itemBarcode.UnitId,
                    Quantity = 1m,
                    LineId   = Guid.NewGuid().ToString()
                };

                salesTransaction.SalesLines.Add(salesLine);

                GetIndependentPriceDiscountServiceRequest priceRequest = new GetIndependentPriceDiscountServiceRequest(salesTransaction);

                GetPriceServiceResponse pricingServiceResponse = this.Context.Execute <GetPriceServiceResponse>(priceRequest);

                SalesLine resultLine = pricingServiceResponse.Transaction.SalesLines[0];

                ProductPrice productPrice = GetProductPrice(
                    resultLine.ItemId,
                    resultLine.InventoryDimensionId,
                    resultLine.BasePrice,
                    resultLine.TotalAmount,
                    this.Context.GetChannelConfiguration().Currency);

                var productPrices = new List <ProductPrice> {
                    productPrice
                };

                return(new PriceCheckResponse(productPrices.AsPagedResult()));
            }
예제 #5
0
            /// <summary>
            /// Barcode workflow handler to process the incoming workflow requests.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The response.</returns>
            protected override GetBarcodeResponse Process(GetBarcodeRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.ScanInfo, "request.ScanInfo");
                ThrowIf.NullOrWhiteSpace(request.ScanInfo.ScannedText, "request.ScanInfo.ScanDataLabel");

                string      barcodeId   = request.ScanInfo.ScannedText;
                ItemBarcode itemBarcode = GetItemBarcode(request.RequestContext, barcodeId);
                BarcodeMask barcodeMask = GetBarcodeTypeFromMask(request.RequestContext, barcodeId);

                Barcode barcode = new Barcode();

                if (itemBarcode == null)
                {
                    if (barcodeMask == null)
                    {
                        return(new GetBarcodeResponse());
                    }
                }
                else
                {
                    barcode.ItemBarcode = itemBarcode;
                }

                if (barcodeMask != null)
                {
                    barcode.Mask = barcodeMask;
                }
                else
                {
                    barcode.Mask.MaskType = BarcodeMaskType.Item;
                }

                barcode.BarcodeId       = barcodeId;
                barcode.TimeStarted     = DateTime.UtcNow;
                barcode.EntryMethodType = request.ScanInfo.EntryMethodType;

                if (barcodeMask != null)
                {
                    barcode = ProcessBarcodeMask(request.RequestContext, barcode, barcodeMask);
                }

                return(new GetBarcodeResponse(barcode));
            }
예제 #6
0
    public ItemBarcode GetItemBarcodeFromReader(IDataReader reader)
    {
        try
        {
            ItemBarcode itemBarcode = new ItemBarcode
                (
                    (int)reader["ItemBarcodeID"],
                    (int)reader["SubCategoryID"],
                    (int)reader["NoOfItem"],
                    reader["BarcodeText"].ToString(),
                    (DateTime)reader["AddedDate"]
                );

            try {
                itemBarcode.IteamDetails = reader["IteamCategoryName"].ToString() + " --> " + reader["IteamSubCategoryName"].ToString();
            }
            catch (Exception ex) { }
             return itemBarcode;
        }
        catch(Exception ex)
        {
            return null;
        }
    }
예제 #7
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            int SubCategory = 0;
            string categoryName = "";
            string SubCategoryName = "";

            if (txtCategory.Text != "")
            {
                INV_IteamCategory iNV_IteamCategory = new INV_IteamCategory();
                //	iNV_IteamCategory.IteamCategoryID=  int.Parse(ddlIteamCategoryID.SelectedValue);
                iNV_IteamCategory.IteamCategoryName = txtCategory.Text;
                iNV_IteamCategory.AddedBy = Profile.card_id;
                iNV_IteamCategory.AddedDate = DateTime.Now;
                iNV_IteamCategory.UpdatedBy = Profile.card_id;
                iNV_IteamCategory.UpdatedDate = DateTime.Now;
                int categoryID = INV_IteamCategoryManager.InsertINV_IteamCategory(iNV_IteamCategory);
                categoryName = txtCategory.Text;

                INV_IteamSubCategory iNV_IteamSubCategory = new INV_IteamSubCategory();
                //	iNV_IteamSubCategory.IteamSubCategoryID=  int.Parse(ddlIteamSubCategoryID.SelectedValue);
                iNV_IteamSubCategory.IteamSubCategoryName = txtSubCategory.Text;
                iNV_IteamSubCategory.IteamCategoryID = categoryID;
                iNV_IteamSubCategory.AddedBy = Profile.card_id;
                iNV_IteamSubCategory.AddedDate = DateTime.Now;
                iNV_IteamSubCategory.UpdatedBy = Profile.card_id;
                iNV_IteamSubCategory.UpdatedDate = DateTime.Now;
                SubCategory = INV_IteamSubCategoryManager.InsertINV_IteamSubCategory(iNV_IteamSubCategory);

                SubCategoryName = txtSubCategory.Text;
            }
            else if (txtSubCategory.Text != "")
            {
                INV_IteamSubCategory iNV_IteamSubCategory = new INV_IteamSubCategory();
                //	iNV_IteamSubCategory.IteamSubCategoryID=  int.Parse(ddlIteamSubCategoryID.SelectedValue);
                iNV_IteamSubCategory.IteamSubCategoryName = txtSubCategory.Text;
                iNV_IteamSubCategory.IteamCategoryID = int.Parse(ddlIteamCategoryID.SelectedValue);
                iNV_IteamSubCategory.AddedBy = Profile.card_id;
                iNV_IteamSubCategory.AddedDate = DateTime.Now;
                iNV_IteamSubCategory.UpdatedBy = Profile.card_id;
                iNV_IteamSubCategory.UpdatedDate = DateTime.Now;
                SubCategory = INV_IteamSubCategoryManager.InsertINV_IteamSubCategory(iNV_IteamSubCategory);

                categoryName = ddlIteamCategoryID.SelectedItem.Text;
                SubCategoryName = txtSubCategory.Text;
            }
            else
            {
                SubCategory = int.Parse(ddlIteamSubCategoryID.SelectedValue);
                categoryName = ddlIteamCategoryID.SelectedItem.Text;
                SubCategoryName = ddlIteamSubCategoryID.SelectedItem.Text;
            }

            string barcodes = categoryName + "  --->  " + SubCategoryName + "<br/><br/>" + "<table><tr>";
            int remaining = 5;
            for (int i = 0; i < int.Parse(txtNoOfItems.Text.Trim()); i++)
            {

                INV_Iteam iNV_Iteam = new INV_Iteam();
                //	iNV_Iteam.IteamID=  int.Parse(ddlIteamID.SelectedValue);
                iNV_Iteam.CampusID =  int.Parse(ddlCampusID.SelectedValue);
                iNV_Iteam.IteamCode = txtIteamCode.Text;
                iNV_Iteam.Description = txtDescription.Text;
                iNV_Iteam.IteamSubCategoryID = SubCategory;
                iNV_Iteam.Price = decimal.Parse(txtPrice.Text);
                iNV_Iteam.Quantity = decimal.Parse(txtQuantity.Text);
                iNV_Iteam.Unit = txtUnit.Text;
                iNV_Iteam.AddedBy = Profile.card_id;
                iNV_Iteam.AddedDate = DateTime.Now;
                iNV_Iteam.UpdatedBy = Profile.card_id;
                iNV_Iteam.UpdatedDate = DateTime.Now;
                int resutl = INV_IteamManager.InsertINV_Iteam(iNV_Iteam);

                if (i % 5 == 0)
                {
                    barcodes += "</tr><tr>";
                    remaining = 4;
                }
                else
                {
                    remaining--;
                }

                barcodes += "<td><div style='overflow:hidden;margin-left:-12px;width:157px; height:30px;margin-top: 28px;'><img style='margin-top:-30px' src='http://www.bcgen.com/demo/linear-dbgs.aspx?D=";
                barcodes+=resutl.ToString()+"'/></div></td>";
            }

            for (int i = 0; i < remaining; i++)
            {
                barcodes += "<td></td>";
            }
            barcodes += "</tr></table>";

            lblBarCode.Text = barcodes;

            ItemBarcode itemBarcode = new ItemBarcode();

            itemBarcode.SubCategoryID = SubCategory;
            itemBarcode.NoOfItem = Int32.Parse(txtNoOfItems.Text);
            itemBarcode.BarcodeText = barcodes;
            itemBarcode.AddedDate = DateTime.Now;
            int result = ItemBarcodeManager.InsertItemBarcode(itemBarcode);
        }
        catch (Exception ex) { }

        //Response.Redirect("AdminDisplayINV_Iteam.aspx");
    }
예제 #8
0
 public static bool UpdateItemBarcode(ItemBarcode itemBarcode)
 {
     SqlItemBarcodeProvider sqlItemBarcodeProvider = new SqlItemBarcodeProvider();
     return sqlItemBarcodeProvider.UpdateItemBarcode(itemBarcode);
 }
예제 #9
0
 public static int InsertItemBarcode(ItemBarcode itemBarcode)
 {
     SqlItemBarcodeProvider sqlItemBarcodeProvider = new SqlItemBarcodeProvider();
     return sqlItemBarcodeProvider.InsertItemBarcode(itemBarcode);
 }
예제 #10
0
            private static GetProductBarcodeDataResponse GetProductBarcodeData(GetProductBarcodeDataRequest request)
            {
                string         barcode = request.Barcode;
                RequestContext context = request.RequestContext;

                ThrowIf.Null(barcode, "barcode");
                ThrowIf.Null(context, "context");
                ColumnSet columns = request.QueryResultSettings != null ? request.QueryResultSettings.ColumnSet : new ColumnSet();

                ItemL2CacheDataStoreAccessor level2CacheDataAccessor = GetCacheAccessor(request.RequestContext);

                bool        found;
                bool        updateL2Cache;
                ItemBarcode result = DataManager.GetDataFromCache(() => level2CacheDataAccessor.GetItemsByBarcode(barcode, columns), out found, out updateL2Cache);

                if (!found)
                {
                    var query = new SqlPagedQuery(QueryResultSettings.AllRecords)
                    {
                        Select = columns,
                        From   = BarcodesViewName,
                        Where  = string.Format("{0} LIKE {1} AND {2} = {3}", ItemBarcodeColumnName, ItemBarcodeVariableName, DataAreaIdColumnName, DataAreaIdVariableName),
                    };

                    query.Parameters[ItemBarcodeVariableName] = barcode;
                    query.Parameters[DataAreaIdVariableName]  = context.GetChannelConfiguration().InventLocationDataAreaId;

                    IEnumerable <ItemBarcode> itemBarcodes;
                    using (DatabaseContext databaseContext = new DatabaseContext(context))
                    {
                        itemBarcodes = databaseContext.ReadEntity <ItemBarcode>(query).Results;
                    }

                    // If the barcode matches with more than one variant, then we should set the variant details to null/ empty.
                    // When this scenario occurs, the client should pop up new dialog to get the variant details.
                    if (itemBarcodes.Count() > 1)
                    {
                        ItemBarcode itemBarcode = itemBarcodes.FirstOrDefault();

                        if (itemBarcode != null)
                        {
                            itemBarcode.SetVariantDetailsToEmpty();

                            result = itemBarcode;
                        }
                    }
                    else
                    {
                        using (DatabaseContext databaseContext = new DatabaseContext(context))
                        {
                            result = databaseContext.ReadEntity <ItemBarcode>(query).SingleOrDefault();
                        }
                    }

                    updateL2Cache &= result != null;
                }

                if (updateL2Cache)
                {
                    level2CacheDataAccessor.PutItemsByBarcode(barcode, columns, result);
                }

                return(new GetProductBarcodeDataResponse(result));
            }
            /// <summary>
            /// Executes the workflow for a get nearby stores with availability.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The response.</returns>
            protected override GetStoreProductAvailabilityResponse Process(GetStoreProductAvailabilityRequest request)
            {
                ThrowIf.Null(request, "request");

                string variantId = request.VariantId;

                if (request.Items == null || !request.Items.Any())
                {
                    if (string.IsNullOrWhiteSpace(request.ItemId) && string.IsNullOrWhiteSpace(request.Barcode))
                    {
                        throw new DataValidationException(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_ItemIdBarcodeMissing, "Please specify either an item id or a barcode.");
                    }

                    List <string> itemIds = new List <string>(1);
                    if (!string.IsNullOrWhiteSpace(request.Barcode))
                    {
                        GetProductBarcodeDataRequest dataRequest = new GetProductBarcodeDataRequest(request.Barcode)
                        {
                            QueryResultSettings = new QueryResultSettings(new ColumnSet("ITEMID"), PagingInfo.AllRecords)
                        };
                        ItemBarcode itemBarcode = this.Context.Runtime.Execute <GetProductBarcodeDataResponse>(dataRequest, this.Context).Barcode;

                        if (itemBarcode == null)
                        {
                            throw new DataValidationException(
                                      DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_BarcodeNotFound,
                                      string.Format("The specified barcode ({0}) was not found.", request.Barcode));
                        }

                        itemIds.Add(itemBarcode.ItemId);
                        variantId = itemBarcode.VariantId;
                    }
                    else
                    {
                        itemIds.Add(request.ItemId);
                    }

                    var getItemsRequest = new GetItemsDataRequest(itemIds)
                    {
                        QueryResultSettings = new QueryResultSettings(new ColumnSet("INVENTUNITID"), PagingInfo.AllRecords)
                    };
                    var getItemsResponse = request.RequestContext.Runtime.Execute <GetItemsDataResponse>(getItemsRequest, request.RequestContext);

                    ReadOnlyCollection <Item> items = getItemsResponse.Items;
                    if (items == null || items.Count == 0)
                    {
                        throw new DataValidationException(
                                  DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_ObjectNotFound,
                                  string.Format("No items were found for the specified item identifiers ({0}).", string.Join(", ", itemIds)));
                    }

                    if (items.Count > 1)
                    {
                        throw new DataValidationException(
                                  DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_DuplicateObject,
                                  string.Format("More than one item was found for the specified item identifiers ({0}).", string.Join(", ", itemIds)));
                    }

                    var getStoresRequest = new GetStoresDataRequest(this.Context.GetPrincipal().ChannelId, request.SearchArea, QueryResultSettings.AllRecords);
                    ReadOnlyCollection <OrgUnitLocation> storeLocations = this.Context.Execute <EntityDataServiceResponse <OrgUnitLocation> >(getStoresRequest).PagedEntityCollection.Results;

                    var productAvailabilityRequest  = new Services.GetStoreAvailabilityServiceRequest(items[0].ItemId, variantId ?? string.Empty);
                    var productAvailabilityResponse = this.Context.Execute <Services.GetStoreAvailabilityServiceResponse>(productAvailabilityRequest);

                    var storeAvailabilities = GetStoreAvailabilities(productAvailabilityResponse.ItemsAvailability, storeLocations, items[0].InventoryUnitOfMeasure);
                    return(new GetStoreProductAvailabilityResponse(storeAvailabilities.AsPagedResult()));
                }
                else
                {
                    ThrowIf.Null(request.Items, "request.Items");

                    var getStoresRequest = new GetStoresDataRequest(this.Context.GetPrincipal().ChannelId, request.SearchArea, QueryResultSettings.AllRecords);
                    ReadOnlyCollection <OrgUnitLocation> storeLocations = this.Context.Execute <EntityDataServiceResponse <OrgUnitLocation> >(getStoresRequest).PagedEntityCollection.Results;

                    var storeAvailabilities = ChannelAvailabilityHelper.GetChannelAvailabiltiy(this.Context, storeLocations, request.Items);
                    return(new GetStoreProductAvailabilityResponse(storeAvailabilities.AsPagedResult()));
                }
            }
예제 #12
0
    public bool UpdateItemBarcode(ItemBarcode itemBarcode)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("Cuc_UpdateItemBarcode", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ItemBarcodeID", SqlDbType.Int).Value = itemBarcode.ItemBarcodeID;
            cmd.Parameters.Add("@SubCategoryID", SqlDbType.Int).Value = itemBarcode.SubCategoryID;
            cmd.Parameters.Add("@NoOfItem", SqlDbType.Int).Value = itemBarcode.NoOfItem;
            cmd.Parameters.Add("@BarcodeText", SqlDbType.NText).Value = itemBarcode.BarcodeText;
            cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = itemBarcode.AddedDate;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }