protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { decimal sum; if (decimal.TryParse(grid.UpdatedRow["Sum"], out sum)) { var certificate = GiftCertificateService.GetCertificateByID(Convert.ToInt32(grid.UpdatedRow["ID"])); if (!certificate.Paid && Convert.ToBoolean(grid.UpdatedRow["Paid"]) && !CustomerSession.CurrentCustomer.IsVirtual) { GiftCertificateService.SendCertificateMails(certificate); } certificate.Sum = sum; certificate.Enable = Convert.ToBoolean(grid.UpdatedRow["Enable"]); certificate.Type = (CertificatePostType)int.Parse(grid.UpdatedRow["Type"]); certificate.Used = Convert.ToBoolean(grid.UpdatedRow["Used"]); certificate.Paid = Convert.ToBoolean(grid.UpdatedRow["Paid"]); GiftCertificateService.UpdateCertificateById(certificate); } } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(); }
protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { var certificate = GiftCertificateService.GetCertificateByID(SQLDataHelper.GetInt(grid.UpdatedRow["ID"])); //if (!certificate.Paid && SQLDataHelper.GetBoolean(grid.UpdatedRow["Paid"]) && !CustomerContext.CurrentCustomer.IsVirtual) //{ // GiftCertificateService.SendCertificateMails(certificate); //} OrderService.PayOrder(certificate.OrderId, SQLDataHelper.GetBoolean(grid.UpdatedRow["Paid"])); certificate.Enable = SQLDataHelper.GetBoolean(grid.UpdatedRow["Enable"]); certificate.Used = SQLDataHelper.GetBoolean(grid.UpdatedRow["Used"]); GiftCertificateService.UpdateCertificateById(certificate); } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(); }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteCertificate") { GiftCertificateService.DeleteCertificateById(SQLDataHelper.GetInt(e.CommandArgument)); } if (e.CommandName == "SendCertificate") { GiftCertificateService.SendCertificateMails( GiftCertificateService.GetCertificateByID(SQLDataHelper.GetInt(e.CommandArgument))); } }
protected void LoadCertificateById(int certificateId) { Certificate = GiftCertificateService.GetCertificateByID(certificateId); if (Certificate == null) { MsgErr("Certificate with this ID does not exist"); return; } lblCertificateCode.Text = Certificate.CertificateCode; txtFromName.Text = Certificate.FromName; txtToName.Text = Certificate.ToName; txtSum.Text = Certificate.Sum.ToString("#0.00"); chkPaid.Checked = Certificate.Paid; chkUsed.Checked = Certificate.Used; rbtnEmail.Checked = Certificate.Type == CertificatePostType.Email; rbtnMail.Checked = Certificate.Type == CertificatePostType.Mail; chkEnable.Checked = Certificate.Enable; txtMessage.Text = Certificate.CertificateMessage; txtFromEmail.Text = Certificate.FromEmail; if (Certificate.Type == CertificatePostType.Mail) { rbtnMail.Checked = true; cboCountry.SelectedItem.Selected = false; cboCountry.Items.FindByText(Certificate.Country).Selected = true; var region = cboRegion.Items.FindByText(Certificate.Zone); if (region != null) { MultiViewRegion.ActiveViewIndex = 0; cboRegion.SelectedItem.Selected = false; region.Selected = true; } else { MultiViewRegion.ActiveViewIndex = 1; txtState.Text = Certificate.Zone; } txtCity.Text = Certificate.City; txtZip.Text = Certificate.Zip; txtAddress.Text = Certificate.Address; } else { rbtnEmail.Checked = true; txtEmail.Text = Certificate.Email; } }
protected void LoadCertificateById(int certificateId) { Certificate = GiftCertificateService.GetCertificateByID(certificateId); if (Certificate == null) { MsgErr("Certificate with this ID does not exist"); return; } lblCertificateCode.Text = Certificate.CertificateCode; txtFromName.Text = Certificate.FromName; txtToName.Text = Certificate.ToName; txtSum.Text = Certificate.Sum.ToString("#0.00"); chkUsed.Checked = Certificate.Used; chkEnable.Checked = Certificate.Enable; txtMessage.Text = Certificate.CertificateMessage; txtEmail.Text = Certificate.ToEmail; chkPaid.Checked = OrderService.IsPaidOrder(Certificate.OrderId); }