Example #1
0
    protected void uxTaxClassGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            string taxClassID = ((Label)uxTaxClassGrid.Rows[e.RowIndex].FindControl("uxTaxClassIDLabel")).Text;
            string name       = ((TextBox)uxTaxClassGrid.Rows[e.RowIndex].FindControl("uxNameText")).Text;

            if (!String.IsNullOrEmpty(taxClassID))
            {
                TaxClass taxClass = new TaxClass();
                taxClass.TaxClassID   = taxClassID;
                taxClass.TaxClassName = name;
                DataAccessContext.TaxClassRepository.Save(taxClass);
            }

            // End editing
            uxTaxClassGrid.EditIndex = -1;
            RefreshGrid();

            uxMessage.DisplayMessage(Resources.TaxClassMessages.UpdateSuccess);
        }
        catch (Exception)
        {
            string message = Resources.TaxClassMessages.UpdateError;
            throw new ApplicationException(message);
        }
        finally
        {
            // Avoid calling Update() automatically by GridView
            e.Cancel = true;
        }
    }
        public virtual TaxClass UpdateTaxClass(TaxClass entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            TaxClass other = GetTaxClass(entity.TaxClassId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update TaxClass set  [TaxClassGUID]=@TaxClassGUID
							, [Name]=@Name
							, [TaxCode]=@TaxCode
							, [DisplayOrder]=@DisplayOrder
							, [CreatedOn]=@CreatedOn 
							 where TaxClassID=@TaxClassID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@TaxClassID", entity.TaxClassId)
                , new SqlParameter("@TaxClassGUID", entity.TaxClassGuid)
                , new SqlParameter("@Name", entity.Name)
                , new SqlParameter("@TaxCode", entity.TaxCode)
                , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetTaxClass(entity.TaxClassId));
        }
Example #3
0
    protected void uxTaxClassGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Add")
        {
            try
            {
                string name = ((TextBox)uxTaxClassGrid.FooterRow.FindControl("uxNameText")).Text;

                TaxClass taxClass = new TaxClass();
                taxClass.TaxClassName = name;
                TaxClassRule taxClassRule = new TaxClassRule();
                taxClass.TaxClassRule.Add(taxClassRule);
                DataAccessContext.TaxClassRepository.Save(taxClass);

                ((TextBox)uxTaxClassGrid.FooterRow.FindControl("uxNameText")).Text = "";

                uxMessage.DisplayMessage(Resources.TaxClassMessages.AddSuccess);
            }
            catch (Exception)
            {
                string message = Resources.TaxClassMessages.AddError;
                throw new VevoException(message);
            }
            finally
            {
            }
            RefreshGrid();
        }

        if (e.CommandName == "Edit")
        {
            uxTaxClassGrid.ShowFooter = false;
            uxAddButton.Visible       = true;
        }
    }
        private void grdTaxClass_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridView grid = (GridView)sender;
            Guid     guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString());

            TextBox  txtTitle       = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtTitle");
            TextBox  txtDescription = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtDescription");
            TaxClass taxClass;

            if (guid != Guid.Empty)
            {
                taxClass = new TaxClass(guid);
            }
            else
            {
                taxClass         = new TaxClass();
                taxClass.Created = DateTime.UtcNow;
            }

            taxClass.SiteGuid     = siteSettings.SiteGuid;
            taxClass.Title        = txtTitle.Text;
            taxClass.Description  = txtDescription.Text;
            taxClass.LastModified = DateTime.UtcNow;
            taxClass.Save();

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
Example #5
0
        private Item GetItemFromRow(string row, TaxClass tax)
        {
            if (row == null)
            {
                return(null);
            }
            var rowList = row.Split(';');
            var barcode = "?";
            var name    = "?";
            var price   = "?";

            if (rowList.Length > 1)
            {
                barcode = rowList[1];
            }
            if (rowList.Length > 3)
            {
                name = rowList[3];
            }
            if (rowList.Length > 11)
            {
                price = rowList[10];
            }
            Item it = new Item();

            it.Id    = barcode;
            it.Price = price;
            it.Text  = name;
            it.Tax   = tax;
            return(it);
        }
        private void BindGrid()
        {
            using (IDataReader reader = TaxClass.GetPage(
                       siteSettings.SiteGuid,
                       pageNumber,
                       pageSize,
                       out totalPages))
            {
                if (this.totalPages > 1)
                {
                    string pageUrl = SiteRoot + "/Admin/AdminTaxClass.aspx?pagenumber={0}&sort=" + this.sort;

                    pgrTaxClass.Visible       = true;
                    pgrTaxClass.PageURLFormat = pageUrl;
                    pgrTaxClass.ShowFirstLast = true;
                    pgrTaxClass.CurrentIndex  = pageNumber;
                    pgrTaxClass.PageSize      = pageSize;
                    pgrTaxClass.PageCount     = totalPages;
                }
                else
                {
                    pgrTaxClass.Visible = false;
                }

                grdTaxClass.DataSource = reader;
                grdTaxClass.PageIndex  = pageNumber;
                grdTaxClass.PageSize   = pageSize;
                grdTaxClass.DataBind();
            }

            EnsureTaxClasses();
        }
