protected void Themes_OnRowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("editThemes")) { Response.Redirect("EditThemes.aspx?themeId=" + e.CommandArgument.ToString()); } else if (e.CommandName.Equals("SetDefault")) { SiteThemes _t = new SiteThemes(this.ConnectionString); _t.LitePopulate(e.CommandArgument.ToString(), false); _t.Default = true; _t.Save(); BindData(); } }
protected void Updade_Click(object sender, EventArgs e) { SiteThemes _st = null; foreach (GridViewRow I in gv_Themes.Rows) { Label _id = (Label)I.FindControl("lbl_Id"); if (_id != null) { TextBox _sort = (TextBox)I.FindControl("txt_Sort"); if (Regex.IsMatch(_sort.Text, @"\d+", RegexOptions.IgnoreCase)) { _st = new SiteThemes(this.ConnectionString); _st.LitePopulate(_id.Text, false); _st.Sort = Convert.ToInt32(_sort.Text); _st.Save(); } } } BindData(); }
/// <summary> /// Save Themes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Save_Themes(object sender, EventArgs e) { if (IsValid) { SiteThemes _tms = new SiteThemes(this.ConnectionString); String _orgFileName = ""; if (ViewState["themeId"] != null) { _tms.LitePopulate(ViewState["themeId"], false); _orgFileName = _tms.Name; } _tms.Name = Regex.Replace(txt_Name.Text, @"\s+", "_"); _tms.Status = Convert.ToInt32(dd_Status.SelectedValue); if (_tms.Save()) { String _path = Server.MapPath(String.Format(ConfigurationManager.AppSettings["ThemesZipPath"], _tms.Name)); String _orgPath = Server.MapPath(String.Format(ConfigurationManager.AppSettings["ThemesZipPath"], _orgFileName)); if (fu_File.HasFile) { fu_File.SaveAs(_path); String _themesPath = Server.MapPath(String.Format("../App_Themes/{0}/", _tms.Name)); Directory.CreateDirectory(_themesPath); _tms.UnZip(_themesPath, fu_File.PostedFile.InputStream); } //if (!String.IsNullOrEmpty(_orgFileName)) //{ // if (!_orgFileName.Equals(_tms.Name)) // { // File.Move(_orgPath, _path); // File.Delete(_orgPath); // } //} this.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('Record has been updated successfully.');self.location = 'Themes.aspx';", true); } else { lbl_Error.Text = "An unexpected error has occurred. Please try again."; lbl_Error.Visible = true; } } }