/// <summary> /// To Get Vulnerability /// </summary> /// <returns></returns> public VulnerabilityList GetVulnerability() { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); OracleCommand cmd; string proc = " USP_MST_GET_VUL"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); VulnerabilityBO objUser = null; VulnerabilityList Users = new VulnerabilityList(); while (dr.Read()) { objUser = new VulnerabilityBO(); objUser.VulnerabilityID = Convert.ToInt32(dr.GetValue(dr.GetOrdinal("DISABILITYID"))); objUser.VulnerabilityType = dr.GetString(dr.GetOrdinal("DISABILITYNAME")); Users.Add(objUser); } dr.Close(); return(Users); }
//to get record for the grid for update private void GetVulnerabiltyDetails() { VulnerabilityBLLObj = new VulnerabilityBLL(); int VulnerabilityID = 0; if (ViewState["VulnerabilityID"] != null) { VulnerabilityID = Convert.ToInt32(ViewState["VulnerabilityID"]); } VulnerabilityBOObj = new VulnerabilityBO(); VulnerabilityBOObj = VulnerabilityBLLObj.GetVulnerablitybyID(VulnerabilityID); txtVulnerability.Text = VulnerabilityBOObj.VulnerabilityType; }
/// <summary> /// To Update /// </summary> /// <param name="VulnerabilityBOObj"></param> /// <param name="VulnerabilityID"></param> /// <returns></returns> public string Update(VulnerabilityBO VulnerabilityBOObj, int VulnerabilityID) { VulnerabilityDAL VulnerabilityDALObj = new VulnerabilityDAL(); try { return(VulnerabilityDALObj.Update(VulnerabilityBOObj, VulnerabilityID)); } catch (Exception ex) { throw ex; } finally { VulnerabilityDALObj = null; } }
/// <summary> /// To Insert /// </summary> /// <param name="VulnerabilityBOObj"></param> /// <returns></returns> public string insert(VulnerabilityBO VulnerabilityBOObj) { VulnerabilityDAL VulnerabilityDALObj = new VulnerabilityDAL(); try { return(VulnerabilityDALObj.insert(VulnerabilityBOObj)); } catch (Exception ex) { throw ex; } finally { VulnerabilityDALObj = null; } }
/// <summary> /// To Update /// </summary> /// <param name="VulnerabilityBOobj"></param> /// <param name="VulnerabilityID"></param> /// <returns></returns> public string Update(VulnerabilityBO VulnerabilityBOobj, int VulnerabilityID) { string returnResult = string.Empty; OracleConnection conn = new OracleConnection(AppConfiguration.ConnectionString); conn.Open(); OracleCommand dCmd = new OracleCommand("USP_MST_UPD_VUL", conn); dCmd.CommandType = CommandType.StoredProcedure; try { dCmd.Parameters.Add("p_VULNERABILITYID", VulnerabilityID); dCmd.Parameters.Add("p_MST_VULNERABILITY", VulnerabilityBOobj.VulnerabilityType); dCmd.Parameters.Add("p_UPDATEDBY", VulnerabilityBOobj.CreatedBy); dCmd.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; dCmd.ExecuteNonQuery(); if (dCmd.Parameters["errorMessage_"].Value != null) { returnResult = dCmd.Parameters["errorMessage_"].Value.ToString(); } else { returnResult = string.Empty; } } catch (Exception ex) { throw ex; } finally { dCmd.Dispose(); conn.Close(); conn.Dispose(); } return(returnResult); }
/// <summary> /// To Insert /// </summary> /// <param name="VulnerabilityBOobj"></param> /// <returns></returns> public string insert(VulnerabilityBO VulnerabilityBOobj) { OracleConnection con = new OracleConnection(AppConfiguration.ConnectionString); con.Open(); OracleCommand dcmd = new OracleCommand("USP_MST_INS_VUL", con); dcmd.CommandType = CommandType.StoredProcedure; int count = Convert.ToInt32(dcmd.CommandType); try { dcmd.Parameters.Add("p_VULNERABILITY", VulnerabilityBOobj.VulnerabilityType); dcmd.Parameters.Add("p_CREATEDBY", VulnerabilityBOobj.CreatedBy); //return dcmd.ExecuteNonQuery(); dcmd.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; dcmd.ExecuteNonQuery(); if (dcmd.Parameters["errorMessage_"].Value != null) { returnResult = dcmd.Parameters["errorMessage_"].Value.ToString(); } else { returnResult = string.Empty; } } catch (Exception ex) { throw ex; } finally { dcmd.Dispose(); con.Close(); con.Dispose(); } return(returnResult); }
private string Insert() { string message = string.Empty; try { string uID = Session["USER_ID"].ToString(); VulnerabilityBOObj = new VulnerabilityBO(); VulnerabilityBOObj.VulnerabilityType = txtVulnerability.Text.ToString(); VulnerabilityBOObj.CreatedBy = Convert.ToInt32(uID);; VulnerabilityBLLObj = new VulnerabilityBLL(); message = VulnerabilityBLLObj.insert(VulnerabilityBOObj); } catch (Exception ex) { throw ex; } finally { VulnerabilityBLLObj = null; } return(message); }
/// <summary> /// Save, clear, update the data. /// </summary> #region for Save, clear, update(Insert) the Record protected void btnSave_Click(object sender, EventArgs e) { string AlertMessage = string.Empty; string message = string.Empty; if (ViewState["VulnerabilityID"].ToString() == "0") { message = Insert(); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data saved successfully"; ClearFields(); BindGrid(); } } else { string uID = Session["USER_ID"].ToString(); int reasonid = Convert.ToInt32(ViewState["VulnerabilityID"]); VulnerabilityBOObj = new VulnerabilityBO(); VulnerabilityBOObj.VulnerabilityType = txtVulnerability.Text.ToString(); VulnerabilityBOObj.CreatedBy = Convert.ToInt32(uID); VulnerabilityBLLObj = new VulnerabilityBLL(); message = VulnerabilityBLLObj.Update(VulnerabilityBOObj, reasonid); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; ClearFields(); BindGrid(); SetUpdateMode(false); } } AlertMessage = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); }