/// <summary> /// To LoadMNEGoalElement /// </summary> /// <returns></returns> public MNEGoalElementList LoadMNEGoalElement() { string con = AppConfiguration.ConnectionString; OracleConnection cnn; OracleCommand cmd; string proc = string.Empty; cnn = new OracleConnection(AppConfiguration.ConnectionString); proc = "USP_LOAD_MNEGOALELEMENTS"; 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); MNEGoalElementBOL objMNEGoalElementBOL = null; MNEGoalElementList MNEGoalEvalElements = new MNEGoalElementList(); while (dr.Read()) { objMNEGoalElementBOL = new MNEGoalElementBOL(); if (!dr.IsDBNull(dr.GetOrdinal("ID"))) { objMNEGoalElementBOL.GoalElementID = dr.GetInt32(dr.GetOrdinal("ID")); } if (!dr.IsDBNull(dr.GetOrdinal("Name"))) { objMNEGoalElementBOL.GoalElement = dr.GetString(dr.GetOrdinal("Name")); } MNEGoalEvalElements.Add(objMNEGoalElementBOL); } dr.Close(); return(MNEGoalEvalElements); }
/// <summary> /// Set edit mode for edit comand /// Delete data from the database for delete comand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvGoalElement_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { ViewState["GOALELEMENTID"] = e.CommandArgument; MNEGoalElementBLL MNEGoalElementBLLObj = new MNEGoalElementBLL(); MNEGoalElementBOL MNEGoalElementBOLObj = new MNEGoalElementBOL(); MNEGoalElementBOLObj = MNEGoalElementBLLObj.GetMNEGoalElementDetailsbyID(Convert.ToInt32(ViewState["GOALELEMENTID"])); txtGoalElement.Text = MNEGoalElementBOLObj.GoalElement; SetUpdateMode(true); } else if (e.CommandName == "DeleteRow") { string message = string.Empty; MNEGoalElementBLL MNEGoalElementBLLObj = new MNEGoalElementBLL(); message = MNEGoalElementBLLObj.DeleteGoalElement(Convert.ToInt32(e.CommandArgument)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data deleted successfully"; } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } ClearData(); SetUpdateMode(false); BindGrid(); } }
/// <summary> /// To Get MNE Goal Element Details by ID /// </summary> /// <param name="GOALElementID"></param> /// <returns></returns> public MNEGoalElementBOL GetMNEGoalElementDetailsbyID(int GOALElementID) { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); OracleCommand cmd; string proc = "USP_MST_MNE_GETGOALELEMENT"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("GoalElementID_", GOALElementID); cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); MNEGoalElementBOL MNEGoalElementBOLObj = new MNEGoalElementBOL(); while (dr.Read()) { MNEGoalElementBOLObj = new MNEGoalElementBOL(); MNEGoalElementBOLObj.GoalElementID = Convert.ToInt32(dr.GetValue(dr.GetOrdinal("GOAL_ELEMENTID"))); MNEGoalElementBOLObj.GoalElement = dr.GetString(dr.GetOrdinal("GOAL_ELEMENTNAME")); } dr.Close(); return(MNEGoalElementBOLObj); }
/// <summary> /// To Update MNE Goal Element Details /// </summary> /// <param name="GoalElementBOObj"></param> /// <returns></returns> public string UpdateMNEGoalElementDetails(MNEGoalElementBOL GoalElementBOObj) { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); cnn.Open(); OracleCommand dcmd = new OracleCommand("USP_MST_MNE_UPDATE_GOALELEMENT ", cnn); dcmd.CommandType = CommandType.StoredProcedure; string result = ""; try { dcmd.Parameters.Add("GOAL_ELEMENTNAME_", GoalElementBOObj.GoalElement); dcmd.Parameters.Add("UPDATEDBY_", GoalElementBOObj.CreatedBy); dcmd.Parameters.Add("GOAL_ELEMENTID_", GoalElementBOObj.GoalElementID); dcmd.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; dcmd.ExecuteNonQuery(); if (dcmd.Parameters["errorMessage_"].Value != null) { result = dcmd.Parameters["errorMessage_"].Value.ToString(); } } catch { throw; } finally { dcmd.Dispose(); cnn.Close(); cnn.Dispose(); } return(result); }
/// <summary> /// To Insert MNE Goal Element Details /// </summary> /// <param name="GoalElementBOObj"></param> /// <returns></returns> public string InsertMNEGoalElementDetails(MNEGoalElementBOL GoalElementBOObj) { string result = ""; OracleConnection Con = new OracleConnection(AppConfiguration.ConnectionString); Con.Open(); OracleCommand cmd = new OracleCommand("USP_MST_MNE_INSERT_GOALELEMENT", Con); cmd.CommandType = CommandType.StoredProcedure; int Count = Convert.ToInt32(cmd.CommandType); try { cmd.Parameters.Add(" GOAL_ELEMENTNAME", GoalElementBOObj.GoalElement); cmd.Parameters.Add("CREATEDBY", GoalElementBOObj.CreatedBy); cmd.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); if (cmd.Parameters["errorMessage_"].Value != null) { result = cmd.Parameters["errorMessage_"].Value.ToString(); } } catch { throw; } finally { cmd.Dispose(); Con.Close(); Con.Dispose(); } return(result); }
/// <summary> /// To save details to database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { MNEGoalElementBOL MNEGoalElementBOObj = null; string message = ""; if (Convert.ToInt32(ViewState["GOALELEMENTID"]) == 0) { try { MNEGoalElementBOObj = new MNEGoalElementBOL(); MNEGoalElementBLL MNEGoalElementBLLObj = new MNEGoalElementBLL(); MNEGoalElementBOObj.GoalElement = txtGoalElement.Text.Trim(); MNEGoalElementBOObj.CreatedBy = Convert.ToInt32(Session["USER_ID"].ToString()); message = MNEGoalElementBLLObj.InsertMNEGoalElementDetails(MNEGoalElementBOObj); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data saved successfully"; } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } } catch (Exception ex) { throw ex; } } else { try { MNEGoalElementBOObj = new MNEGoalElementBOL(); MNEGoalElementBLL MNEGoalElementBLLObj = new MNEGoalElementBLL(); MNEGoalElementBOObj.GoalElementID = Convert.ToInt32(ViewState["GOALELEMENTID"]); MNEGoalElementBOObj.GoalElement = txtGoalElement.Text.ToString().Trim(); MNEGoalElementBOObj.CreatedBy = Convert.ToInt32(Session["USER_ID"].ToString()); message = MNEGoalElementBLLObj.UpdateGoalElement(MNEGoalElementBOObj); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } } catch (Exception ex) { throw ex; } finally { MNEGoalElementBOObj = null; } } BindGrid(); ClearData(); }
/// <summary> /// To Update Goal Element /// </summary> /// <param name="MNEGoalElementBOLObj"></param> /// <returns></returns> public string UpdateGoalElement(MNEGoalElementBOL MNEGoalElementBOLObj) { MNEGoalElementDAL MNEGoalElementDALObj = new MNEGoalElementDAL(); return(MNEGoalElementDALObj.UpdateMNEGoalElementDetails(MNEGoalElementBOLObj)); }
/// <summary> /// To Insert MNE Goal Element Details /// </summary> /// <param name="GoalElementBOObj"></param> /// <returns></returns> public string InsertMNEGoalElementDetails(MNEGoalElementBOL GoalElementBOObj) { MNEGoalElementDAL MNEGoalElementDAL = new MNEGoalElementDAL(); return(MNEGoalElementDAL.InsertMNEGoalElementDetails(GoalElementBOObj)); }