コード例 #1
0
        new protected void Page_Load(object sender, EventArgs e)
        {
            Page.DataBind();
            _gradeUiMapping = new GradeUiMapping();

            string purchaseIdString = Request["ID"];

            if (!int.TryParse(purchaseIdString, out _purchaseID))
            {
                Response.Redirect(Pages.InfoPage + "?ID=" + InfoMessages.PurchaseNotFound.ToString());
            }

            if (!IsPostBack)
            {
                _gradeUiMapping.PopulateGradeDropDownList(DropDownListGrade);

                GasPurchase purchase = GasPurchasesDBRetriever.GetPurchase(Context.User.Identity.Name, _purchaseID);
                if (purchase == null)
                {
                    Response.Redirect(Pages.InfoPage + "?ID=" + InfoMessages.PurchaseNotFound.ToString());
                }

                Calendar.SelectedDate = purchase.When;
                Calendar.VisibleDate  = Calendar.SelectedDate;
                PriceTextBox.Text     = purchase.Price.ToString();
                AmountTextBox.Text    = purchase.Amount.ToString();
                DistanceTextBox.Text  = purchase.Distance.ToString();

                int gradeIndex = _gradeUiMapping.GradeToIndex(purchase.GradeOfFuel);
                DropDownListGrade.SelectedIndex = gradeIndex;
                NoteTextBox.Text = purchase.Note;
            }

            RegularExpressionValidator priceValidator = (RegularExpressionValidator)Page.FindControl("RegularExpression_PriceValidator");

            if (priceValidator != null)
            {
                priceValidator.ValidationExpression = RegExpr_NNNN_nn;
            }
            RegularExpressionValidator amountValidator = (RegularExpressionValidator)Page.FindControl("RegularExpression_AmountValidator");

            if (amountValidator != null)
            {
                amountValidator.ValidationExpression = RegExpr_NNNN_nn;
            }
            RegularExpressionValidator distanceValidator = (RegularExpressionValidator)Page.FindControl("RegularExpression_DistanceValidator");

            if (distanceValidator != null)
            {
                distanceValidator.ValidationExpression = RegExpr_NNNN_nn;
            }
        }
コード例 #2
0
        protected new void Page_Load(object sender, EventArgs e)
        {
            Page.DataBind();
            _gradeUiMapping = new GradeUiMapping();

            string purchaseIdString = Request["ID"];

            if (!int.TryParse(purchaseIdString, out _purchaseID))
            {
                Response.Redirect(Pages.InfoPage + "?ID=" + InfoMessages.PurchaseNotFound.ToString());
            }

            if (!IsPostBack)
            {
                _gradeUiMapping.PopulateGradeDropDownList(DropDownListGrade);

                GasPurchase purchase = GasPurchasesDBRetriever.GetPurchase(Context.User.Identity.Name, _purchaseID);
                if (purchase == null)
                {
                    Response.Redirect(Pages.InfoPage + "?ID=" + InfoMessages.PurchaseNotFound.ToString());
                }

                Calendar.SelectedDate = purchase.When;
                Calendar.VisibleDate = Calendar.SelectedDate;
                PriceTextBox.Text = purchase.Price.ToString();
                AmountTextBox.Text = purchase.Amount.ToString();
                DistanceTextBox.Text = purchase.Distance.ToString();

                int gradeIndex = _gradeUiMapping.GradeToIndex(purchase.GradeOfFuel);
                DropDownListGrade.SelectedIndex = gradeIndex;
                NoteTextBox.Text = purchase.Note;

            }

            RegularExpressionValidator priceValidator = (RegularExpressionValidator)Page.FindControl("RegularExpression_PriceValidator");
            if (priceValidator != null)
                priceValidator.ValidationExpression = RegExpr_NNNN_nn;
            RegularExpressionValidator amountValidator = (RegularExpressionValidator)Page.FindControl("RegularExpression_AmountValidator");
            if (amountValidator != null)
                amountValidator.ValidationExpression = RegExpr_NNNN_nn;
            RegularExpressionValidator distanceValidator = (RegularExpressionValidator)Page.FindControl("RegularExpression_DistanceValidator");
            if (distanceValidator != null)
                distanceValidator.ValidationExpression = RegExpr_NNNN_nn;
        }