Example #7
0
    private string DeleteItem(string taxClassRuleID)
    {
        int deleteIndex = -1;

        TaxClass     taxClass     = DataAccessContext.TaxClassRepository.GetOne(TaxClassID);
        TaxClassRule taxClassRule = new TaxClassRule();

        for (int i = 0; i < taxClass.TaxClassRule.Count; i++)
        {
            if (taxClass.TaxClassRule[i].TaxClassRuleID == taxClassRuleID)
            {
                taxClassRule = taxClass.TaxClassRule[i];
                deleteIndex  = i;
            }
        }

        string message = String.Empty;

        if (taxClassRule.IsDefaultState && taxClassRule.IsDefaultZip)
        {
            if (HaveChildState(taxClassRule.CountryCode))
            {
                message = Resources.TaxClassRuleMessages.DeleteDefaultStateError;
            }
            else
            {
                if (deleteIndex > -1)
                {
                    taxClass.TaxClassRule.RemoveAt(deleteIndex);
                    DataAccessContext.TaxClassRepository.Save(taxClass);
                }
            }
        }
        else if (taxClassRule.IsDefaultZip)
        {
            if (HaveChildZip(taxClassRule.CountryCode, taxClassRule.StateCode))
            {
                message = Resources.TaxClassRuleMessages.DeleteDefaultZipError;
            }
            else
            {
                if (deleteIndex > -1)
                {
                    taxClass.TaxClassRule.RemoveAt(deleteIndex);
                    DataAccessContext.TaxClassRepository.Save(taxClass);
                }
            }
        }
        else
        {
            if (deleteIndex > -1)
            {
                taxClass.TaxClassRule.RemoveAt(deleteIndex);
                DataAccessContext.TaxClassRepository.Save(taxClass);
            }
            SetupDefaultTaxRule(taxClassRule.CountryCode, taxClassRule.StateCode, taxClassRule.ZipCode);
        }
        return(message);
    }
Example #8
0
 /// <summary>
 /// Create a new OrderData specification
 /// </summary>
 /// <param name="productId">Your systems product ID</param>
 /// <param name="description">Description of the product (max 45 characters)</param>
 /// <param name="price">Amount in cents of the product (amount incl. vat)</param>
 /// <param name="vatCode">The vat code</param>
 /// <param name="quantity">Quantity of products with this product id</param>
 public OrderData(string productId, string description, int price, string vatCode, int quantity)
 {
     ProductId   = productId;
     Description = description;
     Price       = price;
     Quantity    = quantity;
     VatCode     = VatCode = EnumUtil.ToEnum <TaxClass>(vatCode);
 }
        private void grdTaxClass_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridView grid = (GridView)sender;
            Guid     guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString());

            TaxClass.Delete(guid);
            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
Example #10
0
    private void CreateDummyRow(IList <TaxClass> list)
    {
        TaxClass taxClass = new TaxClass();

        taxClass.TaxClassID = "-1";

        list.Add(taxClass);
    }
Example #11
0
 private void PopulateTaxClassList()
 {
     using (IDataReader reader = TaxClass.GetBySite(siteSettings.SiteGuid))
     {
         ddTaxClassGuid.DataSource = reader;
         ddTaxClassGuid.DataBind();
     }
 }
