protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e) { try { string id = Convert.ToString(e.CommandArgument); if (!string.IsNullOrEmpty(id)) { TutorialBLL tutorialBLL = new TutorialBLL(); DataTable dt = tutorialBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id))); if (dt != null) { if (dt.Rows.Count > 0) { string actionStatus = "Updated"; Tutorials tutorial = new Tutorials(); tutorial.TutorialId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["TutorialId"])); tutorial.TutorialCode = Convert.ToString(dt.Rows[0]["TutorialCode"]); tutorial.Title = Convert.ToString(dt.Rows[0]["Title"]); tutorial.Slug = Convert.ToString(dt.Rows[0]["Slug"]); tutorial.Description = Convert.ToString(dt.Rows[0]["Description"]); tutorial.ExternalUrl = Convert.ToString(dt.Rows[0]["ExternalUrl"]); tutorial.IsActive = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"])); tutorial.PlayListId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["PlayListId"])); tutorial.CreatedDate = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"])); tutorial.CreatedBy = Convert.ToString(dt.Rows[0]["CreatedBy"]); tutorial.CreatedFrom = Convert.ToString(dt.Rows[0]["CreatedFrom"]); tutorial.UpdatedDate = DateTime.Now; tutorial.UpdatedBy = UserInfo; tutorial.UpdatedFrom = StationInfo; if (tutorial.IsActive) { tutorial.IsActive = false; actionStatus = "Deactivated"; } else { tutorial.IsActive = true; actionStatus = "Activated"; } if (tutorialBLL.Update(tutorial)) { Alert(AlertType.Success, actionStatus + " successfully."); LoadList(); } else { Alert(AlertType.Error, "Failed to update."); } } } } } catch (Exception) { Alert(AlertType.Error, "Failed to process."); } }
private void SaveAndUpdate() { try { if (string.IsNullOrEmpty(txtTitle.Text)) { Alert(AlertType.Warning, "Enter title."); txtTitle.Focus(); } else if (string.IsNullOrEmpty(txtExternalUrl.Text)) { Alert(AlertType.Warning, "Enter YouTube link."); txtExternalUrl.Focus(); } else { QuaintLibraryManager lib = new QuaintLibraryManager(); string title = Convert.ToString(txtTitle.Text); string slug = lib.ConvertToSlug(title); string description = Convert.ToString(txtDescription.Text); string externalUrl = Convert.ToString(txtExternalUrl.Text); int playListId = 0; TutorialBLL tutorialBLL = new TutorialBLL(); if (this.ModelId > 0) { DataTable dt = tutorialBLL.GetById(this.ModelId); Tutorials tutorial = new Tutorials(); tutorial.TutorialId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["TutorialId"])); tutorial.TutorialCode = Convert.ToString(dt.Rows[0]["TutorialCode"]); tutorial.Title = Convert.ToString(dt.Rows[0]["Title"]); tutorial.Slug = Convert.ToString(dt.Rows[0]["Slug"]); tutorial.Description = Convert.ToString(dt.Rows[0]["Description"]); tutorial.ExternalUrl = Convert.ToString(dt.Rows[0]["ExternalUrl"]); tutorial.IsActive = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"])); tutorial.PlayListId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["PlayListId"])); tutorial.CreatedDate = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"])); tutorial.CreatedBy = Convert.ToString(dt.Rows[0]["CreatedBy"]); tutorial.CreatedFrom = Convert.ToString(dt.Rows[0]["CreatedFrom"]); tutorial.Title = title.Trim(); tutorial.Slug = slug; tutorial.Description = description; tutorial.ExternalUrl = externalUrl; tutorial.PlayListId = playListId; tutorial.UpdatedDate = DateTime.Now; tutorial.UpdatedBy = this.UserInfo; tutorial.UpdatedFrom = this.StationInfo; if (tutorialBLL.Update(tutorial)) { this.MultiEntryDisallow = true; Alert(AlertType.Success, "Updated successfully."); ClearFields(); } else { Alert(AlertType.Error, "Failed to update."); } } else { Tutorials tutorial = new Tutorials(); tutorial.TutorialCode = this.ModelCode; tutorial.Title = title.Trim(); tutorial.Slug = slug; tutorial.Description = description; tutorial.ExternalUrl = externalUrl; tutorial.IsActive = true; tutorial.PlayListId = playListId; tutorial.CreatedDate = DateTime.Now; tutorial.CreatedBy = this.UserInfo; tutorial.CreatedFrom = this.StationInfo; if (tutorialBLL.Save(tutorial)) { Alert(AlertType.Success, "Saved successfully."); ClearFields(); GenerateCode(); } else { Alert(AlertType.Error, "Failed to save."); } } } } catch (Exception ex) { Alert(AlertType.Error, ex.Message.ToString()); } }