public static string Insert(DemoModel _demoModel) { DbCommand command = Catalog_Access.CreateCommand(); //Have to wite the stored procedure command.CommandText = "sp_insert_Demo"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@Name"; param.Value = _demoModel.Name; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@CreatedBy"; param.Value = _demoModel.CreatedBy; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Return"; param.DbType = DbType.String; param.Size = 2; param.Direction = ParameterDirection.Output; command.Parameters.Add(param); Catalog_Access.ExecuteNonQuery(command); string Return = command.Parameters["@Return"].Value.ToString(); return(Return); }
public static int Delete(int Code) { DbCommand command = Catalog_Access.CreateCommand(); command.CommandText = "sp_Delete_Demo_By_Code"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@Code"; param.Value = Code; param.DbType = DbType.Int32; command.Parameters.Add(param); return(Catalog_Access.ExecuteNonQuery(command)); }
public static string Update(DemoModel _demoModel) { DbCommand command = Catalog_Access.CreateCommand(); command.CommandText = "sp_Update_Demo"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@Code"; param.Value = _demoModel.Code; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Name"; param.Value = _demoModel.Name; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@UpdatedBy"; param.Value = _demoModel.UpdatedBy; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Return"; param.DbType = DbType.String; param.Size = 2; param.Direction = ParameterDirection.Output; command.Parameters.Add(param); Catalog_Access.ExecuteNonQuery(command); string Return = command.Parameters["@Return"].Value.ToString(); return(Return); }