Example #12
0
    protected void uxTaxClassRuleGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Add")
        {
            try
            {
                TaxClass     taxClass     = DataAccessContext.TaxClassRepository.GetOne(TaxClassID);
                TaxClassRule taxClassRule = GetAddDetails();

                if (String.IsNullOrEmpty(taxClassRule.CountryCode))
                {
                    uxMessage.DisplayError(Resources.TaxClassRuleMessages.AddErrorSelectCountry);
                    return;
                }
                string existMessage;
                if (!IsExist(taxClassRule, out existMessage))
                {
                    taxClass.TaxClassRule.Add(taxClassRule);
                    DataAccessContext.TaxClassRepository.Save(taxClass);
                    AddDefaultTaxRule(taxClassRule.CountryCode, taxClassRule.StateCode, taxClassRule.ZipCode);

                    uxMessage.DisplayMessage(Resources.TaxClassRuleMessages.AddSuccess);
                    existMessage = String.Empty;
                }
                else
                {
                    uxMessage.DisplayError(existMessage);
                }

                ((TextBox)uxTaxClassRuleGrid.FooterRow.FindControl("uxZipCodeText")).Text = "";
                ((TextBox)uxTaxClassRuleGrid.FooterRow.FindControl("uxTaxRateText")).Text = "";
            }
            catch (Exception)
            {
                string message = Resources.TaxClassRuleMessages.AddError;
                throw new VevoException(message);
            }
            finally
            {
            }
            RefreshGrid();
        }
        if (e.CommandName == "Edit")
        {
            try
            {
                CurrentTaxClassRuleID         = e.CommandArgument.ToString();
                uxTaxClassRuleGrid.ShowFooter = false;
                uxAddButton.Visible           = true;
            }
            catch (Exception ex)
            {
                uxMessage.DisplayError(ex.Message);
            }
        }
    }
Example #13
0
 /// <summary>
 /// Create a new OrderData specification
 /// </summary>
 /// <param name="productId">Your systems product ID</param>
 /// <param name="description">Description of the product (max 45 characters)</param>
 /// <param name="price">Amount in cents of the product (amount incl. vat)</param>
 /// <param name="vatCode">The vat code</param>
 /// <param name="quantity">Quantity of products with this product id</param>
 public OrderData(string productId, string description, int price, TaxClass vatCode, int quantity)
 {
     ProductId = productId;
     Description = description;
     Price = price;
     Quantity = quantity;
     VatCode = vatCode;
     //VatCode = EnumUtil.ToEnumString<TaxClass>((TaxClass)vatCode);
     //VatCode = EnumUtil.ToEnum<TaxClass>(vatCode);
 }
Example #14
0
 /// <summary>
 /// Create a new OrderData specification
 /// </summary>
 /// <param name="productId">Your systems product ID</param>
 /// <param name="description">Description of the product (max 45 characters)</param>
 /// <param name="price">Amount in cents of the product (amount incl. vat)</param>
 /// <param name="vatCode">The vat code</param>
 /// <param name="quantity">Quantity of products with this product id</param>
 /// <param name="productType">Product Type</param>
 public OrderData(string productId, string description, int price, TaxClass vatCode, int quantity, ProductType productType)
 {
     ProductId   = productId;
     Description = description;
     Price       = price;
     Quantity    = quantity;
     VatCode     = vatCode;
     //VatCode = EnumUtil.ToEnumString<TaxClass>((TaxClass)vatCode);
     //VatCode = EnumUtil.ToEnum<TaxClass>(vatCode);
     ProductType = productType;
 }
Example #15
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TaxClass taxClass = taxClassService.Find(id.Value);

            if (taxClass == null)
            {
                return(HttpNotFound());
            }
            return(View(taxClass));
        }
Example #16
0
    /// <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;
        }
    }
Example #17
0
    private bool HaveChildState(string countryCode)
    {
        TaxClass taxClass = DataAccessContext.TaxClassRepository.GetOne(TaxClassID);

        for (int i = 0; i < taxClass.TaxClassRule.Count; i++)
        {
            if (taxClass.TaxClassRule[i].CountryCode == countryCode &&
                taxClass.TaxClassRule[i].IsDefaultCountry == false &&
                taxClass.TaxClassRule[i].IsDefaultState == false &&
                taxClass.TaxClassRule[i].IsDefaultZip == false)
            {
                return(true);
            }
        }
        return(false);
    }
