/// <summary> /// Bind data to the fields in edit mode /// </summary> protected void BindEditData() { TaxRuleAdmin taxAdmin = new TaxRuleAdmin(); TaxRule taxRule = new TaxRule(); if (ItemId > 0) { taxRule = taxAdmin.GetTaxRule(ItemId); // Destination CountryCode if (taxRule.DestinationCountryCode != null) { lstCountries.SelectedValue = taxRule.DestinationCountryCode; if (lstCountries.SelectedValue != null) { BindStates(); } } // Destination StateCode if (taxRule.DestinationStateCode != null) { lstStateOption.SelectedValue = taxRule.DestinationStateCode; if (lstStateOption.SelectedValue != null) { BindCounty(); } } // CountyFIPS if (taxRule.CountyFIPS != null) { lstCounty.SelectedValue = taxRule.CountyFIPS; } // Tax Rates txtSalesTax.Text = taxRule.SalesTax.ToString(); txtVAT.Text = taxRule.VAT.ToString(); txtGST.Text = taxRule.GST.ToString(); txtPST.Text = taxRule.PST.ToString(); txtHST.Text = taxRule.HST.ToString(); // Tax Preferences txtPrecedence.Text = taxRule.Precedence.ToString(); chkTaxInclusiveInd.Checked = taxRule.InclusiveInd; ddlRuleTypes.SelectedValue = taxRule.TaxRuleTypeID.GetValueOrDefault().ToString(); } else { //nothing to do here } }
/// <summary> /// Bind data in the edit mode /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BindEditData() { TaxRuleAdmin taxRuleAdmin = new TaxRuleAdmin(); TaxClass taxClass = new TaxClass(); if (taxId > 0) { taxClass = taxRuleAdmin.GetByTaxClassID(taxId); lblTitle.Text = lblTitle.Text + " - " + taxClass.Name; txtTaxClassName.Text = taxClass.Name; txtDisplayOrder.Text = taxClass.DisplayOrder.ToString(); chkActiveInd.Checked = taxClass.ActiveInd; } }
/// <summary> /// Get a County Name for grid display /// </summary> /// <param name="regionCode"></param> /// <returns></returns> protected string GetCountyName(object regionCode) { string countyName = ""; if (regionCode == null) { countyName = "ALL"; } else if (regionCode.ToString().Length == 0) { countyName = "ALL"; } else { //return regionCode.ToString(); TaxRuleAdmin taxruleAdmin = new TaxRuleAdmin(); countyName = taxruleAdmin.GetNameByCountyFIPS(regionCode.ToString()); } return countyName; }
/// <summary> /// Submit button click event to store in Tax Class /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { TaxRuleAdmin taxRuleAdmin = new TaxRuleAdmin(); TaxClass taxClass = new TaxClass(); if (taxId > 0) { taxClass = taxRuleAdmin.GetByTaxClassID(taxId); } taxClass.Name = txtTaxClassName.Text; taxClass.DisplayOrder = int.Parse(txtDisplayOrder.Text); taxClass.ActiveInd = chkActiveInd.Checked; bool retval = false; if (taxId > 0) { retval = taxRuleAdmin.UpdateTaxClass(taxClass); } else { retval = taxRuleAdmin.InsertTaxClass(taxClass); } if (retval) { // redirect to view page Response.Redirect("~/admin/secure/settings/taxes/view.aspx?taxId=" + taxClass.TaxClassID); } else { // display error message lblMsg.Text = "An error occurred while updating. Please try again."; } }
/// <summary> /// Bind data to grid /// </summary> private void BindData() { if (taxId > 0) { TaxRuleAdmin taxAdmin = new TaxRuleAdmin(); TaxClass taxClass = taxAdmin.DeepLoadByTaxClassId(taxId); taxClass.TaxRuleCollection.Sort("Precedence"); lblProfileName.Text = taxClass.Name; if (taxClass.DisplayOrder.HasValue) lblDisplayOrder.Text = taxClass.DisplayOrder.ToString(); imgActive.Src = ZNodeHelper.GetCheckMark((bool)taxClass.ActiveInd); uxGrid.DataSource = taxClass.TaxRuleCollection; uxGrid.DataBind(); } }
/// <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") { EditRuleLink = EditRuleLink + "?itemid=" + Id + "&taxId=" + taxId; Response.Redirect(EditRuleLink); } else if (e.CommandName == "Delete") { TaxRuleAdmin taxAdmin = new TaxRuleAdmin(); TaxRule taxRule = new TaxRule(); taxRule.TaxRuleID = int.Parse(Id); bool status = taxAdmin.DeleteTaxRule(taxRule); if(status) System.Web.HttpContext.Current.Cache.Remove("InclusiveTaxRules"); } } }
/// <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 == "View") { ViewLink = ViewLink + "?taxid=" + Id; Response.Redirect(ViewLink); } else if (e.CommandName == "Edit") { EditLink = EditLink + "?taxid=" + Id; Response.Redirect(EditLink); } else if (e.CommandName == "Delete") { TaxRuleAdmin taxRuleAdmin = new TaxRuleAdmin(); bool status = taxRuleAdmin.DeleteTaxClass(int.Parse(Id)); if (!status) { lblErrorMsg.Text = "Delete action could not be completed because the Tax class is in use."; } } } }
/// <summary> /// Bind data to the grid /// </summary> private void BindGridData() { TaxRuleAdmin taxRuleAdmin = new TaxRuleAdmin(); uxGrid.DataSource = taxRuleAdmin.GetAllTaxClass(); uxGrid.DataBind(); }
/// <summary> /// Bind the Countries /// </summary> private void BindTaxRuleTypes() { TaxRuleAdmin taxAdmin = new TaxRuleAdmin(); ddlRuleTypes.DataSource = taxAdmin.GetTaxRuleTypes(); ddlRuleTypes.DataTextField = "Name"; ddlRuleTypes.DataValueField = "TaxRuleTypeId"; ddlRuleTypes.DataBind(); }
/// <summary> /// Bind the County from ZnodeZipcode table /// </summary> private void BindCounty() { TaxRuleAdmin taxrule = new TaxRuleAdmin(); DataSet _countylist = taxrule.GetCountyCodeByStateAbbr(lstStateOption.SelectedValue); lstCounty.DataSource = _countylist; lstCounty.DataTextField = "CountyName"; lstCounty.DataValueField = "CountyFIPS"; lstCounty.DataBind(); ListItem li = new ListItem("Apply to ALL Counties", "0"); lstCounty.Items.Insert(0, li); }
/// <summary> /// Submit button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { TaxRuleAdmin taxAdmin = new TaxRuleAdmin(); TaxRule taxRule = new TaxRule(); taxRule.PortalID = ZNodeConfigManager.SiteConfig.PortalID; // If edit mode then retrieve data first if (ItemId > 0) { taxRule = taxAdmin.GetTaxRule(ItemId); } // TaxClassID taxRule.TaxClassID = taxId; // Destination Country if (lstCountries.SelectedValue.Equals("*")) taxRule.DestinationCountryCode = null; else taxRule.DestinationCountryCode = lstCountries.SelectedValue; // Destination State if (lstStateOption.SelectedValue != "0") taxRule.DestinationStateCode = lstStateOption.SelectedValue; else taxRule.DestinationStateCode = null; // CountyFIPS if (lstCounty.SelectedValue != "0") taxRule.CountyFIPS = lstCounty.SelectedValue; else taxRule.CountyFIPS = null; // Tax Rates taxRule.SalesTax = Convert.ToDecimal(txtSalesTax.Text); taxRule.VAT = Convert.ToDecimal(txtVAT.Text); taxRule.GST = Convert.ToDecimal(txtGST.Text); taxRule.PST = Convert.ToDecimal(txtPST.Text); taxRule.HST = Convert.ToDecimal(txtHST.Text); // Tax Preferences taxRule.InclusiveInd = chkTaxInclusiveInd.Checked; taxRule.Precedence = int.Parse(txtPrecedence.Text); if (ddlRuleTypes.SelectedIndex != -1) { taxRule.TaxRuleTypeID = int.Parse(ddlRuleTypes.SelectedValue); } bool retval = false; if (ItemId > 0) { retval = taxAdmin.UpdateTaxRule(taxRule); } else { retval = taxAdmin.AddTaxRule(taxRule); } if (retval) { System.Web.HttpContext.Current.Cache.Remove("InclusiveTaxRules"); //redirect to view page Response.Redirect("~/admin/secure/settings/taxes/view.aspx?taxId=" + taxId); } else { //display error message lblMsg.Text = "An error occurred while updating. Please try again."; } }
public void BindData() { //Bind product Type ProductTypeAdmin productTypeAdmin = new ProductTypeAdmin(); ProductTypeList.DataSource = productTypeAdmin.GetAllProductTypes(ZNodeConfigManager.SiteConfig.PortalID); ProductTypeList.DataTextField = "name"; ProductTypeList.DataValueField = "productTypeid"; ProductTypeList.DataBind(); //Bind Manufacturer ManufacturerAdmin ManufacturerAdmin = new ManufacturerAdmin(); ManufacturerList.DataSource=ManufacturerAdmin.GetAllByPortalID(ZNodeConfigManager.SiteConfig.PortalID); ManufacturerList.DataTextField = "name"; ManufacturerList.DataValueField = "manufacturerid"; ManufacturerList.DataBind(); ListItem li = new ListItem("No Manufacturer Selected", "0"); ManufacturerList.Items.Insert(0,li); //Bind Supplier SupplierService serv = new SupplierService(); TList<ZNode.Libraries.DataAccess.Entities.Supplier> list = serv.GetAll(); list.Sort("DisplayOrder Asc"); list.ApplyFilter(delegate(ZNode.Libraries.DataAccess.Entities.Supplier supplier) { return (supplier.ActiveInd == true); }); DataSet ds = list.ToDataSet(false); DataView dv = new DataView(ds.Tables[0]); ddlSupplier.DataSource = dv; ddlSupplier.DataTextField = "name"; ddlSupplier.DataValueField = "supplierid"; ddlSupplier.DataBind(); ListItem li1 = new ListItem("None", "0"); ddlSupplier.Items.Insert(0, li1); //Bind Categories this.BindTreeViewCategory(); // Bind Tax Class TaxRuleAdmin TaxRuleAdmin = new TaxRuleAdmin(); ddlTaxClass.DataSource = TaxRuleAdmin.GetAllTaxClass(); ddlTaxClass.DataTextField = "name"; ddlTaxClass.DataValueField = "TaxClassID"; ddlTaxClass.DataBind(); }
/// <summary> /// Bind tax classes list /// </summary> private void BindTaxClasses() { // Bind Tax Class TaxRuleAdmin TaxRuleAdmin = new TaxRuleAdmin(); ddlTaxClass.DataSource = TaxRuleAdmin.GetAllTaxClass(); ddlTaxClass.DataTextField = "name"; ddlTaxClass.DataValueField = "TaxClassID"; ddlTaxClass.DataBind(); }
/// <summary> /// Binding Product Values into label Boxes /// </summary> public void BindViewData() { //Create Instance for Product Admin and Product entity ZNode.Libraries.Admin.ProductAdmin prodAdmin = new ProductAdmin(); Product product=prodAdmin.GetByProductId(ItemId); DataSet ds = prodAdmin.GetProductDetails(ItemId); int Count = 0; //Check for Number of Rows if (ds.Tables[0].Rows.Count != 0) { //Bind ProductType,Manufacturer,Supplier lblProdType.Text = ds.Tables[0].Rows[0]["producttype name"].ToString(); lblManufacturerName.Text = ds.Tables[0].Rows[0]["MANUFACTURER NAME"].ToString(); //Check For Product Type productTypeID = int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString()); Count = prodAdmin.GetAttributeCount(int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString()), ZNodeConfigManager.SiteConfig.PortalID); //Check product atributes count if (Count > 0) { tabProductDetails.Tabs[2].Enabled = true; // Enable Manage inventory tab } else { tabProductDetails.Tabs[2].Enabled = false;// Disable Manage inventory tab } } if (product != null) { //General Information lblProdName.Text = product.Name; lblProdNum.Text = product.ProductNum.ToString(); if (Count > 0) { lblProductSKU.Text = "See Manage SKUs tab"; lblQuantity.Text = "See Manage SKUs tab"; lblReOrder.Text = "See Manage SKUs tab"; lblSupplierName.Text = "See Manage SKUs tab"; } else { lblProductSKU.Text = product.SKU; if(product.QuantityOnHand.HasValue) lblQuantity.Text = product.QuantityOnHand.Value.ToString(); if(product.ReorderLevel.HasValue) lblReOrder.Text = product.ReorderLevel.Value.ToString(); lblSupplierName.Text = ds.Tables[0].Rows[0]["Supplier Name"].ToString(); } if (product.MaxQty.HasValue) lblMaxQuantity.Text = product.MaxQty.Value.ToString(); //image if (product.ImageFile.Trim().Length > 0) { string ImageFilePath = ZNodeConfigManager.EnvironmentConfig.MediumImagePath + product.ImageFile; ItemImage.ImageUrl = ImageFilePath; } else { ItemImage.ImageUrl = ZNodeConfigManager.SiteConfig.ImageNotAvailablePath; } //Product Description and Features lblShortDescription.Text = product.ShortDescription; lblProductDescription.Text = product.Description; lblProductFeatures.Text = product.FeaturesDesc; lblproductspecification.Text = product.Specifications; lbladditionalinfo.Text = product.AdditionalInformation; lblDownloadLink.Text = product.DownloadLink; //Product Attributes if (product.RetailPrice.HasValue) lblRetailPrice.Text = product.RetailPrice.Value.ToString("c"); if (product.WholesalePrice.HasValue) lblWholeSalePrice.Text = product.WholesalePrice.Value.ToString("c"); lblSalePrice.Text = FormatPrice(product.SalePrice); lblWeight.Text = this.FormatProductWeight(product.Weight); if (product.Height.HasValue) lblHeight.Text = product.Height.Value.ToString("N2") + " " + ZNodeConfigManager.SiteConfig.DimensionUnit; if (product.Width.HasValue) lblWidth.Text = product.Width.Value.ToString("N2") + " " + ZNodeConfigManager.SiteConfig.DimensionUnit; if (product.Length.HasValue) lblLength.Text = product.Length.Value.ToString("N2") + " " + ZNodeConfigManager.SiteConfig.DimensionUnit; //Display Settings chkProductEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse(product.ActiveInd.ToString())); lblProdDisplayOrder.Text = product.DisplayOrder.ToString(); chkIsSpecialProduct.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.HomepageSpecial)); chkIsNewItem.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.NewProductInd)); chkProductPricing.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.CallForPricing)); chkproductInventory.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.InventoryDisplay)); // Display Tax Class Name if (product.TaxClassID.HasValue) { TaxRuleAdmin taxRuleAdmin = new TaxRuleAdmin(); TaxClass taxClass = taxRuleAdmin.GetByTaxClassID(product.TaxClassID.Value); if(taxClass != null) lblTaxClass.Text = taxClass.Name; } // Recurring Billing imgRecurringBillingInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.RecurringBillingInd)); lblBillingPeriod.Text = product.RecurringBillingPeriod; lblFrequency.Text = product.RecurringBillingFrequency; lblTotalCycles.Text = product.RecurringBillingTotalCycles.GetValueOrDefault(0).ToString(); shipSeparatelyInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(product.ShipSeparately); lblMastePageName.Text = product.MasterPage; //seo lblSEODescription.Text = product.SEODescription; lblSEOKeywords.Text = product.SEOKeywords; lblSEOTitle.Text = product.SEOTitle; lblSEOURL.Text = product.SEOURL; //checking whether the image is active or not //ZNode.Libraries.Admin.ProductViewAdmin pp = new ProductViewAdmin(); //Inventory Setting - Out of Stock Options if (product.TrackInventoryInd.HasValue && product.AllowBackOrder.HasValue) { if ((product.TrackInventoryInd.Value) && (product.AllowBackOrder.Value == false)) { chkCartInventoryEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("true")); chkIsBackOrderEnabled.Src = SetCheckMarkImage(); chkIstrackInvEnabled.Src = SetCheckMarkImage(); } else if (product.TrackInventoryInd.Value && product.AllowBackOrder.Value) { chkCartInventoryEnabled.Src = SetCheckMarkImage(); chkIsBackOrderEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("true")); chkIstrackInvEnabled.Src = SetCheckMarkImage(); } else if ((product.TrackInventoryInd.Value == false) && (product.AllowBackOrder.Value == false)) { chkCartInventoryEnabled.Src = SetCheckMarkImage(); chkIsBackOrderEnabled.Src = SetCheckMarkImage(); chkIstrackInvEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("true")); } } else { chkCartInventoryEnabled.Src = SetCheckMarkImage(); chkIsBackOrderEnabled.Src = SetCheckMarkImage(); chkIstrackInvEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("true")); } //Inventory Setting - Stock Messages lblInStockMsg.Text = product.InStockMsg; lblOutofStock.Text = product.OutOfStockMsg; lblBackOrderMsg.Text = product.BackOrderMsg; if (product.DropShipInd.HasValue) { IsDropShipEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(product.DropShipInd.Value); } else { IsDropShipEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("false")); } //Binding product Category DataSet dsCategory = prodAdmin.Get_CategoryByProductID(ItemId); StringBuilder Builder = new StringBuilder(); foreach (System.Data.DataRow dr in dsCategory.Tables[0].Rows) { Builder.Append(prodAdmin.GetCategorypath(dr["Name"].ToString(),dr["Parent1CategoryName"].ToString(), dr["Parent2CategoryName"].ToString())); Builder.Append("<br>"); } if (product.FeaturedInd) { FeaturedProduct.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(true); } else { FeaturedProduct.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(false); } lblProductCategories.Text = Builder.ToString(); //Bind ShippingRule type if(product.ShippingRuleTypeID.HasValue) lblShippingRuleTypeName.Text = GetShippingRuleTypeName(product.ShippingRuleTypeID.Value); if (product.FreeShippingInd.HasValue) freeShippingInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(product.FreeShippingInd.Value); else freeShippingInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(false); //Bind Grid - Product Related Items this.BindRelatedItems(); //this.BindImage(); this.BindImageDatas(); //Bind Grid - Product Addons BindProductAddons(); //Bind Grid - Inventory BindSKU(); //Tiered Pricing BindTieredPricing(); //Digital Asset BindDigitalAssets(); //Bind product highlights BindProductHighlights(); } else { throw (new ApplicationException("Product Requested could not be found.")); } }