public static void InsertIBFForm(OrderDTO orderDetails) { try { var productItems = orderDetails.Items.ToList(); foreach (var product in productItems) { bool isExist = true; InboundTrackingItem inboundData = CustomTableItemProvider.GetItems <InboundTrackingItem>().WhereEquals("SKUID", product.SKU.KenticoSKUID).FirstOrDefault(); if (inboundData == null) { inboundData = new InboundTrackingItem(); isExist = false; } inboundData.SKUID = product.SKU.KenticoSKUID; inboundData.QtyOrdered = product.UnitCount; if (!isExist) { inboundData.Insert(); } else { inboundData.Update(); } } } catch (Exception ex) { EventLogProvider.LogInformation("ShoppingCartHelper", "GetOrderTotal", ex.Message); } }
/// <summary> /// Updating the products /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void inboundProducts_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { string skuid = ((HiddenField)gdvInboundProducts.Rows[e.RowIndex].FindControl("hfSKUID")).Value; bool isExist = true; InboundTrackingItem inboundData = CustomTableItemProvider.GetItems <InboundTrackingItem>().WhereEquals("SKUID", ValidationHelper.GetInteger(skuid, default(int))).FirstOrDefault(); if (inboundData == null) { inboundData = new InboundTrackingItem(); isExist = false; } inboundData.SKUID = ValidationHelper.GetInteger(skuid, default(int)); inboundData.QtyOrdered = ValidationHelper.GetInteger(((Label)gdvInboundProducts.Rows[e.RowIndex].FindControl("lblQtyOrdered")).Text, default(int)); inboundData.DemandGoal = ValidationHelper.GetInteger(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtDemandGoal")).Text, default(int)); inboundData.QtyReceived = ValidationHelper.GetInteger(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtQtyReceived")).Text, default(int)); inboundData.QtyProduced = ValidationHelper.GetInteger(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtQtyProduced")).Text, default(int)); inboundData.Overage = inboundData.QtyReceived - inboundData.QtyOrdered; inboundData.Vendor = ValidationHelper.GetString(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtVendor")).Text, string.Empty); inboundData.ExpArrivalToCenveo = ValidationHelper.GetString(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtExpArrivalToCenveo")).Text, string.Empty); inboundData.DeliveryToDistBy = ValidationHelper.GetString(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtDeliveryToDistBy")).Text, string.Empty); inboundData.ShippedToDist = ValidationHelper.GetString(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtShippedToDist")).Text, string.Empty); inboundData.CenveoComments = ValidationHelper.GetString(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtCenveoComments")).Text, string.Empty); inboundData.TweComments = ValidationHelper.GetString(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtTweComments")).Text, string.Empty); inboundData.ActualPrice = ValidationHelper.GetDouble(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtActualPrice")).Text, default(double)); if (!isExist) { inboundData.Insert(); } else { inboundData.Update(); } UpdateSkuTable(ValidationHelper.GetInteger(skuid, default(int)), ValidationHelper.GetDouble(((TextBox)gdvInboundProducts.Rows[e.RowIndex].FindControl("txtActualPrice")).Text, default(double)), ValidationHelper.GetInteger(((DropDownList)gdvInboundProducts.Rows[e.RowIndex].FindControl("ddlStatus")).SelectedValue, default(int))); gdvInboundProducts.EditIndex = -1; GetProducts(); } catch (Exception ex) { EventLogProvider.LogException("Updating Products", "inboundProducts_RowUpdating()", ex, CurrentSite.SiteID, ex.Message); } }