Example #18
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TaxClass taxClass = taxClassService.Find(id.Value);

            if (taxClass == null)
            {
                return(HttpNotFound());
            }
            var model = Mapper.Map <TaxClassViewModel>(taxClass);

            return(View(model));
        }
        public async Task <IActionResult> Post([FromBody] TaxClassForm model)
        {
            if (ModelState.IsValid)
            {
                var tagClass = new TaxClass
                {
                    Name = model.Name
                };

                _taxClassRepository.Add(tagClass);
                await _taxClassRepository.SaveChangesAsync();

                return(CreatedAtAction(nameof(Get), new { id = tagClass.Id }, null));
            }
            return(BadRequest(ModelState));
        }
        public virtual TaxClass TaxClassFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            TaxClass entity = new TaxClass();

            entity.TaxClassId   = (System.Int32)dr["TaxClassID"];
            entity.TaxClassGuid = (System.Guid)dr["TaxClassGUID"];
            entity.Name         = dr["Name"].ToString();
            entity.TaxCode      = dr["TaxCode"].ToString();
            entity.DisplayOrder = (System.Int32)dr["DisplayOrder"];
            entity.CreatedOn    = (System.DateTime)dr["CreatedOn"];
            return(entity);
        }
Example #21
0
        private void grdTaxRate_RowEditing(object sender, GridViewEditEventArgs e)
        {
            if (ddGeoZones.SelectedIndex > -1)
            {
                geoZoneGuid = new Guid(ddGeoZones.SelectedValue);
            }

            GridView grid = (GridView)sender;

            grid.EditIndex = e.NewEditIndex;
            Guid guid = new Guid(grid.DataKeys[grid.EditIndex].Value.ToString());

            BindGrid();

            Button btnDelete = (Button)grid.Rows[e.NewEditIndex].Cells[0].FindControl("btnGridDelete");

            if (btnDelete != null)
            {
                btnDelete.Attributes.Add("OnClick", "return confirm('"
                                         + Resource.TaxRateGridDeleteWarning + "');");
            }

            DropDownList ddTaxClass = (DropDownList)grid.Rows[grid.EditIndex].Cells[0].FindControl("ddTaxClass");

            if (ddTaxClass != null)
            {
                using (IDataReader reader = TaxClass.GetBySite(siteSettings.SiteGuid))
                {
                    ddTaxClass.DataSource = reader;
                    ddTaxClass.DataBind();
                }

                if (guid != Guid.Empty)
                {
                    TaxRate  taxRate  = new TaxRate(guid);
                    ListItem listItem = ddTaxClass.Items.FindByValue(taxRate.TaxClassGuid.ToString());
                    if (listItem != null)
                    {
                        ddTaxClass.ClearSelection();
                        listItem.Selected = true;
                    }
                }
            }

            ddCountry.Enabled  = false;
            ddGeoZones.Enabled = false;
        }
Example #22
0
    private bool IsExistCountry(TaxClassRule taxClassRule)
    {
        TaxClass taxClass = DataAccessContext.TaxClassRepository.GetOne(TaxClassID);

        for (int i = 0; i < taxClass.TaxClassRule.Count; i++)
        {
            if (taxClass.TaxClassRule[i].CountryCode == taxClassRule.CountryCode &&
                String.IsNullOrEmpty(taxClass.TaxClassRule[i].StateCode) &&
                String.IsNullOrEmpty(taxClass.TaxClassRule[i].ZipCode) &&
                taxClass.TaxClassRule[i].IsDefaultCountry == false &&
                taxClass.TaxClassRule[i].TaxClassRuleID != taxClassRule.TaxClassRuleID)
            {
                return(true);
            }
        }
        return(false);
    }
