/// <summary> /// Saves the changes. /// </summary> /// <param name="context">The context.</param> public void SaveChanges(IDictionary context) { OrderGroup order = (OrderGroup)context[_OrderContextObjectString]; order.Status = OrderStatusList.SelectedValue; order.BillingCurrency = OrderCurrencyList.SelectedValue; order.AddressId = AddressesList.SelectedValue; if (!String.IsNullOrEmpty(order.AddressId) && order.OrderForms.Count > 0) { order.OrderForms[0].BillingAddressId = order.AddressId; } /* * if(typeof(order) == typeof(OrderGroup)) * order.TrackingNumber = TrackingNo.Text; * * order.ExpirationDate = OrderExpires.Value; * */ if (CustomerName.SelectedItem != null) { order.CustomerId = new Guid(CustomerName.SelectedValue); // assign order.CustomerName OrderAddress address = null; if (!String.IsNullOrEmpty(order.AddressId)) { if (order.OrderAddresses != null && order.OrderAddresses.Count > 0) { foreach (OrderAddress addr in order.OrderAddresses) { if (String.Compare(addr.Name, order.AddressId, true) == 0) { address = addr; break; } } } } if (address != null) { order.CustomerName = address.FirstName + " " + address.LastName; } else { order.CustomerName = CustomerName.SelectedItem.Text; } } // Save meta data MetaDataTab.ObjectId = order.OrderGroupId; IDictionary dic = new ListDictionary(); dic.Add("MetaObjectContext-" + MetaDataTab.Languages[0], order); MetaDataTab.SaveChanges(dic); }
/// <summary> /// Handles the Click event of the SaveChangesButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SaveChangesButton_Click(object sender, EventArgs e) { if (String.Compare(Request.Form["__EVENTARGUMENT"], _PostBackArgumentString) == 0) { if (_order != null) { OrderAddress address = null; if (AddressId != 0) // find existing { foreach (OrderAddress a in _order.OrderAddresses) { if (a.OrderGroupAddressId == AddressId) { address = a; break; } } } if (address == null) { address = _order.OrderAddresses.AddNew(); } address.Name = Name.Text; address.FirstName = FirstName.Text; address.LastName = LastName.Text; address.Organization = Organization.Text; address.Line1 = Line1.Text; address.Line2 = Line2.Text; address.City = City.Text; address.State = State.Text; address.CountryCode = CountryCode.Text; address.CountryName = CountryName.Text; address.PostalCode = PostalCode.Text; address.RegionCode = RegionCode.Text; address.RegionName = RegionName.Text; address.DaytimePhoneNumber = DayTimePhone.Text; address.EveningPhoneNumber = EveningPhone.Text; address.FaxNumber = FaxNumber.Text; address.Email = Email.Text; // Put a dictionary key that can be used by other tabs IDictionary dic = new ListDictionary(); dic.Add(MetaDataTab._MetaObjectContextKey + MetaDataTab.Languages[0], address); MetaDataTab.SaveChanges(dic); ScriptManager.RegisterStartupScript(MetaDataTab, typeof(AddressEditTab), "DialogClose", "Address_CloseDialog();", true); } } }
/// <summary> /// Handles the RowChanged event of the CatalogNode control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Data.DataRowChangeEventArgs"/> instance containing the event data.</param> void CatalogNode_RowChanged(object sender, DataRowChangeEventArgs e) { CatalogNodeDto.CatalogNodeDataTable table = (CatalogNodeDto.CatalogNodeDataTable)sender; CatalogNodeDto.CatalogNodeRow row = (CatalogNodeDto.CatalogNodeRow)table.Rows[0]; if (row.CatalogNodeId > 0) { MetaDataTab.MetaClassId = row.MetaClassId; MetaDataTab.ObjectId = row.CatalogNodeId; MetaDataTab.SaveChanges(null); } //throw new Exception("The method or operation is not implemented."); }
/// <summary> /// Binds the form. /// </summary> private void BindForm() { CatalogDto catalogDto = null; if (MetaClassId > 0) { MetaDataTab.MetaClassId = MetaClassId; catalogDto = CatalogContext.Current.GetCatalogDto(ParentCatalogId); } else if (MetaClassId == 0 && CatalogNodeId == 0 && Session["CatalogNode-MetaClassId"] != null) { if (!String.IsNullOrEmpty(Session["CatalogNode-MetaClassId"].ToString())) { MetaDataTab.MetaClassId = Int32.Parse(Session["CatalogNode-MetaClassId"].ToString()); catalogDto = CatalogContext.Current.GetCatalogDto(ParentCatalogId); } } else if (CatalogNodeId > 0) { MetaDataTab.ObjectId = CatalogNodeId; CatalogNodeDto dto = CatalogContext.Current.GetCatalogNodeDto(CatalogNodeId); if (dto.CatalogNode.Count > 0) { catalogDto = CatalogContext.Current.GetCatalogDto(dto.CatalogNode[0].CatalogId); MetaDataTab.MetaClassId = dto.CatalogNode[0].MetaClassId; } } if (HttpContext.Current.Items["CatalogNode-MetaClassId"] != null) { MetaDataTab.MetaClassId = Int32.Parse(HttpContext.Current.Items["CatalogNode-MetaClassId"].ToString()); } if (catalogDto != null) { List <string> list = new List <string>(); list.Add(catalogDto.Catalog[0].DefaultLanguage); if (catalogDto.CatalogLanguage.Count > 0) { foreach (CatalogDto.CatalogLanguageRow row in catalogDto.CatalogLanguage.Rows) { list.Add(row.LanguageCode); } MetaDataTab.Languages = list.ToArray(); } MetaDataTab.DataBind(); } }
/// <summary> /// Handles the Click event of the SaveChangesButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SaveChangesButton_Click(object sender, EventArgs e) { if (String.Compare(Request.Form["__EVENTARGUMENT"], _PostBackArgumentString) == 0) { LineItem lineItem = null; if (LineItemId != 0) // find existing { lineItem = _order.OrderForms[0].LineItems.FindItem(LineItemId); } // if not found, create new if (lineItem == null) { lineItem = _order.OrderForms[0].LineItems.AddNew(); lineItem.CatalogEntryId = CatalogEntryIdLabel.Text; } // update lineItem fields if (lineItem != null) { decimal price = Decimal.Parse(ListPrice.Text); lineItem.DisplayName = DisplayName.Text; lineItem.ListPrice = price; lineItem.PlacedPrice = price; lineItem.LineItemDiscountAmount = Decimal.Parse(DiscountAmount.Text); lineItem.Quantity = Decimal.Parse(Quantity.Text); decimal extPrice = lineItem.Quantity * price; lineItem.ExtendedPrice = extPrice > lineItem.LineItemDiscountAmount ? extPrice - lineItem.LineItemDiscountAmount : extPrice; //ListItem selectedAddressItem = LineItemAddressesFilter.Items.FindByValue(SelectedAddressField.Value); //if (selectedAddressItem != null) // lineItem.ShippingAddressId = selectedAddressItem.Value; //ListItem selectedSMItem = ShippingMethodList.Items.FindByValue(SelectedShippingMethodField.Value); //if (selectedSMItem != null) // lineItem.ShippingMethodId = new Guid(selectedSMItem.Value); } //lineItem.AcceptChanges(); // Put a dictionary key that can be used by other tabs MetaDataTab.ObjectId = lineItem.LineItemId; IDictionary dic = new ListDictionary(); dic.Add(MetaDataTab._MetaObjectContextKey + MetaDataTab.Languages[0], lineItem); MetaDataTab.SaveChanges(dic); } ScriptManager.RegisterStartupScript(MetaDataTab, typeof(LineItemEditPopup), "DialogClose", "LineItemAddresses_CloseDialog();", true); }
/// <summary> /// Binds the meta form. /// </summary> private void BindMetaForm() { string metaClassName = Request.QueryString["class"]; MetaClass metaClass = null; if ((_order == null || _order.OrderGroupId <= 0) || String.IsNullOrEmpty(metaClassName)) { // Call clear meta cache so we have the latest meta class when binding to an item OrderContext.Current.ClearMetaCache(); if (_order is Cart) { // if this is new order/cart/payment plan metaClass = OrderContext.Current.ShoppingCartMetaClass; } else { // if we are in edit mode if (this.ViewId.StartsWith("PaymentPlan", StringComparison.OrdinalIgnoreCase)) { metaClass = OrderContext.Current.PaymentPlanMetaClass; } else if (this.ViewId.StartsWith("PurchaseOrder", StringComparison.OrdinalIgnoreCase)) { metaClass = OrderContext.Current.PurchaseOrderMetaClass; } else if (this.ViewId.StartsWith("ShoppingCart", StringComparison.OrdinalIgnoreCase)) { metaClass = OrderContext.Current.ShoppingCartMetaClass; } } } else { metaClass = MetaClass.Load(OrderContext.MetaDataContext, metaClassName); } // Bind Meta Form MetaDataTab.MetaClassId = metaClass.Id; Dictionary <string, MetaObject> metaObjects = new Dictionary <string, MetaObject>(); metaObjects.Add(MetaDataTab.Languages[0], _order); IDictionary dic = new ListDictionary(); dic.Add("MetaObjectsContext", metaObjects); MetaDataTab.LoadContext(dic); MetaDataTab.DataBind(); }
private void BindMetaForm() { // Bind Meta Form MetaDataTab.MetaClassId = OrderContext.Current.LineItemMetaClass.Id; Dictionary <string, MetaObject> metaObjects = new Dictionary <string, MetaObject>(); metaObjects.Add(MetaDataTab.Languages[0], SelectedLineItem); IDictionary dic = new ListDictionary(); dic.Add("MetaObjectsContext", metaObjects); MetaDataTab.LoadContext(dic); MetaDataTab.DataBind(); }
/// <summary> /// Binds the meta form. /// </summary> private void BindMetaForm() { CatalogDto catalogDto = null; if (CatalogEntryId == 0) { catalogDto = CatalogContext.Current.GetCatalogDto(ParentCatalogId); } else if (CatalogEntryId > 0) { MetaDataTab.ObjectId = CatalogEntryId; CatalogEntryDto dto = CatalogContext.Current.GetCatalogEntryDto(CatalogEntryId); if (dto.CatalogEntry.Count > 0) { catalogDto = CatalogContext.Current.GetCatalogDto(dto.CatalogEntry[0].CatalogId); MetaDataTab.MetaClassId = dto.CatalogEntry[0].MetaClassId; } } //if (this.IsPostBack) if (!String.IsNullOrEmpty(MetaClassList.SelectedValue)) { MetaDataTab.MetaClassId = Int32.Parse(MetaClassList.SelectedValue); } if (catalogDto != null) { List <string> list = new List <string>(); list.Add(catalogDto.Catalog[0].DefaultLanguage); if (catalogDto.CatalogLanguage.Count > 0) { foreach (CatalogDto.CatalogLanguageRow row in catalogDto.CatalogLanguage.Rows) { list.Add(row.LanguageCode); } } MetaDataTab.Languages = list.ToArray(); MetaDataTab.DataBind(); } // add parent catalognode if (ParentCatalogNodeId > 0) { } }
private void BindMetaForm() { // Bind Meta Form MetaDataTab.MetaClassId = Int32.Parse(PaymentType.SelectedValue); Dictionary <string, MetaObject> metaObjects = new Dictionary <string, MetaObject>(); if (SelectedPayment != null && SelectedPayment.MetaClass.Id.ToString() == PaymentType.SelectedValue) { metaObjects.Add(MetaDataTab.Languages[0], SelectedPayment); } else { metaObjects.Add(MetaDataTab.Languages[0], null); } IDictionary dic = new ListDictionary(); dic.Add("MetaObjectsContext", metaObjects); MetaDataTab.LoadContext(dic); MetaDataTab.DataBind(); }
/// <summary> /// Pre-commit changes. /// </summary> /// <param name="context">The context.</param> public void PreCommitChanges(IDictionary context) { CatalogEntryDto dto = (CatalogEntryDto)context[_CatalogEntryDtoString]; CatalogRelationDto relationDto = (CatalogRelationDto)context[_CatalogRelationDtoString]; // Save Meta Data IDictionary dic = new ListDictionary(); MetaDataTab.MDContext = CatalogContext.MetaDataContext; MetaDataTab.SaveChanges(dic); byte[] serializedObject = ((MetaObjectSerialized)dic["MetaObjectSerialized"]).BinaryValue; dto.CatalogEntry[0][MetaObjectSerialized.SerializedFieldName] = serializedObject; // Update relations foreach (CatalogRelationDto.NodeEntryRelationRow row in relationDto.NodeEntryRelation) { if (row.CatalogEntryId == dto.CatalogEntry[0].CatalogEntryId && row.CatalogId == this.ParentCatalogId && row.CatalogNodeId == this.ParentCatalogNodeId) { row.SortOrder = Int32.Parse(SortOrder.Text); } } }
/// <summary> /// Handles the Click event of the SaveChangesButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SaveChangesButton_Click(object sender, EventArgs e) { if (String.Compare(Request.Form["__EVENTARGUMENT"], _PostBackArgumentString) == 0) { Payment payment = null; if (PaymentId != 0) // find existing { foreach (Payment p in _order.OrderForms[0].Payments) { if (p.PaymentId == PaymentId) { payment = p; break; } } } // Create payment of selected type if (payment == null) { // determine which payment type to create // temporary solution, since the algorythm below is rather slow MetaClass mc = MetaClass.Load(OrderContext.MetaDataContext, Int32.Parse(PaymentType.SelectedValue)); if (mc != null) { Type[] paymentTypes = ReflectionHelper.GetInheritedClasses(typeof(Payment)); Type paymentType = null; if (paymentTypes != null) { foreach (Type pt in paymentTypes) { ClassInfo classInfo = new ClassInfo(pt); Payment tmpPayment = (Payment)classInfo.CreateInstance(); if (tmpPayment.MetaClass.Id == mc.Id) { paymentType = pt; break; } } } if (paymentType != null) { payment = _order.OrderForms[0].Payments.AddNew(paymentType); } //payment = _order.OrderForms[0].Payments.AddNew(typeof(CreditCardPayment)); } } if (payment != null) { payment.Amount = Decimal.Parse(Amount.Text); ListItem selectedPaymentStatus = PaymentStatus.Items.FindByValue(SelectedPaymentStatusField.Value); if (selectedPaymentStatus != null) { payment.Status = selectedPaymentStatus.Value; } payment.PaymentMethodId = new Guid(PaymentMethodList.SelectedValue); payment.PaymentMethodName = Name.Text; ListItem selectedPaymentMethod = PaymentMethodList.Items.FindByValue(SelectedPaymentMethodField.Value); if (selectedPaymentMethod != null) { payment.PaymentMethodId = new Guid(selectedPaymentMethod.Value); } //ListItem selectedPaymentType = PaymentType.Items.FindByValue(SelectedPaymentTypeField.Value); //if (selectedPaymentType != null) // payment.MetaClass = new Guid(selectedPaymentMethod.Value); } // Put a dictionary key that can be used by other tabs MetaDataTab.ObjectId = payment.PaymentId; IDictionary dic = new ListDictionary(); dic.Add(MetaDataTab._MetaObjectContextKey + MetaDataTab.Languages[0], payment); MetaDataTab.SaveChanges(dic); } ScriptManager.RegisterStartupScript(MetaDataTab, typeof(OrderPaymentEditTab), "DialogClose", "Payment_CloseDialog();", true); }
/// <summary> /// Pre-commit changes. /// </summary> /// <param name="context">The context.</param> public void PreCommitChanges(IDictionary context) { MetaDataTab.MDContext = CatalogContext.MetaDataContext; MetaDataTab.SaveChanges(null); }
/// <summary> /// Handles the Click event of the SaveChangesButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SaveChangesButton_Click(object sender, EventArgs e) { if (String.Compare(Request.Form["__EVENTARGUMENT"], _PostBackArgumentString) == 0) { if (_order != null) { if (SelectedShipment == null) { _shipment = _order.OrderForms[0].Shipments.AddNew(); } decimal parsedDecimal = 0; ListItem selectedSMItem = ShippingMethodList.Items.FindByValue(SelectedShippingMethodField.Value); if (selectedSMItem != null) { SelectedShipment.ShippingMethodId = new Guid(selectedSMItem.Value); } else { SelectedShipment.ShippingMethodId = Guid.NewGuid(); } SelectedShipment.ShippingMethodName = MethodName.Text; ListItem selectedAddressItem = AddressList.Items.FindByText(SelectedAddressField.Value); if (selectedAddressItem != null) { SelectedShipment.ShippingAddressId = selectedAddressItem.Text; } else { SelectedShipment.ShippingAddressId = AddressList.SelectedItem.Text; } SelectedShipment.ShipmentTrackingNumber = TrackingNumber.Text; if (decimal.TryParse(ShipmentTotal.Text, out parsedDecimal)) { SelectedShipment.ShipmentTotal = parsedDecimal; } if (decimal.TryParse(DiscountAmount.Text, out parsedDecimal)) { SelectedShipment.ShippingDiscountAmount = parsedDecimal; } SelectedShipment.Status = Status.Text; // update lineItems foreach (DataListItem dlItem in ShipmentItemsList.Items) { CheckBox chb = dlItem.FindControl("chbIsInShipment") as CheckBox; if (chb != null) { bool itemRemoved = false; string lineItemIndex = ShipmentItemsList.DataKeys[dlItem.ItemIndex].ToString(); if (chb.Checked && !SelectedShipment.LineItemIndexes.Contains(lineItemIndex)) { // add lineItem SelectedShipment.LineItemIndexes.Add(lineItemIndex); } else if (!chb.Checked && SelectedShipment.LineItemIndexes.Contains(lineItemIndex)) { // remove lineItem SelectedShipment.LineItemIndexes.Remove(lineItemIndex); itemRemoved = true; } if (itemRemoved) { UpdateLineItemShippingProperties(lineItemIndex, String.Empty, Guid.Empty, String.Empty); } else if (chb.Checked) { // if item was added or already existed, update it UpdateLineItemShippingProperties(lineItemIndex, SelectedShipment.ShippingAddressId, SelectedShipment.ShippingMethodId, SelectedShipment.ShippingMethodName); } } } // Put a dictionary key that can be used by other tabs IDictionary dic = new ListDictionary(); dic.Add(MetaDataTab._MetaObjectContextKey + MetaDataTab.Languages[0], SelectedShipment); MetaDataTab.SaveChanges(dic); ScriptManager.RegisterStartupScript(MetaDataTab, typeof(OrderShipmentEditTab), "DialogClose", "Shipment_CloseDialog();", true); } } }