protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { var temp = MailFormatService.Get(SQLDataHelper.GetInt(grid.UpdatedRow["ID"])); temp.FormatName = grid.UpdatedRow["FormatName"]; temp.Enable = SQLDataHelper.GetBoolean(grid.UpdatedRow["Enable"]); temp.SortOrder = SQLDataHelper.GetInt(grid.UpdatedRow["SortOrder"]); temp.FormatType = (MailType)SQLDataHelper.GetInt(grid.UpdatedRow["FormatType"]); MailFormatService.Update(temp); } 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(CultureInfo.InvariantCulture); }
protected void btnSave_Click(object sender, EventArgs e) { if (txtName.Text.Trim().Length == 0 || txtSubject.Text.Trim().Length == 0) { MsgErr(Resource.Admin_MailFormat_NoName); return; } if (CKEditorControl1.Text.Trim().Length == 0) { MsgErr(Resource.Admin_MailFormat_NoText); return; } int result = 0; if (!Int32.TryParse(txtSortOrder.Text, out result)) { MsgErr(Resource.Admin_MailFormat_SortNotNum); return; } MailFormat mailFormat = AddingNew ? new MailFormat() : MailFormatService.Get(MailFormatId); mailFormat.FormatName = txtName.Text.Trim(); mailFormat.FormatSubject = txtSubject.Text.Trim(); mailFormat.FormatText = CKEditorControl1.Text.Trim(); mailFormat.Enable = chkActive.Checked; mailFormat.SortOrder = Int32.Parse(txtSortOrder.Text); mailFormat.FormatType = (MailType)Int32.Parse(ddlTypes.SelectedValue); if (AddingNew) { MailFormatService.Add(mailFormat); Response.Redirect("MailFormat.aspx"); } else { lblMessage.Text = Resource.Admin_MailFormatDetail_Saved + "<br />"; lblMessage.Visible = true; MailFormatService.Update(mailFormat); LoadMailFormat(); } }
private void LoadMailFormat() { if (!AddingNew) { ddlTypes.DataBind(); MailFormat mailFormat = MailFormatService.Get(MailFormatId); txtName.Text = mailFormat.FormatName; txtSubject.Text = mailFormat.FormatSubject; lblHead.Text = mailFormat.FormatName; CKEditorControl1.Text = mailFormat.FormatText; chkActive.Checked = mailFormat.Enable; txtSortOrder.Text = mailFormat.SortOrder.ToString(CultureInfo.InvariantCulture); ddlTypes.SelectedValue = ((int)mailFormat.FormatType).ToString(CultureInfo.InvariantCulture); ShowMailFormatTypeDescription(); Page.Title = string.Format("{0} - {1}", AdvantShop.Configuration.SettingsMain.ShopName, mailFormat.FormatName); } }