Example #23
0
    protected void uxDeleteButton_Click(object sender, EventArgs e)
    {
        string[] checkedIDs = GetCheckedIDs();

        string containingID;

        if (ContainsProducts(checkedIDs, out containingID))
        {
            TaxClass taxClass = DataAccessContext.TaxClassRepository.GetOne(containingID);
            uxMessage.DisplayError(
                Resources.TaxClassMessages.DeleteErrorContainingProducts,
                taxClass.TaxClassName, containingID);
        }
        else
        {
            DeleteItems(checkedIDs);
        }
    }
Example #24
0
        private void EnsureTaxClasses()
        {
            if (grdTaxClass.Rows.Count == 0)
            {
                TaxClass taxClass = new TaxClass();
                taxClass.SiteGuid    = siteSettings.SiteGuid;
                taxClass.Title       = Resource.TaxClassTaxable;
                taxClass.Description = Resource.TaxClassTaxable;
                taxClass.Save();

                taxClass             = new TaxClass();
                taxClass.SiteGuid    = siteSettings.SiteGuid;
                taxClass.Title       = Resource.TaxClassNotTaxable;
                taxClass.Description = Resource.TaxClassNotTaxable;
                taxClass.Save();

                WebUtils.SetupRedirect(this, Request.RawUrl);
            }
        }
Example #25
0
    private TaxClassRule GetEditDetails(int index)
    {
        TaxClass     taxClass     = DataAccessContext.TaxClassRepository.GetOne(TaxClassID);
        TaxClassRule taxClassRule = new TaxClassRule();

        for (int i = 0; i < taxClass.TaxClassRule.Count; i++)
        {
            if (taxClass.TaxClassRule[i].TaxClassRuleID ==
                ((Label)uxTaxClassRuleGrid.Rows[index].FindControl("uxTaxClassRuleIDLabel")).Text.Trim())
            {
                taxClassRule = taxClass.TaxClassRule[i];
            }
        }

        taxClassRule.TaxRate = ConvertUtilities.ToDecimal(
            ((TextBox)uxTaxClassRuleGrid.Rows[index].FindControl("uxTaxRateText")).Text);

        return(taxClassRule);
    }
