예제 #1
0
 protected void btnAddNewRegion_Click(System.Object sender, System.Web.UI.ImageClickEventArgs e)
 {
     msg.ClearMessage();
     try
     {
         MerchantTribe.Commerce.Taxes.TaxSchedule t = new TaxSchedule();
         t.Name = this.DisplayNameField.Text.Trim();
         MTApp.OrderServices.TaxSchedules.Create(t);
         msg.ShowOk("Added: " + t.Name);
         LoadSchedules();
         DisplayNameField.Text = "";
     }
     catch (Exception Ex)
     {
         msg.ShowException(Ex);
     }
 }
예제 #2
0
        // Create or Update
        public override string PostAction(string parameters, System.Collections.Specialized.NameValueCollection querystring, string postdata)
        {
            string data = string.Empty;
            string ids = FirstParameter(parameters);
            long id = 0;
            long.TryParse(ids, out id);
            ApiResponse<TaxScheduleDTO> response = new ApiResponse<TaxScheduleDTO>();

            TaxScheduleDTO postedCategory = null;
            try
            {
                postedCategory = MerchantTribe.Web.Json.ObjectFromJson<TaxScheduleDTO>(postdata);
            }
            catch(Exception ex)
            {
                response.Errors.Add(new ApiError("EXCEPTION", ex.Message));
                return MerchantTribe.Web.Json.ObjectToJson(response);                
            }

            TaxSchedule item = new TaxSchedule();
            item.FromDto(postedCategory);

            if (id < 1)
            {
                TaxSchedule existing = MTApp.OrderServices.TaxSchedules.FindByName(item.Name);
                if (existing == null)
                {
                    // Create
                    MTApp.OrderServices.TaxSchedules.Create(item);
                }
                else
                {
                    item.Id = existing.Id;
                }
            }
            else
            {
                MTApp.OrderServices.TaxSchedules.Update(item);
            }            
            response.Content = item.ToDto();
            
            data = MerchantTribe.Web.Json.ObjectToJson(response);            
            return data;
        }
예제 #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            msg.ClearMessage();

            ts = new TaxSchedule();

            if (!Page.IsPostBack)
            {

                string id = Request.QueryString["id"];

                PopulateCountries();
                string homeCountry = WebAppSettings.ApplicationCountryBvin;
                lstCountry.SelectedValue = homeCountry;
                PopulateRegions(lstCountry.SelectedItem.Value);

                LoadSchedule(long.Parse(id));

            }
        }
예제 #4
0
 private void LoadSchedule(long id)
 {
     ts = MTApp.OrderServices.TaxSchedules.FindForThisStore(id);            
     this.ScheduleNameField.Text = ts.Name;
     LoadRates(ts);            
 }
예제 #5
0
 private void LoadRates(TaxSchedule ts)
 {
     this.litRates.Text = string.Empty;
     foreach (Tax t in MTApp.OrderServices.Taxes.GetRates(MTApp.CurrentStore.Id, ts.Id))
     {
         RenderTax(t);
     }
 }
예제 #6
0
 private bool Save()
 {
     string ids = Request.QueryString["id"];
     long id = long.Parse(ids);
     ts = MTApp.OrderServices.TaxSchedules.FindForThisStore(id);
     ts.Name = this.ScheduleNameField.Text;
     return MTApp.OrderServices.TaxSchedules.Update(ts);
 }