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