Example #26
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Attributes != null?Attributes.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (CatalogVisibility != null ? CatalogVisibility.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Categories != null ? Categories.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ExternalUrl != null ? ExternalUrl.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Featured.GetHashCode();
                hashCode = (hashCode * 397) ^ Id;
                hashCode = (hashCode * 397) ^ (Images != null ? Images.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ InStock.GetHashCode();
                hashCode = (hashCode * 397) ^ ManageStock.GetHashCode();
                hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ OnSale.GetHashCode();
                hashCode = (hashCode * 397) ^ ParentId;
                hashCode = (hashCode * 397) ^ (Permalink != null ? Permalink.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (PriceHtml != null ? PriceHtml.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Purchasable.GetHashCode();
                hashCode = (hashCode * 397) ^ (RegularPrice != null ? RegularPrice.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (RelatedIds != null ? RelatedIds.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (SalePrice != null ? SalePrice.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ShortDescription != null ? ShortDescription.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Slug != null ? Slug.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (StockQuantity != null ? StockQuantity.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (TaxClass != null ? TaxClass.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (TaxStatus != null ? TaxStatus.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ TotalSales;
                hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Virtual.GetHashCode();
                return(hashCode);
            }
        }
Example #27
0
    protected void uxTaxClassRuleGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            TaxClass     taxClass     = DataAccessContext.TaxClassRepository.GetOne(TaxClassID);
            TaxClassRule taxClassRule = GetEditDetails(e.RowIndex);

            string existMessage;
            if (!IsExist(taxClassRule, out existMessage))
            {
                DataAccessContext.TaxClassRepository.Save(taxClass);

                // End editing
                uxTaxClassRuleGrid.EditIndex = -1;
                CurrentTaxClassRuleID        = "";
                RefreshGrid();

                existMessage = String.Empty;
                uxMessage.DisplayMessage(Resources.TaxClassRuleMessages.UpdateSuccess);
            }
            else
            {
                uxMessage.DisplayError(existMessage);
            }
        }
        catch (Exception)
        {
            string message = Resources.TaxClassRuleMessages.UpdateError;
            throw new ApplicationException(message);
        }
        finally
        {
            // Avoid calling Update() automatically by GridView
            e.Cancel = true;
        }
    }
Example #28
0
    /// <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.";
        }
    }
        public virtual TaxClass InsertTaxClass(TaxClass entity)
        {
            TaxClass other = new TaxClass();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into TaxClass ( [TaxClassGUID]
				,[Name]
				,[TaxCode]
				,[DisplayOrder]
				,[CreatedOn] )
				Values
				( @TaxClassGUID
				, @Name
				, @TaxCode
				, @DisplayOrder
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@TaxClassID", entity.TaxClassId)
                    , new SqlParameter("@TaxClassGUID", entity.TaxClassGuid)
                    , new SqlParameter("@Name", entity.Name)
                    , new SqlParameter("@TaxCode", entity.TaxCode)
                    , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetTaxClass(Convert.ToInt32(identity)));
            }
            return(entity);
        }
Example #30
0
 /// <summary>
 /// Create a new OrderData specification
 /// </summary>
 /// <param name="productId">Your systems product ID</param>
 /// <param name="description">Description of the product (max 45 characters)</param>
 /// <param name="price">Amount in cents of the product (amount incl. vat)</param>
 /// <param name="vatCode">The vat code</param>
 public OrderData(string productId, string description, int price, TaxClass vatCode) : this(productId, description, price, vatCode, 1)
 {
 }
Example #31
0
 /// <summary>
 /// Create a new OrderData specification
 /// </summary>
 /// <param name="productId">Your systems product ID</param>
 /// <param name="description">Description of the product (max 45 characters)</param>
 /// <param name="price">Amount in cents of the product (amount incl. vat)</param>
 /// <param name="vatCode">The vat code</param>
 public OrderData(string productId, string description, int price, TaxClass vatCode)
     : this(productId, description, price, vatCode, 1)
 {
 }
Example #32
0
 /// <summary>
 /// Create a new OrderData specification
 /// </summary>
 /// <param name="productId">Your systems product ID</param>
 /// <param name="price">Amount in cents of the product (amount incl. vat)</param>
 /// <param name="vatCode">The vat code</param>
 public OrderData(string productId, int price, TaxClass vatCode)
     : this(productId, "", price, vatCode, 1)
 {
 }
Example #33
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce))
        {
            Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error"));
        }

        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        Util_CheckAccess();
        AppPath = m_refContentApi.ApplicationPath;

        try
        {
            PageLabel.Text = PageLabel.ToolTip = GetMessage("lbl pagecontrol page");
            OfLabel.Text = OfLabel.ToolTip = GetMessage("lbl pagecontrol of");

            FirstPage.ToolTip = GetMessage("lbl first page");
            lnkBtnPreviousPage.ToolTip = GetMessage("lbl previous page");
            NextPage.ToolTip = GetMessage("lbl next page");
            LastPage.ToolTip = GetMessage("lbl last page");

            FirstPage.Text = "[" + GetMessage("lbl first page") + "]";
            lnkBtnPreviousPage.Text = "[" + GetMessage("lbl previous page") + "]";
            NextPage.Text = "[" + GetMessage("lbl next page") + "]";
            LastPage.Text = "[" + GetMessage("lbl last page") + "]";

            m_refTaxClass = new TaxClass(this.m_refContentApi.RequestInformationRef);
            switch (this.m_sPageAction)
            {
                case "addedit":
                    if (Page.IsPostBack)
                    {
                        Process_AddEdit();
                    }
                    else
                    {
                        Display_AddEdit();
                    }
                    break;
                case "del":
                    Process_Delete();
                    break;
                case "view":
                    Display_View();
                    break;
                default:
                    if (Page.IsPostBack == false)
                    {
                        Display_All();
                    }
                    break;
            }

            Util_SetLabels();
            Util_SetJS();
            Ektron.Cms.API.Css.RegisterCss(this, Ektron.Cms.API.Css.ManagedStyleSheet.EktronFixedPositionToolbarCss);

        }
        catch (Exception ex)
        {
            Utilities.ShowError(ex.Message);
        }
    }
