Пример #1
0
        protected void gvCustomFees_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Insert":
                    var descriptionTextBox = (TextBox)gvCustomFees.FooterRow.FindControl("NewFeeDescriptionTextBox");
                    var amountTextBox = (TextBox)gvCustomFees.FooterRow.FindControl("NewFeeAmountTextBox");
                    var recurringCheckBox = (CheckBox)gvCustomFees.FooterRow.FindControl("NewFeeRecurringCheckBox");

                    var fee = new CustomFee()
                                  {
                                      Description = descriptionTextBox.Text,
                                      Amount = amountTextBox.Text.ToDecimalCurrency(),
                                      IsRecurring = recurringCheckBox.Checked
                                  };

                    var response = InvoicingService.SaveCustomFee(fee);
                    if (response.IsSuccessful) {
                        gvCustomFees.EditIndex = -1;
                        RefreshFeeGrid();
                        UserMessage.SetSuccess("Custom Fee added.");
                    }
                    else {
                        UserMessage.SetFailure(response.Message);
                    }

                    break;

                case "Cancel":
                    gvCustomFees.EditIndex = -1;
                    RefreshFeeGrid();
                    break;
            }
        }
Пример #2
0
        protected void gvCustomFees_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (this.Request["x"] != null && this.Request["y"] != null)
            {
                gvCustomFees.EditIndex = -1;
                RefreshFeeGrid();
            }
            else
            {

                int customFeeId = (int)gvCustomFees.DataKeys[e.RowIndex].Value;

                var fee = new CustomFee(customFeeId);

                var response = InvoicingService.RemoveCustomFee(fee);
                if (response.IsSuccessful)
                {
                    gvCustomFees.EditIndex = -1;
                    RefreshFeeGrid();

                    UserMessage.SetSuccess("Custom Fee deleted.");
                }
                else
                {
                    UserMessage.SetFailure(response.Message);
                }
            }
        }
Пример #3
0
        public IList<AirtimeBilling.Core.Entities.CustomFee> GetAllCustomFeesForContract(AirtimeBilling.Core.Entities.Contract contract)
        {
            IList<AirtimeBilling.Core.Entities.CustomFee> customFees = new List<AirtimeBilling.Core.Entities.CustomFee>();

            using (var db = DbFactory.GetDataContext()) {
                var fees = from cont in db.Contracts
                           where cont.ContractId == contract.Id.Value
                           select cont.ContractCustomFee;

                foreach (var fee in fees) {
                    var item = new AirtimeBilling.Core.Entities.CustomFee(fee.ContractCustomFeeId)
                                   {
                                       Description = fee.CustomFee.Description,
                                       Amount = fee.CustomFee.Amount,
                                       IsRecurring = fee.CustomFee.IsRecurring
                                   };
                    customFees.Add(item);
                }
            }

            // TODO
            return customFees;
        }
Пример #4
0
        protected void gvCustomFees_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var customFeeId = (int)gvCustomFees.DataKeys[e.RowIndex].Value;
            var description = gvCustomFees.Rows[e.RowIndex].Cells[2].Controls[1] as TextBox;
            var amount = gvCustomFees.Rows[e.RowIndex].Cells[3].Controls[1] as TextBox;
            var isRecurring = gvCustomFees.Rows[e.RowIndex].Cells[4].Controls[1] as CheckBox;

            var fee = new CustomFee(customFeeId)
                          {
                              Description = description.Text,
                              Amount = amount.Text.ToDecimalCurrency(),
                              IsRecurring = isRecurring.Checked
                          };

            var response = InvoicingService.SaveCustomFee(fee);

            if (response.IsSuccessful)
            {
                gvCustomFees.EditIndex = -1;
                RefreshFeeGrid();
                UserMessage.SetSuccess("Custom Fee updated.");
            }
            else
            {
                UserMessage.SetFailure(response.Message);
            }
        }
Пример #5
0
        protected void SaveNewFee(object sender, ImageClickEventArgs e)
        {
            var fee = new CustomFee
            {
                Description = NewFeeDescriptionTextBox.Text,
                Amount = NewFeeAmountTextBox.Text.ToDecimalCurrency(),
                IsRecurring = NewIsRecurringCheckBox.Checked
            };

            var response = InvoicingService.SaveCustomFee(fee);
            if (response.IsSuccessful)
            {
                gvCustomFees.EditIndex = -1;
                RefreshFeeGrid();

                UserMessage.SetSuccess("Custom Fee added.");
            }
            else
            {
                UserMessage.SetFailure(response.Message);
            }
        }