protected void NumericOnly_ServerValidate(object source, ServerValidateEventArgs args)
        {
            string pattern = @"^[0-9]*$";
            Regex  rgx     = new Regex(pattern, RegexOptions.IgnoreCase);
            bool   result  = true;

            MatchCollection matches = rgx.Matches(txtImplemationCount.Text);

            if (matches.Count == 0 && txtImplemationCount.Text != "")
            {
                result = false;
            }
            matches = rgx.Matches(txtDestinationSum.Text);
            if (matches.Count == 0 && (txtImplemationCount.Text != "" || txtDestinationSum.Text != ""))
            {
                result = false;
            }
            matches = rgx.Matches(txtDestinationCount.Text);
            if (matches.Count == 0 && (txtImplemationCount.Text != "" || txtDestinationSum.Text != ""))
            {
                result = false;
            }
            matches = rgx.Matches(txtPrecentDiscount.Text);
            if (matches.Count == 0 && cbIsDiscount.Checked)
            {
                result = false;
            }
            if (result == false)
            {
                args.IsValid = result;
                Master.MessageCenter.DisplayErrorMessage(CampaignStrings.GetText(@"NumericOnly"));
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            HasEditPermission = Permissions.PermissionsForUser(SessionHelper.UserId()).Contains(Permissions.PermissionKeys.sys_perm);

            Master.AddButtonNew(CampaignStrings.GetText(@"NewCampaignButton"), @"EditCampaign.aspx?New=yes", new string[] { Permissions.PermissionKeys.sys_perm });
            dgCampaign.PageIndexChanged += dgCampaign_PageIndexChanged;
        }
 protected void ValidateCountOrSum_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (txtDestinationCount.Text != "" && txtDestinationSum.Text != "" && txtDestinationCount.Text != "0" && txtDestinationSum.Text != "0")
     {
         args.IsValid = false;
         Master.MessageCenter.DisplayErrorMessage(CampaignStrings.GetText(@"CountOrSum"));
     }
 }
 protected void ValidateCheckbox_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (cbIsDiscount.Checked && cbIsGift.Checked || !cbIsDiscount.Checked && !cbIsGift.Checked)
     {
         args.IsValid = false;
         Master.MessageCenter.DisplayErrorMessage(CampaignStrings.GetText(@"ErrorCheckBox"));
     }
 }
        protected void Date_ServerValidate(object source, ServerValidateEventArgs args)
        {
            bool result = !(cStartDate.SelectedDate == null || cStartDate.SelectedDate == new DateTime(0001, 1, 1, 0, 0, 0) ||
                            cEndDate.SelectedDate == null || cEndDate.SelectedDate == new DateTime(0001, 1, 1, 0, 0, 0) || cEndDate.SelectedDate <= cStartDate.SelectedDate);

            if (result == false)
            {
                args.IsValid = result;
                Master.MessageCenter.DisplayErrorMessage(CampaignStrings.GetText(@"ErrorDate"));
            }
        }
        protected void dgCampaign_ItemCommand(object sender, DataGridCommandEventArgs e)
        {
            int   index = e.Item.ItemIndex;
            Int64 CampaignId;

            if (e.CommandName.Equals("Delete"))
            {
                CampaignId = Int64.Parse(dgCampaign.DataKeys[index].ToString());
                Campaign c = Campaign.FetchByID(CampaignId);
                if (c.StartDate > DateTime.UtcNow)
                {
                    Query q = new Query(Campaign.TableSchema).Where(Campaign.Columns.CampaignId, CampaignId).Delete();
                    q.Execute();
                    Master.MessageCenter.DisplaySuccessMessage(CampaignStrings.GetText("CampaignDeletedSuccess"));
                }
                else
                {
                    Master.MessageCenter.DisplayErrorMessage(CampaignStrings.GetText("NoDeleteActiveCampaign"));
                }
                // Response.Redirect("DeleteCampaign.aspx?CampaignId=" + CampaignId);
                LoadItems();
            }
            else if (e.CommandName.Equals("Edit"))
            {
                CampaignId = Int64.Parse(dgCampaign.DataKeys[index].ToString());
                Campaign c = Campaign.FetchByID(CampaignId);
                if (c != null && c.EndDate > DateTime.Now)
                {
                    Response.Redirect("EditCampaign.aspx?CampaignId=" + CampaignId);
                }
                else
                {
                    Master.MessageCenter.DisplayErrorMessage(CampaignStrings.GetText("NotActiveCampaign"));
                }

                LoadItems();
            }
        }
 protected void Page_Init(object sender, EventArgs e)
 {
     Master.AddButtonNew(CampaignStrings.GetText(@"NewCampaignButton"), @"EditCampaign.aspx?New=yes", new string[] { Permissions.PermissionKeys.sys_perm });
 }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     Master.PageTitle  = CampaignStrings.GetText(@"CampaignTitlePage");
     Master.ActiveMenu = "Campiagn";
     Master.AddClientScriptInclude(@"dgDateManager.js");
 }