예제 #1
0
        private void FillDropDown(bool isAddNew = true)
        {
            ddlArea.DataSource     = AreaService.GetAll();
            ddlArea.DataTextField  = "Description";
            ddlArea.DataValueField = "ID";
            ddlArea.DataBind();
            ddlArea.Items.Insert(0, new ListItem(String.Empty, "0"));

            ddlFindBranch.DataSource     = BranchService.GetActiveBranches(User.Identity.Name);
            ddlFindBranch.DataTextField  = "Name";
            ddlFindBranch.DataValueField = "ID";
            ddlFindBranch.DataBind();


            ddlBillingType.DataSource     = BillingTypeService.GetActiveBillingTypes(isAddNew);
            ddlBillingType.DataTextField  = "Description";
            ddlBillingType.DataValueField = "ID";
            ddlBillingType.DataBind();
            ddlBillingType.Items.Insert(0, String.Empty);

            ddlPackage.DataSource     = PackageService.GetPackagesInBranch(Convert.ToInt32(ddlFindBranch.SelectedValue), isAddNew);
            ddlPackage.DataTextField  = "Name";
            ddlPackage.DataValueField = "ID";
            ddlPackage.DataBind();
            ddlPackage.Items.Insert(0, String.Empty);

            ddlOccupation.DataSource     = OccupationService.GetAll();
            ddlOccupation.DataValueField = "ID";
            ddlOccupation.DataTextField  = "Description";
            ddlOccupation.DataBind();
            ddlOccupation.Items.Insert(0, new DropDownListItem(String.Empty));

            ddlBillingBank.DataSource     = BankService.GetActiveBanks(isAddNew);
            ddlBillingBank.DataTextField  = "Name";
            ddlBillingBank.DataValueField = "ID";
            ddlBillingBank.DataBind();
            ddlBillingBank.Items.Insert(0, String.Empty);


            ddlCardExpiredMonth.DataSource     = CommonHelper.GetMonthNames();
            ddlCardExpiredMonth.DataTextField  = "Value";
            ddlCardExpiredMonth.DataValueField = "Key";
            ddlCardExpiredMonth.DataBind();
            ddlCardExpiredMonth.SelectedValue = DateTime.Today.Month.ToString(CultureInfo.InvariantCulture);

            ddlCardExpiredYear.DataSource = Enumerable.Range(2005, DateTime.Today.Year + 10 - 2005);
            ddlCardExpiredYear.DataBind();
            ddlCardExpiredYear.SelectedValue = DateTime.Today.Year.ToString();

            ddlMonthlyDuesItem.DataSource     = ItemService.GetMonthlyDuesItem();
            ddlMonthlyDuesItem.DataTextField  = "Description";
            ddlMonthlyDuesItem.DataValueField = "ID";
            ddlMonthlyDuesItem.DataBind();
            ddlMonthlyDuesItem.Items.Insert(0, String.Empty);

            DataBindingHelper.PopulateCreditCardTypes(CreditCardTypeService, ddlBillingCardType, true);
        }
 protected void gvwMaster_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "EditRow")
     {
         int id = Convert.ToInt32(e.CommandArgument);
         RowID = id;
         mvwForm.SetActiveView(viwAddEdit);
         BillingType billingType = BillingTypeService.Get(id);
         txtDescription.Text = billingType.Description;
         txtAutoPayDay.Text  = RowID > BillingTypeConstants.MANUAL_PAYMENT
             ? Convert.ToString(billingType.AutoPayDay)
             : "N/A";
         chkIsActive.Checked = billingType.IsActive;
         txtDescription.Focus();
         btnSave.Enabled = RowID > BillingTypeConstants.MANUAL_PAYMENT;
     }
 }
 protected void lnbDelete_Click(object sender, EventArgs e)
 {
     try
     {
         int[] id = WebFormHelper.GetRowIdForDeletion(gvwMaster);
         if (!id.Contains(1))
         {
             BillingTypeService.Delete(id);
         }
         else
         {
             WebFormHelper.SetLabelTextWithCssClass(lblMessage, "<b>Manual Payment</b> cannot be deleted", LabelStyleNames.ErrorMessage);
         }
         Refresh();
     }
     catch (Exception ex)
     {
         mvwForm.ActiveViewIndex = 0;
         WebFormHelper.SetLabelTextWithCssClass(lblMessage, ex.Message, LabelStyleNames.ErrorMessage);
         LogService.ErrorException(GetType().FullName, ex);
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                switch (RowID)
                {
                case 0:
                    BillingTypeService.Add(
                        txtDescription.Text,
                        Convert.ToInt16(txtAutoPayDay.Value),
                        chkIsActive.Checked);
                    break;

                default:
                    if (chkIsActive.Checked == false && CustomerService.GetCustomersByBillingType(RowID).Any())
                    {
                        mvwForm.ActiveViewIndex = 0;
                        WebFormHelper.SetLabelTextWithCssClass(lblMessage, "Cannot set this billing type to inactive since there are customers use this billing type", LabelStyleNames.ErrorMessage);
                        return;
                    }
                    BillingTypeService.Update(
                        RowID,
                        txtDescription.Text,
                        Convert.ToInt16(txtAutoPayDay.Value),
                        chkIsActive.Checked);
                    break;
                }
                Refresh();
            }
            catch (Exception ex)
            {
                mvwForm.ActiveViewIndex = 0;
                WebFormHelper.SetLabelTextWithCssClass(lblMessage, ex.Message, LabelStyleNames.ErrorMessage);
                LogService.ErrorException(GetType().FullName, ex);
            }
        }