protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e) { try { string id = Convert.ToString(e.CommandArgument); if (!string.IsNullOrEmpty(id)) { RankingBLL rankingBLL = new RankingBLL(); DataTable dt = rankingBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id))); if (dt != null) { if (dt.Rows.Count > 0) { string actionStatus = "Updated"; Rankings ranking = new Rankings(); ranking.RankingId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["RankingId"])); ranking.RankingCode = Convert.ToString(dt.Rows[0]["RankingCode"]); ranking.UniversityName = Convert.ToString(dt.Rows[0]["UniversityName"]); ranking.Rank = Convert.ToInt32(Convert.ToString(dt.Rows[0]["Rank"])); ranking.Url = Convert.ToString(dt.Rows[0]["Url"]); ranking.Description = Convert.ToString(dt.Rows[0]["Description"]); ranking.IsActive = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"])); ranking.CountryId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CountryId"])); ranking.CreatedDate = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"])); ranking.CreatedBy = Convert.ToString(dt.Rows[0]["CreatedBy"]); ranking.CreatedFrom = Convert.ToString(dt.Rows[0]["CreatedFrom"]); ranking.UpdatedDate = DateTime.Now; ranking.UpdatedBy = UserInfo; ranking.UpdatedFrom = StationInfo; if (ranking.IsActive) { ranking.IsActive = false; actionStatus = "Deactivated"; } else { ranking.IsActive = true; actionStatus = "Activated"; } if (rankingBLL.Update(ranking)) { 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(txtUniversityName.Text)) { Alert(AlertType.Warning, "Enter bank name."); txtUniversityName.Focus(); } else if (string.IsNullOrEmpty(txtRank.Text)) { Alert(AlertType.Warning, "Enter rank."); txtRank.Focus(); } else if (ddlCountry.SelectedIndex < 1) { Alert(AlertType.Warning, "Select country"); ddlCountry.Focus(); } else { string universityName = Convert.ToString(txtUniversityName.Text); int rank = Convert.ToInt32(Convert.ToString(txtRank.Text)); string url = Convert.ToString(txtUrl.Text); string description = Convert.ToString(txtDescription.Text); int countryId = Convert.ToInt32(Convert.ToString(ddlCountry.SelectedValue)); RankingBLL rankingBLL = new RankingBLL(); if (this.ModelId > 0) { DataTable dt = rankingBLL.GetById(this.ModelId); Rankings ranking = new Rankings(); ranking.RankingId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["RankingId"])); ranking.RankingCode = Convert.ToString(dt.Rows[0]["RankingCode"]); ranking.UniversityName = Convert.ToString(dt.Rows[0]["UniversityName"]); ranking.Rank = Convert.ToInt32(Convert.ToString(dt.Rows[0]["Rank"])); ranking.Url = Convert.ToString(dt.Rows[0]["Url"]); ranking.Description = Convert.ToString(dt.Rows[0]["Description"]); ranking.IsActive = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"])); ranking.CountryId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CountryId"])); ranking.CreatedDate = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"])); ranking.CreatedBy = Convert.ToString(dt.Rows[0]["CreatedBy"]); ranking.CreatedFrom = Convert.ToString(dt.Rows[0]["CreatedFrom"]); ranking.UniversityName = universityName.Trim(); ranking.Rank = rank; ranking.Url = url; ranking.Description = description; ranking.CountryId = countryId; ranking.UpdatedDate = DateTime.Now; ranking.UpdatedBy = this.UserInfo; ranking.UpdatedFrom = this.StationInfo; if (rankingBLL.Update(ranking)) { this.MultiEntryDisallow = true; Alert(AlertType.Success, "Updated successfully."); ClearFields(); } else { Alert(AlertType.Error, "Failed to update."); } } else { Rankings ranking = new Rankings(); ranking.RankingCode = this.ModelCode; ranking.UniversityName = universityName.Trim(); ranking.Rank = rank; ranking.Url = url; ranking.Description = description; ranking.CountryId = countryId; ranking.IsActive = true; ranking.CreatedDate = DateTime.Now; ranking.CreatedBy = this.UserInfo; ranking.CreatedFrom = this.StationInfo; if (rankingBLL.Save(ranking)) { Alert(AlertType.Success, "Saved successfully."); ClearFields(); GenerateCode(); } else { Alert(AlertType.Error, "Failed to save."); } } } } catch (Exception ex) { Alert(AlertType.Error, ex.Message.ToString()); } }