/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param>e private void BindGrid(bool addRow, bool deleteRow) { RelationshipBO objRel = new RelationshipBO(); RelationshipBLL objRElBLL = new RelationshipBLL(); grdRelationship.DataSource = objRElBLL.GetALLRelationship(); grdRelationship.DataBind(); }
/// <summary> /// To Update Relation /// </summary> /// <param name="objRel"></param> /// <returns></returns> public string UpdateRelation(RelationshipBO objRel) { OracleConnection con = new OracleConnection(AppConfiguration.ConnectionString); string returnResult = string.Empty; { OracleCommand myCommand; myCommand = new OracleCommand("USP_MST_UPD_RELATIONSHIP", con); myCommand.Connection = con; myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add("RELATIONSHIPID", objRel.RELATIONSHIPID); if (string.IsNullOrEmpty(objRel.RELATIONSHIP) == true) { myCommand.Parameters.Add("RELATION", objRel.RELATIONSHIP); } else { myCommand.Parameters.Add("RELATION", objRel.RELATIONSHIP); //myCommand.Parameters.Add("RELATION", objRel.RELATIONSHIP); } myCommand.Parameters.Add("UPDATEDBY", objRel.UserID); //myCommand.Parameters.Add("UPDATEDBY", UPDATEDBY); con.Open(); //result = myCommand.ExecuteNonQuery(); myCommand.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; myCommand.ExecuteNonQuery(); if (myCommand.Parameters["errorMessage_"].Value != null) { returnResult = myCommand.Parameters["errorMessage_"].Value.ToString(); } else { returnResult = string.Empty; } // return returnResult; con.Close(); } return(returnResult); }
/// <summary> /// To save details to database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_Save_Click(object sender, EventArgs e) { string AlertMessage = string.Empty; string message = string.Empty; RelationshipBO objRel = new RelationshipBO(); objRel.RELATIONSHIPID = int.Parse(ViewState["RELATIONSHIPID"].ToString()); objRel.RELATIONSHIP = txtrel.Text.Trim(); objRel.UserID = Convert.ToInt32(Session["USER_ID"].ToString()); RelationshipBLL objRelBLL = new RelationshipBLL(); if (objRel.RELATIONSHIPID == 0) { message = objRelBLL.AddRelation(objRel); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Relationship added successfully');", true); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data saved successfully"; ClearDetails(); //BindGrid(true, true); } } else { message = objRelBLL.UpdateRelationship(objRel); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "alert('Relationship updated successfully');", true); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; ClearDetails(); SetUpdateMode(false); } btn_Save.Text = "Save"; ViewState["RELATIONSHIPID"] = 0; } //ClearDetails(); //BindGrid(true, false); AlertMessage = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); }
/// <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 grdRelationship_RowCommand(object sender, GridViewCommandEventArgs e) { string message = string.Empty; if (e.CommandName == "EditRow") { ViewState["RELATIONSHIPID"] = e.CommandArgument; RelationshipBO objRel = null; RelationshipBLL objrelBLL = new RelationshipBLL(); objRel = objrelBLL.GetRelationshipByID(Convert.ToInt32(ViewState["RELATIONSHIPID"])); if (objRel != null) { txtrel.Text = objRel.RELATIONSHIP; } SetUpdateMode(true); ScriptManager.RegisterStartupScript(this, this.GetType(), "Added", "setDirty();", true); } else if (e.CommandName == "DeleteRow") { // ViewState["RELATIONSHIPID"] = e.CommandArgument; RelationshipBLL objrelBLL = new RelationshipBLL(); message = objrelBLL.DeleteRelation(Convert.ToInt32(e.CommandArgument)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data Deleted successfully"; } SetUpdateMode(true); BindGrid(false, true); } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }
/// <summary> /// To Add Relation /// </summary> /// <param name="objRelr"></param> /// <returns></returns> public string AddRelation(RelationshipBO objRelr) { OracleConnection con = new OracleConnection(AppConfiguration.ConnectionString); string returnResult = string.Empty; { OracleCommand myCommand; myCommand = new OracleCommand("USP_MST_INS_RELATIONSHIP", con); myCommand.Connection = con; myCommand.CommandType = CommandType.StoredProcedure; //Relationship objrel = new Relationship(); myCommand.Parameters.Add("@RELATION_", objRelr.RELATIONSHIP); myCommand.Parameters.Add("@ISDELETEDIN", "False"); myCommand.Parameters.Add("@CREATEDBY", objRelr.UserID); con.Open(); //result = myCommand.ExecuteNonQuery(); myCommand.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; myCommand.ExecuteNonQuery(); if (myCommand.Parameters["errorMessage_"].Value != null) { returnResult = myCommand.Parameters["errorMessage_"].Value.ToString(); } else { returnResult = string.Empty; } con.Close(); } //return objRelr; return(returnResult); }
/// <summary> /// To Update Relation /// </summary> /// <param name="objRel"></param> /// <returns></returns> public string UpdateRelationship(RelationshipBO objRel) { RelationshipDAL objRelDAL = new RelationshipDAL(); return(objRelDAL.UpdateRelation(objRel)); }
/// <summary> /// To Add Relation /// </summary> /// <param name="objRel"></param> /// <returns></returns> public string AddRelation(RelationshipBO objRel) { RelationshipDAL objRelDAL = new RelationshipDAL(); return(objRelDAL.AddRelation(objRel)); }