/// <summary> /// Bind data to the fields /// </summary> protected void BindData() { ShippingAdmin shipAdmin = new ShippingAdmin(); StoreSettingsAdmin settingsAdmin = new StoreSettingsAdmin(); if (ItemId > 0) { Shipping shippingOption = shipAdmin.GetShippingOptionById(ItemId); lblShippingType.Text = shipAdmin.GetShippingTypeName(shippingOption.ShippingTypeID); if (shippingOption.ProfileID.HasValue) lblProfileName.Text = shipAdmin.GetProfileNamee((int)shippingOption.ProfileID); else lblProfileName.Text = "All Profiles"; lblDescription.Text = shippingOption.Description; lblShippingCode.Text = shippingOption.ShippingCode; if (shippingOption.HandlingCharge > 0) { lblHandlingCharge.Text = shippingOption.HandlingCharge.ToString("N2"); } else { lblHandlingCharge.Text = "0.00"; } if (shippingOption.DestinationCountryCode != null) { if (shippingOption.DestinationCountryCode.Length > 0) { lblDestinationCountry.Text = shippingOption.DestinationCountryCode; } } else { lblDestinationCountry.Text = "All Countries"; } imgActive.Src = ZNodeHelper.GetCheckMark((bool)shippingOption.ActiveInd); lblDisplayOrder.Text = shippingOption.DisplayOrder.ToString(); if (shippingOption.ShippingTypeID == 1) { pnlShippingRuletypes.Visible = true; } } else { //nothing to do here } }
/// <summary> /// Delete button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { ShippingAdmin shipAdmin = new ShippingAdmin(); Shipping shipping = new Shipping(); shipping.ShippingID = ItemId; bool retval = shipAdmin.DeleteShippingOption(shipping); if (!retval) { lblMsg.Text = "Error: Delete action could not be completed. You must delete all shipping rules on this option first. "; lblMsg.Text = lblMsg.Text + "You should also ensure that this shipping option is not currently referenced by an order or a product. "; } else { Response.Redirect("~/admin/secure/settings/shipping/default.aspx"); } }
/// <summary> /// Bind data to the fields on the screen /// </summary> protected void BindData() { ShippingAdmin shipAdmin = new ShippingAdmin(); ShippingOptionName = shipAdmin.GetShippingOptionById(ItemId).Description; }
/// <summary> /// Event triggered when a command button is clicked on the grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void uxGrid_RowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName == "page") { } else { // Convert the row index stored in the CommandArgument // property to an Integer. int index = Convert.ToInt32(e.CommandArgument); // Get the values from the appropriate // cell in the GridView control. GridViewRow selectedRow = uxGrid.Rows[index]; TableCell Idcell = selectedRow.Cells[0]; string Id = Idcell.Text; if (e.CommandName == "Edit") { AddRuleLink = AddRuleLink + "?itemid=" + Id + "&sid=" + ItemId.ToString(); Response.Redirect(AddRuleLink); } else if (e.CommandName == "Delete") { ShippingAdmin shipAdmin = new ShippingAdmin(); ShippingRule shipRule = new ShippingRule(); shipRule.ShippingRuleID = int.Parse(Id); shipAdmin.DeleteShippingRule(shipRule); } } }
/// <summary> /// Bind data to grid /// </summary> private void BindGridData() { ShippingAdmin shipAdmin = new ShippingAdmin(); uxGrid.DataSource = shipAdmin.GetShippingRules(ItemId); uxGrid.DataBind(); }
/// <summary> /// Binds Shipping Servic code list /// </summary> private void BindShippingServiceCodes() { ShippingAdmin shipAdmin = new ShippingAdmin(); DataSet ds = shipAdmin.GetShippingServiceCodes(int.Parse(lstShippingType.SelectedValue)); //If FedEx shipping type is selected if (lstShippingType.SelectedValue == "3") { lstShippingServiceCodes.Items.Clear();//Reset dropdownlist items foreach (DataRow dr in ds.Tables[0].Rows) { string description = dr["Description"].ToString(); System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("®"); description = regex.Replace(description,"®"); ListItem li = new ListItem(description, dr["Code"].ToString()); lstShippingServiceCodes.Items.Add(li); } } else { lstShippingServiceCodes.DataSource = ds; lstShippingServiceCodes.DataTextField = "Description"; lstShippingServiceCodes.DataValueField = "code"; lstShippingServiceCodes.DataBind(); } }
/// <summary> /// Bind data to the fields /// </summary> protected void BindData() { ShippingAdmin shipAdmin = new ShippingAdmin(); StoreSettingsAdmin settingsAdmin = new StoreSettingsAdmin(); //GET LIST DATA //Get shipping types lstShippingType.DataSource = shipAdmin.GetShippingTypes(); lstShippingType.DataTextField = "Name"; lstShippingType.DataValueField = "ShippingTypeID"; lstShippingType.DataBind(); lstShippingType.SelectedIndex = 0; //Bind countries BindCountry(); //get profiles lstProfile.DataSource = settingsAdmin.GetProfiles(); lstProfile.DataTextField = "Name"; lstProfile.DataValueField = "ProfileID"; lstProfile.DataBind(); lstProfile.Items.Insert(0, new ListItem("All Profiles", "-1")); lstProfile.SelectedItem.Value = "-1"; if (ItemId > 0) { Shipping shippingOption = shipAdmin.GetShippingOptionById(ItemId); if(shippingOption.ProfileID.HasValue) lstProfile.SelectedValue = shippingOption.ProfileID.Value.ToString(); lstShippingType.SelectedValue = shippingOption.ShippingTypeID.ToString(); lstShippingType.Enabled = false; //If UPS Shipping Option is Selected if (lstShippingType.SelectedValue == "2") { //Bind UPS Service codes BindShippingServiceCodes(); lstShippingServiceCodes.SelectedValue = shippingOption.ShippingCode; pnlShippingServiceCodes.Visible = true; pnlShippingOptions.Visible = false; pnlDestinationCountry.Visible = false; } //If FedEx Shipping Option is Selected else if (lstShippingType.SelectedValue == "3") { //Bind FedEx Service codes BindShippingServiceCodes(); lstShippingServiceCodes.SelectedValue = shippingOption.ShippingCode; pnlShippingServiceCodes.Visible = true; pnlShippingOptions.Visible = false; pnlDestinationCountry.Visible = false; } else { txtDescription.Text = shippingOption.Description; txtShippingCode.Text = shippingOption.ShippingCode; } if (shippingOption.HandlingCharge > 0) { txtHandlingCharge.Text = shippingOption.HandlingCharge.ToString("N2"); } else { txtHandlingCharge.Text = "0.00"; } if (shippingOption.DestinationCountryCode != null) { if (shippingOption.DestinationCountryCode.Length > 0) { lstCountries.SelectedValue = shippingOption.DestinationCountryCode; } } chkActiveInd.Checked = (bool)shippingOption.ActiveInd; txtDisplayOrder.Text = shippingOption.DisplayOrder.ToString(); } else { //nothing to do here } }
/// <summary> /// Submit button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { StoreSettingsAdmin settingsAdmin = new StoreSettingsAdmin(); ShippingAdmin shipAdmin = new ShippingAdmin(); Shipping shipOption = new Shipping(); //If edit mode then retrieve data first if (ItemId > 0) { shipOption = shipAdmin.GetShippingOptionById(ItemId); } //set values shipOption.ActiveInd = chkActiveInd.Checked; //If UPS Shipping type is selected if (lstShippingType.SelectedValue == "2") { shipOption.ShippingCode = lstShippingServiceCodes.SelectedItem.Value; shipOption.Description = lstShippingServiceCodes.SelectedItem.Text; } //If FedEx Shipping type is selected else if (lstShippingType.SelectedValue == "3") { shipOption.ShippingCode = lstShippingServiceCodes.SelectedItem.Value; shipOption.Description = lstShippingServiceCodes.SelectedItem.Text; } else { shipOption.ShippingCode = txtShippingCode.Text; shipOption.Description = txtDescription.Text; } if (lstCountries.SelectedValue.Equals("*")) { shipOption.DestinationCountryCode = null; } else { shipOption.DestinationCountryCode = lstCountries.SelectedValue; } shipOption.DisplayOrder = int.Parse(txtDisplayOrder.Text); //Profile settings if (lstProfile.SelectedValue != "-1") { shipOption.ProfileID = int.Parse(lstProfile.SelectedValue); } else { shipOption.ProfileID = null; } shipOption.ShippingTypeID = int.Parse(lstShippingType.SelectedValue); if (txtHandlingCharge.Text.Length > 0) { shipOption.HandlingCharge = decimal.Parse(txtHandlingCharge.Text); } bool retval = false; if (ItemId > 0) { retval = shipAdmin.UpdateShippingOption(shipOption); } else { retval = shipAdmin.AddShippingOption(shipOption); } if (retval) { //redirect to main page Response.Redirect("~/admin/secure/settings/shipping/default.aspx"); } else { //display error message lblMsg.Text = "An error occurred while updating. Please try again."; } }
/// <summary> /// Binds country drop-down list /// </summary> private void BindCountry() { ShippingAdmin shipAdmin = new ShippingAdmin(); TList<ZNode.Libraries.DataAccess.Entities.Country> countries = shipAdmin.GetDestinationCountries(); lstCountries.DataSource = countries; lstCountries.DataTextField = "Name"; lstCountries.DataValueField = "Code"; lstCountries.DataBind(); lstCountries.SelectedValue = "*"; }
/// <summary> /// Bind data to the fields /// </summary> protected void BindData() { ShippingAdmin shipAdmin = new ShippingAdmin(); Shipping shippingOption = shipAdmin.GetShippingOptionById(ShippingId); //Set Title lblTitle.Text = lblTitle.Text + shippingOption.Description; //Get shipping rule types foreach (ShippingRuleType ruleType in shipAdmin.GetShippingRuleTypes()) { if (ruleType.ShippingRuleTypeID == 3 || ruleType.ShippingRuleTypeID == 4) { // Nothing to do here } else { ListItem li = new ListItem(ruleType.Description, ruleType.ShippingRuleTypeID.ToString()); lstShippingRuleType.Items.Add(li); } } lstShippingRuleType.SelectedIndex = 0; if (ItemId > 0) { ShippingRule shippingRule = shipAdmin.GetShippingRule(ItemId); lstShippingRuleType.SelectedValue = shippingRule.ShippingRuleTypeID.ToString(); SetShippingTypeOptions(shippingRule.ShippingRuleTypeID); if (shippingRule.BaseCost != 0) { txtBaseCost.Text = shippingRule.BaseCost.ToString("N2"); } else { txtBaseCost.Text = "0"; } if (shippingRule.PerItemCost != 0) { txtPerItemCost.Text = shippingRule.PerItemCost.ToString("N2"); } else { txtPerItemCost.Text = "0"; } if (shippingRule.LowerLimit != null) { txtLowerLimit.Text = shippingRule.LowerLimit.ToString(); } else { txtLowerLimit.Text = "0"; } if (shippingRule.UpperLimit != null) { txtUpperLimit.Text = shippingRule.UpperLimit.ToString(); } else { txtUpperLimit.Text = "0"; } } else { pnlNonFlat.Visible = false; } }
/// <summary> /// Submit button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { ShippingAdmin shipAdmin = new ShippingAdmin(); ShippingRule shipRule = new ShippingRule(); //set shipping id for this rule shipRule.ShippingID = ShippingId; //If edit mode then retrieve data first if (ItemId > 0) { shipRule = shipAdmin.GetShippingRule(ItemId); } //set values shipRule.ShippingRuleTypeID = int.Parse(lstShippingRuleType.SelectedValue); shipRule.BaseCost = decimal.Parse(txtBaseCost.Text); // "PerItemCost" field is not saving for Quantity and Weight based Rules //So i have commented this out. //if (int.Parse(lstShippingRuleType.SelectedValue) == 0) //{ shipRule.PerItemCost = decimal.Parse(txtPerItemCost.Text); //} if (int.Parse(lstShippingRuleType.SelectedValue) > 0) { shipRule.LowerLimit = decimal.Parse(txtLowerLimit.Text); shipRule.UpperLimit = decimal.Parse(txtUpperLimit.Text); } else { shipRule.LowerLimit = null; shipRule.UpperLimit = null; } //Update or Add bool retval = false; if (ItemId > 0) { retval = shipAdmin.UpdateShippingRule(shipRule); } else { retval = shipAdmin.AddShippingRule(shipRule); } if (retval) { //redirect to main page Response.Redirect("~/admin/secure/settings/shipping/view.aspx?itemid=" + ShippingId.ToString() ); } else { //display error message lblMsg.Text = "An error occurred while updating. Please try again."; } }
/// <summary> /// Bind data to grid /// </summary> private void BindGridData() { ShippingAdmin shipAdmin = new ShippingAdmin(); uxGrid.DataSource = shipAdmin.GetAllShippingOptions(ZNodeConfigManager.SiteConfig.PortalID); uxGrid.DataBind(); }
/// <summary> /// Bind Shipping option list /// </summary> private void BindShippingTypes() { // Bind ShippingRuleTypes ShippingAdmin shippingAdmin = new ShippingAdmin(); ShippingTypeList.DataSource = shippingAdmin.GetShippingRuleTypes(); ShippingTypeList.DataTextField = "description"; ShippingTypeList.DataValueField = "shippingruletypeid"; ShippingTypeList.DataBind(); }
/// <summary> /// /// </summary> /// <param name="ds"></param> /// <returns></returns> private DataSet FormatReportDataSet(DataSet ds) { //This will copied the structure and data from the Original dataset DataSet tempDataSet = ds.Copy(); # region Local Variables OrderAdmin orderAdmin = new OrderAdmin(); ShippingAdmin shippingAdmin = new ShippingAdmin(); StoreSettingsAdmin storeAdmin = new StoreSettingsAdmin(); #endregion //Initialize new columns for OrderStatus,ShippingType,Payment Type //Add column to this temporary dataset DataColumn columnOrderStatus = new DataColumn("OrderStatus"); tempDataSet.Tables[0].Columns.Add(columnOrderStatus); //Add ShippingType column DataColumn columnShippingType = new DataColumn("ShippingTypeName"); tempDataSet.Tables[0].Columns.Add(columnShippingType); //Add Paymenttype column DataColumn columnPaymentType = new DataColumn("PaymentTypeName"); tempDataSet.Tables[0].Columns.Add(columnPaymentType); //Loop through the Orders in the dataset foreach (DataRow dr in tempDataSet.Tables[0].Rows) { //Get Order Status int OrderStateId = int.Parse(dr["OrderStateId"].ToString()); OrderState entity = orderAdmin.GetByOrderStateID(OrderStateId); int shippingId = int.Parse(dr["ShippingId"].ToString()); Shipping shippingEntity = shippingAdmin.GetShippingOptionById(shippingId); int paymentTypeId = 0; if(dr["PaymentTypeId"].ToString().Length > 0) //If PaymentTypeId value length is greater than Zero paymentTypeId = int.Parse(dr["PaymentTypeId"].ToString()); PaymentType paymentType = storeAdmin.GetPaymentTypeById(paymentTypeId); if (entity != null) dr["OrderStatus"] = entity.OrderStateName; if (shippingEntity != null) dr["ShippingTypeName"] = (shippingAdmin.GetShippingTypeName(shippingEntity.ShippingTypeID)); if (paymentType != null) dr["PaymentTypeName"] = paymentType.Name; } //Return dataset return tempDataSet; }