Example #34
0
        private void Display_EntryTab()
        {
            System.Collections.Generic.List<TaxClassData> TaxClassList = new System.Collections.Generic.List<TaxClassData>();
            Ektron.Cms.Common.Criteria<TaxClassProperty> criteria = new Ektron.Cms.Common.Criteria<TaxClassProperty>(TaxClassProperty.Id, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);

            //Excluding the shipping Tax class that comes in to the system.5 is the shipping tax id.
            criteria.AddFilter(TaxClassProperty.Id, CriteriaFilterOperator.NotEqualTo, 5);
            m_refTaxClass = new TaxClass(this.m_refContentApi.RequestInformationRef);
            TaxClassList = m_refTaxClass.GetList(criteria);

            drp_taxclass.DataTextField = "name";
            drp_taxclass.DataValueField = "id";
            drp_taxclass.DataSource = TaxClassList;
            drp_taxclass.DataBind();

            if (m_refContentApi.RequestInformationRef.MeasurementSystem == Ektron.Cms.Common.EkEnumeration.MeasurementSystem.English)
            {

                ltr_heightmeasure.Text = GetMessage("lbl inches");
                ltr_lengthmeasure.Text = GetMessage("lbl inches");
                ltr_widthmeasure.Text = GetMessage("lbl inches");
                ltr_weightmeasure.Text = GetMessage("lbl pounds");

            }
            else
            {

                ltr_heightmeasure.Text = GetMessage("lbl centimeters");
                ltr_lengthmeasure.Text = GetMessage("lbl centimeters");
                ltr_widthmeasure.Text = GetMessage("lbl centimeters");
                ltr_weightmeasure.Text = GetMessage("lbl kilograms");

            }

            Util_BindFieldList();

            if (entry_edit_data != null)
            {
                txt_sku.Text = entry_edit_data.Sku;
                txt_quantity.Text = entry_edit_data.QuantityMultiple.ToString();
                drp_taxclass.SelectedValue = entry_edit_data.TaxClassId.ToString();
                chk_avail.Checked = entry_edit_data.IsArchived;
                // chk_markdel.Checked = entry_edit_data.IsMarkedForDeletion
                if (entry_edit_data.Id == 0)
                {
                    chk_buyable.Checked = true;
                }
                if (entry_edit_data.IsArchived)
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "chk_buyable", "document.getElementById(\'chk_buyable\').disabled = true;", true);
                }
                if (!entry_edit_data.IsArchived)
                {
                    chk_buyable.Checked = entry_edit_data.IsBuyable;
                }
                else
                {
                    chk_buyable.Checked = false;
                }

                chk_tangible.Checked = entry_edit_data.IsTangible;
                chk_disableInv.Enabled = Util_IsEditable();
                if (Util_IsEditable() == false || !entry_edit_data.IsTangible)
                {
                    txt_height.Enabled = false;
                    txt_length.Enabled = false;
                    txt_width.Enabled = false;
                    txt_weight.Enabled = false;
                }

                txt_height.Text = entry_edit_data.Dimensions.Height.ToString();
                txt_length.Text = entry_edit_data.Dimensions.Length.ToString();
                txt_width.Text = entry_edit_data.Dimensions.Width.ToString();
                txt_weight.Text = entry_edit_data.Weight.Amount.ToString();

                InventoryApi inventoryApi = new InventoryApi();
                InventoryData inventoryData = inventoryApi.GetInventory(entry_edit_data.Id);

                chk_disableInv.Checked = entry_edit_data.DisableInventoryManagement;
                chk_disableInv.Enabled = Util_IsEditable();
                if (Util_IsEditable() == false || entry_edit_data.DisableInventoryManagement)
                {
                    txt_instock.Enabled = false;
                    txt_onorder.Enabled = false;
                    txt_reorder.Enabled = false;
                }

                txt_instock.Text = inventoryData.UnitsInStock.ToString();
                txt_onorder.Text = inventoryData.UnitsOnOrder.ToString();
                txt_reorder.Text = inventoryData.ReorderLevel.ToString();
            }
            else
            {

                txt_height.Enabled = false;
                txt_length.Enabled = false;
                txt_width.Enabled = false;
                txt_weight.Enabled = false;

                txt_instock.Enabled = false;
                txt_onorder.Enabled = false;
                txt_reorder.Enabled = false;

            }

            Util_ToggleProperties(Util_IsEditable());
        }
