/// <summary> /// Get CopMechanism By Id /// </summary> /// <param name="CopMechanismID"></param> /// <returns></returns> public CopMechanismBO GetCopMechanismById(int CopMechanismID) { cnn = new OracleConnection(con); proc = "USP_MST_GET_COPMECHANISM_BYID"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("cop_mechanismid_", CopMechanismID); cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); CopMechanismBO objCopMechanism = null; while (dr.Read()) { objCopMechanism = new CopMechanismBO(); if (ColumnExists(dr, "cop_mechanismid") && !dr.IsDBNull(dr.GetOrdinal("cop_mechanismid"))) { objCopMechanism.CopMechanismID = Convert.ToInt32(dr.GetValue(dr.GetOrdinal("cop_mechanismid"))); } if (ColumnExists(dr, "cop_mechanism") && !dr.IsDBNull(dr.GetOrdinal("cop_mechanism"))) { objCopMechanism.CopMechanismName = dr.GetString(dr.GetOrdinal("cop_mechanism")); } } dr.Close(); return(objCopMechanism); }
/// <summary> /// To update details into database /// </summary> /// <param name="oCopMechanism"></param> /// <returns></returns> public string UpdateCopMechanism(CopMechanismBO oCopMechanism) { string returnResult = string.Empty; cnn = new OracleConnection(con); proc = "USP_MST_UPDATE_COPMECHANISM"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); cmd.Parameters.Add("cop_mechanismid_", oCopMechanism.CopMechanismID); cmd.Parameters.Add("cop_mechanism_", oCopMechanism.CopMechanismName); cmd.Parameters.Add("updatedby_", oCopMechanism.CreatedBy); cmd.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); if (cmd.Parameters["errorMessage_"].Value != null) { returnResult = cmd.Parameters["errorMessage_"].Value.ToString(); } else { returnResult = string.Empty; } return(returnResult); }
/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param>e private void BindGrid(bool addRow, bool deleteRow) { objCopMechanismBLL = new CopMechanismBLL(); objCopMechanism = new CopMechanismBO(); objCopMechanism.CopMechanismName = string.Empty; objCopMechanism.CopMechanismID = 0; grdCopMechansim.DataSource = objCopMechanismBLL.GetALLCopMechanism();//(objCopMechanism); grdCopMechansim.DataBind(); }
/// <summary> /// get the Grid value into textBox /// </summary> private void GetCopMechanismDetails() { objCopMechanismBLL = new CopMechanismBLL(); int CopMechanismID = 0; if (ViewState["CopMechanismID"] != null) { CopMechanismID = Convert.ToInt32(ViewState["CopMechanismID"].ToString()); } objCopMechanism = new CopMechanismBO(); objCopMechanism = objCopMechanismBLL.GetCopMechanismById(CopMechanismID); txtCopingMechanism.Text = objCopMechanism.CopMechanismName; }
/// <summary> /// Get ALL CopMechanism /// </summary> /// <returns></returns> public CopMechanismList GetALLCopMechanism()//(CopMechanism oCopMechanism) { proc = "USP_MST_GETALLCOP_MECHANISM"; cnn = new OracleConnection(con); CopMechanismBO objCopMechanism = null; CopMechanismList lstCopMechanismList = new CopMechanismList(); cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; try { cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { objCopMechanism = new CopMechanismBO(); if (ColumnExists(dr, "cop_mechanismid") && !dr.IsDBNull(dr.GetOrdinal("cop_mechanismid"))) { objCopMechanism.CopMechanismID = Convert.ToInt32(dr.GetValue(dr.GetOrdinal("cop_mechanismid"))); } if (ColumnExists(dr, "cop_mechanism") && !dr.IsDBNull(dr.GetOrdinal("cop_mechanism"))) { objCopMechanism.CopMechanismName = dr.GetString(dr.GetOrdinal("cop_mechanism")); } if (ColumnExists(dr, "isdeleted") && !dr.IsDBNull(dr.GetOrdinal("isdeleted"))) { objCopMechanism.IsDeleted = dr.GetString(dr.GetOrdinal("isdeleted")); } lstCopMechanismList.Add(objCopMechanism); } dr.Close(); } catch (Exception ex) { throw ex; } return(lstCopMechanismList); }
/// <summary> /// to insert data to database /// </summary> protected void btnSave_Click(object sender, EventArgs e) { string AlertMessage = string.Empty; string message = string.Empty; objCopMechanism = new CopMechanismBO(); objCopMechanismBLL = new CopMechanismBLL(); objCopMechanism.CopMechanismName = txtCopingMechanism.Text.Trim(); if (ViewState["CopMechanismID"] != null) { objCopMechanism.CopMechanismID = Convert.ToInt32(ViewState["CopMechanismID"].ToString()); } objCopMechanism.IsDeleted = "False"; if (Session["userId"] != null) { objCopMechanism.CreatedBy = Convert.ToInt32(Session["USER_ID"].ToString()); } else { objCopMechanism.CreatedBy = 1; //Default Value } if (objCopMechanism.CopMechanismID < 1) { //If CopMechanismID does Not exists then SaveCopMechanism objCopMechanism.CopMechanismID = -1;//For New CopMechanism message = objCopMechanismBLL.AddCopMechanism(objCopMechanism); AlertMessage = "alert('" + message + "');"; if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data saved successfully"; ClearDetails(); BindGrid(true, true); } } else { //If CopMechanismID exists then UpdateCopMechanism message = objCopMechanismBLL.UpdateCopMechanism(objCopMechanism); //For Updating CopMechanism if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; ClearDetails(); BindGrid(true, true); SetUpdateMode(false); } } //ClearDetails(); //BindGrid(true, false); //ViewState["CopMechanismID"] = "-1"; AlertMessage = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); }
/// <summary> /// To Update Cop Mechanism /// </summary> /// <param name="oCopMechanism"></param> /// <returns></returns> public string UpdateCopMechanism(CopMechanismBO oCopMechanism) { objCopMechanismDAL = new CopMechanismDAL(); return(objCopMechanismDAL.UpdateCopMechanism(oCopMechanism)); }
/// <summary> /// To Add Cop Mechanism /// </summary> /// <param name="oCopMechanism"></param> /// <returns></returns> public string AddCopMechanism(CopMechanismBO oCopMechanism) { objCopMechanismDAL = new CopMechanismDAL(); return(objCopMechanismDAL.SaveCopMechanism(oCopMechanism)); }