private int AddRecord_DiscountStore() { int intActionResult = 0; DiscountZone discountZone = new DiscountZone(); DateTimeValidation dateTimeValidation = new DateTimeValidation(); DiscountManegar manager = new DiscountManegar(); discountZone.ProfileID = Convert.ToInt16(ProfileID); discountZone.DiscountUserType = Convert.ToInt16(GetDiscountType); discountZone.IsActive = true; discountZone.CheckAdminForListing = false; discountZone.CheckAdminForListingFeatureStore = false; discountZone.IsAdminAuthentication = true; discountZone.UserType = Convert.ToBoolean(IsAdmin); try { if (ProfileID != 0 && policyRadioButtonList.SelectedValue.ToString() == "1") { intActionResult = manager.Ad_Store(discountZone); } else { intActionResult = -1; } } catch (Exception ex) { lblSystemMessage.Text = ex.Message; } return(intActionResult); }
protected void Page_Load(object sender, EventArgs e) { DateTime dtFrom; DateTime dtTo; DateTimeValidation dateTimeValidation = new DateTimeValidation(); DateTimeValidation.Date_Validation dateValidation = new DateTimeValidation.Date_Validation(); ddlCouponType.Enabled = false; this.CheckUserSession(); if (!Page.IsPostBack) { this.CheckQueryString(); dtFrom = DateTime.Today; dtTo = DateTime.Today.AddMonths(1); txtFromDate.Text = dtFrom.ToString("MM/dd/yyyy"); txtToDate.Text = dtTo.ToString("MM/dd/yyyy"); //txtFromDate.Text = Convert.ToString(dateValidation.date_Format_Front_End(DateTime.Today)); //txtToDate.Text = Convert.ToString(dateValidation.date_Format_Front_End(DateTime.Today.AddMonths(1))); } }
private void ValidateTexBoxDate(TextBox textBox) { var tag = textBox.Tag.ToString(); // проверяем корректность формата даты if (!DateTimeValidation.CheckDateStringFormat(textBox.Text)) { InsertErrorField(tag); throw new FormatException(string.Format("Incorrect {0}", tag)); } RemoveErrorField(tag); }
private int AddRecord_DiscountProfile() { int intActionResult = 0; int validateInputDate = 0; int validateInputCoupon = 0; DataTable dt = new DataTable(); int startDigit = 00000; DiscountZone discountZone = new DiscountZone(); DateTimeValidation dateTimeValidation = new DateTimeValidation(); DiscountManegar manager = new DiscountManegar(); DateTimeValidation.Date_Validation dateValidation = new DateTimeValidation.Date_Validation(); int validDateRange = DateTime.Compare(Convert.ToDateTime(dateValidation.date_Format_Back_End(txtToDate.Text.Trim())), Convert.ToDateTime(dateValidation.date_Format_Back_End(txtFromDate.Text.Trim()))); try { dt = manager.GenerateCouponCode(); if (dt.Rows.Count > 0) { GeneratedCopunCode = dt.Rows[0]["MaxCouponCode"].ToString(); } } catch (Exception ex) { lblSystemMessage.Text = ex.Message; } if (validDateRange > 0) { validateInputDate = 1; dateTimeLabel.Text = ""; } else { validateInputDate = 0; dateTimeLabel.Text = "*Enter valid date range."; } discountZone.CategoryID = Convert.ToInt16(CategoryID); discountZone.SubcategoryID = Convert.ToInt16(SubCategoryID); discountZone.ProfileID = Convert.ToInt16(ProfileID); discountZone.CouponTitle = couponTitleTextBox.Text.ToString(); discountZone.TermsCondition = termsConditionsTextBox.Text.ToString(); discountZone.CouponDescription = couponDescriptionTextBox.Text.ToString(); discountZone.CouponType = ddlCouponType.SelectedItem.ToString(); if (GetDiscountType == "1") { discountZone.CouponCode = "ApnerDeal-" + (startDigit + Convert.ToInt32(GeneratedCopunCode) + 1); } else { discountZone.CouponCode = "BM-STAN-" + (startDigit + Convert.ToInt32(GeneratedCopunCode) + 1); } discountZone.NeedToPrintCoupon = Convert.ToBoolean(isPrintedCouponNeedRadioButtonList.SelectedValue); discountZone.UseBoromelaCoupon = Convert.ToInt16(DiscountType.SelectedValue); discountZone.UserUploadedCouponPath = ImagePath.ToString(); discountZone.IsActive = true; discountZone.IsAdminAuthentication = true; discountZone.CheckAdminForListing = false; discountZone.UserType = Convert.ToBoolean(IsAdmin); discountZone.CouponEffectiveDate = Convert.ToDateTime(dateValidation.date_Format_Back_End(txtFromDate.Text)); discountZone.CouponExpirydate = Convert.ToDateTime(dateValidation.date_Format_Back_End(txtToDate.Text)); discountZone.UpdatedOn = DateTime.Now; discountZone.DiscountCouponURL = urlTextBox.Text.ToString(); if (DiscountType.SelectedValue.ToString() == "2" && ImagePath == "") { validateInputCoupon = 0; couponLabel.Text = "*Please upload your own coupon."; } else { validateInputCoupon = 1; couponLabel.Text = ""; } try { if (validateInputCoupon == 1 && validateInputDate == 1) { intActionResult = manager.Ad_Discount(discountZone); } else { } } catch (Exception ex) { lblSystemMessage.Text = ex.Message; } return(intActionResult); }
private int UpdateRecord_DiscountProfile() { DateTime dtFrom; DateTime dtTo; dtFrom = Convert.ToDateTime(txtFromDate.Text); dtTo = Convert.ToDateTime(txtToDate.Text); txtFromDate.Text = dtFrom.ToString("MM/dd/yyyy"); txtToDate.Text = dtTo.ToString("MM/dd/yyyy"); int intActionResult = 0; int validateInputDate = 0; int validateInputCoupon = 0; DataTable dt = new DataTable(); DiscountZone discountZone = new DiscountZone(); discountZone.CouponID = CouponID; discountZone.ProfileID = ProfileID; discountZone.CouponCode = CouponCode; DateTimeValidation dateTimeValidation = new DateTimeValidation(); DiscountManegar manager = new DiscountManegar(); DateTimeValidation.Date_Validation dateValidation = new DateTimeValidation.Date_Validation(); int validDateRange = DateTime.Compare(Convert.ToDateTime(dateValidation.date_Format_Back_End(txtToDate.Text.Trim())), Convert.ToDateTime(dateValidation.date_Format_Back_End(txtFromDate.Text.Trim()))); if (validDateRange >= 0) { validateInputDate = 1; dateTimeLabel.Text = ""; } else { validateInputDate = 0; dateTimeLabel.Text = "*Enter valid date range."; } discountZone.CouponTitle = couponTitleTextBox.Text.ToString(); discountZone.TermsCondition = termsConditionsTextBox.Text.ToString(); discountZone.CouponDescription = couponDescriptionTextBox.Text.ToString(); discountZone.CouponType = ddlCouponType.SelectedItem.ToString(); discountZone.UseBoromelaCoupon = Convert.ToInt16(DiscountType.SelectedValue); discountZone.UserUploadedCouponPath = ImagePath.ToString(); discountZone.NeedToPrintCoupon = Convert.ToBoolean(isPrintedCouponNeedRadioButtonList.SelectedValue); discountZone.CouponEffectiveDate = Convert.ToDateTime(dateValidation.date_Format_Back_End(txtFromDate.Text.Trim())); discountZone.CouponExpirydate = Convert.ToDateTime(dateValidation.date_Format_Back_End(txtToDate.Text.Trim())); discountZone.UpdatedOn = DateTime.Now; discountZone.DiscountCouponURL = urlTextBox.Text.ToString(); if (DiscountType.SelectedValue.ToString() == "2" && ImagePath == "") { validateInputCoupon = 0; couponLabel.Text = "*Please upload your won coupon."; } else { validateInputCoupon = 1; couponLabel.Text = ""; } try { if (validateInputCoupon == 1 && validateInputDate == 1) { intActionResult = manager.Update_Discount(discountZone); } else { } } catch (Exception ex) { lblSystemMessage.Text = ex.Message; } return(intActionResult); }
private void SelectRecordDiscount() { DiscountZone discountZone = new DiscountZone(); DateTimeValidation dateTimeValidation = new DateTimeValidation(); DiscountManegar manager = new DiscountManegar(); DataTable dt = new DataTable(); discountZone.CouponID = CouponID; discountZone.ProfileID = ProfileID; discountZone.CouponCode = CouponCode; dt = manager.LoadRecord_BS_SpecificDiscount(discountZone); if (dt.Rows.Count > 0) { couponTitleTextBox.Text = dt.Rows[0]["CouponTitle"].ToString(); couponDescriptionTextBox.Text = dt.Rows[0]["CouponDescription"].ToString(); txtFromDate.Text = dt.Rows[0]["CouponEffectiveDate"].ToString(); txtToDate.Text = dt.Rows[0]["CouponExpirydate"].ToString(); string PrientedCouponNeed = dt.Rows[0]["PrintedCouponNeed"].ToString(); if (PrientedCouponNeed == "True") { isPrintedCouponNeedRadioButtonList.SelectedValue = "True"; } else if (PrientedCouponNeed == "False") { isPrintedCouponNeedRadioButtonList.SelectedValue = "False"; } string CouponTemplate = dt.Rows[0]["UseBoromelaCoupon"].ToString(); if (CouponTemplate == "UsedBoromelaCouponTemplate") { DiscountType.SelectedValue = "1"; Enable_Panel(userCouponUpload, false); Enable_Panel(urlPanel, false); } else if (CouponTemplate == "UsedCompanyCouponTemplate") { DiscountType.SelectedValue = "2"; Enable_Panel(userCouponUpload, true); Enable_Panel(urlPanel, false); ImagePath = dt.Rows[0]["UserUploadedCouponPath"].ToString(); } else if (CouponTemplate == "UsedCompanyURL") { DiscountType.SelectedValue = "3"; Enable_Panel(urlPanel, true); Enable_Panel(userCouponUpload, false); urlTextBox.Text = dt.Rows[0]["DiscountCouponURL"].ToString(); } termsConditionsTextBox.Text = dt.Rows[0]["TermsCondition"].ToString(); } else { strSystemMessage = "<table style='width:500px; border:1px dashed #666666;'>"; strSystemMessage += "<tr>"; strSystemMessage += "<td colspan='2' style='width:100%; color:#000000; padding-top:7px; padding-left:10px;'>"; strSystemMessage += "Product Profile not found!"; strSystemMessage += "<br/><br/>"; strSystemMessage += "<strong>How did this happen? </strong>"; strSystemMessage += "<ul>"; strSystemMessage += "<li>You login session may be expired.</li>"; strSystemMessage += "<li>Your Discount may be deleted by ApnerDeal authority for some reason.</li>"; strSystemMessage += "</ul>"; strSystemMessage += "</td>"; strSystemMessage += "</tr>"; strSystemMessage += "</table>"; lblSystemMessage.Text = UTLUtilities.ShowErrorMessage(strSystemMessage); } }
public void Test_DateTimeFormatValidationError() { const string date = "2021-10"; Assert.IsFalse(DateTimeValidation.CheckDateStringFormat(date)); }
public void Test_DateTimeFormatValidation() { const string date = "2021-10-10"; DateTimeValidation.CheckDateStringFormat(date); }