Example #35
0
 /// <summary>
 /// Create a new OrderData specification
 /// </summary>
 /// <param name="productId">Your systems product ID</param>
 /// <param name="price">Amount in cents of the product (amount incl. vat)</param>
 /// <param name="vatCode">The vat code</param>
 public OrderData(string productId, int price, TaxClass vatCode) : this(productId, "", price, vatCode, 1, ProductType.ARTICLE)
 {
 }
Example #36
0
 /// <summary>
 /// Create a new OrderData specification
 /// </summary>
 /// <param name="productId">Your systems product ID</param>
 /// <param name="price">Amount in cents of the product (amount incl. vat)</param>
 /// <param name="vatCode">The vat code</param>
 public OrderData(string productId, int price, TaxClass vatCode) : this(productId, "", price, vatCode, 1)
 {
 }
Example #37
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Page.Validate("webstore");
            if ((Page.IsValid) && (store != null))
            {
                SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

                if (store.SiteGuid == Guid.Empty)
                {
                    store.SiteGuid = siteSettings.SiteGuid;
                }
                if (store.ModuleId == -1)
                {
                    store.ModuleId = moduleId;
                }

                Module module = new Module(moduleId);
                module.ModuleTitle = txtName.Text;
                module.Save();

                store.Name          = txtName.Text;
                store.Description   = edDescription.Text;
                store.OwnerName     = txtOwnerName.Text;
                store.OwnerEmail    = txtOwnerEmail.Text;
                store.SalesEmail    = txtSalesEmail.Text;
                store.SupportEmail  = txtSupportEmail.Text;
                store.EmailFrom     = txtEmailFrom.Text;
                store.OrderBccEmail = txtOrderBCCEmail.Text;
                store.Phone         = txtPhone.Text;
                store.Fax           = txtFax.Text;
                store.Address       = txtAddress.Text;
                store.City          = txtCity.Text;

                if (!String.IsNullOrEmpty(ddZoneGuid.SelectedValue))
                {
                    store.ZoneGuid = new Guid(ddZoneGuid.SelectedValue);
                }

                store.PostalCode = txtPostalCode.Text;

                if (!String.IsNullOrEmpty(ddCountryGuid.SelectedValue))
                {
                    store.CountryGuid = new Guid(ddCountryGuid.SelectedValue);
                }

                store.IsClosed      = chkIsClosed.Checked;
                store.ClosedMessage = edClosedMessage.Text;


                if (store.Guid == Guid.Empty)
                {
                    store.Created   = DateTime.UtcNow;
                    store.CreatedBy = siteUser.UserGuid;
                }

                store.Save();

                List <TaxClass> taxClasses = TaxClass.GetList(siteSettings.SiteGuid);

                if (taxClasses.Count == 0)
                {
                    TaxClass taxClass = new TaxClass();
                    taxClass.SiteGuid    = siteSettings.SiteGuid;
                    taxClass.Title       = WebStoreResources.TaxClassTaxable;
                    taxClass.Description = WebStoreResources.TaxClassTaxable;
                    taxClass.Save();

                    taxClass             = new TaxClass();
                    taxClass.SiteGuid    = siteSettings.SiteGuid;
                    taxClass.Title       = WebStoreResources.TaxClassNotTaxable;
                    taxClass.Description = WebStoreResources.TaxClassNotTaxable;
                    taxClass.Save();
                }

                List <FullfillDownloadTerms> downloadTerms = FullfillDownloadTerms.GetList(store.Guid);
                if (downloadTerms.Count == 0)
                {
                    if (currentUser == null)
                    {
                        currentUser = SiteUtils.GetCurrentSiteUser();
                    }
                    if (currentUser != null)
                    {
                        FullfillDownloadTerms term = new FullfillDownloadTerms();
                        term.Name          = WebStoreResources.DownloadUnlimited;
                        term.Description   = WebStoreResources.DownloadUnlimited;
                        term.CreatedBy     = currentUser.UserGuid;
                        term.CreatedFromIP = SiteUtils.GetIP4Address();
                        term.StoreGuid     = store.Guid;
                        term.Save();
                    }
                }

                WebUtils.SetupRedirect(this, Request.RawUrl);
            }
        }